mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
static support lib
This commit is contained in:
parent
497eff6f04
commit
514346c3ba
@ -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)
|
||||
|
@ -27,7 +27,7 @@ target_include_directories(slsDetectorShared PUBLIC
|
||||
|
||||
target_link_libraries(slsDetectorShared
|
||||
PUBLIC
|
||||
slsSupportLib
|
||||
slsSupportLibStatic
|
||||
pthread
|
||||
rt
|
||||
slsProjectOptions
|
||||
|
@ -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
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
)
|
||||
|
||||
|
||||
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_OBJECTS:slsSupportObject>)
|
||||
|
||||
target_include_directories(slsSupportLib PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
)
|
||||
|
||||
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 $<TARGET_OBJECTS:slsSupportObject>)
|
||||
|
||||
set_target_properties(slsSupportLibStatic PROPERTIES
|
||||
ARCHIVE_OUTPUT_NAME SlsSupportStatic
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||
)
|
||||
|
||||
target_include_directories(slsSupportLibStatic PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
)
|
||||
|
||||
|
||||
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}
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user