diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index c230b56983b..82f8f390627 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -506,11 +506,11 @@ if(MSVC OR MSVC_IDE) endif() elseif(BUILD_SHARED_LIBS) set(VERSION_SCRIPT_SUPPORT_FLAGS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libfastrtps.version) - set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${VERSION_SCRIPT_SUPPORT_FLAGS}) + set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${VERSION_SCRIPT_SUPPORT_FLAGS}) CHECK_CXX_SOURCE_COMPILES("int main(int, char**){return 0;}" HAS_VERSION_SCRIPT_SUPPORT) - set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS}) - unset(OLD_CMAKE_CXX_FLAGS) + set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) + unset(OLD_CMAKE_REQUIRED_FLAGS) if(HAS_VERSION_SCRIPT_SUPPORT) message(STATUS "Using linker version script to select exported symbols") target_link_options(${PROJECT_NAME} ${PRIVACY} ${VERSION_SCRIPT_SUPPORT_FLAGS})