forked from palacaze/sigslot
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
96 lines (83 loc) · 2.86 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
cmake_minimum_required(VERSION 3.5)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
project(pal_sigslot VERSION 1.2.0 LANGUAGES CXX)
include(SigslotUtils)
### options
option(SIGSLOT_COMPILE_EXAMPLES "Compile optional exemples" ON)
option(SIGSLOT_COMPILE_TESTS "Compile tests" ON)
option(SIGSLOT_RUN_TESTS "Compile and run tests" ON)
option(SIGSLOT_REDUCE_COMPILE_TIME "Attempt at reducing code size and compilation time" OFF)
find_package(Threads REQUIRED)
### sigslot library
add_library(sigslot INTERFACE)
add_library(Pal::Sigslot ALIAS sigslot)
target_include_directories(sigslot INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(sigslot INTERFACE
$<$<BOOL:${SIGSLOT_REDUCE_COMPILE_TIME}>:SIGSLOT_REDUCE_COMPILE_TIME>
)
target_link_options(sigslot INTERFACE
# We deactivate ICF on windows compilers because it interferes with signal
# disconnection by making identical functions not unique.
$<$<CXX_COMPILER_ID:MSVC>:/OPT:NOICF>
$<$<BOOL:${SIGSLOT_COMPILER_CLANGCL}>:/OPT:NOICF>
)
target_link_libraries(sigslot INTERFACE Threads::Threads)
set_target_properties(sigslot PROPERTIES EXPORT_NAME Sigslot)
#installation
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/PalSigslotConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/PalSigslotConfig.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PalSigslot"
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/PalSigslotConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
TARGETS sigslot
EXPORT PalSigslotTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
EXPORT PalSigslotTargets
FILE PalSigslotTargets.cmake
NAMESPACE Pal::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PalSigslot"
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/PalSigslotConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PalSigslotConfigVersion.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PalSigslot"
)
export(TARGETS sigslot
NAMESPACE Pal::
FILE ${CMAKE_CURRENT_BINARY_DIR}/PalSigslotTargets.cmake
)
# Install the Config and ConfigVersion files
install(
FILES ${version_file}
${config_file}
DESTINATION ${cmake_dir}
COMPONENT ${projectname_target}Export
)
# dependencies for examples and tests
if(SIGSLOT_COMPILE_TESTS OR SIGSLOT_COMPILE_EXAMPLES)
find_package(Boost COMPONENTS system QUIET) # test of boost bridge with smart pointers
find_package(Qt5 COMPONENTS Core Widgets Gui QUIET) # optional test of Qt bridge
endif()
if(SIGSLOT_COMPILE_EXAMPLES)
add_subdirectory(example)
endif()
if(SIGSLOT_COMPILE_TESTS OR SIGSLOT_RUN_TESTS)
add_subdirectory(test)
endif()