I use the following rule to generate a precompiled header: # Macro for creating precompiled headers macro(add_precompiled_header HEADERFILE TRIGGERFILE SOURCESVAR) set_source_files_properties(${${SOURCESVAR}} PROPERTIES COMPILE_FLAGS "/Yu${HEADERFILE} /Fp${CMAKE_CURRENT_BINARY_DIR}/precompiled.pch" OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/precompiled.pch" ) set_source_files_properties(${TRIGGERFILE} PROPERTIES COMPILE_FLAGS "/Yc${HEADERFILE} /Fp${CMAKE_CURRENT_BINARY_DIR}/precompiled.pch" OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/precompiled.pch" ) set(${SOURCESVAR} ${${SOURCESVAR}} ${TRIGGERFILE}) endmacro(add_precompiled_header)
The precompiled header file is generated as an extra output of the triggerfile compilation, using the OBJECT_OUTPUTS. However this second output of the build rule is not handled correctly. When I delete the precompiled header file, it is not generated again. The compilation of the triggerfile is not done again. Within the ninja build file, a rule such as this is added for the OBJECT_OUTPUTS: build precompiled.pch: phony ..\precompiled_h.cpp.obj So the precompiled.pch depends on the object file of the trigger file. However when I delete precompiled.pch manually, it is not generated again. -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake