Skip to content
Permalink
Browse files

CMake 3.16 has included pch support, use this instead of cotire.

  • Loading branch information...
turleypol committed Oct 12, 2019
1 parent 17981ff commit a714b31895d606ce9c3719acbd53c1ee1eb12d85
@@ -99,9 +99,11 @@ include(ExternalProject)

include(cmake/compile_defs.cmake)
include(cmake/release.cmake)
include(cmake/cotire.cmake)
#hide the cotire settings
hide_cotire()
if (${CMAKE_VERSION} VERSION_LESS "3.16")
include(cmake/cotire.cmake)
#hide the cotire settings
hide_cotire()
endif()

fix_compiler_flags()
detect_compiler()
@@ -183,9 +183,23 @@ function(source_group_by_folder target)
endfunction()

function (enable_pch target)
# optional argument REUSE or REUSE_COTIRE
# cmake starting with 3.16:
# REUSE and REUSE_COTIRE will use clib pch
# older cmake with cotire:
# REUSE_COTIRE will create new pch with clib stdafx
set(argn "${ARGN}")
if (NOT NO_PCH)
set(_pch_name "${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h")
if (EXISTS ${_pch_name})
if (${CMAKE_VERSION} VERSION_LESS "3.16")
if (NOT EXISTS ${_pch_name})
if ("REUSE_COTIRE" STREQUAL "${argn}")
set(_pch_name "${CMAKE_CURRENT_SOURCE_DIR}/../clib/StdAfx.h")
else()
return()
endif()
endif()

set_target_properties(${target} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${_pch_name})
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD OFF)
cotire(${target})
@@ -195,6 +209,12 @@ function (enable_pch target)
add_dependencies(${target}_pch boost)
endif()
endif()
else()
if ("${argn}" MATCHES "REUSE.*")
target_precompile_headers(${target} REUSE_FROM clib)
else()
target_precompile_headers(${target} PUBLIC ${_pch_name})
endif()
endif()
endif()
endfunction()
@@ -23,3 +23,4 @@ endif()
dist(${ex_name} scripts)

use_tidy(${ex_name})
enable_pch(${ex_name} REUSE)
@@ -2,7 +2,6 @@ set (ecompile_sources # sorted !
CMakeSources.cmake
ECompileMain.cpp
ECompileMain.h
StdAfx.h
ecompile.ico
ecompile.rc
resource.h

This file was deleted.

This file was deleted.

@@ -18,3 +18,4 @@ target_link_libraries(${ex_name} PUBLIC
dist(${ex_name} .)

use_tidy(${ex_name})
enable_pch(${ex_name} REUSE)
@@ -2,5 +2,4 @@ set (poltool_sources # sorted !
CMakeSources.cmake
PolToolMain.cpp
PolToolMain.h
StdAfx.h
)

This file was deleted.

This file was deleted.

@@ -9,7 +9,7 @@ add_executable(${ex_name}

set_compile_flags(${ex_name} 1)
warning_suppression(${ex_name})
enable_pch(${ex_name})
enable_pch(${ex_name} REUSE_COTIRE)

target_link_libraries(${ex_name} PUBLIC
bscript
@@ -15,5 +15,4 @@ set (runecl_sources # sorted !
CMakeSources.cmake
RunEclMain.cpp
RunEclMain.h
StdAfx.h
)

This file was deleted.

This file was deleted.

@@ -23,3 +23,4 @@ endif()
dist(${ex_name} .)

use_tidy(${ex_name})
enable_pch(${ex_name} REUSE)
@@ -1,6 +1,5 @@
set (uoconvert_sources # sorted !
CMakeSources.cmake
StdAfx.h
UoConvertMain.cpp
UoConvertMain.h
resource.h

This file was deleted.

This file was deleted.

@@ -9,7 +9,7 @@ add_executable(${ex_name}

set_compile_flags(${ex_name} 1)
warning_suppression(${ex_name})
enable_pch(${ex_name})
enable_pch(${ex_name} REUSE_COTIRE)

target_link_libraries(${ex_name} PUBLIC
clib
@@ -2,7 +2,6 @@ set (uotool_sources # sorted !
../pol/globals/multidefs.cpp
../pol/multi/multidef.cpp
CMakeSources.cmake
StdAfx.h
UoToolMain.cpp
UoToolMain.h
)

This file was deleted.

This file was deleted.

0 comments on commit a714b31

Please sign in to comment.
You can’t perform that action at this time.