Skip to content

Commit 86f709f

Browse files
authored
Export -latomic even if BUILD_TESTING is disabled. (backport ros2#516) (ros2#517)
* Export -latomic even if BUILD_TESTING is disabled. (ros2#516) Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Signed-off-by: Timo Röhling <roehling@debian.org> (cherry picked from commit 1879f2c)
1 parent ef8d270 commit 86f709f

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ endif()
150150

151151
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
152152

153+
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)
154+
155+
if(HAVE_LIBATOMICS AND NOT WIN32)
156+
# Exporting link flag since it won't pass ament_export_libraries() existence check
157+
ament_export_link_flags("-latomic")
158+
target_link_libraries(${PROJECT_NAME} atomic)
159+
endif()
160+
153161
# Needed if pthread is used for thread local storage.
154162
if(IOS AND IOS_SDK_VERSION LESS 10.0)
155163
ament_export_libraries(pthread)
@@ -177,13 +185,6 @@ if(BUILD_TESTING)
177185

178186
find_package(launch_testing_ament_cmake REQUIRED)
179187

180-
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)
181-
182-
if(HAVE_LIBATOMICS AND NOT WIN32)
183-
# Exporting link flag since it won't pass ament_export_libraries() existance check
184-
ament_export_link_flags("-latomic")
185-
endif()
186-
187188
if(ament_cmake_cppcheck_FOUND)
188189
ament_cppcheck(
189190
TESTNAME "cppcheck_logging_macros"

0 commit comments

Comments
 (0)