diff options
-rw-r--r-- | CMakeLists.txt | 156 | ||||
-rw-r--r-- | cmake/ModulePackage.cmake | 50 |
2 files changed, 106 insertions, 100 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e560198..e42527c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -6,6 +6,7 @@ include(CTest) | |||
6 | # versions in a synchronised way. | 6 | # versions in a synchronised way. |
7 | set(PROJECT_VERSION "0.0.0") | 7 | set(PROJECT_VERSION "0.0.0") |
8 | 8 | ||
9 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
9 | 10 | ||
10 | ################################################################################ | 11 | ################################################################################ |
11 | # | 12 | # |
@@ -13,12 +14,19 @@ set(PROJECT_VERSION "0.0.0") | |||
13 | # | 14 | # |
14 | ################################################################################ | 15 | ################################################################################ |
15 | 16 | ||
17 | include(CheckCCompilerFlag) | ||
18 | include(ModulePackage) | ||
19 | |||
16 | set(CMAKE_MACOSX_RPATH ON) | 20 | set(CMAKE_MACOSX_RPATH ON) |
17 | 21 | ||
18 | option(DEBUG "Enable assertions and other debugging facilities" OFF) | 22 | option(DEBUG "Enable assertions and other debugging facilities" OFF) |
19 | if(DEBUG) | 23 | if(DEBUG) |
20 | add_definitions(-DTOX_DEBUG=1) | 24 | add_definitions(-DTOX_DEBUG=1) |
21 | add_definitions(-DMIN_LOGGER_LEVEL=LOG_TRACE) | 25 | add_definitions(-DMIN_LOGGER_LEVEL=LOG_TRACE) |
26 | check_c_compiler_flag("-g3" HAVE_G3) | ||
27 | if(HAVE_G3) | ||
28 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") | ||
29 | endif() | ||
22 | endif() | 30 | endif() |
23 | 31 | ||
24 | option(ASSOC_DHT "Enable module to store currently unused ID <=> IP associations" OFF) | 32 | option(ASSOC_DHT "Enable module to store currently unused ID <=> IP associations" OFF) |
@@ -28,76 +36,38 @@ endif() | |||
28 | 36 | ||
29 | option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF) | 37 | option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF) |
30 | if(ASAN) | 38 | if(ASAN) |
31 | include(CheckCCompilerFlag) | ||
32 | set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") | 39 | set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") |
33 | set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=address") | 40 | set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=address") |
34 | check_c_compiler_flag("-fsanitize=address" HAVE_ASAN) | 41 | check_c_compiler_flag("-fsanitize=address" HAVE_ASAN) |
35 | if(HAVE_ASAN) | 42 | if(HAVE_ASAN) |
36 | set(CMAKE_C_FLAGS "-fsanitize=address") | 43 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") |
37 | endif() | 44 | endif() |
38 | set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") | 45 | set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") |
39 | endif() | 46 | endif() |
40 | 47 | ||
41 | find_package(PkgConfig REQUIRED) | ||
42 | find_package(Threads REQUIRED) | 48 | find_package(Threads REQUIRED) |
43 | 49 | ||
44 | find_library(UTIL_LIBRARIES util ) | 50 | find_library(NCURSES_LIBRARIES ncurses ) |
45 | find_library(RT_LIBRARIES rt ) | 51 | find_library(UTIL_LIBRARIES util ) |
52 | find_library(RT_LIBRARIES rt ) | ||
46 | 53 | ||
47 | # For toxcore. | 54 | # For toxcore. |
48 | pkg_search_module(LIBSODIUM REQUIRED libsodium ) | 55 | pkg_use_module(LIBSODIUM REQUIRED libsodium ) |
49 | 56 | ||
50 | # For toxav. | 57 | # For toxav. |
51 | pkg_search_module(OPUS REQUIRED opus ) | 58 | pkg_use_module(OPUS REQUIRED opus ) |
52 | pkg_search_module(VPX REQUIRED vpx ) | 59 | pkg_use_module(VPX REQUIRED vpx ) |
53 | 60 | ||
54 | # For tox-bootstrapd. | 61 | # For tox-bootstrapd. |
55 | pkg_search_module(LIBCONFIG libconfig ) | 62 | pkg_use_module(LIBCONFIG libconfig ) |
56 | 63 | ||
57 | # For auto tests. | 64 | # For auto tests. |
58 | pkg_search_module(CHECK check ) | 65 | pkg_use_module(CHECK check ) |
59 | 66 | ||
60 | # For av_test. | 67 | # For av_test. |
61 | pkg_search_module(OPENCV opencv ) | 68 | pkg_use_module(OPENCV opencv ) |
62 | pkg_search_module(PORTAUDIO portaudio-2.0) | 69 | pkg_use_module(PORTAUDIO portaudio-2.0 ) |
63 | pkg_search_module(SNDFILE sndfile ) | 70 | pkg_use_module(SNDFILE sndfile ) |
64 | |||
65 | # TODO(iphydf): fold the pkg_search_module call into this function. | ||
66 | function(pkg_use_module mod) | ||
67 | if(${mod}_FOUND) | ||
68 | link_directories(${${mod}_LIBRARY_DIRS}) | ||
69 | include_directories(${${mod}_INCLUDE_DIRS}) | ||
70 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}") | ||
71 | endif() | ||
72 | endfunction() | ||
73 | |||
74 | pkg_use_module(LIBSODIUM) | ||
75 | |||
76 | pkg_use_module(OPUS) | ||
77 | pkg_use_module(VPX) | ||
78 | |||
79 | pkg_use_module(LIBCONFIG) | ||
80 | |||
81 | pkg_use_module(CHECK) | ||
82 | |||
83 | pkg_use_module(OPENCV) | ||
84 | pkg_use_module(PORTAUDIO) | ||
85 | pkg_use_module(SNDFILE) | ||
86 | |||
87 | |||
88 | # Users can call cmake -DLIBTYPE=STATIC or -DLIBTYPE=SHARED to override this. | ||
89 | if(NOT LIBTYPE) | ||
90 | if(WIN32) | ||
91 | # Our win32 builds are fully static, since we use the MXE cross compiling | ||
92 | # environment, which builds everything statically by default. Building | ||
93 | # shared libraries will result in multiple definition errors, since multiple | ||
94 | # tox libraries will link against libsodium and other libraries that are | ||
95 | # built statically in MXE. | ||
96 | set(LIBTYPE STATIC) | ||
97 | else() | ||
98 | set(LIBTYPE SHARED) | ||
99 | endif() | ||
100 | endif() | ||
101 | 71 | ||
102 | 72 | ||
103 | ################################################################################ | 73 | ################################################################################ |
@@ -118,46 +88,46 @@ set(toxcore_PKGCONFIG_LIBS) | |||
118 | 88 | ||
119 | # LAYER 1: Crypto core | 89 | # LAYER 1: Crypto core |
120 | # -------------------- | 90 | # -------------------- |
121 | add_library(toxcrypto ${LIBTYPE} | 91 | add_module(toxcrypto |
122 | toxcore/crypto_core.c) | 92 | toxcore/crypto_core.c) |
123 | target_link_libraries(toxcrypto ${LIBSODIUM_LIBRARIES}) | 93 | target_link_modules(toxcrypto ${LIBSODIUM_LIBRARIES}) |
124 | 94 | ||
125 | # LAYER 2: Basic networking | 95 | # LAYER 2: Basic networking |
126 | # ------------------------- | 96 | # ------------------------- |
127 | add_library(toxnetwork ${LIBTYPE} | 97 | add_module(toxnetwork |
128 | toxcore/logger.c | 98 | toxcore/logger.c |
129 | toxcore/network.c | 99 | toxcore/network.c |
130 | toxcore/util.c) | 100 | toxcore/util.c) |
131 | target_link_libraries(toxnetwork toxcrypto) | 101 | target_link_modules(toxnetwork toxcrypto) |
132 | 102 | ||
133 | if(CMAKE_THREAD_LIBS_INIT) | 103 | if(CMAKE_THREAD_LIBS_INIT) |
134 | target_link_libraries(toxnetwork ${CMAKE_THREAD_LIBS_INIT}) | 104 | target_link_modules(toxnetwork ${CMAKE_THREAD_LIBS_INIT}) |
135 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}") | 105 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}") |
136 | endif() | 106 | endif() |
137 | 107 | ||
138 | if(RT_LIBRARIES) | 108 | if(RT_LIBRARIES) |
139 | target_link_libraries(toxnetwork ${RT_LIBRARIES}) | 109 | target_link_modules(toxnetwork ${RT_LIBRARIES}) |
140 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt") | 110 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt") |
141 | endif() | 111 | endif() |
142 | 112 | ||
143 | if(WIN32) | 113 | if(WIN32) |
144 | target_link_libraries(toxnetwork ws2_32 iphlpapi) | 114 | target_link_modules(toxnetwork ws2_32 iphlpapi) |
145 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lws2_32 -liphlpapi") | 115 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lws2_32 -liphlpapi") |
146 | endif() | 116 | endif() |
147 | 117 | ||
148 | # LAYER 3: Distributed Hash Table | 118 | # LAYER 3: Distributed Hash Table |
149 | # ------------------------------- | 119 | # ------------------------------- |
150 | add_library(toxdht ${LIBTYPE} | 120 | add_module(toxdht |
151 | toxcore/DHT.c | 121 | toxcore/DHT.c |
152 | toxcore/LAN_discovery.c | 122 | toxcore/LAN_discovery.c |
153 | toxcore/assoc.c | 123 | toxcore/assoc.c |
154 | toxcore/ping.c | 124 | toxcore/ping.c |
155 | toxcore/ping_array.c) | 125 | toxcore/ping_array.c) |
156 | target_link_libraries(toxdht toxnetwork) | 126 | target_link_modules(toxdht toxnetwork) |
157 | 127 | ||
158 | # LAYER 4: Onion routing, TCP connections, crypto connections | 128 | # LAYER 4: Onion routing, TCP connections, crypto connections |
159 | # ----------------------------------------------------------- | 129 | # ----------------------------------------------------------- |
160 | add_library(toxnetcrypto ${LIBTYPE} | 130 | add_module(toxnetcrypto |
161 | toxcore/TCP_client.c | 131 | toxcore/TCP_client.c |
162 | toxcore/TCP_connection.c | 132 | toxcore/TCP_connection.c |
163 | toxcore/TCP_server.c | 133 | toxcore/TCP_server.c |
@@ -166,33 +136,33 @@ add_library(toxnetcrypto ${LIBTYPE} | |||
166 | toxcore/onion.c | 136 | toxcore/onion.c |
167 | toxcore/onion_announce.c | 137 | toxcore/onion_announce.c |
168 | toxcore/onion_client.c) | 138 | toxcore/onion_client.c) |
169 | target_link_libraries(toxnetcrypto toxdht) | 139 | target_link_modules(toxnetcrypto toxdht) |
170 | 140 | ||
171 | # LAYER 5: Friend requests and connections | 141 | # LAYER 5: Friend requests and connections |
172 | # ---------------------------------------- | 142 | # ---------------------------------------- |
173 | add_library(toxfriends ${LIBTYPE} | 143 | add_module(toxfriends |
174 | toxcore/friend_connection.c | 144 | toxcore/friend_connection.c |
175 | toxcore/friend_requests.c) | 145 | toxcore/friend_requests.c) |
176 | target_link_libraries(toxfriends toxnetcrypto) | 146 | target_link_modules(toxfriends toxnetcrypto) |
177 | 147 | ||
178 | # LAYER 6: Tox messenger | 148 | # LAYER 6: Tox messenger |
179 | # ---------------------- | 149 | # ---------------------- |
180 | add_library(toxmessenger ${LIBTYPE} | 150 | add_module(toxmessenger |
181 | toxcore/Messenger.c) | 151 | toxcore/Messenger.c) |
182 | target_link_libraries(toxmessenger toxfriends) | 152 | target_link_modules(toxmessenger toxfriends) |
183 | 153 | ||
184 | # LAYER 7: Group chats | 154 | # LAYER 7: Group chats |
185 | # -------------------- | 155 | # -------------------- |
186 | add_library(toxgroup ${LIBTYPE} | 156 | add_module(toxgroup |
187 | toxcore/group.c) | 157 | toxcore/group.c) |
188 | target_link_libraries(toxgroup toxmessenger) | 158 | target_link_modules(toxgroup toxmessenger) |
189 | 159 | ||
190 | # LAYER 8: Public API | 160 | # LAYER 8: Public API |
191 | # ------------------- | 161 | # ------------------- |
192 | add_library(toxcore ${LIBTYPE} | 162 | add_module(toxcore |
193 | toxcore/tox.c | 163 | toxcore/tox.c |
194 | toxcore/tox_group.c) | 164 | toxcore/tox_group.c) |
195 | target_link_libraries(toxcore toxgroup) | 165 | target_link_modules(toxcore toxgroup) |
196 | 166 | ||
197 | 167 | ||
198 | ################################################################################ | 168 | ################################################################################ |
@@ -201,7 +171,7 @@ target_link_libraries(toxcore toxgroup) | |||
201 | # | 171 | # |
202 | ################################################################################ | 172 | ################################################################################ |
203 | 173 | ||
204 | add_library(toxav ${LIBTYPE} | 174 | add_module(toxav |
205 | toxav/audio.c | 175 | toxav/audio.c |
206 | toxav/bwcontroller.c | 176 | toxav/bwcontroller.c |
207 | toxav/group.c | 177 | toxav/group.c |
@@ -210,7 +180,7 @@ add_library(toxav ${LIBTYPE} | |||
210 | toxav/toxav.c | 180 | toxav/toxav.c |
211 | toxav/toxav_old.c | 181 | toxav/toxav_old.c |
212 | toxav/video.c) | 182 | toxav/video.c) |
213 | target_link_libraries(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES}) | 183 | target_link_modules(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES}) |
214 | 184 | ||
215 | 185 | ||
216 | ################################################################################ | 186 | ################################################################################ |
@@ -219,13 +189,13 @@ target_link_libraries(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES}) | |||
219 | # | 189 | # |
220 | ################################################################################ | 190 | ################################################################################ |
221 | 191 | ||
222 | add_library(toxdns ${LIBTYPE} | 192 | add_module(toxdns |
223 | toxdns/toxdns.c) | 193 | toxdns/toxdns.c) |
224 | target_link_libraries(toxdns toxcore) | 194 | target_link_modules(toxdns toxcore) |
225 | 195 | ||
226 | add_library(toxencryptsave ${LIBTYPE} | 196 | add_module(toxencryptsave |
227 | toxencryptsave/toxencryptsave.c) | 197 | toxencryptsave/toxencryptsave.c) |
228 | target_link_libraries(toxencryptsave toxcore) | 198 | target_link_modules(toxencryptsave toxcore) |
229 | 199 | ||
230 | 200 | ||
231 | ################################################################################ | 201 | ################################################################################ |
@@ -240,7 +210,7 @@ add_test(format_test | |||
240 | function(auto_test target) | 210 | function(auto_test target) |
241 | if(CHECK_FOUND) | 211 | if(CHECK_FOUND) |
242 | add_executable(auto_${target} auto_tests/${target}.c) | 212 | add_executable(auto_${target} auto_tests/${target}.c) |
243 | target_link_libraries(auto_${target} | 213 | target_link_modules(auto_${target} |
244 | toxcore | 214 | toxcore |
245 | toxav | 215 | toxav |
246 | toxencryptsave | 216 | toxencryptsave |
@@ -272,7 +242,7 @@ auto_test(toxav_many_test) | |||
272 | add_executable(DHT_bootstrap | 242 | add_executable(DHT_bootstrap |
273 | other/DHT_bootstrap.c | 243 | other/DHT_bootstrap.c |
274 | other/bootstrap_node_packets.c) | 244 | other/bootstrap_node_packets.c) |
275 | target_link_libraries(DHT_bootstrap toxnetcrypto) | 245 | target_link_modules(DHT_bootstrap toxnetcrypto) |
276 | 246 | ||
277 | if(LIBCONFIG_FOUND) | 247 | if(LIBCONFIG_FOUND) |
278 | add_executable(tox-bootstrapd | 248 | add_executable(tox-bootstrapd |
@@ -287,8 +257,7 @@ if(LIBCONFIG_FOUND) | |||
287 | other/bootstrap_daemon/src/global.h | 257 | other/bootstrap_daemon/src/global.h |
288 | other/bootstrap_node_packets.c | 258 | other/bootstrap_node_packets.c |
289 | other/bootstrap_node_packets.h) | 259 | other/bootstrap_node_packets.h) |
290 | 260 | target_link_modules(tox-bootstrapd toxnetcrypto ${LIBCONFIG_LIBRARIES}) | |
291 | target_link_libraries(tox-bootstrapd toxnetcrypto ${LIBCONFIG_LIBRARIES}) | ||
292 | endif() | 261 | endif() |
293 | 262 | ||
294 | 263 | ||
@@ -300,7 +269,7 @@ endif() | |||
300 | 269 | ||
301 | if(NOT WIN32 AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FOUND) | 270 | if(NOT WIN32 AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FOUND) |
302 | add_executable(av_test testing/av_test.c) | 271 | add_executable(av_test testing/av_test.c) |
303 | target_link_libraries(av_test | 272 | target_link_modules(av_test |
304 | toxav | 273 | toxav |
305 | ${OPENCV_LIBRARIES} | 274 | ${OPENCV_LIBRARIES} |
306 | ${PORTAUDIO_LIBRARIES} | 275 | ${PORTAUDIO_LIBRARIES} |
@@ -309,31 +278,31 @@ endif() | |||
309 | 278 | ||
310 | if(NOT WIN32) | 279 | if(NOT WIN32) |
311 | add_executable(nTox testing/nTox.c) | 280 | add_executable(nTox testing/nTox.c) |
312 | target_link_libraries(nTox toxcore ncurses) | 281 | target_link_modules(nTox toxcore ${NCURSES_LIBRARIES}) |
313 | endif() | 282 | endif() |
314 | 283 | ||
315 | add_executable(DHT_test testing/DHT_test.c) | 284 | add_executable(DHT_test testing/DHT_test.c) |
316 | target_link_libraries(DHT_test toxdht) | 285 | target_link_modules(DHT_test toxdht) |
317 | 286 | ||
318 | add_executable(Messenger_test testing/Messenger_test.c) | 287 | add_executable(Messenger_test testing/Messenger_test.c) |
319 | target_link_libraries(Messenger_test toxmessenger) | 288 | target_link_modules(Messenger_test toxmessenger) |
320 | 289 | ||
321 | add_executable(dns3_test testing/dns3_test.c) | 290 | add_executable(dns3_test testing/dns3_test.c) |
322 | target_link_libraries(dns3_test toxdns) | 291 | target_link_modules(dns3_test toxdns) |
323 | 292 | ||
324 | if(NOT WIN32) | 293 | if(NOT WIN32) |
325 | add_executable(tox_sync testing/tox_sync.c) | 294 | add_executable(tox_sync testing/tox_sync.c) |
326 | target_link_libraries(tox_sync toxcore) | 295 | target_link_modules(tox_sync toxcore) |
327 | endif() | 296 | endif() |
328 | 297 | ||
329 | if(UTIL_LIBRARIES) | 298 | if(UTIL_LIBRARIES) |
330 | add_executable(tox_shell testing/tox_shell.c) | 299 | add_executable(tox_shell testing/tox_shell.c) |
331 | target_link_libraries(tox_shell toxcore ${UTIL_LIBRARIES}) | 300 | target_link_modules(tox_shell toxcore ${UTIL_LIBRARIES}) |
332 | endif() | 301 | endif() |
333 | 302 | ||
334 | if(NOT WIN32) | 303 | if(NOT WIN32) |
335 | add_executable(irc_syncbot testing/irc_syncbot.c) | 304 | add_executable(irc_syncbot testing/irc_syncbot.c) |
336 | target_link_libraries(irc_syncbot toxcore) | 305 | target_link_modules(irc_syncbot toxcore) |
337 | endif() | 306 | endif() |
338 | 307 | ||
339 | 308 | ||
@@ -374,19 +343,6 @@ install(FILES | |||
374 | ${CMAKE_BINARY_DIR}/toxdns.pc | 343 | ${CMAKE_BINARY_DIR}/toxdns.pc |
375 | ${CMAKE_BINARY_DIR}/toxencryptsave.pc | 344 | ${CMAKE_BINARY_DIR}/toxencryptsave.pc |
376 | DESTINATION "lib/pkgconfig") | 345 | DESTINATION "lib/pkgconfig") |
377 | install(TARGETS | ||
378 | toxav | ||
379 | toxcore | ||
380 | toxcrypto | ||
381 | toxdht | ||
382 | toxdns | ||
383 | toxencryptsave | ||
384 | toxfriends | ||
385 | toxgroup | ||
386 | toxmessenger | ||
387 | toxnetcrypto | ||
388 | toxnetwork | ||
389 | DESTINATION "lib") | ||
390 | install(FILES | 346 | install(FILES |
391 | toxav/toxav.h | 347 | toxav/toxav.h |
392 | toxcore/tox.h | 348 | toxcore/tox.h |
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake new file mode 100644 index 00000000..1e49503a --- /dev/null +++ b/cmake/ModulePackage.cmake | |||
@@ -0,0 +1,50 @@ | |||
1 | option(ENABLE_SHARED "Build shared (dynamic) libraries for all modules" ON) | ||
2 | option(ENABLE_STATIC "Build static libraries for all modules" ON) | ||
3 | |||
4 | find_package(PkgConfig REQUIRED) | ||
5 | |||
6 | function(pkg_use_module mod) | ||
7 | pkg_search_module(${mod} ${ARGN}) | ||
8 | if(${mod}_FOUND) | ||
9 | link_directories(${${mod}_LIBRARY_DIRS}) | ||
10 | include_directories(${${mod}_INCLUDE_DIRS}) | ||
11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}") | ||
12 | endif() | ||
13 | endfunction() | ||
14 | |||
15 | function(add_module lib) | ||
16 | if(ENABLE_SHARED) | ||
17 | add_library(${lib}_shared SHARED ${ARGN}) | ||
18 | set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib}) | ||
19 | install(TARGETS ${lib}_shared DESTINATION "lib") | ||
20 | endif() | ||
21 | if(ENABLE_STATIC) | ||
22 | add_library(${lib}_static STATIC ${ARGN}) | ||
23 | set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib}) | ||
24 | install(TARGETS ${lib}_static DESTINATION "lib") | ||
25 | endif() | ||
26 | endfunction() | ||
27 | |||
28 | function(target_link_modules target) | ||
29 | if(TARGET ${target}_shared) | ||
30 | set(_targets ${_targets} ${target}_shared) | ||
31 | endif() | ||
32 | if(TARGET ${target}_static) | ||
33 | set(_targets ${_targets} ${target}_static) | ||
34 | endif() | ||
35 | if(NOT _targets) | ||
36 | set(_targets ${_targets} ${target}) | ||
37 | endif() | ||
38 | |||
39 | foreach(target ${_targets}) | ||
40 | foreach(dep ${ARGN}) | ||
41 | if(TARGET ${dep}_shared) | ||
42 | target_link_libraries(${target} ${dep}_shared) | ||
43 | elseif(TARGET ${dep}_static) | ||
44 | target_link_libraries(${target} ${dep}_static) | ||
45 | else() | ||
46 | target_link_libraries(${target} ${dep}) | ||
47 | endif() | ||
48 | endforeach() | ||
49 | endforeach() | ||
50 | endfunction() | ||