diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d4222b0..e8cf5e03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,6 +193,22 @@ endif() update_cached_list(MK_LINK_LIBRARIES "") update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_VERSION) +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + include(CheckCXXSourceCompiles) + file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/checks/atomic_check.cpp atomic_check_cpp) + check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITHOUT_LIB) + if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) + # cmake --help-policy CMP0075 + list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") + check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITH_LIB) + if(NOT HAVE_CXX_ATOMICS_WITH_LIB) + message(WARNING "Compiler doesn't support std::atomic") + else() + update_cached_list(MK_LINK_LIBRARIES atomic) + endif() + endif() +endif() + # 多个模块依赖 ffmpeg 相关库, 统一查找 if(ENABLE_FFMPEG) find_package(PkgConfig QUIET) @@ -368,22 +384,6 @@ elseif(NOT ANDROID OR IOS) update_cached_list(MK_LINK_LIBRARIES pthread) endif() -if(CMAKE_SYSTEM_NAME MATCHES "Linux") - include(CheckCXXSourceCompiles) - file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/checks/atomic_check.cpp atomic_check_cpp) - check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITHOUT_LIB) - if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) - # cmake --help-policy CMP0075 - list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") - check_cxx_source_compiles("${atomic_check_cpp}" HAVE_CXX_ATOMICS_WITH_LIB) - if(NOT HAVE_CXX_ATOMICS_WITH_LIB) - message(WARNING "Compiler doesn't support std::atomic") - else() - update_cached_list(MK_LINK_LIBRARIES atomic) - endif() - endif() -endif() - # ---------------------------------------------------------------------------- # Solution folders: # ----------------------------------------------------------------------------