From b0dbd52f592d9455949838a16d46b25ccdb891b1 Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Thu, 22 Oct 2026 16:24:56 +1000 Subject: [PATCH] Windows: name CMake intermediate dirs by short hashes Long package names push MSVC object paths past 260 characters, e.g. rosbag2_performance_benchmarking_msgs' generated type support failed with C1083: Cannot open compiler generated file: '' in RoboStack's jazzy and lyrical win-64 builds. CMAKE_INTERMEDIATE_DIR_STRATEGY=SHORT (CMake >= 4.2, Ninja and Visual Studio generators) names the intermediate directories and object files by short hashes. It has to be a CMake argument: rattler-build doesn't pass the environment variable through to the build script. Co-Authored-By: Claude Opus 5.5 --- vinca/templates/bld_ament_cmake.bat.in | 3 +++ vinca/templates/bld_catkin.bat.in | 3 +++ vinca/templates/bld_colcon_merge.bat.in | 1 + 3 files changed, 7 insertions(+) diff --git a/vinca/templates/bld_ament_cmake.bat.in b/vinca/templates/bld_ament_cmake.bat.in index 182adc4..d1a8227 100644 --- a/vinca/templates/bld_ament_cmake.bat.in +++ b/vinca/templates/bld_ament_cmake.bat.in @@ -37,6 +37,8 @@ set "CMAKE_GENERATOR=Visual Studio %VS_MAJOR% %VS_YEAR%" :: The equivalent in bash is PYTHON_INSTALL_DIR=`python -c ...` FOR /F "tokens=* USEBACKQ" %%i IN (`python -c "import os;print(os.path.relpath(os.environ['SP_DIR'],os.environ['LIBRARY_PREFIX']).replace('\\','/'))"`) DO SET PYTHON_INSTALL_DIR=%%i +:: Name intermediate directories and object files by short hashes (CMake >= 4.2): long +:: package names otherwise push object paths past MSVC's 260 characters (error C1083). cmake ^ -G "%CMAKE_GENERATOR%" ^ -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ @@ -49,6 +51,7 @@ cmake ^ -DBUILD_SHARED_LIBS=ON ^ -DBUILD_TESTING=OFF ^ -DCMAKE_OBJECT_PATH_MAX=255 ^ + -DCMAKE_INTERMEDIATE_DIR_STRATEGY=SHORT ^ --compile-no-warning-as-error ^ -DPYTHON_INSTALL_DIR=%PYTHON_INSTALL_DIR% ^ @(additional_cmake_args) ^ diff --git a/vinca/templates/bld_catkin.bat.in b/vinca/templates/bld_catkin.bat.in index 20b865c..1f8c341 100644 --- a/vinca/templates/bld_catkin.bat.in +++ b/vinca/templates/bld_catkin.bat.in @@ -28,8 +28,11 @@ pushd build set SKIP_TESTING=@(skip_testing) +:: Name intermediate directories and object files by short hashes (CMake >= 4.2): long +:: package names otherwise push object paths past MSVC's 260 characters (error C1083). cmake ^ -G "Ninja" ^ + -DCMAKE_INTERMEDIATE_DIR_STRATEGY=SHORT ^ --compile-no-warning-as-error ^ -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ -DCMAKE_BUILD_TYPE=Release ^ diff --git a/vinca/templates/bld_colcon_merge.bat.in b/vinca/templates/bld_colcon_merge.bat.in index d62f4c4..54883e2 100644 --- a/vinca/templates/bld_colcon_merge.bat.in +++ b/vinca/templates/bld_colcon_merge.bat.in @@ -24,6 +24,7 @@ colcon build ^ --cmake-args ^ --compile-no-warning-as-error ^ -G Ninja ^ + -DCMAKE_INTERMEDIATE_DIR_STRATEGY=SHORT ^ -DCMAKE_BUILD_TYPE=Release ^ -DBUILD_TESTING=OFF ^ -DPYTHON_INSTALL_DIR=%PYTHON_INSTALL_DIR% ^