From 71fd7068d96ca2351629ecc725178f4d9430eff5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 29 Sep 2022 21:36:07 -0700 Subject: [PATCH] CI: call CPack via CMake MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit CPack is CMake’s “packaging driver,” exposed as `cpack.exe`. Yet if you call `cpack.exe` in some CI environments, you will find the binary in your `$PATH` is _not_ CMake’s packaging driver. This is what the logic in the Windows setup script that is being removed in this commit was attempting to detect and workaround or diagnose: a `cpack.exe` in your `$PATH` that is some unrelated and unhelpful platform management executable. But there is a simpler way. CMake’s docs¹ tell us: Instead of `cpack`, one may call `cmake --build . --target package` or `make package` or `ninja package`. In this change, we drop the `cpack` and `$PATH` workarounds and just call `cmake`, relying on it to know where its own packaging driver is. ¹ https://cmake.org/cmake/help/latest/module/CPack.html --- ci/build.sh | 2 +- ci/windows_build.py | 4 +++- windows/bin/setup-build-utilities.ps1 | 15 +-------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index c4e3272d8..6e9e7a6c4 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -38,7 +38,7 @@ if [ "${build_system}" = "cmake" ]; then pushd build cmake --log-level=VERBOSE ${CMAKE_OPTIONS:-} .. cmake --build . - cpack + cmake --build . --target package popd if [ "${OSTYPE}" = "linux-gnu" ]; then GV_VERSION=$(python3 gen_version.py) diff --git a/ci/windows_build.py b/ci/windows_build.py index 1db270ad0..e84afab5e 100644 --- a/ci/windows_build.py +++ b/ci/windows_build.py @@ -39,7 +39,9 @@ def main(args: List[str]) -> int: #pylint: disable=C0116 options.platform, "-D", "with_cxx_api=ON", ".."], build) run(["cmake", "--build", ".", "--config", options.configuration], build) - run(["cpack", "-C", options.configuration], build) + run(["cmake", "--build", ".", "--config", options.configuration, "--target", + "package"], + build) else: run(["msbuild.exe", f"-p:Configuration={options.configuration}", diff --git a/windows/bin/setup-build-utilities.ps1 b/windows/bin/setup-build-utilities.ps1 index f05c68bb9..74e488cfd 100644 --- a/windows/bin/setup-build-utilities.ps1 +++ b/windows/bin/setup-build-utilities.ps1 @@ -52,14 +52,9 @@ $build_utilities_path = "$GRAPHVIZ_ROOT\windows\dependencies\graphviz-build-util find_or_fallback "swig" "$build_utilities_path" find_or_fallback "win_bison win_flex" "$build_utilities_path\winflexbison" find_or_fallback "makensis" "$build_utilities_path\NSIS\Bin" -find_or_fallback "cmake cpack" "$CMAKE_BIN" +find_or_fallback "cmake" "$CMAKE_BIN" find_or_fallback "msbuild" "$MSBUILD_BIN" -if (-NOT (cpack.exe --help | Select-String 'CPACK_GENERATOR')) { - echo "Moving $CMAKE_BIN to front of PATH in order to find CMake's cpack" - $Env:Path="$CMAKE_BIN;$path" -} - echo "Final check where all utilites are found:" $script:all_programs.Trim().Split(" ") | ForEach { @@ -72,14 +67,6 @@ $script:all_programs.Trim().Split(" ") | ForEach { } } -# Special checks - -if (-NOT (cpack.exe --help | Select-String 'CPACK_GENERATOR')) { - $exe = (Get-Command cpack.exe 2>$null).Source - Write-Error -EA Continue "Found an unknown cpack at $exe" - $exit_status = 1 -} - if ($exit_status -eq 0) { echo "All utilities have been found. Happy building!" } else { -- 2.40.0