cmake-precompiled-header
cmake-precompiled-header copied to clipboard
Ninja build does not work if you have more than one lib/exe
This is because with Ninja generator 'CMAKE_CFG_INTDIR' get resolves to '.' thus making all projects pointing to the same file which at this point in time it is not supported. one can use CMAKE_CURRENT_BINARY_DIR instead.
There is a bug in setting the output path for the precompiled headers for visual studio. It should say
if(MSVC) set(pch_cxx_pch "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/cxx${_input_we}.pch") set(pch_c_pch "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/c${_input_we}.pch")
not set(pch_cxx_pch "${CMAKE_CFG_INTDIR}/cxx${_input_we}.pch") set(pch_c_pch "${CMAKE_CFG_INTDIR}/c${_input_we}.pch")
This is indeed necessary for project that have multiple pch, but pch_cxx_pch is now _pch_cxx_pch:
set(_pch_cxx_pch "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/cxx${_input_we}.pch")
set(_pch_c_pch "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/c${_input_we}.pch")