Created
March 27, 2012 07:47
-
-
Save euler0/2213792 to your computer and use it in GitHub Desktop.
CMake macro for precompiled headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: http://stackoverflow.com/questions/148570/using-pre-compiled-headers-with-cmake/2956392#2956392 | |
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar) | |
IF(MSVC) | |
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE) | |
SET(PrecompiledBinary "$(IntDir)/${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\"${PrecompiledHeader}\" /FI\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"" | |
OBJECT_DEPENDS "${PrecompiledBinary}") | |
# Add precompiled header to SourcesVar | |
LIST(APPEND ${SourcesVar} ${PrecompiledSource}) | |
ENDIF(MSVC) | |
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment