[CMake] Doesn't anyone know how to get precompiled headers working under CMake for Visual Studio 2010?

david_bjornbak at agilent.com david_bjornbak at agilent.com
Thu Feb 16 19:39:21 EST 2012


My team has been using precompiled headers under CMake and Visual Studio 2008 for quite a while.  Now we've switched to VS 2010,  the cmake code we used to support precompiled headers is no longer working.

The following is the code in question and we're just using set_source_files_properties to add the appropreiate /Yc , /Yu and /FI flags.

It appears, under VS 2010, the property manager is not accepting or over writing these settings.

Doesn't anyone know how to get precompiled headers working under CMake for Visual Studio 2010?




IF(EXISTS ${pch_unity})
   FILE(READ ${pch_unity} buffer)
ENDIF(EXISTS ${pch_unity})
IF(NOT (${buffer} STREQUAL ${file_contents}))
   FILE(WRITE ${pch_unity} ${file_contents})
ENDIF(NOT (${buffer} STREQUAL ${file_contents}))
SET_SOURCE_FILES_PROPERTIES(${pch_unity}  PROPERTIES COMPILE_FLAGS "/Yc\"${pch_abs}\"")

###########################################################
#
# Update properties of source files to use the precompiled header.
# Additionally, force the inclusion of the precompiled header at beginning of each source file.
#
FOREACH(source_file ${srcFilesThatUsePCH} )
   SET_SOURCE_FILES_PROPERTIES(
     ${source_file}
     PROPERTIES COMPILE_FLAGS
     "/Yu\"${pch_abs}\" /FI\"${pch_abs}\""
   )
ENDFOREACH(source_file)

###########################################################
#
# Finally, update the source file collection to contain the precompiled header translation unit
#
SET(${FILES_VARIABLE_NAME} ${${FILES_VARIABLE_NAME}} ${pch_unity} PARENT_SCOPE)



++David->Bjornbak;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120216/e7b6ff49/attachment-0001.htm>


More information about the CMake mailing list