CMake: Implement correct USE_CCACHE
All checks were successful
eden-license / license-header (pull_request) Successful in 26s
All checks were successful
eden-license / license-header (pull_request) Successful in 26s
* it depends on changes made on 9f137adad7
Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
This commit is contained in:
parent
66083d1a18
commit
b625453d06
1 changed files with 20 additions and 16 deletions
|
@ -188,7 +188,11 @@ cmake_dependent_option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF
|
||||||
option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}")
|
option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}")
|
||||||
|
|
||||||
# Build optimization
|
# Build optimization
|
||||||
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ${EXT_DEFAULT})
|
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" OFF)
|
||||||
|
if (YUZU_USE_PRECOMPILED_HEADERS)
|
||||||
|
message(STATUS "Using Precompiled Headers.")
|
||||||
|
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
|
||||||
|
endif()
|
||||||
option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF)
|
option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF)
|
||||||
if(YUZU_ENABLE_LTO)
|
if(YUZU_ENABLE_LTO)
|
||||||
include(CheckIPOSupported)
|
include(CheckIPOSupported)
|
||||||
|
@ -199,6 +203,21 @@ if(YUZU_ENABLE_LTO)
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${COMPILER_SUPPORTS_LTO})
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${COMPILER_SUPPORTS_LTO})
|
||||||
endif()
|
endif()
|
||||||
|
option(USE_CCACHE "Use ccache for compilation" OFF)
|
||||||
|
set(CCACHE_PATH "ccache" CACHE STRING "Path to ccache binary")
|
||||||
|
if(USE_CCACHE)
|
||||||
|
find_program(CCACHE_BINARY ${CCACHE_PATH})
|
||||||
|
if(CCACHE_BINARY)
|
||||||
|
message(STATUS "Found ccache at: ${CCACHE_BINARY}")
|
||||||
|
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_BINARY})
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_BINARY})
|
||||||
|
if (YUZU_USE_PRECOMPILED_HEADERS)
|
||||||
|
message(FATAL_ERROR "Precompiled headers are incompatible with ccache. Re-run CMake with -DYUZU_USE_PRECOMPILED_HEADERS=OFF.")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "USE_CCACHE enabled, but no executable found at: ${CCACHE_PATH}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Android-specific
|
# Android-specific
|
||||||
# TODO(crueter): CI this?
|
# TODO(crueter): CI this?
|
||||||
|
@ -270,21 +289,6 @@ if (ANDROID)
|
||||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5) # Workaround for Oboe
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.5) # Workaround for Oboe
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_USE_PRECOMPILED_HEADERS)
|
|
||||||
if (MSVC AND CCACHE)
|
|
||||||
# buildcache does not properly cache PCH files, leading to compilation errors.
|
|
||||||
# See https://github.com/mbitsnbites/buildcache/discussions/230
|
|
||||||
message(WARNING "buildcache does not properly support Precompiled Headers. Disabling PCH")
|
|
||||||
set(DYNARMIC_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(YUZU_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (YUZU_USE_PRECOMPILED_HEADERS)
|
|
||||||
message(STATUS "Using Precompiled Headers.")
|
|
||||||
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Default to a Release build
|
# Default to a Release build
|
||||||
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||||
if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE)
|
if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue