mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-24 19:50:38 +08:00
link atomic library automatic when compile on raspberrypi (#1405)
* 增加检测atomic源文件 * 支持树莓派编译,自动检测atomic链接库 * 精简cmake操作
This commit is contained in:
parent
c97aa8483e
commit
80a0e27d8c
@ -25,6 +25,18 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|||||||
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/linux/${CMAKE_BUILD_TYPE})
|
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/linux/${CMAKE_BUILD_TYPE})
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/linux/${CMAKE_BUILD_TYPE})
|
SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/linux/${CMAKE_BUILD_TYPE})
|
||||||
add_compile_options(-fPIC -Wall -Wno-unused-variable -Wno-unused-value)
|
add_compile_options(-fPIC -Wall -Wno-unused-variable -Wno-unused-value)
|
||||||
|
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)
|
||||||
|
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()
|
||||||
|
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||||
if (CMAKE_CL_64)
|
if (CMAKE_CL_64)
|
||||||
set(CL_32_64 64)
|
set(CL_32_64 64)
|
||||||
|
12
cmake/checks/atomic_check.cpp
Normal file
12
cmake/checks/atomic_check.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
static int test()
|
||||||
|
{
|
||||||
|
std::atomic<long long> x;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return test();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user