Skip to content

Commit

Permalink
Add a CMake option controlling whether to link to libatomic. Refs #169.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Oct 12, 2024
1 parent ba4f9a5 commit 8b85cda
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,34 @@ target_link_libraries(boost_uuid

target_compile_features(boost_uuid INTERFACE cxx_std_11)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"))
# Link Boost::uuid to libatomic

set(_def_linkatomic OFF)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

set(_def_linkatomic ON)

endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")

set(_def_linkatomic ON)

endif()

option(BOOST_UUID_LINK_LIBATOMIC "Boost.UUID: link Boost::uuid to libatomic" ${_def_linkatomic})

unset(_def_linkatomic)

if(BOOST_UUID_LINK_LIBATOMIC)

target_link_libraries(boost_uuid INTERFACE atomic)

endif()

# Testing support

if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")

add_subdirectory(test)
Expand Down

0 comments on commit 8b85cda

Please sign in to comment.