From eb3b1f419b413d0b33e305c63c533f00efecdde2 Mon Sep 17 00:00:00 2001 From: DraVee Date: Tue, 11 Nov 2025 03:17:09 +0100 Subject: [PATCH] externals: fix Debug builds on Windows with ccache * add .cmake module * nuke unused .cmake modules Signed-off-by: Caio Oliveira --- CMakeLists.txt | 7 +++ CMakeModules/DisableCCachePackage.cmake | 19 ++++++++ CMakeModules/MinGWClangCross.cmake | 58 ------------------------- CMakeModules/MinGWCross.cmake | 57 ------------------------ externals/CMakeLists.txt | 13 +++--- 5 files changed, 31 insertions(+), 123 deletions(-) create mode 100644 CMakeModules/DisableCCachePackage.cmake delete mode 100644 CMakeModules/MinGWClangCross.cmake delete mode 100644 CMakeModules/MinGWCross.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ff0667d8e8..a46037e72f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,6 +173,12 @@ if (YUZU_STATIC_BUILD) endif() endif() +# This will be used for CI packages, cause we need to build symbols +set(IS_DEBUG_BUILD OFF) +if (CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo") + set(IS_DEBUG_BUILD ON) +endif() + # Detect current compilation architecture and create standard definitions # ======================================================================= @@ -629,6 +635,7 @@ if (YUZU_USE_CPM) # zlib AddJsonPackage(zlib) + DisableCCacheForPackage(zlib) if (ZLIB_ADDED) add_library(ZLIB::ZLIB ALIAS zlibstatic) diff --git a/CMakeModules/DisableCCachePackage.cmake b/CMakeModules/DisableCCachePackage.cmake new file mode 100644 index 0000000000..f1dd9cb5a3 --- /dev/null +++ b/CMakeModules/DisableCCachePackage.cmake @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +# Disable CCache for packages that build too fast and break ccache on Windows +function(DisableCCacheForPackage) + if (WIN32 AND (CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo")) + foreach(target_package IN LISTS ARGV) + if (TARGET ${target_package}) + message(STATUS "DisableCCacheForPackage: Disabling compiler launcher for target '${target_package}'") + set_target_properties(${target_package} PROPERTIES + C_COMPILER_LAUNCHER "" + CXX_COMPILER_LAUNCHER "" + ) + else() + message(WARNING "DisableCCacheForPackage: Target '${target_package}' does not exist — skipping") + endif() + endforeach() + endif() +endfunction() diff --git a/CMakeModules/MinGWClangCross.cmake b/CMakeModules/MinGWClangCross.cmake deleted file mode 100644 index 286a59a7ad..0000000000 --- a/CMakeModules/MinGWClangCross.cmake +++ /dev/null @@ -1,58 +0,0 @@ -# SPDX-FileCopyrightText: 2022 yuzu Emulator Project -# 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_FIND_ROOT_PATH ${MINGW_PREFIX}) -set(SDL2_PATH ${MINGW_PREFIX}) -set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-) - -# Specify the cross compiler -set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}clang) -set(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}clang++) -set(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres) -set(CMAKE_C_COMPILER_AR ${MINGW_TOOL_PREFIX}ar) -set(CMAKE_CXX_COMPILER_AR ${MINGW_TOOL_PREFIX}ar) -set(CMAKE_C_COMPILER_RANLIB ${MINGW_TOOL_PREFIX}ranlib) -set(CMAKE_CXX_COMPILER_RANLIB ${MINGW_TOOL_PREFIX}ranlib) - -# Mingw tools -set(STRIP ${MINGW_TOOL_PREFIX}strip) -set(WINDRES ${MINGW_TOOL_PREFIX}windres) -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 -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - - -# Echo modified cmake vars to screen for debugging purposes -if(NOT DEFINED ENV{MINGW_DEBUG_INFO}) - message("") - message("Custom cmake vars: (blank = system default)") - message("-----------------------------------------") - message("* CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}") - message("* CMAKE_CXX_COMPILER : ${CMAKE_CXX_COMPILER}") - message("* CMAKE_RC_COMPILER : ${CMAKE_RC_COMPILER}") - message("* WINDRES : ${WINDRES}") - message("* ENV{PKG_CONFIG} : $ENV{PKG_CONFIG}") - message("* STRIP : ${STRIP}") - message("* USE_CCACHE : ${USE_CCACHE}") - message("") - # So that the debug info only appears once - set(ENV{MINGW_DEBUG_INFO} SHOWN) -endif() diff --git a/CMakeModules/MinGWCross.cmake b/CMakeModules/MinGWCross.cmake deleted file mode 100644 index 61464f7dae..0000000000 --- a/CMakeModules/MinGWCross.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-FileCopyrightText: 2018 tech4me -# 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 -set(CMAKE_HOST_WIN32 TRUE) - - -set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX}) -set(SDL2_PATH ${MINGW_PREFIX}) -set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-) - -# Specify the cross compiler -set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc) -set(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++) -set(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres) - -# Mingw tools -set(STRIP ${MINGW_TOOL_PREFIX}strip) -set(WINDRES ${MINGW_TOOL_PREFIX}windres) -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 -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - - -# Echo modified cmake vars to screen for debugging purposes -if(NOT DEFINED ENV{MINGW_DEBUG_INFO}) - message("") - message("Custom cmake vars: (blank = system default)") - message("-----------------------------------------") - message("* CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}") - message("* CMAKE_CXX_COMPILER : ${CMAKE_CXX_COMPILER}") - message("* CMAKE_RC_COMPILER : ${CMAKE_RC_COMPILER}") - message("* WINDRES : ${WINDRES}") - message("* ENV{PKG_CONFIG} : $ENV{PKG_CONFIG}") - message("* STRIP : ${STRIP}") - message("* USE_CCACHE : ${USE_CCACHE}") - message("") - # So that the debug info only appears once - set(ENV{MINGW_DEBUG_INFO} SHOWN) -endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 096760925f..c27191be4a 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -41,6 +41,7 @@ endif() # enet AddJsonPackage(enet) +DisableCCacheForPackage(enet) if (enet_ADDED) target_include_directories(enet INTERFACE ${enet_SOURCE_DIR}/include) @@ -52,6 +53,7 @@ endif() # mbedtls AddJsonPackage(mbedtls) +DisableCCacheForPackage(mbedtls mbedx509 mbedcrypto) # VulkanUtilityHeaders - pulls in headers and utility libs AddJsonPackage(vulkan-utility-headers) @@ -156,21 +158,15 @@ set(BUILD_SHARED_LIBS OFF) AddJsonPackage(spirv-headers) # Sirit -if (YUZU_USE_BUNDLED_SIRIT) +if (YUZU_USE_BUNDLED_SIRIT AND NOT IS_DEBUG_BUILD) AddJsonPackage(sirit-ci) else() AddJsonPackage(sirit) - # Change to old-but-more-cacheable debug info on Windows - if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")) - get_target_property(sirit_opts sirit COMPILE_OPTIONS) - list(FILTER sirit_opts EXCLUDE REGEX "/Zi") - list(APPEND sirit_opts "/Z7") - set_target_properties(sirit PROPERTIES COMPILE_OPTIONS "${sirit_opts}") - endif() if(MSVC AND CXX_CLANG) target_compile_options(siritobj PRIVATE -Wno-error=unused-command-line-argument) endif() endif() +DisableCCacheForPackage(sirit) # SPIRV Tools AddJsonPackage(spirv-tools) @@ -196,6 +192,7 @@ add_subdirectory(glad) # libusb if (ENABLE_LIBUSB) add_subdirectory(libusb) + DisableCCacheForPackage(usb) endif() # VMA