避免其他模块查找过程污染基础环境

Close https://github.com/ZLMediaKit/ZLMediaKit/issues/1840
This commit is contained in:
Xiaofeng Wang 2022-07-30 11:26:48 +08:00
parent d9d33b8522
commit 25e9cd07db

View File

@ -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<long long>")
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<long long>")
else()
update_cached_list(MK_LINK_LIBRARIES atomic)
endif()
endif()
endif()
# ----------------------------------------------------------------------------
# Solution folders:
# ----------------------------------------------------------------------------