cmake: fix MSVC PCH support

I'm not sure if the previous implementation ever worked.
This commit is contained in:
Scott Mansell 2022-04-27 18:57:13 +12:00 committed by Admiral H. Curtiss
commit 0909e00117
No known key found for this signature in database
GPG key ID: F051B4C4044F33FB
5 changed files with 37 additions and 6 deletions

View file

@ -308,3 +308,14 @@ if(UNIX)
elseif(WIN32)
target_link_libraries(common PRIVATE "-INCLUDE:enableCompatPatches")
endif()
if(MSVC)
# Add precompiled header
# it will propergate down to everything that depends on common
target_link_libraries(common PUBLIC pch)
# We need to disable PCH for this one file, because it's C and our PCH is C++
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/ImageC.c
PROPERTIES COMPILE_FLAGS "/Y- /I${CMAKE_SOURCE_DIR}/Source/PCH/nopch")
endif()