Skip to content

Commit

Permalink
cmake: check_compiler_flag: Fix bug where checks were aliased
Browse files Browse the repository at this point in the history
Fix a bug where different compiler checks were aliased and therefore
the test results were incorrectly re-used.

The 'check' string is used by CMake internally to cache test results,
but when testing linker flags the check string has been aliased
between the different linker checks. To fix the aliasing issue we add
the CMAKE_REQUIRED_FLAGS variable to the 'check' string. The aliasing
issue disappears because the linker flag-under-test is in
'CMAKE_REQUIRED_FLAGS'.

Signed-off-by: Sebastian Bøe <[email protected]>
  • Loading branch information
SebastianBoe authored and Anas Nashif committed May 2, 2018
1 parent 6c65ac2 commit 632fe1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmake/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,11 @@ endfunction()
# check_compiler_flag(C "-Wall" my_check)
# print(my_check) # my_check is now 1
function(check_compiler_flag lang option ok)
string(MAKE_C_IDENTIFIER check${option}_${lang} ${ok})

string(MAKE_C_IDENTIFIER
check${option}_${lang}_${CMAKE_REQUIRED_FLAGS}
${ok}
)

if(${lang} STREQUAL C)
check_c_compiler_flag("${option}" ${${ok}})
Expand Down

0 comments on commit 632fe1d

Please sign in to comment.