From 514346c3ba5a6d8a1544fd99606e133073c34e8d Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 4 Sep 2020 11:00:34 +0200 Subject: [PATCH 1/3] static support lib --- CMakeLists.txt | 23 ++++++----- slsDetectorSoftware/CMakeLists.txt | 2 +- slsSupportLib/CMakeLists.txt | 65 ++++++++++++++++++++---------- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 581a83dc5..756389d2a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,17 +63,18 @@ find_package(ClangFormat) check_ipo_supported(RESULT SLS_LTO_AVAILABLE) -# Use ld.gold if it is available and isn't disabled explicitly -option(SLS_USE_LD_GOLD "Use GNU gold linker" ON) -if (SLS_USE_LD_GOLD) - execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) - if ("${LD_VERSION}" MATCHES "GNU gold") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") - else () - message(WARNING "GNU gold linker isn't available, using the default system linker.") - endif () -endif () +# # Use ld.gold if it is available and isn't disabled explicitly +# option(SLS_USE_LD_GOLD "Use GNU gold linker" ON) +# if (SLS_USE_LD_GOLD) +# execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) +# if ("${LD_VERSION}" MATCHES "GNU gold") +# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") +# set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") +# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") +# else () +# message(WARNING "GNU gold linker isn't available, using the default system linker.") +# endif () +# endif () set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 264ab07b9..2725a84da 100755 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -27,7 +27,7 @@ target_include_directories(slsDetectorShared PUBLIC target_link_libraries(slsDetectorShared PUBLIC - slsSupportLib + slsSupportLibStatic pthread rt slsProjectOptions diff --git a/slsSupportLib/CMakeLists.txt b/slsSupportLib/CMakeLists.txt index c447dd773..8ec99a318 100755 --- a/slsSupportLib/CMakeLists.txt +++ b/slsSupportLib/CMakeLists.txt @@ -44,54 +44,75 @@ if(SLS_DEVEL_HEADERS) ) endif() -add_library(slsSupportLib SHARED +# Create a Object library to avoid duplicating the build +add_library(slsSupportObject OBJECT ${SOURCES} ${HEADERS} ) -if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) - set_property(TARGET slsSupportLib PROPERTY INTERPROCEDURAL_OPTIMIZATION True) -endif() +target_include_directories(slsSupportObject PUBLIC + "$" + "$" +) + + +target_include_directories(slsSupportObject PRIVATE + ${ZeroMQ_INCLUDE_DIRS} +) + +target_link_libraries(slsSupportObject + PUBLIC + slsProjectOptions + zmq + rapidjson + PRIVATE + slsProjectWarnings +) + +if (SLS_USE_TESTS) + add_subdirectory(tests) +endif(SLS_USE_TESTS) + +add_library(slsSupportLib SHARED $) target_include_directories(slsSupportLib PUBLIC "$" "$" ) -target_include_directories(slsSupportLib PRIVATE - ${ZeroMQ_INCLUDE_DIRS} -) - - set_target_properties(slsSupportLib PROPERTIES LIBRARY_OUTPUT_NAME SlsSupport LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin PUBLIC_HEADER "${PUBLICHEADERS}" ) -target_link_libraries(slsSupportLib - PUBLIC - slsProjectOptions - # ${ZeroMQ_LIBRARIES} - zmq - rapidjson - PRIVATE - slsProjectWarnings +add_library(slsSupportLibStatic STATIC $) + +set_target_properties(slsSupportLibStatic PROPERTIES + ARCHIVE_OUTPUT_NAME SlsSupportStatic + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + PUBLIC_HEADER "${PUBLICHEADERS}" ) +target_include_directories(slsSupportLibStatic PUBLIC + "$" + "$" +) - -if (SLS_USE_TESTS) - add_subdirectory(tests) -endif(SLS_USE_TESTS) +if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) + set_property(TARGET slsSupportObject PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_property(TARGET slsSupportLib PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_property(TARGET slsSupportLibStatic PROPERTY INTERPROCEDURAL_OPTIMIZATION True) +endif() # Install the library -install(TARGETS slsSupportLib +install(TARGETS slsSupportLib slsSupportLibStatic EXPORT "${TARGETS_EXPORT_NAME}" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) + From a1b88d3a622834daf59bc1852f4d43c8ef4c63d7 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Fri, 4 Sep 2020 11:20:33 +0200 Subject: [PATCH 2/3] fix --- slsReceiverSoftware/CMakeLists.txt | 8 ++++--- slsSupportLib/CMakeLists.txt | 35 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index ecc9a262a..7c8394ef5 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -34,10 +34,12 @@ if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET slsReceiverShared PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() -target_link_libraries(slsReceiverShared PUBLIC +target_link_libraries(slsReceiverShared + PUBLIC slsProjectOptions - slsProjectWarnings - slsSupportLib + slsSupportLibStatic + PRIVATE + slsProjectWarnings #don't propagate warnigns ) target_include_directories(slsReceiverShared PUBLIC diff --git a/slsSupportLib/CMakeLists.txt b/slsSupportLib/CMakeLists.txt index 8ec99a318..9958a2178 100755 --- a/slsSupportLib/CMakeLists.txt +++ b/slsSupportLib/CMakeLists.txt @@ -12,9 +12,6 @@ set(SOURCES src/sls_detector_exceptions.cpp ) -set(HEADERS -) - set(PUBLICHEADERS include/sls_detector_defs.h include/sls_detector_exceptions.h @@ -26,6 +23,10 @@ set(PUBLICHEADERS include/TimeHelper.h ) +# Additional headers to be installed if SLS_DEVEL_HEADERS +# is specified as an option. Aim is to give the developer +# access to utilities in the support library while +# at the same time offer a minimal install if(SLS_DEVEL_HEADERS) set(PUBLICHEADERS ${PUBLICHEADERS} @@ -44,15 +45,12 @@ if(SLS_DEVEL_HEADERS) ) endif() -# Create a Object library to avoid duplicating the build +# Create a Object library to avoidbuilding the library twice add_library(slsSupportObject OBJECT ${SOURCES} ${HEADERS} ) - - - target_include_directories(slsSupportObject PUBLIC "$" "$" @@ -77,11 +75,11 @@ if (SLS_USE_TESTS) endif(SLS_USE_TESTS) add_library(slsSupportLib SHARED $) - -target_include_directories(slsSupportLib PUBLIC - "$" - "$" -) +target_link_libraries(slsSupportLib PUBLIC slsSupportObject) +# target_include_directories(slsSupportLib PUBLIC +# "$" +# "$" +# ) set_target_properties(slsSupportLib PROPERTIES LIBRARY_OUTPUT_NAME SlsSupport @@ -90,6 +88,7 @@ set_target_properties(slsSupportLib PROPERTIES ) add_library(slsSupportLibStatic STATIC $) +target_link_libraries(slsSupportLibStatic PUBLIC slsSupportObject) set_target_properties(slsSupportLibStatic PROPERTIES ARCHIVE_OUTPUT_NAME SlsSupportStatic @@ -97,19 +96,19 @@ set_target_properties(slsSupportLibStatic PROPERTIES PUBLIC_HEADER "${PUBLICHEADERS}" ) -target_include_directories(slsSupportLibStatic PUBLIC - "$" - "$" -) +# target_include_directories(slsSupportLibStatic PUBLIC +# "$" +# "$" +# ) if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET slsSupportObject PROPERTY INTERPROCEDURAL_OPTIMIZATION True) - set_property(TARGET slsSupportLib PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_property(TARGET slsSupportLib PROPERTY INTERPROCEDURAL_OPTIMIZATION True) set_property(TARGET slsSupportLibStatic PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() # Install the library -install(TARGETS slsSupportLib slsSupportLibStatic +install(TARGETS slsSupportLib slsSupportLibStatic slsSupportObject EXPORT "${TARGETS_EXPORT_NAME}" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} From fb8842e048074df36506c7798ded0cb97434e2c9 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Mon, 7 Sep 2020 09:14:47 +0200 Subject: [PATCH 3/3] build and libname --- CMakeLists.txt | 2 +- conda-recepie/meta.yaml | 3 ++ ctbGui/CMakeLists.txt | 4 +- python/CMakeLists.txt | 2 +- sample/CMakeLists.txt | 4 +- .../moenchExecutables/CMakeLists.txt | 2 +- slsDetectorGui/CMakeLists.txt | 8 +-- slsDetectorSoftware/CMakeLists.txt | 2 +- slsReceiverSoftware/CMakeLists.txt | 20 ++++---- slsSupportLib/CMakeLists.txt | 50 ++++++++----------- tests/CMakeLists.txt | 6 +-- 11 files changed, 50 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 756389d2a..d8dd022de 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,7 +241,7 @@ if(SLS_MASTER_PROJECT) # Set install dir CMake packages set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}") # Set the list of exported targets - set(PROJECT_LIBRARIES slsSupportLib slsDetectorShared slsReceiverShared) + set(PROJECT_LIBRARIES slsSupportShared slsDetectorShared slsReceiverShared) # Generate and install package config file and version include(cmake/package_config.cmake) endif() diff --git a/conda-recepie/meta.yaml b/conda-recepie/meta.yaml index b472b205d..d3bf39d60 100755 --- a/conda-recepie/meta.yaml +++ b/conda-recepie/meta.yaml @@ -33,6 +33,7 @@ requirements: - {{ cdt('libselinux') }} # [linux] - {{ cdt('libxdamage') }} # [linux] - {{ cdt('libxxf86vm') }} # [linux] + - expat host: - libstdcxx-ng @@ -45,6 +46,7 @@ requirements: - xorg-libxau - xorg-libxrender - xorg-libxfixes + - expat run: - zeromq @@ -96,3 +98,4 @@ outputs: - {{ pin_subpackage('slsdetlib', exact=True) }} - qwt 6.* - qt 4.8.* + - expat diff --git a/ctbGui/CMakeLists.txt b/ctbGui/CMakeLists.txt index 1d2e43f56..758d8175d 100644 --- a/ctbGui/CMakeLists.txt +++ b/ctbGui/CMakeLists.txt @@ -59,14 +59,13 @@ set( HEADERS #set(ROOT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) # ROOT dictionary generation -include("${ROOT_DIR}/modules/RootNewMacros.cmake") +include("${ROOT_DIR}/RootMacros.cmake") root_generate_dictionary(ctbDict ${HEADERS} LINKDEF ctbLinkDef.h) add_library(ctbRootLib SHARED ctbDict.cxx) target_include_directories(ctbRootLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(ctbRootLib PUBLIC ROOT::Core slsDetectorShared - slsSupportLib ${ROOT_LIBRARIES} ${ROOT_EXE_LINKER_FLAGS} ) @@ -78,7 +77,6 @@ set_target_properties( target_link_libraries(ctbGui PUBLIC slsDetectorShared - slsSupportLib ctbRootLib ${TIFF_LIBRARIES} ) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 948b44d9c..bb7a6bf3e 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,7 +11,7 @@ pybind11_add_module(_slsdet target_link_libraries(_slsdet PUBLIC slsDetectorShared slsReceiverShared - slsSupportLib + slsSupportShared ${ZeroMQ_LIBRARIES} ) diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index dca5fd59b..98ae46d35 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(using_logger using_logger.cpp) target_link_libraries(using_logger - slsSupportLib + slsSupportShared pthread rt ) @@ -22,7 +22,7 @@ set_target_properties(using_logger PROPERTIES # add_executable(udp udp.cpp) # target_link_libraries(udp # slsDetectorShared -# slsSupportLib +# slsSupportShared # pthread # rt # fmt diff --git a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt index c9f81a3f5..f644f9978 100644 --- a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt +++ b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt @@ -23,7 +23,7 @@ foreach(exe ${MOENCH_EXECUTABLES}) target_link_libraries(${exe} PUBLIC - slsSupportLib + slsSupportShared ${ZeroMQ_LIBRARIES} pthread tiff diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt index ac9277a16..d05da8e06 100755 --- a/slsDetectorGui/CMakeLists.txt +++ b/slsDetectorGui/CMakeLists.txt @@ -88,6 +88,7 @@ target_include_directories(slsDetectorGui PUBLIC ) target_link_libraries(slsDetectorGui PUBLIC + slsProjectOptions slsProjectWarnings slsDetectorShared ${QT_QTCORE_LIBRARIES} @@ -97,6 +98,7 @@ target_link_libraries(slsDetectorGui PUBLIC ZLIB::ZLIB Qt4::QtOpenGL Qt4::QtSvg + expat ) set_target_properties(slsDetectorGui PROPERTIES @@ -104,10 +106,10 @@ set_target_properties(slsDetectorGui PROPERTIES ) install(TARGETS slsDetectorGui - # EXPORT "${TARGETS_EXPORT_NAME}" + EXPORT "${TARGETS_EXPORT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - # LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - # ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 2725a84da..349f5d9d6 100755 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -27,7 +27,7 @@ target_include_directories(slsDetectorShared PUBLIC target_link_libraries(slsDetectorShared PUBLIC - slsSupportLibStatic + slsSupportStatic pthread rt slsProjectOptions diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 7c8394ef5..577e08dc7 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -35,10 +35,10 @@ if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) endif() target_link_libraries(slsReceiverShared - PUBLIC + PUBLIC slsProjectOptions - slsSupportLibStatic - PRIVATE + slsSupportStatic + PRIVATE slsProjectWarnings #don't propagate warnigns ) @@ -80,13 +80,13 @@ set_target_properties(slsReceiver PROPERTIES ) target_link_libraries(slsReceiver PUBLIC - slsProjectOptions - slsProjectWarnings - slsSupportLib + PUBLIC slsReceiverShared pthread ${ZeroMQ_LIBRARIES} rt + PRIVATE + slsProjectWarnings ) add_executable(slsMultiReceiver @@ -97,14 +97,14 @@ set_target_properties(slsMultiReceiver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -target_link_libraries(slsMultiReceiver PUBLIC - slsProjectOptions - slsProjectWarnings - slsSupportLib +target_link_libraries(slsMultiReceiver + PUBLIC slsReceiverShared pthread ${ZeroMQ_LIBRARIES} rt + PRIVATE + slsProjectWarnings ) if (SLS_USE_TESTS) diff --git a/slsSupportLib/CMakeLists.txt b/slsSupportLib/CMakeLists.txt index 9958a2178..787942ea6 100755 --- a/slsSupportLib/CMakeLists.txt +++ b/slsSupportLib/CMakeLists.txt @@ -12,6 +12,7 @@ set(SOURCES src/sls_detector_exceptions.cpp ) +# Header files to install as a part of the library set(PUBLICHEADERS include/sls_detector_defs.h include/sls_detector_exceptions.h @@ -45,28 +46,27 @@ if(SLS_DEVEL_HEADERS) ) endif() -# Create a Object library to avoidbuilding the library twice +# Create an object library to avoid building the library twice add_library(slsSupportObject OBJECT ${SOURCES} ${HEADERS} ) -target_include_directories(slsSupportObject PUBLIC +target_include_directories(slsSupportObject + PUBLIC "$" "$" -) - - -target_include_directories(slsSupportObject PRIVATE + PRIVATE ${ZeroMQ_INCLUDE_DIRS} ) target_link_libraries(slsSupportObject - PUBLIC + PUBLIC slsProjectOptions - zmq + # zmq + ${ZeroMQ_LIBRARIES} rapidjson - PRIVATE + PRIVATE slsProjectWarnings ) @@ -74,41 +74,35 @@ if (SLS_USE_TESTS) add_subdirectory(tests) endif(SLS_USE_TESTS) -add_library(slsSupportLib SHARED $) -target_link_libraries(slsSupportLib PUBLIC slsSupportObject) -# target_include_directories(slsSupportLib PUBLIC -# "$" -# "$" -# ) +# Add shared library version of the support lib +add_library(slsSupportShared SHARED $) -set_target_properties(slsSupportLib PROPERTIES +target_link_libraries(slsSupportShared PUBLIC slsSupportObject) + +set_target_properties(slsSupportShared PROPERTIES LIBRARY_OUTPUT_NAME SlsSupport LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin PUBLIC_HEADER "${PUBLICHEADERS}" ) -add_library(slsSupportLibStatic STATIC $) -target_link_libraries(slsSupportLibStatic PUBLIC slsSupportObject) +# Add static version of the support lib +add_library(slsSupportStatic STATIC $) -set_target_properties(slsSupportLibStatic PROPERTIES +target_link_libraries(slsSupportStatic PUBLIC slsSupportObject) + +set_target_properties(slsSupportStatic PROPERTIES ARCHIVE_OUTPUT_NAME SlsSupportStatic ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin PUBLIC_HEADER "${PUBLICHEADERS}" ) -# target_include_directories(slsSupportLibStatic PUBLIC -# "$" -# "$" -# ) - if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET slsSupportObject PROPERTY INTERPROCEDURAL_OPTIMIZATION True) - set_property(TARGET slsSupportLib PROPERTY INTERPROCEDURAL_OPTIMIZATION True) - set_property(TARGET slsSupportLibStatic PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_property(TARGET slsSupportShared PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_property(TARGET slsSupportStatic PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() -# Install the library -install(TARGETS slsSupportLib slsSupportLibStatic slsSupportObject +install(TARGETS slsSupportShared slsSupportStatic slsSupportObject EXPORT "${TARGETS_EXPORT_NAME}" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 62f3fe847..3cdb3d634 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,12 +8,12 @@ set(SLS_TEST_SOURCES ) add_executable(testclient src/testclient.cpp) -target_link_libraries(testclient slsSupportLib) +target_link_libraries(testclient slsSupportShared) set_target_properties(testclient PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) add_executable(testserver src/testserver.cpp) -target_link_libraries(testserver slsSupportLib) +target_link_libraries(testserver slsSupportShared) set_target_properties(testserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -21,7 +21,7 @@ add_executable(tests ${SLS_TEST_SOURCES}) target_link_libraries(tests slsProjectOptions slsProjectWarnings - slsSupportLib + slsSupportShared pthread rt )