]> granicus.if.org Git - icinga2/blob - lib/base/CMakeLists.txt
420e3204ca9c481030c4fce95a4e3b32e9d767cd
[icinga2] / lib / base / CMakeLists.txt
1 # Icinga 2
2 # Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/)
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 mkclass_target(application.ti application.tcpp application.thpp)
19 mkclass_target(configobject.ti configobject.tcpp configobject.thpp)
20 mkclass_target(datetime.ti datetime.tcpp datetime.thpp)
21 mkclass_target(filelogger.ti filelogger.tcpp filelogger.thpp)
22 mkclass_target(function.ti function.tcpp function.thpp)
23 mkclass_target(logger.ti logger.tcpp logger.thpp)
24 mkclass_target(streamlogger.ti streamlogger.tcpp streamlogger.thpp)
25 mkclass_target(sysloglogger.ti sysloglogger.tcpp sysloglogger.thpp)
26
27 set(base_SOURCES
28   application.cpp application.thpp application-version.cpp array.cpp
29   array-script.cpp boolean.cpp boolean-script.cpp console.cpp context.cpp
30   convert.cpp datetime.cpp datetime.thpp datetime-script.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp
31   configobject.cpp configobject.thpp configobject-script.cpp configtype.cpp configwriter.cpp dependencygraph.cpp
32   exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp
33   json-script.cpp loader.cpp logger.cpp logger.thpp math-script.cpp
34   netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp
35   object-script.cpp objecttype.cpp primitivetype.cpp process.cpp ringbuffer.cpp scriptframe.cpp
36   function.cpp function.thpp function-script.cpp functionwrapper.cpp scriptglobal.cpp
37   scriptutils.cpp serializer.cpp socket.cpp socketevents.cpp socketevents-epoll.cpp socketevents-poll.cpp stacktrace.cpp
38   statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp string-script.cpp
39   sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp udpsocket.cpp threadpool.cpp timer.cpp
40   tlsstream.cpp tlsutility.cpp type.cpp typetype-script.cpp unixsocket.cpp utility.cpp value.cpp
41   value-operators.cpp workqueue.cpp
42 )
43
44 set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/application-version.cpp PROPERTY EXCLUDE_UNITY_BUILD TRUE)
45
46 if(ICINGA2_UNITY_BUILD)
47     mkunity_target(base base base_SOURCES)
48 endif()
49
50 add_library(base SHARED ${base_SOURCES})
51
52 target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${YAJL_LIBRARIES} mmatch socketpair)
53
54 if(HAVE_LIBEXECINFO)
55     target_link_libraries(base execinfo)
56 endif()
57
58 include_directories(${icinga2_SOURCE_DIR}/third-party/execvpe)
59 link_directories(${icinga2_BINARY_DIR}/third-party/execvpe)
60
61 include_directories(${icinga2_SOURCE_DIR}/third-party/mmatch)
62 link_directories(${icinga2_BINARY_DIR}/third-party/mmatch)
63
64 include_directories(${icinga2_SOURCE_DIR}/third-party/socketpair)
65 link_directories(${icinga2_BINARY_DIR}/third-party/socketpair)
66
67 if(UNIX OR CYGWIN)
68   target_link_libraries(base execvpe)
69 endif()
70
71 if(WIN32)
72   target_link_libraries(base ws2_32 dbghelp shlwapi msi)
73 endif()
74
75 set_target_properties (
76   base PROPERTIES
77   INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
78   DEFINE_SYMBOL I2_BASE_BUILD
79   FOLDER Lib
80   VERSION ${SPEC_VERSION}
81 )
82
83 install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/icinga2\")")
84 install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2/crash\")")
85
86 install(
87   TARGETS base
88   RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
89   LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
90 )
91
92 if(APPLE)
93   install(
94     TARGETS base
95     LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}/icinga-studio.app/Contents
96   )
97 endif()
98
99 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)