Skip to content

Commit e5dc114

Browse files
committed
CMake - introduce dependency on libatomic
1 parent 85a5836 commit e5dc114

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

cmake/dependencies.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
# Project dependencies
2+
find_package(PkgConfig REQUIRED)
3+
4+
find_package(Threads REQUIRED)
5+
find_package(Atomic REQUIRED)

cmake/modules/FindAtomic.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Try to find libatomic
2+
# Once done, this will define
3+
#
4+
# ATOMIC_FOUND - system has libatomic
5+
# ATOMIC_LIBRARIES - libraries needed to use libatomic
6+
#
7+
8+
find_library(ATOMIC_LIBRARY
9+
NAMES atomic libatomic.so.1
10+
HINTS ${ATOMIC_ROOT}
11+
${CMAKE_INSTALL_LIBDIR})
12+
13+
include(FindPackageHandleStandardArgs)
14+
find_package_handle_standard_args (Atomic
15+
REQUIRED_VARS ATOMIC_LIBRARY
16+
)
17+
18+
if (ATOMIC_FOUND AND NOT TARGET atomic::atomic)
19+
add_library(atomic::atomic STATIC IMPORTED)
20+
set_target_properties(atomic::atomic PROPERTIES
21+
IMPORTED_LOCATION "${ATOMIC_LIBRARY}"
22+
INTERFACE_INCLUDE_DIRECTORIES "${ATOMIC_INCLUDE_DIR}")
23+
target_compile_definitions(atomic::atomic INTERFACE UNWIND_FOUND)
24+
else()
25+
message(CRITICAL "Notice: atomic not found")
26+
add_library(atomic::atomic INTERFACE IMPORTED)
27+
endif()
28+
29+
unset(ATOMIC_LIBRARY)

0 commit comments

Comments
 (0)