gcc 12 has __FILE__NAME__
defined which is a great improvement to __FILE__
for reducing the string contamination in the binaries. In the lack of gcc 12, is there a way to have cmake generate a base file name to the pre-processed file in a portable way? If often see this makefile hack in cmake, but this does not work on e.g. ninja
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
I was trying to make use of -fmacro-prefix-map
, so at least I can eliminate the path to the source tree, but it does not give me the base name of the file.