Skip to content

Commit

Permalink
Support BUILD_SHARED_LIBS flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisklein committed Sep 19, 2018
1 parent adfa0e2 commit 60f27b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cmake/FairMQLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,14 @@ macro(set_fairmq_defaults)
endif()
set(CMAKE_CXX_EXTENSIONS OFF)

if(NOT BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Whether to build shared libraries or static archives")
endif()

# Set -fPIC as default for all library types
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

# Generate compile_commands.json file (https://clang.llvm.org/docs/JSONCompilationDatabase.html)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
7 changes: 4 additions & 3 deletions fairmq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ if(FAST_BUILD)
else()
set(_target FairMQ)
endif()
add_library(${_target} SHARED
add_library(${_target}
${FAIRMQ_SOURCE_FILES}
${FAIRMQ_PUBLIC_HEADER_FILES} # for IDE integration
${FAIRMQ_PRIVATE_HEADER_FILES} # for IDE integration
Expand Down Expand Up @@ -237,7 +237,7 @@ target_link_libraries(${_target}
PUBLIC # libFairMQ AND consumers of libFairMQ link aginst public dependencies
Threads::Threads
dl
rt
$<$<PLATFORM_ID:Linux>:rt>
Boost::boost
Boost::program_options
Boost::thread
Expand Down Expand Up @@ -301,7 +301,7 @@ target_link_libraries(runConfigExample FairMQ)
add_executable(fairmq-shmmonitor shmem/Monitor.cxx shmem/Monitor.h shmem/runMonitor.cxx)
target_link_libraries(fairmq-shmmonitor PUBLIC
Threads::Threads
rt
$<$<PLATFORM_ID:Linux>:rt>
Boost::boost
Boost::date_time
Boost::program_options
Expand Down Expand Up @@ -332,6 +332,7 @@ install(
EXPORT ${PROJECT_EXPORT_SET}
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${PROJECT_INSTALL_LIBDIR}
)

# preserve relative path and prepend fairmq
Expand Down

0 comments on commit 60f27b9

Please sign in to comment.