I started to use the precompiled-header feature introduced with Make 3.16.x (Thank you for this!)
It all works fine when using it in the planned way. What I would like to achieve is to extract the compile instruction used for a target that makes use of the precompiled headers and write it to a file. I require this file within a just-in-time compilation framework.
See this mini example:
add_executable(demo demo.cpp)
target_precompile_headers(demo PUBLIC “${CMAKE_CURRENT_SOURCE_DIR}/demo.hpp”)
What I tried so far is this
add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo “$<FILTER:$<TARGET_OBJECTS:demo>,INCLUDE, *.${CMAKE_PCH_EXTENSION}>”)
which outputs:
/home/<…>/build-gcc-5.5.0/libket/CMakeFiles/demo.dir/cmake_pch.hxx.gch
Is it possible to strip away the “.gch” suffix inside the generator expression? If so, I could piece together the compile instructions from CMAKE_CXX_COMPILE_OPTIONS_CREATE_PCH (-Winvalid-pch-xc+±header-include<PCH_HEADER>).
Alternatively, can I evaluate CMAKE_CXX_COMPILE_OPTIONS_CREATE_PCH for the target “demo” so that <PCH_HEADER> gets replaced by /home/<…>/build-gcc-5.5.0/libket/CMakeFiles/demo.dir/cmake_pch.hxx?
Thanks very much in advanced,
Matthias