- CMake: use precompiled headers when compiling for msvc. This makes compilation about 40% faster.
parent
f476634461
commit
4b748c2442
|
@ -27,6 +27,8 @@ endif()
|
|||
INCLUDE (FindPkgConfig)
|
||||
INCLUDE_DIRECTORIES( include )
|
||||
|
||||
INCLUDE (PrecompiledHeader)
|
||||
|
||||
# If this is an in-source build (CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR),
|
||||
# write the library/executable files to the respective directories in the
|
||||
# source tree. During an out-of-source build, however, do not litter this
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
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}")
|
||||
|
||||
# Do not consider .c files
|
||||
foreach(fname ${Sources})
|
||||
GET_FILENAME_COMPONENT(fext ${fname} EXT)
|
||||
if(fext STREQUAL ".cpp")
|
||||
SET_SOURCE_FILES_PROPERTIES(${fname}
|
||||
PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledBinary}\" /FI\"${PrecompiledBinary}\" /Fp\"${PrecompiledBinary}\""
|
||||
OBJECT_DEPENDS "${PrecompiledBinary}")
|
||||
endif(fext STREQUAL ".cpp")
|
||||
endforeach(fname)
|
||||
|
||||
ENDIF(MSVC)
|
||||
# Add precompiled header to SourcesVar
|
||||
LIST(APPEND ${SourcesVar} ${PrecompiledSource})
|
||||
|
||||
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)
|
|
@ -58,8 +58,6 @@ SET( PUBLIC_HEADERS
|
|||
|
||||
SET( Core_SRCS
|
||||
Assimp.cpp
|
||||
AssimpPCH.cpp
|
||||
AssimpPCH.h
|
||||
)
|
||||
|
||||
SET( Boost_SRCS
|
||||
|
@ -620,7 +618,7 @@ else (UNZIP_FOUND)
|
|||
SET (unzip_compile_SRCS ${unzip_SRCS})
|
||||
endif (UNZIP_FOUND)
|
||||
|
||||
SET( assim_src
|
||||
SET( assimp_src
|
||||
# Assimp Files
|
||||
${Core_SRCS}
|
||||
${Common_SRCS}
|
||||
|
@ -681,13 +679,16 @@ SET( assim_src
|
|||
${PUBLIC_HEADERS}
|
||||
${COMPILER_HEADERS}
|
||||
)
|
||||
|
||||
ADD_MSVC_PRECOMPILED_HEADER("AssimpPCH.h" "AssimpPCH.cpp" assimp_src)
|
||||
|
||||
IF ( ASSIMP_BUILD_STATIC_LIB )
|
||||
ADD_LIBRARY( assimp STATIC
|
||||
${assim_src}
|
||||
${assimp_src}
|
||||
)
|
||||
ELSE ( ASSIMP_BUILD_STATIC_LIB )
|
||||
ADD_LIBRARY( assimp SHARED
|
||||
${assim_src}
|
||||
${assimp_src}
|
||||
)
|
||||
ENDIF ( ASSIMP_BUILD_STATIC_LIB )
|
||||
|
||||
|
|
Loading…
Reference in New Issue