From 25e9cd07db254c091b90c1c12852cbc03091911e Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Sat, 30 Jul 2022 11:26:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=85=B6=E4=BB=96=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E6=9F=A5=E6=89=BE=E8=BF=87=E7=A8=8B=E6=B1=A1=E6=9F=93?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close https://github.com/ZLMediaKit/ZLMediaKit/issues/1840 --- CMakeLists.txt | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) 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: # ----------------------------------------------------------------------------