mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-23 07:08:30 +00:00
Fix test for whether atomic library is needed
Some platforms need it for atomic<long long> but not for atomic<int>.
This commit is contained in:
parent
198b96471a
commit
6dcb26d21e
@ -154,6 +154,7 @@ if(WIN32 AND NOT SKIP_OS_SECURE_RANDOM)
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(ATOMIC_LIBRARY)
|
||||
function(check_atomic)
|
||||
foreach(I 0 1)
|
||||
if(I)
|
||||
@ -162,8 +163,8 @@ function(check_atomic)
|
||||
check_cxx_source_compiles(
|
||||
"#include <atomic>
|
||||
int main() {
|
||||
static std::atomic<int> a{0};
|
||||
a = a.fetch_add(1);
|
||||
static std::atomic<unsigned long long> a{0};
|
||||
a = a.fetch_add(1LL);
|
||||
return 0;
|
||||
}"
|
||||
ATOMIC_WORKED${I})
|
||||
@ -172,7 +173,7 @@ int main() {
|
||||
endif()
|
||||
endforeach()
|
||||
if(ATOMIC_WORKED1)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES atomic)
|
||||
set(ATOMIC_WORKED1 atomic PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
check_atomic()
|
||||
|
@ -410,6 +410,9 @@ target_include_directories(${OBJECT_LIB}
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_directories(${OBJECT_LIB} INTERFACE ${dep_link_directories})
|
||||
target_link_libraries(${OBJECT_LIB} INTERFACE ${dep_link_libraries})
|
||||
if(ATOMIC_LIBRARY)
|
||||
target_link_libraries(${OBJECT_LIB} INTERFACE ${ATOMIC_LIBRARY})
|
||||
endif()
|
||||
|
||||
set(LD_VERSION_FLAGS "")
|
||||
function(ld_version_script)
|
||||
@ -490,6 +493,9 @@ if(BUILD_SHARED_LIBS)
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
target_link_directories(${SHARED_LIB} PRIVATE ${dep_link_directories})
|
||||
target_link_libraries(${SHARED_LIB} PRIVATE ${dep_link_libraries})
|
||||
if(ATOMIC_LIBRARY)
|
||||
target_link_libraries(${SHARED_LIB} PRIVATE ${ATOMIC_LIBRARY})
|
||||
endif()
|
||||
if(LD_VERSION_FLAGS)
|
||||
target_link_options(${SHARED_LIB} PRIVATE ${LD_VERSION_FLAGS})
|
||||
endif()
|
||||
@ -527,6 +533,9 @@ if(BUILD_STATIC_LIBS)
|
||||
INTERFACE $<BUILD_INTERFACE:${dep_link_directories}>
|
||||
PRIVATE $<INSTALL_INTERFACE:${dep_link_directories}>)
|
||||
target_link_libraries(${STATIC_LIB} INTERFACE ${dep_link_libraries})
|
||||
if(ATOMIC_LIBRARY)
|
||||
target_link_libraries(${STATIC_LIB} INTERFACE ${ATOMIC_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Avoid name clashes on Windows with the the DLL import library.
|
||||
if(NOT DEFINED STATIC_SUFFIX AND BUILD_SHARED_LIBS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user