[feature] bootstrap build: allow using currently installed cmake binary?
Not really an issue but more to see if you'd be open to the suggestion above:
Context: "meta" build systems that are part of distribution/packaging protocols like (in my case) MacPorts, HB, Gentoo Prefix, but also any Linux distro that has users build packages from source.
Currently, those systems can choose to run the bootstrap script that builds (and runs) a bootstrap cmake binary or to use the currently installed cmake binary run configure and build the cmake sources. Idem for users simply building an occasional copy or starting to do development on cmake.
Why not let the bootstrap script check for an installed cmake binary and use that, rather than go through the build process? That bootstrap build has always been slow, and if the current build time of the final binary is any indication that initial step will only have become more expensive (esp. if any tests are also built).
I'm pasting my current, simplest implementation of this idea (last used with 3.29.2) below; a proprer implementation would probably check the currently installed cmake version and offer either an override (to force a bootstrap) or an opt-in (to skip the bootstrap, if possible).
The advantages I see are that the aforementioned meta builds systems do not all have to implement the conditional code and nor do they (or anyone else) have to map the bootstrap script arguments to cmake options (the script already does that). I'd expect that using a single approach to cmake's own configure phase will also help decrease the likelihood that the bootstrap script and CMakeLists file get out of sync.
diff --git bootstrap bootstrap
--- bootstrap
+++ bootstrap
@@ -1935,20 +1935,29 @@ fi
echo "---------------------------------------------"
-# Run make to build bootstrap cmake
-if test "${cmake_bootstrap_generator}" = "Ninja"; then
- ninja_v=-v
-else
- ninja_v=
-fi
-if test "x${cmake_parallel_make}" != "x"; then
- ${cmake_make_processor} ${cmake_make_flags} ${ninja_v}
+if [ -x ${cmake_prefix_dir}/bin/cmake ] ;then
+ # use the existing cmake that we'll be replacing.
+ ln -s ${cmake_prefix_dir}/bin/cmake ${cmake_bootstrap_dir}/cmake
+ if test -n "${cmake_verbose}"; then
+ echo "Bootstrap cmake: ${cmake_prefix_dir}/bin/cmake"
+ echo "---------------------------------------------"
+ fi
else
- ${cmake_make_processor} ${ninja_v}
-fi
-RES=$?
-if test "${RES}" -ne "0"; then
- cmake_error 9 "Problem while running ${cmake_make_processor}"
+ # Run make to build bootstrap cmake
+ if test "${cmake_bootstrap_generator}" = "Ninja"; then
+ ninja_v=-v
+ else
+ ninja_v=
+ fi
+ if test "x${cmake_parallel_make}" != "x"; then
+ ${cmake_make_processor} ${cmake_make_flags} ${ninja_v}
+ else
+ ${cmake_make_processor} ${ninja_v}
+ fi
+ RES=$?
+ if test "${RES}" -ne "0"; then
+ cmake_error 9 "Problem while running ${cmake_make_processor}"
+ fi
fi
cd "${cmake_binary_dir}"