Skip to content

Commit

Permalink
[#54] Link to libatomic on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperpedersen committed Jan 4, 2023
1 parent 6ede688 commit 3effaa5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ else ()
endif()

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
find_package(Libatomic)
if (LIBATOMIC_FOUND)
message(STATUS "libatomic found")
else ()
message(FATAL_ERROR "libatomic needed")
endif()

find_package(Systemd)
if (SYSTEMD_FOUND)
message(STATUS "systemd found")
Expand Down
22 changes: 22 additions & 0 deletions cmake/FindLibatomic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# - Try to find libatomic
# Once done this will define
# LIBATOMIC_FOUND - System has libatomic
# LIBATOMIC_LIBRARY - The library needed to use libatomic

FIND_LIBRARY(LIBATOMIC_LIBRARY NAMES atomic atomic.so.1 libatomic.so.1
HINTS
/usr/local/lib64
/usr/local/lib
/opt/local/lib64
/opt/local/lib
/usr/lib64
/usr/lib
/lib64
/lib
)

IF (LIBATOMIC_LIBRARY)
SET(LIBATOMIC_FOUND TRUE)
ELSE ()
SET(LIBATOMIC_FOUND FALSE)
ENDIF ()
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
${OPENSSL_SSL_LIBRARY}
${SYSTEMD_LIBRARIES}
${LIBYAML_LIBRARIES}
${LIBATOMIC_LIBRARY}
)

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
Expand Down

0 comments on commit 3effaa5

Please sign in to comment.