Merge pull request #6831 from Benitoite/patch-27
detects libatomic flags in a cmake module
This commit is contained in:
commit
7f08287fdd
@ -565,6 +565,12 @@ if(WITH_MYFILE_MMAP)
|
|||||||
add_definitions(-DMYFILE_MMAP)
|
add_definitions(-DMYFILE_MMAP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Atomic is required in some builds: #6821
|
||||||
|
find_package(ATOMIC)
|
||||||
|
if(ATOMIC_FOUND)
|
||||||
|
target_link_libraries(executable ${ATOMIC_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_LTO)
|
if(WITH_LTO)
|
||||||
# Using LTO with older versions of binutils requires setting extra flags
|
# Using LTO with older versions of binutils requires setting extra flags
|
||||||
set(BINUTILS_VERSION_MININUM "2.29")
|
set(BINUTILS_VERSION_MININUM "2.29")
|
||||||
|
36
cmake/modules/FindATOMIC.cmake
Normal file
36
cmake/modules/FindATOMIC.cmake
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
|
set(ATOMIC_CXX_TEST_SOURCE
|
||||||
|
"
|
||||||
|
#include <atomic>
|
||||||
|
int main() {
|
||||||
|
std::atomic<bool> b(false);
|
||||||
|
std::atomic<int> i(0);
|
||||||
|
std::atomic<unsigned int> ui(0);
|
||||||
|
b.exchange(true);
|
||||||
|
++i;
|
||||||
|
return ++ui;
|
||||||
|
}
|
||||||
|
")
|
||||||
|
|
||||||
|
set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic")
|
||||||
|
|
||||||
|
check_cxx_source_compiles("${ATOMIC_CXX_TEST_SOURCE}" HAVE_CXX_ATOMICS_WITHOUT_LIB)
|
||||||
|
|
||||||
|
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
|
||||||
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
|
||||||
|
check_cxx_source_compiles("${ATOMIC_CXX_TEST_SOURCE}" HAVE_CXX_ATOMICS_WITH_LIB)
|
||||||
|
if (NOT HAVE_CXX_ATOMICS_WITH_LIB)
|
||||||
|
message(FATAL_ERROR "libatomic support needed for std::atomic<> but not
|
||||||
|
found.")
|
||||||
|
endif()
|
||||||
|
set(ATOMIC_LIBRARIES "atomic")
|
||||||
|
set(ATOMIC_FOUND ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
unset(SAFE_CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
|
||||||
|
mark_as_advanced(ATOMIC_LIBRARIES)
|
||||||
|
mark_as_advanced(ATOMIC_FOUND)
|
@ -251,9 +251,10 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Excluding libatomic needed by Clang/FreeBSD, #3636
|
# Excluding libatomic needed by Clang/FreeBSD, #3636
|
||||||
if(OPENMP_FOUND AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
# Now handled in cmake/modules/findATOMIC.cmake, #6821
|
||||||
set(EXTRA_LIB_RTGUI "${EXTRA_LIB_RTGUI}" "atomic")
|
# if(OPENMP_FOUND AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||||
endif()
|
# set(EXTRA_LIB_RTGUI "${EXTRA_LIB_RTGUI}" "atomic")
|
||||||
|
# endif()
|
||||||
|
|
||||||
# Create config.h which defines where data are stored
|
# Create config.h which defines where data are stored
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user