Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions PrecompiledHeader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ function(add_precompiled_header _target _input)
set(_pch "${_pch_c_pch}")
endif()

if(_source STREQUAL "${_PCH_SOURCE_CXX}")
if(_source STREQUAL "${_PCH_SOURCE_CXX}" OR _source MATCHES "^.*[\/]${_PCH_SOURCE_CXX}$")
set(_pch_compile_flags "${_pch_compile_flags} \"/Fp${_pch_cxx_pch}\" \"/Yc${_input}\"")
set(_pch_source_cxx_found TRUE)
set_source_files_properties("${_source}" PROPERTIES OBJECT_OUTPUTS "${_pch_cxx_pch}")
elseif(_source STREQUAL "${_PCH_SOURCE_C}")
elseif(_source STREQUAL "${_PCH_SOURCE_C}" OR _source MATCHES "^.*[\/]${_PCH_SOURCE_C}$")
set(_pch_compile_flags "${_pch_compile_flags} \"/Fp${_pch_c_pch}\" \"/Yc${_input}\"")
set(_pch_source_c_found TRUE)
set_source_files_properties("${_source}" PROPERTIES OBJECT_OUTPUTS "${_pch_c_pch}")
Expand Down Expand Up @@ -149,7 +149,21 @@ function(add_precompiled_header _target _input)

if(CMAKE_COMPILER_IS_GNUCXX)
get_filename_component(_name ${_input} NAME)
set(_pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${_input}")

#find pch header
get_target_property(sources ${_target} SOURCES)
foreach(_source ${sources})
if(_source MATCHES "^.*[\/]${_input}$")
set(_PCH_HEADER_WITH_PATH ${_source})
endif()
endforeach()

if(_PCH_HEADER_WITH_PATH)
set(_pch_header "${_PCH_HEADER_WITH_PATH}")
else()
set(_pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${_input}")
endif()

set(_pch_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/${_target}_pch")
set(_pchfile "${_pch_binary_dir}/${_input}")
set(_outdir "${CMAKE_CURRENT_BINARY_DIR}/${_target}_pch/${_name}.gch")
Expand Down