Moved libatomic linking to upper level CMakeLists.txt since it applies to multiple modules.

Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com>
This commit is contained in:
binary1248 2024-01-27 15:13:00 +01:00 committed by Lukas Dürrenberger
parent ebf916edf8
commit b0e45cfaba
2 changed files with 16 additions and 11 deletions

View File

@ -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 <atomic> 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 <atomic>
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()

View File

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