]> granicus.if.org Git - icinga2/blob - lib/config/CMakeLists.txt
Ensure that flex meets the version requirements
[icinga2] / lib / config / CMakeLists.txt
1 # Icinga 2
2 # Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org)
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 find_package(BISON 2.3.0 REQUIRED)
19 find_package(FLEX 2.5.31 REQUIRED)
20
21 if("${FLEX_VERSION}" VERSION_LESS "2.5.31")
22     message(SEND_ERROR "Your version of flex is too old. You can specify an alternative path using -DFLEX_EXECUTABLE=/path/to/flex")
23 endif()
24
25 bison_target(config_parser config_parser.yy ${CMAKE_CURRENT_BINARY_DIR}/config_parser.cc)
26 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_parser.cc PROPERTY EXCLUDE_UNITY_BUILD TRUE)
27
28 flex_target(config_lexer config_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc)
29 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc PROPERTY EXCLUDE_UNITY_BUILD TRUE)
30
31 add_flex_bison_dependency(config_lexer config_parser)
32
33 mkembedconfig_target(base-type.conf base-type.cpp)
34
35 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
36
37 set(config_SOURCES
38   applyrule.cpp base-type.conf base-type.cpp
39   configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp
40   configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
41   configtype.cpp expression.cpp objectrule.cpp typerule.cpp typerulelist.cpp
42 )
43
44 if(ICINGA2_UNITY_BUILD)
45     mkunity_target(config config_SOURCES)
46 endif()
47
48 add_library(config SHARED ${config_SOURCES})
49
50 target_link_libraries(config ${Boost_LIBRARIES} base) 
51
52 set_target_properties (
53   config PROPERTIES
54   INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
55   DEFINE_SYMBOL I2_CONFIG_BUILD
56   FOLDER Lib
57 )
58
59 install(
60   TARGETS config
61   RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
62   LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
63 )