From 79725ee05cf2ee8320437810a23a31150f49752f Mon Sep 17 00:00:00 2001 From: RookieCLY <2238379153@qq.com> Date: Mon, 24 Feb 2025 16:35:31 +0800 Subject: [PATCH] fix:fix cmake problem about MinGW-Compile. Signed-off-by: RookieCLY <2238379153@qq.com> --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87e2d107dea..648c2db52a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,6 +395,7 @@ endif() ############################################################################### # Tools default setup ############################################################################### +set(MINGW_COMPILE FALSE) if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine @@ -407,7 +408,7 @@ if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_definitions(-DMINGW_COMPILER=1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-stringop-overread -Wno-builtin-macro-redefined -Wno-cast-function-type -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -Wno-missing-field-initializers") - target_link_libraries(fastdds PUBLIC ws2_32 mswsock) + set(MINGW_COMPILE TRUE) else() message(STATUS "Using a GNU compiler on Windows but not MinGW.") endif() @@ -429,6 +430,9 @@ option(FASTDDS_STATISTICS "Enable Fast DDS Statistics Module" ON) # Compile library. ############################################################################### add_subdirectory(src/cpp) +if(MINGW_COMPILE) + target_link_libraries(fastdds PUBLIC ws2_32 mswsock) +endif() ############################################################################### # Add http://optionparser.sourceforge.net/ as unified cli parser