From 3ea82ca589726c05e46fbee60f398f013d7216ab Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 18 Nov 2012 00:29:43 -0500 Subject: [PATCH] Be smarter about Pch.[h|cpp] files As pointed out in #225, Pch.cpp looks suspiciously like a garbage file when precompiled headers are disabled in cmake. To solve that, I have changed the precompiled header function to add the Pch source files only when pch is enabled. This should prevent future accidents. --- Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt | 4 +--- cmake/PrecompiledHeader.cmake | 9 +++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt b/Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt index dd743fb963..f1ef9460ea 100644 --- a/Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt +++ b/Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt @@ -19,7 +19,6 @@ set(pfPython_SOURCES cyParticleSys.cpp cyPhysics.cpp cyPythonInterface.cpp - Pch.cpp plPythonFileMod.cpp plPythonPack.cpp plPythonSDLModifier.cpp @@ -105,7 +104,6 @@ set(pfPython_HEADERS cyParticleSys.h cyPhysics.h cyPythonInterface.h - Pch.h pfPythonCreatable.h plPythonFileMod.h plPythonHelpers.h @@ -340,7 +338,7 @@ set(pfPython_GAMES ${pfPython_VSYNC} ) -use_precompiled_header(Pch.h Pch.cpp) +use_precompiled_header(Pch.h Pch.cpp pfPython_HEADERS pfPython_SOURCES) add_library(pfPython STATIC ${pfPython_SOURCES} ${pfPython_HEADERS} ${pfPython_GLUE} ${pfPython_GAME_GLUE} ${pfPython_GAMES}) source_group("Source Files" FILES ${pfPython_SOURCES}) diff --git a/cmake/PrecompiledHeader.cmake b/cmake/PrecompiledHeader.cmake index 8392b2e3e9..116c90c79f 100644 --- a/cmake/PrecompiledHeader.cmake +++ b/cmake/PrecompiledHeader.cmake @@ -8,7 +8,7 @@ if(PCH_SUPPORTED) option(PLASMA_USE_PCH "Enable precompiled headers?" ON) endif(PCH_SUPPORTED) -macro(use_precompiled_header PrecompiledHeader PrecompiledSource) +function(use_precompiled_header PrecompiledHeader PrecompiledSource Headers Sources) if(PLASMA_USE_PCH) if(MSVC) get_filename_component(PrecompiledBasename ${PrecompiledHeader} NAME_WE) @@ -19,5 +19,10 @@ macro(use_precompiled_header PrecompiledHeader PrecompiledSource) add_definitions(/FI"${PrecompiledHeader}") set_source_files_properties(${PrecompiledSource} PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\"") endif(MSVC) + + # Add the Pch.[h|cpp] to the appropriate sets + # OT: This has to be the oddest thing I've ever written =/ + set(${Headers} ${${Headers}} ${PrecompiledHeader} PARENT_SCOPE) + set(${Sources} ${${Sources}} ${PrecompiledSource} PARENT_SCOPE) endif(PLASMA_USE_PCH) -endmacro(use_precompiled_header) \ No newline at end of file +endfunction(use_precompiled_header)