summaryrefslogtreecommitdiffstats
path: root/bootstrap
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-08-11 17:19:05 (GMT)
committerBrad King <brad.king@kitware.com>2017-08-16 14:13:38 (GMT)
commitfd4fd9a276126a1b1044d57a064c3b8201a91a33 (patch)
tree4c0868140907e09853e2e65484fcab2beaf1b9cb /bootstrap
parentc47c011c77bfd1bfb8d2060511a2b957ce181c62 (diff)
downloadCMake-fd4fd9a276126a1b1044d57a064c3b8201a91a33.zip
CMake-fd4fd9a276126a1b1044d57a064c3b8201a91a33.tar.gz
CMake-fd4fd9a276126a1b1044d57a064c3b8201a91a33.tar.bz2
Require C++11 to build CMake itself
CMake can now compile as C++11 on all supported platforms. Check that std::unique_ptr is available and fail early if missing. This will allow us to use C++11 more broadly in CMake's implementation (previously it was restricted to the serve mode implementation). Co-Author: Daniel Pfeifer <daniel@pfeifer-mail.de>
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap51
1 files changed, 19 insertions, 32 deletions
diff --git a/bootstrap b/bootstrap
index 9d73233..aee210f 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1004,58 +1004,45 @@ fi
# Check if C++ compiler works
TMPFILE=`cmake_tmp_file`
echo '
-#if defined(TEST1)
-# include <iostream>
-#else
-# include <iostream.h>
-#endif
+#include <iostream>
+#include <memory>
#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
#endif
-class NeedCXX
+class Class
{
public:
- NeedCXX() { this->Foo = 1; }
- int GetFoo() { return this->Foo; }
+ int Get() const { return this->Member; }
private:
- int Foo;
+ int Member = 1;
};
int main()
{
- NeedCXX c;
-#ifdef TEST3
- cout << c.GetFoo() << endl;
-#else
- std::cout << c.GetFoo() << std::endl;
-#endif
+ auto const c = std::unique_ptr<Class>(new Class);
+ std::cout << c->Get() << std::endl;
return 0;
}
' > "${TMPFILE}.cxx"
-for a in ${cmake_cxx_compilers}; do
- for b in 1 2 3; do
- if [ -z "${cmake_cxx_compiler}" ] && \
- cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- cmake_cxx_compiler="${a}"
- fi
- done
-done
-for std in 14 11 98; do
+for std in 17 14 11; do
try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`"
- for flag in $try_flags; do
- echo "Checking for wheter ${cmake_cxx_flags} supports ${flag}" >> cmake_bootstrap.log 2>&1
- if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${flag} -DTEST1" \
- "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- cmake_cxx_flags="${cmake_cxx_flags} ${flag} "
- break 2
- fi
+ for compiler in ${cmake_cxx_compilers}; do
+ for flag in '' $try_flags; do
+ echo "Checking whether '${compiler} ${cmake_cxx_flags} ${flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${flag}" \
+ "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
+ cmake_cxx_compiler="${compiler}"
+ cmake_cxx_flags="${cmake_cxx_flags} ${flag} "
+ break 3
+ fi
+ done
done
done
rm -f "${TMPFILE}.cxx"
if [ -z "${cmake_cxx_compiler}" ]; then
- cmake_error 7 "Cannot find appropriate C++ compiler on this system.
+cmake_error 7 "Cannot find a C++ compiler supporting C++11 on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted."
fi