diff --git a/recipes/ignition-math/all/test_package/CMakeLists.txt b/recipes/ignition-math/all/test_package/CMakeLists.txt index 3a7c5512ebfe1..ff3d47f08d989 100644 --- a/recipes/ignition-math/all/test_package/CMakeLists.txt +++ b/recipes/ignition-math/all/test_package/CMakeLists.txt @@ -15,3 +15,11 @@ find_package(ignition-math${IGN_MATH_MAJOR_VER} REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} ignition-math${IGN_MATH_MAJOR_VER}::ignition-math${IGN_MATH_MAJOR_VER}) +# When using clang in Linux with libc++, it seems that we need to explicitly link "libc++" +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + string(FIND CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++" LIBCPP) + if (NOT ${LIBCPP} EQUAL -1) + target_link_libraries(${PROJECT_NAME} "c++") + endif() +endif() +