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
07a18099
Unverified
Commit
07a18099
authored
Jan 17, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check atomic
parent
4732004b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
3 deletions
+67
-3
CMakeLists.txt
+4
-3
cmake/FindAtomic.cmake
+63
-0
No files found.
CMakeLists.txt
View file @
07a18099
...
@@ -38,6 +38,7 @@ include(CheckLibraryExists)
...
@@ -38,6 +38,7 @@ include(CheckLibraryExists)
include
(
CMakePackageConfigHelpers
)
include
(
CMakePackageConfigHelpers
)
include
(
Dart
)
include
(
Dart
)
include
(
FindFilesystem
)
include
(
FindFilesystem
)
include
(
FindAtomic
)
include
(
GenerateExportHeader
)
include
(
GenerateExportHeader
)
set
(
CXX_EXTENSIONS OFF
)
set
(
CXX_EXTENSIONS OFF
)
...
@@ -200,7 +201,7 @@ if(CIFPP_RECREATE_SYMOP_DATA)
...
@@ -200,7 +201,7 @@ if(CIFPP_RECREATE_SYMOP_DATA)
add_executable
(
symop-map-generator
"
${
CMAKE_SOURCE_DIR
}
/tools/symop-map-generator.cpp"
)
add_executable
(
symop-map-generator
"
${
CMAKE_SOURCE_DIR
}
/tools/symop-map-generator.cpp"
)
target_link_libraries
(
symop-map-generator Threads::Threads
${
Boost_LIBRARIES
}
std::filesystem
${
ZLIB_LIBRARIES
}
)
target_link_libraries
(
symop-map-generator Threads::Threads
${
Boost_LIBRARIES
}
std::filesystem
std::atomic
${
ZLIB_LIBRARIES
}
)
if
(
Boost_INCLUDE_DIR
)
if
(
Boost_INCLUDE_DIR
)
target_include_directories
(
symop-map-generator PUBLIC
${
Boost_INCLUDE_DIR
}
)
target_include_directories
(
symop-map-generator PUBLIC
${
Boost_INCLUDE_DIR
}
)
endif
()
endif
()
...
@@ -271,7 +272,7 @@ target_include_directories(cifpp
...
@@ -271,7 +272,7 @@ target_include_directories(cifpp
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
)
)
target_link_libraries
(
cifpp Threads::Threads
${
Boost_LIBRARIES
}
std::filesystem
${
ZLIB_LIBRARIES
}
)
target_link_libraries
(
cifpp Threads::Threads
${
Boost_LIBRARIES
}
std::filesystem
std::atomic
${
ZLIB_LIBRARIES
}
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
target_link_options
(
cifpp PRIVATE -undefined dynamic_lookup
)
target_link_options
(
cifpp PRIVATE -undefined dynamic_lookup
)
...
@@ -428,7 +429,7 @@ if(CIFPP_BUILD_TESTS)
...
@@ -428,7 +429,7 @@ if(CIFPP_BUILD_TESTS)
${
CMAKE_CURRENT_BINARY_DIR
}
# for config.h
${
CMAKE_CURRENT_BINARY_DIR
}
# for config.h
)
)
target_link_libraries
(
${
CIFPP_TEST
}
PRIVATE Threads::Threads cifpp
${
Boost_LIBRARIES
}
std::filesystem
${
ZLIB_LIBRARIES
}
)
target_link_libraries
(
${
CIFPP_TEST
}
PRIVATE Threads::Threads cifpp
${
Boost_LIBRARIES
}
std::filesystem
std::atomic
${
ZLIB_LIBRARIES
}
)
if
(
CIFPP_USE_RSRC
)
if
(
CIFPP_USE_RSRC
)
mrc_target_resources
(
${
CIFPP_TEST
}
${
CMAKE_SOURCE_DIR
}
/rsrc/mmcif_pdbx_v50.dic
)
mrc_target_resources
(
${
CIFPP_TEST
}
${
CMAKE_SOURCE_DIR
}
/rsrc/mmcif_pdbx_v50.dic
)
...
...
cmake/FindAtomic.cmake
0 → 100644
View file @
07a18099
# Simplistic
if
(
TARGET std::atomic
)
return
()
endif
()
cmake_minimum_required
(
VERSION 3.10
)
include
(
CMakePushCheckState
)
include
(
CheckIncludeFileCXX
)
include
(
CheckCXXSourceCompiles
)
cmake_push_check_state
()
set
(
CMAKE_CXX_STANDARD 17
)
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) {
struct Test { int val; };
std::atomic<Test> s;
return static_cast<int>(s.is_lock_free());
}
]]
)
CHECK_CXX_SOURCE_COMPILES
(
"
${
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_COMPILES
(
"
${
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
)
endif
()
endif
()
cmake_pop_check_state
()
set
(
Atomic_FOUND
${
_found
}
CACHE BOOL
"TRUE if we can run a program using std::atomic"
FORCE
)
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