From b0e45cfabaa114bcd6e01ab3d246e14b58998bad Mon Sep 17 00:00:00 2001 From: binary1248 Date: Sat, 27 Jan 2024 15:13:00 +0100 Subject: [PATCH] Moved libatomic linking to upper level CMakeLists.txt since it applies to multiple modules. Co-authored-by: Chris Thrasher --- src/SFML/CMakeLists.txt | 16 ++++++++++++++++ src/SFML/Graphics/CMakeLists.txt | 11 ----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 5a3f74598..4dd69c88b 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -65,3 +65,19 @@ endif() if(SFML_BUILD_AUDIO) add_subdirectory(Audio) endif() + +# on some platforms (e.g. Raspberry Pi 3 armhf), GCC requires linking libatomic to use features +# that aren't supported by native CPU instructions (64-bit atomic operations on 32-bit architecture) +if(SFML_COMPILER_GCC) + include(CheckCXXSourceCompiles) + check_cxx_source_compiles("#include + int main(){std::atomic_ullong x(1); return x.fetch_add(1);}" ATOMIC_TEST) + if(NOT ATOMIC_TEST) + if(SFML_BUILD_GRAPHICS) + target_link_libraries(sfml-graphics PRIVATE atomic) + endif() + if(SFML_BUILD_AUDIO) + target_link_libraries(sfml-audio PRIVATE atomic) + endif() + endif() +endif() diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index d7adf0fca..1e77eec76 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -119,17 +119,6 @@ endif() find_package(Freetype REQUIRED) target_link_libraries(sfml-graphics PRIVATE Freetype::Freetype) -# on some platforms (e.g. Raspberry Pi 3 armhf), GCC requires linking libatomic to use features -# that aren't supported by native CPU instructions (64-bit atomic operations on 32-bit architecture) -if(SFML_COMPILER_GCC) - include(CheckCXXSourceCompiles) - check_cxx_source_compiles("#include - int main(){std::atomic_ullong x(1); return x.fetch_add(1);}" ATOMIC_TEST) - if(NOT ATOMIC_TEST) - target_link_libraries(sfml-graphics PRIVATE atomic) - endif() -endif() - # add preprocessor symbols target_compile_definitions(sfml-graphics PRIVATE "STBI_FAILURE_USERMSG")