Skip to content

Commit

Permalink
CMake 3.16 has included pch support, use this instead of cotire.
Browse files Browse the repository at this point in the history
  • Loading branch information
turleypol committed Oct 12, 2019
1 parent 17981ff commit a714b31
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 131 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Expand Up @@ -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()
Expand Down
22 changes: 21 additions & 1 deletion cmake/compile_defs.cmake
Expand Up @@ -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})
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions pol-core/ecompile/CMakeLists.txt
Expand Up @@ -23,3 +23,4 @@ endif()
dist(${ex_name} scripts)

use_tidy(${ex_name})
enable_pch(${ex_name} REUSE)
1 change: 0 additions & 1 deletion pol-core/ecompile/CMakeSources.cmake
Expand Up @@ -2,7 +2,6 @@ set (ecompile_sources # sorted !
CMakeSources.cmake
ECompileMain.cpp
ECompileMain.h
StdAfx.h
ecompile.ico
ecompile.rc
resource.h
Expand Down
9 changes: 0 additions & 9 deletions pol-core/ecompile/StdAfx.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions pol-core/ecompile/StdAfx.h

This file was deleted.

1 change: 1 addition & 0 deletions pol-core/poltool/CMakeLists.txt
Expand Up @@ -18,3 +18,4 @@ target_link_libraries(${ex_name} PUBLIC
dist(${ex_name} .)

use_tidy(${ex_name})
enable_pch(${ex_name} REUSE)
1 change: 0 additions & 1 deletion pol-core/poltool/CMakeSources.cmake
Expand Up @@ -2,5 +2,4 @@ set (poltool_sources # sorted !
CMakeSources.cmake
PolToolMain.cpp
PolToolMain.h
StdAfx.h
)
9 changes: 0 additions & 9 deletions pol-core/poltool/StdAfx.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions pol-core/poltool/StdAfx.h

This file was deleted.

2 changes: 1 addition & 1 deletion pol-core/runecl/CMakeLists.txt
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pol-core/runecl/CMakeSources.cmake
Expand Up @@ -15,5 +15,4 @@ set (runecl_sources # sorted !
CMakeSources.cmake
RunEclMain.cpp
RunEclMain.h
StdAfx.h
)
9 changes: 0 additions & 9 deletions pol-core/runecl/StdAfx.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions pol-core/runecl/StdAfx.h

This file was deleted.

1 change: 1 addition & 0 deletions pol-core/uoconvert/CMakeLists.txt
Expand Up @@ -23,3 +23,4 @@ endif()
dist(${ex_name} .)

use_tidy(${ex_name})
enable_pch(${ex_name} REUSE)
1 change: 0 additions & 1 deletion pol-core/uoconvert/CMakeSources.cmake
@@ -1,6 +1,5 @@
set (uoconvert_sources # sorted !
CMakeSources.cmake
StdAfx.h
UoConvertMain.cpp
UoConvertMain.h
resource.h
Expand Down
9 changes: 0 additions & 9 deletions pol-core/uoconvert/StdAfx.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions pol-core/uoconvert/StdAfx.h

This file was deleted.

2 changes: 1 addition & 1 deletion pol-core/uotool/CMakeLists.txt
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pol-core/uotool/CMakeSources.cmake
Expand Up @@ -2,7 +2,6 @@ set (uotool_sources # sorted !
../pol/globals/multidefs.cpp
../pol/multi/multidef.cpp
CMakeSources.cmake
StdAfx.h
UoToolMain.cpp
UoToolMain.h
)
9 changes: 0 additions & 9 deletions pol-core/uotool/StdAfx.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions pol-core/uotool/StdAfx.h

This file was deleted.

0 comments on commit a714b31

Please sign in to comment.