From 1bf304c43caa94e491e4659362b1252ec50abb3e Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 6 Oct 2024 22:18:55 +0300 Subject: [PATCH] [libpng16] ci: Use modern CMake command options in ci_verify_cmake.sh Due to raising the minimum CMake version to 3.14, we can now run the CMake build verification (ci_verify_cmake.sh) from the libpng source dir, just as in the other scripts (ci_verify_*.sh). This is possible thanks to the modern CMake command options `cmake -B` and `cmake -S`. We can finally simplify the implementation of ci_verify_cmake.sh by removing a code complication that was annoying, and yet, necessary in peculiar Bash-on-Windows setups. Fun fact: CMake version 3.14 was released on 2019-03-14. Reportedly, on purpose! This is a cherry-pick of commit 558dfbb7570cb74205f978f11504b217a2c03c2c from branch 'libpng18'. --- ci/ci_verify_cmake.sh | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh index 9fe6340263..d48062cf51 100755 --- a/ci/ci_verify_cmake.sh +++ b/ci/ci_verify_cmake.sh @@ -17,12 +17,6 @@ CI_OUT_DIR="$CI_TOPLEVEL_DIR/out" CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build" CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install" -# Keep the following relative paths in sync with the absolute paths. -# We use them for the benefit of native Windows tools that might be -# otherwise confused by the path encoding used by Bash-on-Windows. -CI_BUILD_TO_SRC_RELDIR="../.." -CI_BUILD_TO_INSTALL_RELDIR="../ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install" - function ci_init_build { # Ensure that the mandatory variables are initialized. CI_CMAKE="${CI_CMAKE:-cmake}" @@ -148,40 +142,33 @@ function ci_build { all_cmake_build_flags+=($CI_CMAKE_BUILD_FLAGS) all_ctest_flags+=($CI_CTEST_FLAGS) # And... build! - # Use $CI_BUILD_TO_SRC_RELDIR and $CI_BUILD_TO_INSTALL_RELDIR - # instead of $CI_SRC_DIR and $CI_INSTALL_DIR from this point onwards. ci_spawn mkdir -p "$CI_BUILD_DIR" - ci_spawn cd "$CI_BUILD_DIR" - [[ $CI_BUILD_TO_SRC_RELDIR -ef $CI_SRC_DIR ]] || { - ci_err_internal "bad or missing \$CI_BUILD_TO_SRC_RELDIR" - } - ci_spawn mkdir -p "$CI_INSTALL_DIR" - [[ $CI_BUILD_TO_INSTALL_RELDIR -ef $CI_INSTALL_DIR ]] || { - ci_err_internal "bad or missing \$CI_BUILD_TO_INSTALL_RELDIR" - } # Spawn "cmake ...". - ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_BUILD_TO_INSTALL_RELDIR" \ - "${all_cmake_vars[@]}" \ - "$CI_BUILD_TO_SRC_RELDIR" + ci_spawn "$CI_CMAKE" -B "$CI_BUILD_DIR" \ + -S . \ + -DCMAKE_INSTALL_PREFIX="$CI_INSTALL_DIR" \ + "${all_cmake_vars[@]}" # Spawn "cmake --build ...". - ci_spawn "$CI_CMAKE" --build . \ + ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \ --config "$CI_CMAKE_BUILD_TYPE" \ "${all_cmake_build_flags[@]}" ci_expr $((CI_NO_TEST)) || { # Spawn "ctest" if testing is not disabled. + ci_spawn pushd "$CI_BUILD_DIR" ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \ "${all_ctest_flags[@]}" + ci_spawn popd } ci_expr $((CI_NO_INSTALL)) || { # Spawn "cmake --build ... --target install" if installation is not disabled. - ci_spawn "$CI_CMAKE" --build . \ + ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \ --config "$CI_CMAKE_BUILD_TYPE" \ --target install \ "${all_cmake_build_flags[@]}" } ci_expr $((CI_NO_CLEAN)) || { # Spawn "make --build ... --target clean" if cleaning is not disabled. - ci_spawn "$CI_CMAKE" --build . \ + ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \ --config "$CI_CMAKE_BUILD_TYPE" \ --target clean \ "${all_cmake_build_flags[@]}"