1# Copyright 2018 Mike Dev 2# Copyright 2019 Peter Dimov 3# Copyright 2020 Andrey Semashev 4# Distributed under the Boost Software License, Version 1.0. 5# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt 6 7cmake_minimum_required(VERSION 3.5...3.16) 8project(boost_atomic VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 10include(CheckCXXSourceCompiles) 11 12set(boost_atomic_sources src/lock_pool.cpp) 13if(WIN32) 14 set(boost_atomic_sources ${boost_atomic_sources} src/wait_ops_windows.cpp) 15endif() 16 17if(WIN32) 18 # Note: We can't use the Boost::library targets here as they may not yet be included by the superproject when this CMakeLists.txt is included. 19 set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../..") 20 set(CMAKE_REQUIRED_LIBRARIES synchronization) 21 check_cxx_source_compiles("#include <${CMAKE_CURRENT_SOURCE_DIR}/config/has_synchronization.cpp>" BOOST_ATOMIC_HAS_SYNCHRONIZATION) 22 unset(CMAKE_REQUIRED_LIBRARIES) 23 unset(CMAKE_REQUIRED_INCLUDES) 24endif() 25 26add_library(boost_atomic ${boost_atomic_sources}) 27add_library(Boost::atomic ALIAS boost_atomic) 28 29target_include_directories(boost_atomic PUBLIC include) 30target_include_directories(boost_atomic PRIVATE src) 31 32target_link_libraries(boost_atomic 33 PUBLIC 34 Boost::assert 35 Boost::config 36 Boost::static_assert 37 Boost::type_traits 38 PRIVATE 39 Boost::predef 40 Boost::preprocessor 41) 42 43if(WIN32) 44 target_link_libraries(boost_atomic 45 PUBLIC 46 Boost::winapi 47 ) 48 49 if(BOOST_ATOMIC_HAS_SYNCHRONIZATION) 50 target_link_libraries(boost_atomic PRIVATE synchronization) 51 endif() 52endif() 53 54target_compile_definitions(boost_atomic 55 PUBLIC 56 BOOST_ATOMIC_NO_LIB 57 PRIVATE 58 BOOST_ATOMIC_SOURCE 59) 60 61if(BUILD_SHARED_LIBS) 62 target_compile_definitions(boost_atomic PUBLIC BOOST_ATOMIC_DYN_LINK) 63else() 64 target_compile_definitions(boost_atomic PUBLIC BOOST_ATOMIC_STATIC_LINK) 65endif() 66