From d951e1c45213d7378c67a6f0751dd4949a920e55 Mon Sep 17 00:00:00 2001 From: StudioEtrange Date: Thu, 5 Sep 2013 17:18:01 +0200 Subject: [PATCH] ** PCH Support for NMake with VS2012 NMAKE-VS2012 Error LNK2011 while NMAKE-VS2010 does not complain we need to link the pch.obj file see http://msdn.microsoft.com/en-us/library/3ay26wa2(v=vs.110).aspx ** PCH Support for Ninja Ninja need to add property OBJECT_DEPENDS for using PCH OBJECT_OUTPUTS for create PCH see http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html --- code/CMakeModules/PCHSupport.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index bcca9d877..da26978c5 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -209,6 +209,9 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS) IF(MSVC) GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target}) SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") + # Ninja PCH Support + # http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html + SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj") ELSE(MSVC) SET(HEADER_FORMAT "c++-header") SET(_FLAGS "") @@ -268,6 +271,18 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName) IF(MSVC) SET(_target_cflags "${oldProps} /Yu\"${PCH_INPUT}\" /FI\"${PCH_INPUT}\" /Fp\"${PCH_OUTPUT}\"") + # Ninja PCH Support + # http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html + SET_TARGET_PROPERTIES(${_targetName} PROPERTIES OBJECT_DEPENDS "${PCH_OUTPUT}") + + # NMAKE-VS2012 Error LNK2011 (NMAKE-VS2010 do not complain) + # we need to link the pch.obj file, see http://msdn.microsoft.com/en-us/library/3ay26wa2(v=vs.110).aspx + GET_TARGET_PROPERTY(DEPS ${_targetName} LINK_LIBRARIES) + if (NOT DEPS) + set (DEPS) + endif () + list (INSERT DEPS 0 "${PCH_OUTPUT}.obj") + SET_TARGET_PROPERTIES(${_targetName} PROPERTIES LINK_LIBRARIES "${DEPS}") ELSE(MSVC) # for use with distcc and gcc >4.0.1 if preprocessed files are accessible # on all remote machines set