The check above reminds me of the part of the XZ backdoor where the attacker inserted a single . character to disable a linux security feature in a similar cmake check:
https://git.tukaani.org/?p=xz.git;a=blobdiff;f=CMakeLists.txt;h=d2b1af7ab0ab759b6805ced3dff2555e2a4b3f8e;hp=76700591059711e3a4da5b45cf58474dac4e12a7;hb=328c52da8a2bbb81307644efdb58db2c422d9ba7;hpb=eb8ad59e9bab32a8d655796afd39597ea6dcc64d
So I think it might be useful to add a sanity check to confirm that cxx_supports_fortify_source
is actually true in release builds:
0if(NOT cxx_supports_fortify_source AND CMAKE_BUILD_TYPE MATCHES "Release")
1 message(FATAL_ERROR "Error: Current release build flags are incompatible with fortify_source")
2endif()
Separately, one theoretical drawback of this new implementation is it probably disables fortify source unconditionally in multi-configuration cmake backends like visual studio and xcode, whereas the previous $<$<NOT:$<CONFIG:Debug>>:
generator expression was more flexible and it could enable fortify source in release configurations while disabling it in debug configurations. But I think this doesn’t matter in practice because source fortification is a GNU feature which presumably doesn’t work in visual studio or xcode anyway.