Skip to content

Commit

Permalink
Cmake scripts for MSVC precompiled headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoikas committed Jun 17, 2012
1 parent 5cfefd1 commit 1ac35ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -34,6 +34,7 @@ endif(WIN32)
find_package(MaxSDK) #TODO: Only find this if we are building PlasmaMax find_package(MaxSDK) #TODO: Only find this if we are building PlasmaMax
find_package(Bink) #TODO: Find Bink, but don't require it if plPipeline isn't built... find_package(Bink) #TODO: Find Bink, but don't require it if plPipeline isn't built...
# Or better yet, just eliminate bink altogether # Or better yet, just eliminate bink altogether
include(PrecompiledHeader) #Precompiled Header helper macros


# libCurl isn't smart enough to detect this for us, so we have to configure it ourselves # libCurl isn't smart enough to detect this for us, so we have to configure it ourselves
option(CURL_IS_STATIC "Using the static version of libcurl?" ON) option(CURL_IS_STATIC "Using the static version of libcurl?" ON)
Expand Down
23 changes: 23 additions & 0 deletions cmake/PrecompiledHeader.cmake
@@ -0,0 +1,23 @@
if(MSVC)
set(PCH_SUPPORTED TRUE)
else()
set(PCH_SUPPORTED FALSE)
endif()

if(PCH_SUPPORTED)
option(PLASMA_USE_PCH "Enable precompiled headers?" ON)
endif(PCH_SUPPORTED)

macro(use_precompiled_header PrecompiledHeader PrecompiledSource)
if(PLASMA_USE_PCH)
if(MSVC)
get_filename_component(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
set(PrecompiledBinary ${PrecompiledBasename}.pch)

add_definitions(/Fp"${PrecompiledBinary}")
add_definitions(/Yu"${PrecompiledHeader}")
add_definitions(/FI"${PrecompiledHeader}")
set_source_files_properties(${PrecompiledSource} PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\"")
endif(MSVC)
endif(PLASMA_USE_PCH)
endmacro(use_precompiled_header)

0 comments on commit 1ac35ed

Please sign in to comment.