Skip to content

Commit dc19b4b

Browse files
christianrauchsloretz
authored andcommitted
check and link against libatomic (#172)
Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de> Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
1 parent b26fdf4 commit dc19b4b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ if(NOT CMAKE_CXX_STANDARD)
1111
set(CMAKE_CXX_STANDARD 14)
1212
endif()
1313

14+
include(CheckLibraryExists)
15+
1416
find_package(ament_cmake_python REQUIRED)
1517
find_package(ament_cmake_ros REQUIRED)
1618

@@ -122,6 +124,8 @@ if(BUILD_TESTING)
122124

123125
find_package(launch_testing_ament_cmake REQUIRED)
124126

127+
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)
128+
125129
if(ament_cmake_cppcheck_FOUND)
126130
ament_cppcheck(
127131
TESTNAME "cppcheck_logging_macros"
@@ -215,6 +219,11 @@ if(BUILD_TESTING)
215219
LANGUAGE C
216220
)
217221
target_link_libraries(test_atomics_executable ${PROJECT_NAME})
222+
if(HAVE_LIBATOMICS)
223+
target_link_libraries(test_atomics_executable atomic)
224+
ament_export_libraries(atomic)
225+
endif()
226+
218227
add_test(NAME test_atomics COMMAND test_atomics_executable)
219228

220229
rcutils_custom_add_gmock(test_error_handling test/test_error_handling.cpp

0 commit comments

Comments
 (0)