Skip to content

Commit a141e03

Browse files
committed
CMake: use CMAKE_CXX_COMPILER_FRONTEND_VARIANT to control warnings
1 parent ebeabae commit a141e03

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ macro(configure_tests target)
4242
)
4343

4444
# Add warnings
45-
if (NOT MSVC)
45+
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "GNU")
4646
target_compile_options(${target} PRIVATE
4747
-Wall -Wextra -Wcast-align -Wmissing-declarations -Wmissing-include-dirs
4848
-Wnon-virtual-dtor -Wodr -Wpedantic -Wredundant-decls -Wundef -Wunreachable-code
@@ -51,10 +51,12 @@ macro(configure_tests target)
5151
endif()
5252

5353
# Configure optimization options
54-
target_compile_options(${target} PRIVATE
55-
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>>:-O0>
56-
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU>>:-Og>
57-
)
54+
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "GNU")
55+
target_compile_options(${target} PRIVATE
56+
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>>:-O0>
57+
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU>>:-Og>
58+
)
59+
endif()
5860

5961
# Use lld or the gold linker if possible
6062
if (UNIX AND NOT APPLE)

0 commit comments

Comments
 (0)