summaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2023-05-08 18:22:59 +0000
committerBrad King <brad.king@kitware.com>2023-05-08 17:25:55 -0400
commit2ead798f1d7419efb44609b15255e97d7a6c870f (patch)
tree40edec7db9c46e3d0f5e6b6489da495109ac88f7 /bootstrap
parent9a72fed7af608780f8e40006ba49f2e20084ac3e (diff)
downloadcmake-2ead798f1d7419efb44609b15255e97d7a6c870f.tar.gz
bootstrap: Add support for CC containing flags
Rather than treating the user-provided CC as a space-separated series of compilers, treat it as a single command-line fragment which possibly contains flags.
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap44
1 files changed, 29 insertions, 15 deletions
diff --git a/bootstrap b/bootstrap
index f15aff6dc8..5e86a814de 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1206,15 +1206,18 @@ cmake_c_compiler=
# If CC is set, use that for compiler, otherwise use list of known compilers
if test -n "${cmake_toolchain}"; then
eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
-elif test -n "${CC}"; then
- cmake_c_compilers="${CC}"
else
cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
fi
-# Check if C compiler works
-TMPFILE=`cmake_tmp_file`
-echo '
+cmake_c_compiler_try_set()
+{
+ test_compiler="$1"
+ test_thread_flags="$2"
+
+ # Check if C compiler works
+ TMPFILE=`cmake_tmp_file`
+ echo '
#ifdef __cplusplus
# error "The CMAKE_C_COMPILER is set to a C++ compiler"
#endif
@@ -1239,23 +1242,34 @@ int main(int argc, char* argv[])
return argc - 1;
}
' > "${TMPFILE}.c"
-for std in 11 99 90; do
- std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`"
- for compiler in ${cmake_c_compilers}; do
+ for std in 11 99 90; do
+ std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`"
for std_flag in '' $std_flags; do
- for thread_flag in '' $thread_flags; do
- echo "Checking whether '${compiler} ${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
- if cmake_try_run "${compiler}" "${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
+ for thread_flag in '' $test_thread_flags; do
+ echo "Checking whether '${test_compiler} ${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${test_compiler}" "${cmake_c_flags} ${cmake_ld_flags} ${std_flag} ${thread_flag}" \
"${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
- cmake_c_compiler="${compiler}"
+ cmake_c_compiler="${test_compiler}"
cmake_c_flags="${cmake_c_flags} ${std_flag} ${thread_flag}"
- break 4
+ rm -f "${TMPFILE}.c"
+ return 0
fi
done
done
done
-done
-rm -f "${TMPFILE}.c"
+ rm -f "${TMPFILE}.c"
+ return 1
+}
+
+if test -n "${CC}"; then
+ cmake_c_compiler_try_set "${CC}" "${thread_flags}"
+else
+ for compiler in ${cmake_c_compilers}; do
+ if cmake_c_compiler_try_set "${compiler}" "${thread_flags}"; then
+ break
+ fi
+ done
+fi
if test -z "${cmake_c_compiler}"; then
cmake_error 6 "Cannot find appropriate C compiler on this system.