# HG changeset patch # User Sebastien Jodogne # Date 1376916423 -7200 # Node ID b2b56b4e33b0b05d11080ad5a01b31e7ebe0fa83 # Parent a8be42bcf2bb94b2704766f5293a7565b51acfb2 simplifications to cmake diff -r a8be42bcf2bb -r b2b56b4e33b0 CMakeLists.txt --- a/CMakeLists.txt Mon Aug 19 13:40:36 2013 +0200 +++ b/CMakeLists.txt Mon Aug 19 14:47:03 2013 +0200 @@ -14,24 +14,20 @@ SET(BUILD_UNIT_TESTS ON CACHE BOOL "Build the unit tests") SET(DCMTK_DICTIONARY_DIR "/usr/share/dcmtk" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (ignored in standalone builds)") -# Advanced parameters (for Debian packaging) -SET(USE_DYNAMIC_JSONCPP OFF CACHE BOOL "Use the dynamic version of JsonCpp (only for Debian sid)") +# Advanced parameters to fine-tune linking against system libraries +SET(USE_DYNAMIC_JSONCPP OFF CACHE BOOL "Use the dynamic version of JsonCpp") SET(USE_DYNAMIC_GOOGLE_LOG ON CACHE BOOL "Use the dynamic version of Google Log") -SET(USE_DYNAMIC_GOOGLE_TEST ON CACHE BOOL "Use the dynamic version of Google Test (not for Debian sid)") +SET(USE_DYNAMIC_GOOGLE_TEST ON CACHE BOOL "Use the dynamic version of Google Test") SET(USE_DYNAMIC_SQLITE ON CACHE BOOL "Use the dynamic version of SQLite") SET(USE_DYNAMIC_MONGOOSE OFF CACHE BOOL "Use the dynamic version of Mongoose") SET(USE_DYNAMIC_LUA OFF CACHE BOOL "Use the dynamic version of Lua") -SET(DEBIAN_FORCE_HARDENING OFF CACHE BOOL "Force the injection of Debian hardening flags (unrecommended)") -SET(DEBIAN_USE_GTEST_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (only for Debian sid)") -SET(ONLY_CORE_LIBRARY OFF CACHE BOOL "Only build the core library") +SET(DEBIAN_USE_GTEST_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)") mark_as_advanced(USE_DYNAMIC_JSONCPP) mark_as_advanced(USE_DYNAMIC_GOOGLE_LOG) mark_as_advanced(USE_DYNAMIC_GOOGLE_TEST) mark_as_advanced(USE_DYNAMIC_SQLITE) -mark_as_advanced(DEBIAN_FORCE_HARDENING) -mark_as_advanced(DEBIAN_USE_STATIC_GOOGLE_TEST) -mark_as_advanced(ONLY_CORE_LIBRARY) +mark_as_advanced(DEBIAN_USE_GTEST_SOURCE_PACKAGE) # Some basic inclusions include(CheckIncludeFiles) @@ -64,11 +60,7 @@ endif() include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake) - -if(NOT ONLY_CORE_LIBRARY) - include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake) -endif() - +include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake) include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake) include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake) include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake) @@ -164,63 +156,60 @@ ) +add_library(ServerLibrary + STATIC + ${DCMTK_SOURCES} + OrthancServer/DicomProtocol/DicomFindAnswers.cpp + OrthancServer/DicomProtocol/DicomServer.cpp + OrthancServer/DicomProtocol/DicomUserConnection.cpp + OrthancServer/FromDcmtkBridge.cpp + OrthancServer/Internals/CommandDispatcher.cpp + OrthancServer/Internals/FindScp.cpp + OrthancServer/Internals/MoveScp.cpp + OrthancServer/Internals/StoreScp.cpp + OrthancServer/OrthancInitialization.cpp + OrthancServer/OrthancRestApi.cpp + OrthancServer/ServerIndex.cpp + OrthancServer/ToDcmtkBridge.cpp + OrthancServer/DatabaseWrapper.cpp + OrthancServer/ServerContext.cpp + OrthancServer/ServerEnumerations.cpp + OrthancServer/ServerToolbox.cpp + ) -if(NOT ONLY_CORE_LIBRARY) - add_library(ServerLibrary - STATIC - ${DCMTK_SOURCES} - OrthancServer/DicomProtocol/DicomFindAnswers.cpp - OrthancServer/DicomProtocol/DicomServer.cpp - OrthancServer/DicomProtocol/DicomUserConnection.cpp - OrthancServer/FromDcmtkBridge.cpp - OrthancServer/Internals/CommandDispatcher.cpp - OrthancServer/Internals/FindScp.cpp - OrthancServer/Internals/MoveScp.cpp - OrthancServer/Internals/StoreScp.cpp - OrthancServer/OrthancInitialization.cpp - OrthancServer/OrthancRestApi.cpp - OrthancServer/ServerIndex.cpp - OrthancServer/ToDcmtkBridge.cpp - OrthancServer/DatabaseWrapper.cpp - OrthancServer/ServerContext.cpp - OrthancServer/ServerEnumerations.cpp - OrthancServer/ServerToolbox.cpp - ) +# Ensure autogenerated code is built before building ServerLibrary +add_dependencies(ServerLibrary CoreLibrary) + +add_executable(Orthanc + OrthancServer/main.cpp + ) + +target_link_libraries(Orthanc ServerLibrary CoreLibrary) + +install( + TARGETS Orthanc + RUNTIME DESTINATION bin + ) - # Ensure autogenerated code is built before building ServerLibrary - add_dependencies(ServerLibrary CoreLibrary) - - add_executable(Orthanc - OrthancServer/main.cpp +# Build the unit tests if required +if (BUILD_UNIT_TESTS) + add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1) + include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake) + add_executable(UnitTests + ${GTEST_SOURCES} + UnitTests/FileStorage.cpp + UnitTests/MemoryCache.cpp + UnitTests/Png.cpp + UnitTests/RestApi.cpp + UnitTests/SQLite.cpp + UnitTests/SQLiteChromium.cpp + UnitTests/ServerIndex.cpp + UnitTests/Versions.cpp + UnitTests/Zip.cpp + UnitTests/Lua.cpp + UnitTests/main.cpp ) - - target_link_libraries(Orthanc ServerLibrary CoreLibrary) - - install( - TARGETS Orthanc - RUNTIME DESTINATION bin - ) - - # Build the unit tests if required - if (BUILD_UNIT_TESTS) - add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1) - include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake) - add_executable(UnitTests - ${GTEST_SOURCES} - UnitTests/FileStorage.cpp - UnitTests/MemoryCache.cpp - UnitTests/Png.cpp - UnitTests/RestApi.cpp - UnitTests/SQLite.cpp - UnitTests/SQLiteChromium.cpp - UnitTests/ServerIndex.cpp - UnitTests/Versions.cpp - UnitTests/Zip.cpp - UnitTests/Lua.cpp - UnitTests/main.cpp - ) - target_link_libraries(UnitTests ServerLibrary CoreLibrary) - endif() + target_link_libraries(UnitTests ServerLibrary CoreLibrary) endif() diff -r a8be42bcf2bb -r b2b56b4e33b0 Resources/CMake/Compiler.cmake --- a/Resources/CMake/Compiler.cmake Mon Aug 19 13:40:36 2013 +0200 +++ b/Resources/CMake/Compiler.cmake Mon Aug 19 14:47:03 2013 +0200 @@ -29,28 +29,6 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - if (DEBIAN_FORCE_HARDENING) - execute_process( - COMMAND dpkg-buildflags --get CPPFLAGS - OUTPUT_VARIABLE DEBIAN_CPP_FLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process( - COMMAND dpkg-buildflags --get CFLAGS - OUTPUT_VARIABLE DEBIAN_C_FLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process( - COMMAND dpkg-buildflags --get CXXFLAGS - OUTPUT_VARIABLE DEBIAN_CXX_FLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process( - COMMAND dpkg-buildflags --get LDFLAGS - OUTPUT_VARIABLE DEBIAN_LD_FLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEBIAN_C_FLAGS} ${DEBIAN_CPP_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBIAN_CXX_FLAGS} ${DEBIAN_CPP_FLAGS}") - endif() - if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward -fpermissive") endif() @@ -59,9 +37,9 @@ -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed ${DEBIAN_LD_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined ${DEBIAN_LD_FLAGS}") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined ${DEBIAN_LD_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # Remove the "-rdynamic" option # http://www.mail-archive.com/cmake@cmake.org/msg08837.html diff -r a8be42bcf2bb -r b2b56b4e33b0 Resources/Samples/RestApi/CMakeLists.txt --- a/Resources/Samples/RestApi/CMakeLists.txt Mon Aug 19 13:40:36 2013 +0200 +++ b/Resources/Samples/RestApi/CMakeLists.txt Mon Aug 19 14:47:03 2013 +0200 @@ -22,8 +22,8 @@ UPDATE_COMMAND "" SOURCE_DIR ${CMAKE_BINARY_DIR}/Orthanc/src/orthanc/ CMAKE_COMMAND ${CMAKE_COMMAND} - CMAKE_ARGS -DSTATIC_BUILD=ON -DSTANDALONE_BUILD=ON -DUSE_DYNAMIC_GOOGLE_LOG=OFF -DUSE_DYNAMIC_SQLITE=OFF -DONLY_CORE_LIBRARY=ON -DENABLE_SSL=OFF ${TOOLCHAIN} - BUILD_COMMAND $(MAKE) + CMAKE_ARGS -DSTATIC_BUILD=ON -DSTANDALONE_BUILD=ON -DUSE_DYNAMIC_GOOGLE_LOG=OFF -DUSE_DYNAMIC_SQLITE=OFF -DENABLE_SSL=OFF ${TOOLCHAIN} + BUILD_COMMAND $(MAKE) CoreLibrary INSTALL_COMMAND "" BUILD_IN_SOURCE 0 )