diff --git a/CMakeLists.txt b/CMakeLists.txt index 514bd1192ffce..0a9269a7e1399 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3210,9 +3210,11 @@ macro(check_add_debug_flag FLAG SUFFIX) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}") endif() - check_cxx_compiler_flag(${FLAG} HAS_CXX_${SUFFIX}) - if (HAS_CXX_${SUFFIX}) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}") + if(CMAKE_CXX_COMPILER) + check_cxx_compiler_flag(${FLAG} HAS_CXX_${SUFFIX}) + if (HAS_CXX_${SUFFIX}) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}") + endif() endif() endmacro() @@ -3231,18 +3233,20 @@ macro(asan_check_add_debug_flag2 ASAN_FLAG) set (STORED_REQLIBS ${CMAKE_REQUIRED_LIBRARIES}) set (CMAKE_REQUIRED_LIBRARIES "${FLAG};asan") - check_c_compiler_flag (${FLAG} HAS_C_FLAG_${ASAN_FLAG}) - check_cxx_compiler_flag (${FLAG} HAS_CXX_FLAG_${ASAN_FLAG}) - set (CMAKE_REQUIRED_LIBRARIES ${STORED_REQLIBS}) + check_c_compiler_flag (${FLAG} HAS_C_FLAG_${ASAN_FLAG}) if (HAS_C_FLAG_${ASAN_FLAG}) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}") endif() - if (HAS_CXX_${ASAN_FLAG}) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}") + if(CMAKE_CXX_COMPILER) + check_cxx_compiler_flag (${FLAG} HAS_CXX_FLAG_${ASAN_FLAG}) + if (HAS_CXX_${ASAN_FLAG}) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}") + endif() endif() + set (CMAKE_REQUIRED_LIBRARIES ${STORED_REQLIBS}) if(HAS_C_${ASAN_FLAG} OR HAS_CXX_${ASAN_FLAG}) set(HAVE_ASAN ON) endif()