[cmake] USE_CCACHE option to root and fix debug usage
* ccache on cmake based off SDL2 * remove debug info (/Zi) on Release build and use only on Debug builds * change to Z7 on Debug WHEN using CCACHE Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
This commit is contained in:
parent
249e006667
commit
30feb120ce
6 changed files with 50 additions and 77 deletions
|
@ -180,6 +180,7 @@ 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}")
|
||||||
|
|
||||||
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ${EXT_DEFAULT})
|
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ${EXT_DEFAULT})
|
||||||
|
set(DYNARMIC_USE_PRECOMPILED_HEADERS YUZU_USE_PRECOMPILED_HEADERS)
|
||||||
|
|
||||||
# TODO(crueter): CI this?
|
# TODO(crueter): CI this?
|
||||||
option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON)
|
option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON)
|
||||||
|
@ -253,13 +254,25 @@ 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)
|
# Add option to enable CCache
|
||||||
if (MSVC AND CCACHE)
|
option(USE_CCACHE "Use ccache for compilation" OFF)
|
||||||
# buildcache does not properly cache PCH files, leading to compilation errors.
|
set(CCACHE_PATH "ccache" CACHE STRING "Path to ccache binary")
|
||||||
# See https://github.com/mbitsnbites/buildcache/discussions/230
|
if(USE_CCACHE)
|
||||||
message(WARNING "buildcache does not properly support Precompiled Headers. Disabling PCH")
|
find_program(CCACHE_BINARY ${CCACHE_PATH})
|
||||||
set(DYNARMIC_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
if(CCACHE_BINARY)
|
||||||
set(YUZU_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
message(STATUS "Found ccache at: ${CCACHE_BINARY}")
|
||||||
|
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_BINARY})
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_BINARY})
|
||||||
|
set(CMAKE_OBJC_COMPILER_LAUNCHER ${CCACHE_BINARY})
|
||||||
|
if(WIN32)
|
||||||
|
message(WARNING "USE_CCACHE is unstable under Windows, errors may occur...")
|
||||||
|
# we need to downgrade debug info (/Zi -> /Z7) to use an older but more cacheable format
|
||||||
|
# See https://github.com/nanoant/CMakePCHCompiler/issues/21
|
||||||
|
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
|
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "USE_CCACHE enabled, but no executable found at: ${CCACHE_PATH}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2022 yuzu Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
# buildcache wrapper
|
|
||||||
OPTION(USE_CCACHE "Use buildcache for compilation" OFF)
|
|
||||||
IF(USE_CCACHE)
|
|
||||||
FIND_PROGRAM(CCACHE buildcache)
|
|
||||||
IF (CCACHE)
|
|
||||||
MESSAGE(STATUS "Using buildcache found in PATH")
|
|
||||||
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
|
|
||||||
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
|
|
||||||
ELSE(CCACHE)
|
|
||||||
MESSAGE(WARNING "USE_CCACHE enabled, but no buildcache executable found")
|
|
||||||
ENDIF(CCACHE)
|
|
||||||
ENDIF(USE_CCACHE)
|
|
|
@ -1,13 +1,14 @@
|
||||||
# SPDX-FileCopyrightText: 2022 yuzu Emulator Project
|
# SPDX-FileCopyrightText: 2022 yuzu Emulator Project
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
set(MINGW_PREFIX /usr/x86_64-w64-mingw32/)
|
|
||||||
set(CMAKE_SYSTEM_NAME Windows)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||||
|
set(MINGW_FULL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32)
|
||||||
|
set(MINGW_PREFIX /usr/${MINGW_FULL_PREFIX}/)
|
||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
|
||||||
set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
|
set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
|
||||||
set(SDL2_PATH ${MINGW_PREFIX})
|
set(SDL2_PATH ${MINGW_PREFIX})
|
||||||
set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-)
|
set(MINGW_TOOL_PREFIX ${MINGW_FULL_PREFIX}-)
|
||||||
|
|
||||||
# Specify the cross compiler
|
# Specify the cross compiler
|
||||||
set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}clang)
|
set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}clang)
|
||||||
|
@ -23,23 +24,9 @@ set(STRIP ${MINGW_TOOL_PREFIX}strip)
|
||||||
set(WINDRES ${MINGW_TOOL_PREFIX}windres)
|
set(WINDRES ${MINGW_TOOL_PREFIX}windres)
|
||||||
set(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config)
|
set(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config)
|
||||||
|
|
||||||
# ccache wrapper
|
|
||||||
option(USE_CCACHE "Use ccache for compilation" OFF)
|
|
||||||
if(USE_CCACHE)
|
|
||||||
find_program(CCACHE ccache)
|
|
||||||
if(CCACHE)
|
|
||||||
message(STATUS "Using ccache found in PATH")
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
|
|
||||||
else(CCACHE)
|
|
||||||
message(WARNING "USE_CCACHE enabled, but no ccache found")
|
|
||||||
endif(CCACHE)
|
|
||||||
endif(USE_CCACHE)
|
|
||||||
|
|
||||||
# Search for programs in the build host directories
|
# Search for programs in the build host directories
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
|
||||||
|
|
||||||
# Echo modified cmake vars to screen for debugging purposes
|
# Echo modified cmake vars to screen for debugging purposes
|
||||||
if(NOT DEFINED ENV{MINGW_DEBUG_INFO})
|
if(NOT DEFINED ENV{MINGW_DEBUG_INFO})
|
||||||
message("")
|
message("")
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
|
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
# SPDX-FileCopyrightText: 2018 tech4me <guiwanglong@gmail.com>
|
# SPDX-FileCopyrightText: 2018 tech4me <guiwanglong@gmail.com>
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
set(MINGW_PREFIX /usr/x86_64-w64-mingw32/)
|
|
||||||
set(CMAKE_SYSTEM_NAME Windows)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
|
||||||
# Actually a hack, w/o this will cause some strange errors
|
# Actually a hack, w/o this will cause some strange errors
|
||||||
set(CMAKE_HOST_WIN32 TRUE)
|
set(CMAKE_HOST_WIN32 TRUE)
|
||||||
|
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||||
|
set(MINGW_FULL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32)
|
||||||
|
set(MINGW_PREFIX /usr/${MINGW_FULL_PREFIX}/)
|
||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
|
||||||
set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
|
set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
|
||||||
set(SDL2_PATH ${MINGW_PREFIX})
|
set(SDL2_PATH ${MINGW_PREFIX})
|
||||||
set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-)
|
set(MINGW_TOOL_PREFIX ${MINGW_FULL_PREFIX}-)
|
||||||
|
|
||||||
# Specify the cross compiler
|
# Specify the cross compiler
|
||||||
set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc)
|
set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc)
|
||||||
|
@ -22,23 +26,9 @@ set(STRIP ${MINGW_TOOL_PREFIX}strip)
|
||||||
set(WINDRES ${MINGW_TOOL_PREFIX}windres)
|
set(WINDRES ${MINGW_TOOL_PREFIX}windres)
|
||||||
set(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config)
|
set(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config)
|
||||||
|
|
||||||
# ccache wrapper
|
|
||||||
option(USE_CCACHE "Use ccache for compilation" OFF)
|
|
||||||
if(USE_CCACHE)
|
|
||||||
find_program(CCACHE ccache)
|
|
||||||
if(CCACHE)
|
|
||||||
message(STATUS "Using ccache found in PATH")
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
|
|
||||||
else(CCACHE)
|
|
||||||
message(WARNING "USE_CCACHE enabled, but no ccache found")
|
|
||||||
endif(CCACHE)
|
|
||||||
endif(USE_CCACHE)
|
|
||||||
|
|
||||||
# Search for programs in the build host directories
|
# Search for programs in the build host directories
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
|
||||||
|
|
||||||
# Echo modified cmake vars to screen for debugging purposes
|
# Echo modified cmake vars to screen for debugging purposes
|
||||||
if(NOT DEFINED ENV{MINGW_DEBUG_INFO})
|
if(NOT DEFINED ENV{MINGW_DEBUG_INFO})
|
||||||
message("")
|
message("")
|
||||||
|
|
21
externals/CMakeLists.txt
vendored
21
externals/CMakeLists.txt
vendored
|
@ -77,12 +77,21 @@ endif()
|
||||||
# Sirit
|
# Sirit
|
||||||
AddJsonPackage(sirit)
|
AddJsonPackage(sirit)
|
||||||
|
|
||||||
if(MSVC AND USE_CCACHE AND sirit_ADDED)
|
if(WIN32)
|
||||||
get_target_property(_opts sirit COMPILE_OPTIONS)
|
get_target_property(sirit_opts sirit COMPILE_OPTIONS)
|
||||||
list(FILTER _opts EXCLUDE REGEX "/Zi")
|
# Remove Debug Info on ALL Release Builds
|
||||||
list(APPEND _opts "/Z7")
|
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
||||||
set_target_properties(sirit PROPERTIES COMPILE_OPTIONS "${_opts}")
|
list(FILTER sirit_opts EXCLUDE REGEX "/Zi")
|
||||||
elseif(MSVC AND CXX_CLANG)
|
endif()
|
||||||
|
# Change to old-but-more-cacheable debug info WHEN using ccache
|
||||||
|
if(CCACHE_BINARY AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
|
||||||
|
list(FILTER sirit_opts EXCLUDE REGEX "/Zi")
|
||||||
|
list(APPEND sirit_opts "/Z7")
|
||||||
|
endif()
|
||||||
|
set_target_properties(sirit PROPERTIES COMPILE_OPTIONS "${sirit_opts}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC AND CXX_CLANG)
|
||||||
target_compile_options(sirit PRIVATE -Wno-error=unused-command-line-argument)
|
target_compile_options(sirit PRIVATE -Wno-error=unused-command-line-argument)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -101,17 +101,6 @@ if (MSVC AND NOT CXX_CLANG)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS)
|
|
||||||
# when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format
|
|
||||||
# Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21
|
|
||||||
add_compile_options(/Z7)
|
|
||||||
# Avoid D9025 warning
|
|
||||||
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
|
||||||
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
|
||||||
else()
|
|
||||||
add_compile_options(/Zi)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ARCHITECTURE_x86_64)
|
if (ARCHITECTURE_x86_64)
|
||||||
add_compile_options(/QIntel-jcc-erratum)
|
add_compile_options(/QIntel-jcc-erratum)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue