Skip to content

Commit

Permalink
fix precompiled headers bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TotallyNotElite committed Oct 19, 2019
1 parent 09fee92 commit 241ca46
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions CMakeLists.txt
Expand Up @@ -3,14 +3,16 @@ cmake_minimum_required(VERSION 3.10)
set(EnablePrecompiledHeaders 1 CACHE BOOL "Enable Precompiled Headers to reduce compile time")
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
set(EnableCotire 1 CACHE BOOL "Enable CoTiRe (Compile Time Reducer)")
unset(NativePrecompiledHeaders)
else()
set(EnableCotire 0)
set(NativePrecompiledHeaders 1)
unset(EnableCotire CACHE)
endif()

# Ensure that only 32 bit libraries are used.
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/Toolchain-cross-m32.cmake")

if (EnablePrecompiledHeaders AND EnableCotire)
if (EnableCotire)
# Don't enable cotire when running in QtCreator
execute_process(COMMAND "printenv" OUTPUT_VARIABLE contents)
STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
Expand All @@ -23,7 +25,7 @@ if (EnablePrecompiledHeaders AND EnableCotire)
endforeach()
endif()

if (EnablePrecompiledHeaders AND EnableCotire)
if (EnableCotire)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/cotire/CMake")
include(cotire)
file(GLOB_RECURSE ignore_files *.cpp)
Expand Down Expand Up @@ -77,8 +79,6 @@ if (NOT ExternalDrawing)
set(Visuals_EnforceStreamSafety 0)
endif()


set(EnableUnityBuilds 1 CACHE BOOL "Add support for CoTiRe unity builds")
set(EnableProfiler 0 CACHE BOOL "Enable Profiler")
set(EnableGUI 1 CACHE BOOL "Enable GUI")
set(EnableIPC 1 CACHE BOOL "Enable IPC")
Expand Down Expand Up @@ -207,19 +207,21 @@ add_subdirectory(include)
add_subdirectory(external)
add_subdirectory(modules)

if (EnablePrecompiledHeaders AND EnableCotire)
set_target_properties(cathook PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_SOURCE_DIR}/include/common.hpp")
if (EnableCotire)
if (EnablePrecompiledHeaders)
set_target_properties(cathook PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_SOURCE_DIR}/include/common.hpp")
endif()
set_target_properties(cathook PROPERTIES COTIRE_ADD_UNITY_BUILD true)
set_target_properties(cathook PROPERTIES COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES 30)
set_source_files_properties(${ignore_files} PROPERTIES COTIRE_EXCLUDED true)
cotire(cathook)
elseif(EnablePrecompiledHeaders)
elseif(EnablePrecompiledHeaders AND NativePrecompiledHeaders)
target_precompile_headers(cathook PRIVATE "${CMAKE_SOURCE_DIR}/include/common.hpp")
endif()

add_custom_command(TARGET cathook POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:cathook> "${CMAKE_SOURCE_DIR}/bin/$<TARGET_FILE_NAME:cathook>")
if (EnablePrecompiledHeaders AND EnableCotire)
if (EnableCotire)
add_custom_command(TARGET cathook_unity POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:cathook_unity> "${CMAKE_SOURCE_DIR}/bin/$<TARGET_FILE_NAME:cathook_unity>")
endif()

0 comments on commit 241ca46

Please sign in to comment.