From 6dddf001a11bc9275a8975f9cb34474a66a80a00 Mon Sep 17 00:00:00 2001 From: Alexandros Mandravillis Date: Wed, 30 Sep 2026 22:06:39 +0300 Subject: [PATCH] cmake: only look for ccache.exe on windows hosts find_program() searched for both ccache and ccache.exe on every host. Under WSL the Windows PATH is appended to the Linux one, so a Windows ccache.exe (for example from WinLibs) was found first and set as the compiler launcher. Every compile then failed to exec the Linux compiler. Search for ccache.exe only when CMAKE_HOST_WIN32 is true. Native Windows, Linux and macOS hosts find the same program as before. --- runtime/runtime.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/runtime.cmake b/runtime/runtime.cmake index a8d6dd51..017932c8 100644 --- a/runtime/runtime.cmake +++ b/runtime/runtime.cmake @@ -48,7 +48,16 @@ if(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER) if(DEFINED ENV{RETCOMM_TOOLCHAIN_DIR} AND NOT "$ENV{RETCOMM_TOOLCHAIN_DIR}" STREQUAL "") list(APPEND _psx_ccache_hints "$ENV{RETCOMM_TOOLCHAIN_DIR}/bin") endif() - find_program(CCACHE_PROGRAM NAMES ccache ccache.exe HINTS ${_psx_ccache_hints}) + # Only a Windows host can run ccache.exe. Under WSL the Windows PATH is + # appended to the Linux one, so a WinLibs ccache.exe would otherwise win + # and fail to exec a Linux (or osxcross) compiler. + if(CMAKE_HOST_WIN32) + set(_psx_ccache_names ccache ccache.exe) + else() + set(_psx_ccache_names ccache) + endif() + find_program(CCACHE_PROGRAM NAMES ${_psx_ccache_names} HINTS ${_psx_ccache_hints}) + unset(_psx_ccache_names) unset(_psx_ccache_hints) if(CCACHE_PROGRAM) set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "compiler launcher")