Mercurial > hg > orthanc
comparison OrthancFramework/SharedLibrary/CMakeLists.txt @ 4496:9ea70ccf0c21
Possibility to generate a static library containing the Orthanc Framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 08 Feb 2021 18:34:40 +0100 |
parents | d9473bd5ed43 |
children | d64e6f401a8a |
comparison
equal
deleted
inserted
replaced
4495:fa2311f94d9f | 4496:9ea70ccf0c21 |
---|---|
42 # *Do not* use CMAKE_INSTALL_PREFIX, otherwise CMake automatically | 42 # *Do not* use CMAKE_INSTALL_PREFIX, otherwise CMake automatically |
43 # adds CMAKE_INSTALL_PREFIX to the include_directories(), which causes | 43 # adds CMAKE_INSTALL_PREFIX to the include_directories(), which causes |
44 # issues if re-building the shared library after install! | 44 # issues if re-building the shared library after install! |
45 set(ORTHANC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "") | 45 set(ORTHANC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "") |
46 SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests") | 46 SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests") |
47 set(BUILD_SHARED_LIBRARY ON CACHE BOOL "Whether to build a shared library instead of a static library") | |
47 | 48 |
48 | 49 |
49 | 50 |
50 ##################################################################### | 51 ##################################################################### |
51 ## Configuration of the Orthanc framework | 52 ## Configuration of the Orthanc framework |
260 add_custom_command( | 261 add_custom_command( |
261 TARGET OrthancFramework POST_BUILD | 262 TARGET OrthancFramework POST_BUILD |
262 COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/OrthancFramework.js | 263 COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/OrthancFramework.js |
263 ) | 264 ) |
264 else() | 265 else() |
265 add_library(OrthancFramework SHARED | 266 if (BUILD_SHARED_LIBRARY) |
266 ${AUTOGENERATED_SOURCES} | 267 add_library(OrthancFramework SHARED |
267 ${ORTHANC_CORE_SOURCES} | 268 ${AUTOGENERATED_SOURCES} |
268 ${ORTHANC_DICOM_SOURCES} | 269 ${ORTHANC_CORE_SOURCES} |
269 DllMain.cpp | 270 ${ORTHANC_DICOM_SOURCES} |
270 ) | 271 DllMain.cpp |
271 endif() | 272 ) |
272 | 273 |
273 | 274 # By default, hide all the symbols |
274 if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | 275 set_target_properties(OrthancFramework PROPERTIES C_VISIBILITY_PRESET hidden) |
275 # By default, hide all the symbols | 276 set_target_properties(OrthancFramework PROPERTIES CXX_VISIBILITY_PRESET hidden) |
276 set_target_properties(OrthancFramework PROPERTIES C_VISIBILITY_PRESET hidden) | 277 |
277 set_target_properties(OrthancFramework PROPERTIES CXX_VISIBILITY_PRESET hidden) | 278 # Configure the version of the shared library |
278 | 279 set_target_properties( |
279 # Configure the version of the shared library | 280 OrthancFramework PROPERTIES |
280 set_target_properties( | 281 VERSION ${ORTHANC_VERSION} |
281 OrthancFramework PROPERTIES | 282 SOVERSION ${ORTHANC_FRAMEWORK_SOVERSION} |
282 VERSION ${ORTHANC_VERSION} | 283 ) |
283 SOVERSION ${ORTHANC_FRAMEWORK_SOVERSION} | 284 |
284 ) | 285 target_link_libraries(OrthancFramework ${DCMTK_LIBRARIES}) |
285 endif() | 286 |
286 | 287 if (LIBICU_LIBRARIES) |
287 | 288 target_link_libraries(OrthancFramework ${LIBICU_LIBRARIES}) |
288 target_link_libraries(OrthancFramework ${DCMTK_LIBRARIES}) | 289 endif() |
289 | 290 |
290 if (LIBICU_LIBRARIES) | 291 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
291 target_link_libraries(OrthancFramework ${LIBICU_LIBRARIES}) | 292 target_link_libraries(OrthancFramework winpthread) |
292 endif() | 293 endif() |
293 | 294 else() |
294 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | 295 # Building a static library |
295 target_link_libraries(OrthancFramework winpthread) | 296 add_library(OrthancFramework STATIC |
297 ${AUTOGENERATED_SOURCES} | |
298 ${ORTHANC_CORE_SOURCES} | |
299 ${ORTHANC_DICOM_SOURCES} | |
300 ) | |
301 endif() | |
296 endif() | 302 endif() |
297 | 303 |
298 | 304 |
299 | 305 |
300 ##################################################################### | 306 ##################################################################### |
460 | 466 |
461 install( | 467 install( |
462 TARGETS OrthancFramework | 468 TARGETS OrthancFramework |
463 RUNTIME DESTINATION ${ORTHANC_INSTALL_PREFIX}/lib # Destination for Windows | 469 RUNTIME DESTINATION ${ORTHANC_INSTALL_PREFIX}/lib # Destination for Windows |
464 LIBRARY DESTINATION ${ORTHANC_INSTALL_PREFIX}/lib # Destination for Linux | 470 LIBRARY DESTINATION ${ORTHANC_INSTALL_PREFIX}/lib # Destination for Linux |
471 ARCHIVE DESTINATION ${ORTHANC_INSTALL_PREFIX}/lib # Destination for static library | |
465 ) | 472 ) |
466 | 473 |
467 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | 474 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") |
468 install(FILES | 475 install(FILES |
469 ${CMAKE_CURRENT_BINARY_DIR}/OrthancFramework.wasm | 476 ${CMAKE_CURRENT_BINARY_DIR}/OrthancFramework.wasm |
515 -DSTATIC_BUILD:BOOL=${STATIC_BUILD} | 522 -DSTATIC_BUILD:BOOL=${STATIC_BUILD} |
516 -DUNIT_TESTS_WITH_HTTP_CONNEXIONS:BOOL=${UNIT_TESTS_WITH_HTTP_CONNEXIONS} | 523 -DUNIT_TESTS_WITH_HTTP_CONNEXIONS:BOOL=${UNIT_TESTS_WITH_HTTP_CONNEXIONS} |
517 -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE:BOOL=${USE_GOOGLE_TEST_DEBIAN_PACKAGE} | 524 -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE:BOOL=${USE_GOOGLE_TEST_DEBIAN_PACKAGE} |
518 -DUSE_SYSTEM_BOOST:BOOL=${USE_SYSTEM_BOOST} | 525 -DUSE_SYSTEM_BOOST:BOOL=${USE_SYSTEM_BOOST} |
519 -DUSE_SYSTEM_GOOGLE_TEST:BOOL=${USE_SYSTEM_GOOGLE_TEST} | 526 -DUSE_SYSTEM_GOOGLE_TEST:BOOL=${USE_SYSTEM_GOOGLE_TEST} |
527 -DORTHANC_FRAMEWORK_USE_SHARED:BOOL=${BUILD_SHARED_LIBRARY} | |
520 | 528 |
521 ${Flags} | 529 ${Flags} |
522 ) | 530 ) |
523 | 531 |
524 add_dependencies(UnitTests OrthancFramework) | 532 add_dependencies(UnitTests OrthancFramework) |