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")