Skip to content

Commit 5dd09d2

Browse files
authored
Export -latomic even if BUILD_TESTING is disabled. (backport ros2#516) (ros2#519)
* 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 b11330c commit 5dd09d2

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
@@ -132,6 +132,14 @@ endif()
132132

133133
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
134134

135+
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)
136+
137+
if(HAVE_LIBATOMICS AND NOT WIN32)
138+
# Exporting link flag since it won't pass ament_export_libraries() existence check
139+
ament_export_link_flags("-latomic")
140+
target_link_libraries(${PROJECT_NAME} atomic)
141+
endif()
142+
135143
# Needed if pthread is used for thread local storage.
136144
if(IOS AND IOS_SDK_VERSION LESS 10.0)
137145
ament_export_libraries(pthread)
@@ -157,13 +165,6 @@ if(BUILD_TESTING)
157165

158166
find_package(launch_testing_ament_cmake REQUIRED)
159167

160-
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)
161-
162-
if(HAVE_LIBATOMICS AND NOT WIN32)
163-
# Exporting link flag since it won't pass ament_export_libraries() existance check
164-
ament_export_link_flags("-latomic")
165-
endif()
166-
167168
if(ament_cmake_cppcheck_FOUND)
168169
ament_cppcheck(
169170
TESTNAME "cppcheck_logging_macros"

0 commit comments

Comments
 (0)