]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Embed manifest to enable long paths on Windows (#1596) master
authorMorten Engelhardt Olsen <moro.engelhardt@gmail.com>
Wed, 9 Jul 2025 10:39:58 +0000 (03:39 -0700)
committerGitHub <noreply@github.com>
Wed, 9 Jul 2025 10:39:58 +0000 (12:39 +0200)
On a windows build, add a ccache.exe manifest which enables long path awareness in Windows 10+.

Fixes #1595.

CMakeLists.txt
cmake/GenerateVersionFile.cmake
cmake/ccache.exe.manifest.in [new file with mode: 0644]
cmake/version.rc.in [new file with mode: 0644]

index 590fdfedb279fbb8d7c8f5e60de6b46ff3d0411a..48c741f2ba8d90d0773cbb833ce9b07aa436dc3c 100644 (file)
@@ -102,11 +102,24 @@ include(CodeAnalysis)
 add_subdirectory(src/third_party)
 add_subdirectory(src/ccache)
 
 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)
 #
 # 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
 
 #
 # Documentation
index 55d5b88cb3e6fba1b9c800fe0fcc7b31b59388ce..7024a11058a9a509eb4c8cc7a6a8adcf36ca89fd 100644 (file)
@@ -2,3 +2,26 @@ configure_file(
   ${CMAKE_SOURCE_DIR}/cmake/version.cpp.in
   ${CMAKE_BINARY_DIR}/src/ccache/version.cpp
   @ONLY)
   ${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 (file)
index 0000000..83ef4f1
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+    <asmv3:application xmlns="urn:schemas-microsoft-com:asm.v3">
+        <asmv3:windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
+            <ws2:longPathAware>true</ws2:longPathAware>
+        </asmv3:windowsSettings>
+    </asmv3:application>
+</assembly>
diff --git a/cmake/version.rc.in b/cmake/version.rc.in
new file mode 100644 (file)
index 0000000..0e1ae73
--- /dev/null
@@ -0,0 +1,27 @@
+#include <winres.h>
+
+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