Adding option for turning off linking atomic and refactor linking external libraries code block

This commit is contained in:
Bram 2020-06-02 16:32:27 +02:00
parent d3e60fbcdf
commit f3f17032b4
2 changed files with 15 additions and 11 deletions

View File

@ -20,6 +20,7 @@ project(oatpp VERSION ${OATPP_THIS_MODULE_VERSION} LANGUAGES CXX)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(OATPP_INSTALL "Create installation target for oat++" ON)
option(OATPP_BUILD_TESTS "Create test target for oat++" ON)
option(OATPP_LINK_ATOMIC "Link atomic library for other platform than MSVC|MINGW|APPLE|FreeBSD" ON)
###################################################################################################
## COMPILATION CONFIG #############################################################################

View File

@ -257,17 +257,20 @@ set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads REQUIRED)
#######################################################################################################
## Link external libraries
if(MSVC OR MINGW)
target_link_libraries(oatpp PUBLIC ${CMAKE_THREAD_LIBS_INIT} wsock32 ws2_32)
elseif(APPLE)
target_link_libraries(oatpp PUBLIC ${CMAKE_THREAD_LIBS_INIT})
else(MSVC OR MINGW)
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
target_link_libraries(oatpp PUBLIC ${CMAKE_THREAD_LIBS_INIT})
else(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
target_link_libraries(oatpp PUBLIC ${CMAKE_THREAD_LIBS_INIT} atomic)
endif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
endif(MSVC OR MINGW)
SET(ADD_LINK_LIBS wsock32 ws2_32)
elseif(NOT APPLE AND ${CMAKE_SYSTEM_NAME} NOT STREQUAL "FreeBSD")
if(OATPP_LINK_ATOMIC)
SET(ADD_LINK_LIBS atomic)
endif()
endif()
target_link_libraries(oatpp PUBLIC ${CMAKE_THREAD_LIBS_INIT}
${ADD_LINK_LIBS}
)
target_include_directories(oatpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
@ -299,7 +302,7 @@ target_include_directories(oatpp-test PUBLIC
add_dependencies(oatpp-test oatpp)
#######################################################################################################
## install targets
## Install targets
if(OATPP_INSTALL)
include("../cmake/module-install.cmake")