From 99aa28bd6bb53dbc9d5e4e797d1cdf31899ddb5e Mon Sep 17 00:00:00 2001 From: Morten Engelhardt Olsen Date: Wed, 9 Jul 2025 03:39:58 -0700 Subject: [PATCH] feat: Embed manifest to enable long paths on Windows (#1596) On a windows build, add a ccache.exe manifest which enables long path awareness in Windows 10+. Fixes #1595. --- CMakeLists.txt | 13 +++++++++++++ cmake/GenerateVersionFile.cmake | 23 +++++++++++++++++++++++ cmake/ccache.exe.manifest.in | 8 ++++++++ cmake/version.rc.in | 27 +++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 cmake/ccache.exe.manifest.in create mode 100644 cmake/version.rc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 590fdfed..48c741f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,11 +102,24 @@ include(CodeAnalysis) add_subdirectory(src/third_party) add_subdirectory(src/ccache) +# Win32 version library +if(WIN32) + add_library(ccache_win32_manifest OBJECT "${CMAKE_CURRENT_BINARY_DIR}/version.rc") + set_property(TARGET ccache_win32_manifest PROPERTY INCLUDE_DIRECTORIES "") +endif() + + # # ccache executable # add_executable(ccache src/ccache/main.cpp) target_link_libraries(ccache PRIVATE standard_settings standard_warnings ccache_framework) +if(WIN32) + if(MSVC) + target_link_options(ccache PUBLIC "/MANIFEST:NO") + endif() + target_link_libraries(ccache PRIVATE ccache_win32_manifest) +endif() # # Documentation diff --git a/cmake/GenerateVersionFile.cmake b/cmake/GenerateVersionFile.cmake index 55d5b88c..7024a110 100644 --- a/cmake/GenerateVersionFile.cmake +++ b/cmake/GenerateVersionFile.cmake @@ -2,3 +2,26 @@ configure_file( ${CMAKE_SOURCE_DIR}/cmake/version.cpp.in ${CMAKE_BINARY_DIR}/src/ccache/version.cpp @ONLY) + +if(WIN32) + + if(CCACHE_VERSION MATCHES "^([0-9]+)\.([0-9]+)\.([0-9]+)\$") + set(CCACHE_RCVERSION_MAJOR "${CMAKE_MATCH_1}") + set(CCACHE_RCVERSION_MINOR "${CMAKE_MATCH_2}") + set(CCACHE_RCVERSION_PATCH "${CMAKE_MATCH_3}") + set(CCACHE_RCVERSION ${CCACHE_RCVERSION_MAJOR},${CCACHE_RCVERSION_MINOR},${CCACHE_RCVERSION_PATCH},0) + else() + set(CCACHE_RCVERSION 0,0,0,0) + endif() + + + configure_file( + ${CMAKE_SOURCE_DIR}/cmake/version.rc.in + ${CMAKE_BINARY_DIR}/version.rc + @ONLY) + + configure_file( + ${CMAKE_SOURCE_DIR}/cmake/ccache.exe.manifest.in + ${CMAKE_BINARY_DIR}/ccache.exe.manifest + @ONLY) +endif() diff --git a/cmake/ccache.exe.manifest.in b/cmake/ccache.exe.manifest.in new file mode 100644 index 00000000..83ef4f14 --- /dev/null +++ b/cmake/ccache.exe.manifest.in @@ -0,0 +1,8 @@ + + + + + true + + + diff --git a/cmake/version.rc.in b/cmake/version.rc.in new file mode 100644 index 00000000..0e1ae738 --- /dev/null +++ b/cmake/version.rc.in @@ -0,0 +1,27 @@ +#include + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "ccache.exe.manifest" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @CCACHE_RCVERSION@ +PRODUCTVERSION @CCACHE_RCVERSION@ +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "InternalName", "ccache\0" + VALUE "LegalCopyright", "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.\0" + VALUE "OriginalFilename", "ccache.exe\0" + VALUE "ProductName", "Ccache\0" + VALUE "ProductVersion", "@CCACHE_VERSION@\0" + VALUE "FileDescription", "@CMAKE_PROJECT_DESCRIPTION@\0" + VALUE "FileVersion", "@CCACHE_VERSION@\0" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END -- 2.39.5