Here is a code snippet to allow you to use precompiled header for your project.
在 CMakeLists.txt 中添加以下内容,以取代适当的 myprecompiledheaders和 myproject_SOURCE_FILES:
if (MSVC)
# For precompiled header.
# Set
# "Precompiled Header" to "Use (/Yu)"
# "Precompiled Header File" to "stdafx.h"
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yustdafx.h /FIstdafx.h")
endif()