${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib
)
+set(base_DEPS ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${YAJL_LIBRARIES} mmatch socketpair)
+
+if(HAVE_LIBEXECINFO)
+ list(APPEND base_DEPS execinfo)
+endif()
+
+if(UNIX OR CYGWIN)
+ list(APPEND base_DEPS execvpe)
+endif()
+
+if(EDITLINE_FOUND)
+ list(APPEND base_DEPS ${EDITLINE_LIBRARIES})
+ include_directories(${EDITLINE_INCLUDE_DIR})
+endif()
+
+if(TERMCAP_FOUND)
+ list(APPEND base_DEPS ${TERMCAP_LIBRARIES})
+ include_directories(${TERMCAP_INCLUDE_DIR})
+endif()
+
+if(WIN32)
+ list(APPEND base_DEPS ws2_32 dbghelp shlwapi msi)
+endif()
+
set(CMAKE_MACOSX_RPATH 1)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
endif()
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
- function(add_whole_static_library target library)
- target_link_libraries(${target} -force_load ${library})
- endfunction()
-elseif(MSVC)
- function(add_whole_static_library target library)
- target_link_libraries(${target} ${library})
- set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS "/wholearchive:${library} ")
- endfunction()
-else()
- function(add_whole_static_library target library)
- target_link_libraries(${target} -Wl,--whole-archive ${library} -Wl,--no-whole-archive)
- endfunction()
-endif()
-
include(CheckCXXCompilerFlag)
function(check_cxx_linker_flag flag var)
include_directories(${Boost_INCLUDE_DIRS})
-add_executable(icinga-app $<TARGET_OBJECTS:icingaloader>)
-
-add_whole_static_library(icinga-app base)
-add_whole_static_library(icinga-app config)
-add_whole_static_library(icinga-app remote)
-add_whole_static_library(icinga-app cli)
-
if(ICINGA2_WITH_CHECKER)
- add_whole_static_library(icinga-app checker)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:checker>)
endif()
if(ICINGA2_WITH_COMPAT)
- add_whole_static_library(icinga-app compat)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:compat>)
endif()
if(ICINGA2_WITH_MYSQL OR ICINGA2_WITH_PGSQL)
- add_whole_static_library(icinga-app db_ido)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:db_ido>)
endif()
if(ICINGA2_WITH_MYSQL)
- add_whole_static_library(icinga-app db_ido_mysql)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:db_ido_mysql>)
endif()
if(ICINGA2_WITH_PGSQL)
- add_whole_static_library(icinga-app db_ido_pgsql)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:db_ido_pgsql>)
endif()
-add_whole_static_library(icinga-app icinga)
-
if(ICINGA2_WITH_LIVESTATUS)
- add_whole_static_library(icinga-app livestatus)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:livestatus>)
endif()
-add_whole_static_library(icinga-app methods)
-
if(ICINGA2_WITH_NOTIFICATION)
- add_whole_static_library(icinga-app notification)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:notification>)
endif()
if(ICINGA2_WITH_PERFDATA)
- add_whole_static_library(icinga-app perfdata)
+ list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:perfdata>)
endif()
+add_executable(icinga-app
+ $<TARGET_OBJECTS:icingaloader>
+ $<TARGET_OBJECTS:base>
+ $<TARGET_OBJECTS:config>
+ $<TARGET_OBJECTS:remote>
+ $<TARGET_OBJECTS:cli>
+ $<TARGET_OBJECTS:icinga>
+ $<TARGET_OBJECTS:methods>
+ ${icinga_app_SOURCES}
+)
+
+target_link_libraries(icinga-app ${base_DEPS})
+
set_target_properties (
icinga-app PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
connectform.cpp connectform.hpp
mainform.cpp mainform.hpp
icinga.icns ${WindowsSources}
+ $<TARGET_OBJECTS:base>
+ $<TARGET_OBJECTS:config>
+ $<TARGET_OBJECTS:remote>
)
add_executable(icinga-studio MACOSX_BUNDLE WIN32 ${icinga_studio_SOURCES})
-include_directories(${Boost_INCLUDE_DIRS})
-target_link_libraries(icinga-studio ${Boost_LIBRARIES} ${wxWidgets_LIBRARIES})
-add_whole_static_library(icinga-studio base)
-add_whole_static_library(icinga-studio remote)
+target_link_libraries(icinga-studio ${base_DEPS} ${wxWidgets_LIBRARIES})
if(APPLE)
set_source_files_properties(icinga.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
mkunity_target(base base base_SOURCES)
endif()
-add_library(base STATIC ${base_SOURCES})
-
-target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${YAJL_LIBRARIES} mmatch socketpair)
-
-if(HAVE_LIBEXECINFO)
- target_link_libraries(base execinfo)
-endif()
+add_library(base OBJECT ${base_SOURCES})
include_directories(${icinga2_SOURCE_DIR}/third-party/execvpe)
link_directories(${icinga2_BINARY_DIR}/third-party/execvpe)
include_directories(${icinga2_SOURCE_DIR}/third-party/socketpair)
link_directories(${icinga2_BINARY_DIR}/third-party/socketpair)
-if(UNIX OR CYGWIN)
- target_link_libraries(base execvpe)
-endif()
-
-if(WIN32)
- target_link_libraries(base ws2_32 dbghelp shlwapi msi)
-endif()
-
set_target_properties (
base PROPERTIES
FOLDER Lib
mkunity_target(checker checker checker_SOURCES)
endif()
-add_library(checker STATIC ${checker_SOURCES})
+add_library(checker OBJECT ${checker_SOURCES})
-target_link_libraries(checker ${Boost_LIBRARIES} base config icinga remote)
+add_dependencies(checker base config icinga remote)
set_target_properties (
checker PROPERTIES
mkunity_target(cli cli cli_SOURCES)
endif()
-add_library(cli STATIC ${cli_SOURCES})
+add_library(cli OBJECT ${cli_SOURCES})
-target_link_libraries(cli ${Boost_LIBRARIES} base config remote)
-
-if(EDITLINE_FOUND)
- target_link_libraries(cli ${EDITLINE_LIBRARIES})
- include_directories(${EDITLINE_INCLUDE_DIR})
-endif()
-
-if(TERMCAP_FOUND)
- target_link_libraries(cli ${TERMCAP_LIBRARIES})
- include_directories(${TERMCAP_INCLUDE_DIR})
-endif()
+add_dependencies(cli base config remote)
set_target_properties (
cli PROPERTIES
mkunity_target(compat compat compat_SOURCES)
endif()
-add_library(compat STATIC ${compat_SOURCES})
+add_library(compat OBJECT ${compat_SOURCES})
-target_link_libraries(compat ${Boost_LIBRARIES} base config icinga)
+add_dependencies(compat base config icinga)
set_target_properties (
compat PROPERTIES
mkunity_target(config config config_SOURCES)
endif()
-add_library(config STATIC ${config_SOURCES})
+add_library(config OBJECT ${config_SOURCES})
-target_link_libraries(config ${Boost_LIBRARIES} base)
+add_dependencies(config base)
set_target_properties (
config PROPERTIES
mkunity_target(db_ido db_ido db_ido_SOURCES)
endif()
-add_library(db_ido STATIC ${db_ido_SOURCES})
+add_library(db_ido OBJECT ${db_ido_SOURCES})
-include_directories(${Boost_INCLUDE_DIRS})
-target_link_libraries(db_ido ${Boost_LIBRARIES} base config icinga remote)
+add_dependencies(db_ido base config icinga remote)
set_target_properties (
db_ido PROPERTIES
mkunity_target(db_ido_mysql db_ido_mysql db_ido_mysql_SOURCES)
endif()
-add_library(db_ido_mysql STATIC ${db_ido_mysql_SOURCES})
+add_library(db_ido_mysql OBJECT ${db_ido_mysql_SOURCES})
include_directories(${MYSQL_INCLUDE_DIR})
-target_link_libraries(db_ido_mysql ${Boost_LIBRARIES} base config icinga db_ido)
+add_dependencies(db_ido_mysql base config icinga db_ido)
set_target_properties (
db_ido_mysql PROPERTIES
mkunity_target(db_ido_pgsql db_ido_pgsql db_ido_pgsql_SOURCES)
endif()
-add_library(db_ido_pgsql STATIC ${db_ido_pgsql_SOURCES})
+add_library(db_ido_pgsql OBJECT ${db_ido_pgsql_SOURCES})
include_directories(${PostgreSQL_INCLUDE_DIRS})
-target_link_libraries(db_ido_pgsql ${Boost_LIBRARIES} base config icinga db_ido)
+add_dependencies(db_ido_pgsql base config icinga db_ido)
set_target_properties (
db_ido_pgsql PROPERTIES
mkunity_target(icinga icinga icinga_SOURCES)
endif()
-add_library(icinga STATIC ${icinga_SOURCES})
+add_library(icinga OBJECT ${icinga_SOURCES})
-target_link_libraries(icinga ${Boost_LIBRARIES} base config remote)
+add_dependencies(icinga base config remote)
set_target_properties (
icinga PROPERTIES
mkunity_target(livestatus livestatus livestatus_SOURCES)
endif()
-add_library(livestatus STATIC ${livestatus_SOURCES})
+add_library(livestatus OBJECT ${livestatus_SOURCES})
-target_link_libraries(livestatus ${Boost_LIBRARIES} base config icinga remote)
+add_dependencies(livestatus base config icinga remote)
set_target_properties (
livestatus PROPERTIES
mkunity_target(methods methods methods_SOURCES)
endif()
-add_library(methods STATIC ${methods_SOURCES})
+add_library(methods OBJECT ${methods_SOURCES})
-target_link_libraries(methods ${Boost_LIBRARIES} base config icinga)
+add_dependencies(methods base config icinga)
set_target_properties (
methods PROPERTIES
mkunity_target(notification notification notification_SOURCES)
endif()
-add_library(notification STATIC ${notification_SOURCES})
+add_library(notification OBJECT ${notification_SOURCES})
-target_link_libraries(notification ${Boost_LIBRARIES} base config icinga)
+add_dependencies(notification base config icinga)
set_target_properties (
notification PROPERTIES
mkunity_target(perfdata perfdata perfdata_SOURCES)
endif()
-add_library(perfdata STATIC ${perfdata_SOURCES})
+add_library(perfdata OBJECT ${perfdata_SOURCES})
-target_link_libraries(perfdata ${Boost_LIBRARIES} base config icinga)
+add_dependencies(perfdata base config icinga)
set_target_properties (
perfdata PROPERTIES
mkunity_target(remote remote remote_SOURCES)
endif()
-add_library(remote STATIC ${remote_SOURCES})
+add_library(remote OBJECT ${remote_SOURCES})
-include_directories(${Boost_INCLUDE_DIRS})
-target_link_libraries(remote ${Boost_LIBRARIES} base config)
+add_dependencies(remote base config)
set_target_properties (
remote PROPERTIES
# along with this program; if not, write to the Free Software Foundation
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-add_executable ( check_nscp_api check_nscp_api.cpp )
-target_link_libraries ( check_nscp_api ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY})
-add_whole_static_library(check_nscp_api base)
-add_whole_static_library(check_nscp_api config)
-add_whole_static_library(check_nscp_api remote)
+add_executable(check_nscp_api
+ check_nscp_api.cpp
+ $<TARGET_OBJECTS:base>
+ $<TARGET_OBJECTS:config>
+ $<TARGET_OBJECTS:remote>
+)
+target_link_libraries(check_nscp_api ${base_DEPS})
set_target_properties (
check_nscp_api PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
icinga-notification.cpp
icinga-perfdata.cpp
remote-url.cpp
+ $<TARGET_OBJECTS:base>
+ $<TARGET_OBJECTS:config>
+ $<TARGET_OBJECTS:remote>
+ $<TARGET_OBJECTS:icinga>
)
if(ICINGA2_UNITY_BUILD)
add_boost_test(base
SOURCES test-runner.cpp ${base_test_SOURCES}
+ LIBRARIES ${base_DEPS}
TESTS base_array/construct
base_array/getset
base_array/resize
remote_url/illegal_legal_strings
)
-add_whole_static_library(${base_TARGET_NAME} base)
-add_whole_static_library(${base_TARGET_NAME} config)
-add_whole_static_library(${base_TARGET_NAME} icinga)
-
if(ICINGA2_WITH_LIVESTATUS)
set(livestatus_test_SOURCES
livestatus-fixture.cpp
livestatus.cpp
+ $<TARGET_OBJECTS:base>
+ $<TARGET_OBJECTS:config>
+ $<TARGET_OBJECTS:remote>
+ $<TARGET_OBJECTS:icinga>
+ $<TARGET_OBJECTS:livestatus>
+ $<TARGET_OBJECTS:methods>
)
if(ICINGA2_UNITY_BUILD)
add_boost_test(livestatus
SOURCES test-runner.cpp ${livestatus_test_SOURCES}
+ LIBRARIES ${base_DEPS}
TESTS livestatus/hosts livestatus/services
)
-
- add_whole_static_library(${livestatus_TARGET_NAME} base)
- add_whole_static_library(${livestatus_TARGET_NAME} config)
- add_whole_static_library(${livestatus_TARGET_NAME} icinga)
- add_whole_static_library(${livestatus_TARGET_NAME} livestatus)
- add_whole_static_library(${livestatus_TARGET_NAME} methods)
endif()
set(icinga_checkable_test_SOURCES
icinga-checkable-fixture.cpp
icinga-checkable-flapping.cpp
+ $<TARGET_OBJECTS:base>
+ $<TARGET_OBJECTS:config>
+ $<TARGET_OBJECTS:remote>
+ $<TARGET_OBJECTS:icinga>
+ $<TARGET_OBJECTS:cli>
)
if(ICINGA2_UNITY_BUILD)
add_boost_test(icinga_checkable
SOURCES test-runner.cpp ${icinga_checkable_test_SOURCES}
+ LIBRARIES ${base_DEPS}
TESTS icinga_checkable_flapping/host_not_flapping
icinga_checkable_flapping/host_flapping
icinga_checkable_flapping/host_flapping_recover
icinga_checkable_flapping/host_flapping_docs_example
)
-
-add_whole_static_library(${icinga_checkable_TARGET_NAME} base)
-add_whole_static_library(${icinga_checkable_TARGET_NAME} config)
-add_whole_static_library(${icinga_checkable_TARGET_NAME} icinga)
-add_whole_static_library(${icinga_checkable_TARGET_NAME} cli)