mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-21 19:51:27 +00:00
Do not write g_pch.cpp if it's already up-to-date
This eliminates rebuilding of main executable by MSVC on every project generation by CMake
This commit is contained in:
parent
3212da8fcf
commit
220d923e65
1 changed files with 13 additions and 2 deletions
|
@ -14,8 +14,19 @@ function(enable_precompiled_headers PRECOMPILED_HEADER SOURCE_VARIABLE_NAME)
|
||||||
get_filename_component(pch_basename ${PRECOMPILED_HEADER} NAME_WE)
|
get_filename_component(pch_basename ${PRECOMPILED_HEADER} NAME_WE)
|
||||||
set(pch_abs ${CMAKE_CURRENT_SOURCE_DIR}/${PRECOMPILED_HEADER})
|
set(pch_abs ${CMAKE_CURRENT_SOURCE_DIR}/${PRECOMPILED_HEADER})
|
||||||
set(pch_unity ${CMAKE_CURRENT_BINARY_DIR}/${pch_basename}.cpp)
|
set(pch_unity ${CMAKE_CURRENT_BINARY_DIR}/${pch_basename}.cpp)
|
||||||
FILE(WRITE ${pch_unity} "// Precompiled header unity generated by CMake\n")
|
set(pch_content "// Precompiled header unity generated by CMake\n#include <${pch_abs}>\n")
|
||||||
FILE(APPEND ${pch_unity} "#include <${pch_abs}>\n")
|
# Read .cpp if exists
|
||||||
|
if(EXISTS ${pch_unity})
|
||||||
|
file(READ ${pch_unity} pch_content_prev)
|
||||||
|
endif()
|
||||||
|
# Compare existing .cpp content with the actual one
|
||||||
|
if (pch_content_prev AND pch_content STREQUAL pch_content_prev)
|
||||||
|
unset(pch_content)
|
||||||
|
endif()
|
||||||
|
# Write .cpp if it's out-of-date
|
||||||
|
if (pch_content)
|
||||||
|
FILE(WRITE ${pch_unity} "${pch_content}")
|
||||||
|
endif()
|
||||||
set_source_files_properties(${pch_unity} PROPERTIES COMPILE_FLAGS "/Yc\"${pch_abs}\"")
|
set_source_files_properties(${pch_unity} PROPERTIES COMPILE_FLAGS "/Yc\"${pch_abs}\"")
|
||||||
|
|
||||||
# Update properties of source files to use the precompiled header.
|
# Update properties of source files to use the precompiled header.
|
||||||
|
|
Loading…
Reference in a new issue