Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
a5a5f47f
Unverified
Commit
a5a5f47f
authored
Jul 16, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing file
parent
25c900c3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
cmake/FindAtomic.cmake
+63
-0
No files found.
cmake/FindAtomic.cmake
0 → 100644
View file @
a5a5f47f
# Simple check to see if we need a library for std::atomic
if
(
TARGET std::atomic
)
return
()
endif
()
cmake_minimum_required
(
VERSION 3.10
)
include
(
CMakePushCheckState
)
include
(
CheckIncludeFileCXX
)
include
(
CheckCXXSourceRuns
)
cmake_push_check_state
()
check_include_file_cxx
(
"atomic"
_CXX_ATOMIC_HAVE_HEADER
)
mark_as_advanced
(
_CXX_ATOMIC_HAVE_HEADER
)
set
(
code
[[
#include <atomic>
int main(int argc, char** argv) {
std::atomic<long long> s;
++s;
return 0;
}
]]
)
check_cxx_source_runs
(
"
${
code
}
"
_CXX_ATOMIC_BUILTIN
)
if
(
_CXX_ATOMIC_BUILTIN
)
set
(
_found 1
)
else
()
list
(
APPEND CMAKE_REQUIRED_LIBRARIES atomic
)
list
(
APPEND FOLLY_LINK_LIBRARIES atomic
)
check_cxx_source_runs
(
"
${
code
}
"
_CXX_ATOMIC_LIB_NEEDED
)
if
(
NOT _CXX_ATOMIC_LIB_NEEDED
)
message
(
FATAL_ERROR
"unable to link C++ std::atomic code: you may need \
to install GNU libatomic"
)
else
()
set
(
_found 1
)
endif
()
endif
()
if
(
_found
)
add_library
(
std::atomic INTERFACE IMPORTED
)
set_property
(
TARGET std::atomic APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_14
)
if
(
_CXX_ATOMIC_BUILTIN
)
# Nothing to add...
elseif
(
_CXX_ATOMIC_LIB_NEEDED
)
set_target_properties
(
std::atomic PROPERTIES IMPORTED_LIBNAME atomic
)
set
(
STDCPPATOMIC_LIBRARY atomic
)
endif
()
endif
()
cmake_pop_check_state
()
set
(
Atomic_FOUND
${
_found
}
CACHE BOOL
"TRUE if we can run a program using std::atomic"
FORCE
)
mark_as_advanced
(
Atomic_FOUND
)
if
(
Atomic_FIND_REQUIRED AND NOT Atomic_FOUND
)
message
(
FATAL_ERROR
"Cannot run simple program using std::atomic"
)
endif
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment