1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/3rdparty/srt-1-fit/scripts/CheckCXXAtomic.cmake
john fe086dfc31
SRT: Upgrade libsrt from 1.4.1 to 1.5.1. v6.0.12 (#3362)
Co-authored-by: winlin <winlin@vip.126.com>
2023-01-04 19:56:33 +08:00

62 lines
1.5 KiB
CMake

#
# SRT - Secure, Reliable, Transport
# Copyright (c) 2021 Haivision Systems Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Check for c++11 std::atomic.
#
# Sets:
# HAVE_CXX_ATOMIC
# HAVE_CXX_ATOMIC_STATIC
include(CheckCXXSourceCompiles)
include(CheckLibraryExists)
function(CheckCXXAtomic)
unset(HAVE_CXX_ATOMIC CACHE)
unset(HAVE_CXX_ATOMIC_STATIC CACHE)
unset(CMAKE_REQUIRED_FLAGS)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_LINK_OPTIONS)
set(CheckCXXAtomic_CODE
"
#include<cstdint>
#include<atomic>
int main(void)
{
std::atomic<std::ptrdiff_t> x(0);
std::atomic<std::intmax_t> y(0);
return x + y;
}
")
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_cxx_source_compiles(
"${CheckCXXAtomic_CODE}"
HAVE_CXX_ATOMIC)
if(HAVE_CXX_ATOMIC)
# CMAKE_REQUIRED_LINK_OPTIONS was introduced in CMake 3.14.
if(CMAKE_VERSION VERSION_LESS "3.14")
set(CMAKE_REQUIRED_LINK_OPTIONS "-static")
else()
set(CMAKE_REQUIRED_FLAGS "-std=c++11 -static")
endif()
check_cxx_source_compiles(
"${CheckCXXAtomic_CODE}"
HAVE_CXX_ATOMIC_STATIC)
endif()
unset(CMAKE_REQUIRED_FLAGS)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_LINK_OPTIONS)
endfunction(CheckCXXAtomic)