Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
ebf2362b
Commit
ebf2362b
authored
3 years ago
by
Sprite
Browse files
Options
Downloads
Plain Diff
Pull Request #602: cmake: fix incorrectly linking to libatomic on macOS
parents
fe6676f2
619a2d89
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+4
-0
4 additions, 0 deletions
CMakeLists.txt
cmake/CheckAtomic.cmake
+15
-12
15 additions, 12 deletions
cmake/CheckAtomic.cmake
cmake/DetermineGCCCompatible.cmake
+13
-0
13 additions, 0 deletions
cmake/DetermineGCCCompatible.cmake
with
32 additions
and
12 deletions
CMakeLists.txt
+
4
−
0
View file @
ebf2362b
...
...
@@ -49,6 +49,10 @@ find_package(Doxygen)
option
(
OPENDHT_DOCUMENTATION
"Create and install the HTML based API documentation (requires Doxygen)"
${
DOXYGEN_FOUND
}
)
# Dependencies
if
(
NOT HAVE_CXX_ATOMICS_WITHOUT_LIB
)
link_libraries
(
atomic
)
endif
()
list
(
APPEND CMAKE_MODULE_PATH
"
${
PROJECT_SOURCE_DIR
}
/cmake"
)
if
(
NOT MSVC
)
set
(
THREADS_PREFER_PTHREAD_FLAG TRUE
)
...
...
This diff is collapsed.
Click to expand it.
cmake/CheckAtomic.cmake
+
15
−
12
View file @
ebf2362b
...
...
@@ -2,6 +2,7 @@
INCLUDE
(
CheckCXXSourceCompiles
)
INCLUDE
(
CheckLibraryExists
)
INCLUDE
(
"
${
CMAKE_CURRENT_LIST_DIR
}
/DetermineGCCCompatible.cmake"
)
# Sometimes linking against libatomic is required for atomic ops, if
# the platform doesn't support lock-free atomics.
...
...
@@ -32,6 +33,7 @@ function(check_working_cxx_atomics64 varname)
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
(void)i;
return 0;
}
"
${
varname
}
)
...
...
@@ -39,9 +41,10 @@ int main() {
endfunction
(
check_working_cxx_atomics64
)
# This isn't necessary on MSVC, so avoid command-line switch annoyance
# by only running on GCC-like hosts.
if
(
LLVM_COMPILER_IS_GCC_COMPATIBLE
)
# Check for (non-64-bit) atomic operations.
if
(
MSVC
)
set
(
HAVE_CXX_ATOMICS_WITHOUT_LIB True
)
elseif
(
LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES
"XL"
)
# First check if atomics work without the library.
check_working_cxx_atomics
(
HAVE_CXX_ATOMICS_WITHOUT_LIB
)
# If not, check if the library exists, and atomics work with it.
...
...
@@ -57,16 +60,16 @@ endif()
# Check for 64 bit atomic operations.
if
(
MSVC
)
set
(
HAVE_CXX_ATOMICS64_WITHOUT_LIB True
)
else
()
elseif
(
LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES
"XL"
)
# First check if atomics work without the library.
check_working_cxx_atomics64
(
HAVE_CXX_ATOMICS64_WITHOUT_LIB
)
endif
()
# If not, check if the library exists, and atomics work with it.
if
(
NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB
)
list
(
APPEND CMAKE_REQUIRED_LIBRARIES
"atomic"
)
check_working_cxx_atomics64
(
HAVE_CXX_ATOMICS64_WITH_LIB
)
if
(
NOT HAVE_CXX_ATOMICS64_WITH_LIB
)
message
(
FATAL_ERROR
"Host compiler must support 64-bit std::atomic!"
)
# If not, check if the library exists, and atomics work with it.
if
(
NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB
)
list
(
APPEND CMAKE_REQUIRED_LIBRARIES
"atomic"
)
check_working_cxx_atomics64
(
HAVE_CXX_ATOMICS64_WITH_LIB
)
if
(
NOT HAVE_CXX_ATOMICS64_WITH_LIB
)
message
(
FATAL_ERROR
"Host compiler must support 64-bit std::atomic!"
)
endif
()
endif
()
endif
()
...
...
This diff is collapsed.
Click to expand it.
cmake/DetermineGCCCompatible.cmake
0 → 100644
+
13
−
0
View file @
ebf2362b
# Determine if the compiler has GCC-compatible command-line syntax.
if
(
NOT DEFINED LLVM_COMPILER_IS_GCC_COMPATIBLE
)
if
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
LLVM_COMPILER_IS_GCC_COMPATIBLE ON
)
elseif
(
MSVC
)
set
(
LLVM_COMPILER_IS_GCC_COMPATIBLE OFF
)
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"Clang"
)
set
(
LLVM_COMPILER_IS_GCC_COMPATIBLE ON
)
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"Intel"
)
set
(
LLVM_COMPILER_IS_GCC_COMPATIBLE ON
)
endif
()
endif
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment