Skip to content

Commit b53da41

Browse files
committed
[cmake] Check correctly for different flags. Do check twice -Wall
check_cxx_compiler_flag caches its results for the same variable, since all the flags were using the same variable, only the first check was done, and the rest of the flags were just using the result of the first flag. Make each of the check_cxx_compiler_flag use a different variable (by interpolating the flag name) and reorder the list of compiler flags to check. -Wall was added twice, and in the case of MSVC, the equivalent was added last. It doesn't really seem to affect a lot of things.
1 parent 4af5140 commit b53da41

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

stdlib/toolchain/CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@ set(CXX_COMPILE_FLAGS)
88
set(CXX_LINK_FLAGS)
99

1010

11-
set(compile_flags
12-
# Build the runtime with -Wall to catch, e.g., uninitialized variables
13-
# warnings.
14-
"-Wall"
15-
16-
# C++ code in the runtime and standard library should generally avoid
17-
# introducing static constructors or destructors.
18-
"-Wglobal-constructors"
19-
"-Wexit-time-destructors")
20-
11+
set(compile_flags)
2112

2213
# Build the runtime with -Wall to catch, e.g., uninitialized variables
2314
# warnings.
@@ -27,10 +18,15 @@ else()
2718
list(APPEND compile_flags "-Wall")
2819
endif()
2920

21+
list(APPEND compile_flags
22+
# C++ code in the runtime and standard library should generally avoid
23+
# introducing static constructors or destructors.
24+
"-Wglobal-constructors"
25+
"-Wexit-time-destructors")
3026

3127
foreach(flag ${compile_flags})
32-
check_cxx_compiler_flag("${flag}" is_supported)
33-
if(is_supported)
28+
check_cxx_compiler_flag("${flag}" cxx_compiler_flag_${flag}_is_supported)
29+
if(cxx_compiler_flag_${flag}_is_supported)
3430
list(APPEND CXX_COMPILE_FLAGS "${flag}")
3531
endif()
3632
endforeach()

0 commit comments

Comments
 (0)