Skip to content

Commit

Permalink
Do not enable pre-compiled headers when ccache is available and with …
Browse files Browse the repository at this point in the history
…MSVC, as ccache doesn't support that
  • Loading branch information
rouault committed Dec 2, 2024
1 parent 27b5360 commit b546472
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ if (USE_CCACHE)
set(CCACHE_COMPILER_TYPE_GCC_REQUIRED OFF)
endif()
set(CCACHE_INVOCATION_COMMAND "ccache")
if (ccache_key_value_found_index EQUAL -1 )
if (MSVC)
# CCache doesn't work yet with precompiled headers (cf https://github.com/ccache/ccache/issues/1383)
# so no need to set specific ccache configuration items
elseif (ccache_key_value_found_index EQUAL -1 )
if (CCACHE_SLOPPINESS_REQUIRED)
message(FATAL_ERROR "The use of precompiled headers only works if the ccache 'sloppiness' settings contains 'pch_defines' and 'time_macros'. Consider running 'ccache --set-config sloppiness=${CCACHE_SLOPPINESS_REQUIRED}' to define them")
endif()
Expand All @@ -171,6 +174,13 @@ if (USE_CCACHE)
endif(CCACHE_FOUND)
endif(USE_CCACHE)

if (USE_CCACHE AND MSVC)
# CCache doesn't work yet with precompiled headers (cf https://github.com/ccache/ccache/issues/1383)
set(USE_PRECOMPILED_HEADERS OFF)
else()
set(USE_PRECOMPILED_HEADERS ON)
endif()

if (IOS)
set (DEFAULT_FORCE_STATIC_LIBS TRUE)
else()
Expand Down
4 changes: 3 additions & 1 deletion src/3d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ set (QGIS_3D_RCCS shaders.qrc ../../resources/3d/textures/textures.qrc)

add_library(qgis_3d SHARED ${QGIS_3D_SRCS} ${QGIS_3D_HDRS} ${QGIS_3D_RCCS} ${QGIS_3D_PRIVATE_HDRS})

target_precompile_headers(qgis_3d PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
if (USE_PRECOMPILED_HEADERS)
target_precompile_headers(qgis_3d PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
endif()

set_target_properties(qgis_3d PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS})

Expand Down
4 changes: 3 additions & 1 deletion src/analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ endif()

add_library(qgis_analysis ${LIBRARY_TYPE} ${QGIS_ANALYSIS_SRCS} ${QGIS_ANALYSIS_HDRS})

target_precompile_headers(qgis_analysis PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
if (USE_PRECOMPILED_HEADERS)
target_precompile_headers(qgis_analysis PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
endif()

set_target_properties(qgis_analysis PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS})

Expand Down
4 changes: 3 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,9 @@ target_link_libraries(qgis_app

target_compile_definitions(qgis_app PRIVATE "-DQT_NO_FOREACH")

target_precompile_headers(qgis_app PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
if (USE_PRECOMPILED_HEADERS)
target_precompile_headers(qgis_app PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
endif()

set_target_properties(qgis_app PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS})

Expand Down
4 changes: 3 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2339,7 +2339,9 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_library(qgis_core ${LIBRARY_TYPE} ${QGIS_CORE_SRCS} ${QGIS_CORE_HDRS} ${QGIS_CORE_PRIVATE_HDRS} ${IMAGE_RCCS})

target_precompile_headers(qgis_core PRIVATE $<$<COMPILE_LANGUAGE:CXX>:qgis.h>)
if(USE_PRECOMPILED_HEADERS)
target_precompile_headers(qgis_core PRIVATE $<$<COMPILE_LANGUAGE:CXX>:qgis.h>)
endif()

set_target_properties(qgis_core PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS})

Expand Down
4 changes: 3 additions & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,9 @@ add_library(qgis_gui ${LIBRARY_TYPE}
# require c++17
target_compile_features(qgis_gui PRIVATE cxx_std_17)

target_precompile_headers(qgis_gui PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
if (USE_PRECOMPILED_HEADERS)
target_precompile_headers(qgis_gui PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
endif()

set_target_properties(qgis_gui PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS})

Expand Down
4 changes: 3 additions & 1 deletion src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ endif()

add_library(qgis_server SHARED ${QGIS_SERVER_SRCS} ${QGIS_SERVER_HDRS})

target_precompile_headers(qgis_server PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
if (USE_PRECOMPILED_HEADERS)
target_precompile_headers(qgis_server PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/core/qgis.h>)
endif()

set_target_properties(qgis_server PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS})

Expand Down

0 comments on commit b546472

Please sign in to comment.