Last active
January 5, 2020 06:39
-
-
Save SaurabhSangpal/eaf00d8e0c3a0d0b65f2f29b2788aa00 to your computer and use it in GitHub Desktop.
CMake Precompiled Header for Windows
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
#Based on an answer on StackOverflow https://stackoverflow.com/a/1380048 | |
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar) | |
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\"${PrecompiledHeader}\" /FI\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\"" | |
OBJECT_DEPENDS "${PrecompiledBinary}") | |
# Add precompiled header to SourcesVar | |
LIST(APPEND ${SourcesVar} ${PrecompiledSource}) | |
ENDIF(MSVC) | |
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER) | |
# ADD_MSVC_PRECOMPILED_HEADER(pch.h pch.cpp SRC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment