I did some searching and on stackoverflow I found a post that had code in it
to provide precompiled header support:
http://stackoverflow.com/questions/148570/using-pre-compiled-headers-with-cmake

Below is the relevant macro I am using from that post. Unfortunately this
does not seem to work when generating for VS2008 or VS 2003. For some reason
the CPP files other than the precompiled source itself do not have the
"Using precompiled headers" option set on them when I view that file's
properties.

What improvements could be made to this macro? I'm not familiar at all with
the command line parameters so I'm hoping someone can help me out.

macro( set_precompiled_header pch_header pch_source source )
  IF(MSVC)
    GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
    SET(PrecompiledBinary
"${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch")
    SET(Sources ${${SourcesVar}})

    SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
                                PROPERTIES COMPILE_FLAGS
"/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\""
                                           OBJECT_OUTPUTS
"${PrecompiledBinary}")
    SET_SOURCE_FILES_PROPERTIES(${Sources}
                                PROPERTIES COMPILE_FLAGS
"/Yu\"${PrecompiledBinary}\" /FI\"${PrecompiledBinary}\"
/Fp\"${PrecompiledBinary}\""
                                           OBJECT_DEPENDS
"${PrecompiledBinary}")
  ENDIF(MSVC)
endmacro()

---------
Robert Dailey
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to