diff --git a/ci/configs/olddeps.bash b/ci/configs/olddeps.bash index 4684bd58..95f44128 100644 --- a/ci/configs/olddeps.bash +++ b/ci/configs/olddeps.bash @@ -1,5 +1,5 @@ -CI_DESC="CI job using old Cap'n Proto version" +CI_DESC="CI job using old Cap'n Proto and cmake versions" CI_DIR=build-olddeps export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds" -NIX_ARGS=(--argstr capnprotoVersion "0.7.1") +NIX_ARGS=(--argstr capnprotoVersion "0.7.1" --argstr cmakeVersion "3.12.4") BUILD_ARGS=(-k) diff --git a/ci/scripts/ci.sh b/ci/scripts/ci.sh index c50cd3e6..d989e9f4 100755 --- a/ci/scripts/ci.sh +++ b/ci/scripts/ci.sh @@ -18,7 +18,20 @@ fi [ -n "${CI_CLEAN-}" ] && rm -rf "${CI_DIR}" cmake --version +cmake_ver=$(cmake --version | awk '/version/{print $3; exit}') +ver_ge() { [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; } -cmake -B "$CI_DIR" "${CMAKE_ARGS[@]+"${CMAKE_ARGS[@]}"}" -cmake --build "$CI_DIR" -t "${BUILD_TARGETS[@]}" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}" -ctest --test-dir "$CI_DIR" --output-on-failure +src_dir=$PWD +mkdir -p "$CI_DIR" +cd "$CI_DIR" +cmake "$src_dir" "${CMAKE_ARGS[@]+"${CMAKE_ARGS[@]}"}" +if ver_ge "$cmake_ver" "3.15"; then + cmake --build . -t "${BUILD_TARGETS[@]}" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}" +else + # Older versions of cmake can only build one target at a time with --target, + # and do not support -t shortcut + for t in "${BUILD_TARGETS[@]}"; do + cmake --build . --target "$t" -- "${BUILD_ARGS[@]+"${BUILD_ARGS[@]}"}" + done +fi +ctest --output-on-failure diff --git a/shell.nix b/shell.nix index 0b7dce89..24d38201 100644 --- a/shell.nix +++ b/shell.nix @@ -3,6 +3,7 @@ , enableLibcxx ? false # Whether to use libc++ toolchain and libraries instead of libstdc++ , minimal ? false # Whether to create minimal shell without extra tools (faster when cross compiling) , capnprotoVersion ? null +, cmakeVersion ? null }: let @@ -37,12 +38,23 @@ let capnproto = capnprotoBase.override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; }); clang = if enableLibcxx then llvm.libcxxClang else llvm.clang; clang-tools = llvm.clang-tools.override { inherit enableLibcxx; }; + cmakeHashes = { + "3.12.4" = "sha256-UlVYS/0EPrcXViz/iULUcvHA5GecSUHYS6raqbKOMZQ="; + }; + cmakeBuild = if cmakeVersion == null then pkgs.cmake else (pkgs.cmake.overrideAttrs (old: { + version = cmakeVersion; + src = pkgs.fetchurl { + url = "https://cmake.org/files/v${lib.versions.majorMinor cmakeVersion}/cmake-${cmakeVersion}.tar.gz"; + hash = lib.attrByPath [cmakeVersion] "" cmakeHashes; + }; + patches = []; + })).override { isMinimalBuild = true; }; in crossPkgs.mkShell { buildInputs = [ capnproto ]; nativeBuildInputs = with pkgs; [ - cmake + cmakeBuild include-what-you-use ninja ] ++ lib.optionals (!minimal) [