2 #=============================================================================
3 # CMake - Cross Platform Makefile Generator
4 # Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
6 # Distributed under the OSI-approved BSD License (the "License");
7 # see accompanying file Copyright.txt for details.
9 # This software is distributed WITHOUT ANY WARRANTY; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # See the License for more information.
12 #=============================================================================
15 echo "$@" 1>&2 ; exit 1
18 # Version number extraction function.
19 cmake_version_component()
21 cat "${cmake_source_dir}/Source/CMakeVersion.cmake" | sed -n "
22 /^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
28 echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
31 # Detect system and directory information.
33 cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd`
34 cmake_binary_dir=`pwd`
36 # Load version information.
37 cmake_version_major="`cmake_version_component MAJOR`"
38 cmake_version_minor="`cmake_version_component MINOR`"
39 cmake_version_patch="`cmake_version_component PATCH`"
40 cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
41 cmake_version_tweak="`cmake_version_component TWEAK`"
42 if [ "$cmake_version_tweak" != "0" ]; then
43 cmake_version="${cmake_version}.${cmake_version_tweak}"
46 cmake_data_dir="/share/cmake-${cmake_version_major}.${cmake_version_minor}"
47 cmake_doc_dir="/doc/cmake-${cmake_version_major}.${cmake_version_minor}"
50 cmake_bootstrap_system_libs=""
51 cmake_bootstrap_qt_gui=""
52 cmake_bootstrap_qt_qmake=""
54 # Determine whether this is a Cygwin environment.
55 if echo "${cmake_system}" | grep CYGWIN >/dev/null 2>&1; then
56 cmake_system_cygwin=true
58 cmake_system_cygwin=false
61 # Determine whether this is a MinGW environment.
62 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
63 cmake_system_mingw=true
65 cmake_system_mingw=false
68 # Determine whether this is OS X
69 if echo "${cmake_system}" | grep Darwin >/dev/null 2>&1; then
70 cmake_system_darwin=true
72 cmake_system_darwin=false
75 # Determine whether this is BeOS
76 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
77 cmake_system_beos=true
79 cmake_system_beos=false
82 # Determine whether this is Haiku
83 if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
84 cmake_system_haiku=true
86 cmake_system_haiku=false
89 # Determine whether this is OpenVMS
90 if echo "${cmake_system}" | grep OpenVMS >/dev/null 2>&1; then
91 cmake_system_openvms=true
93 cmake_system_openvms=false
96 # Determine whether this is Linux
97 if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then
98 cmake_system_linux=true
99 # find out if it is a HP PA-RISC machine
100 if uname -m | grep parisc >/dev/null 2>&1; then
101 cmake_machine_parisc=true
103 cmake_machine_parisc=false
106 cmake_system_linux=false
109 # Choose the generator to use for bootstrapping.
110 if ${cmake_system_mingw}; then
111 # Bootstrapping from an MSYS prompt.
112 cmake_bootstrap_generator="MSYS Makefiles"
114 # Bootstrapping from a standard UNIX prompt.
115 cmake_bootstrap_generator="Unix Makefiles"
118 # Choose tools and extensions for this platform.
119 if ${cmake_system_openvms}; then
129 # Construct bootstrap directory name.
130 cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"
132 # Helper function to fix windows paths.
133 case "${cmake_system}" in
137 cmd //c echo "$(echo "$1" | sed 's/\\/\//g')" | sed 's/^"//;s/" *$//'
143 echo "$1" | sed 's/\\/\//g'
148 # Choose the default install prefix.
149 if ${cmake_system_mingw}; then
150 if [ "x${PROGRAMFILES}" != "x" ]; then
151 cmake_default_prefix=`cmake_fix_slashes "${PROGRAMFILES}/CMake"`
152 elif [ "x${ProgramFiles}" != "x" ]; then
153 cmake_default_prefix=`cmake_fix_slashes "${ProgramFiles}/CMake"`
154 elif [ "x${SYSTEMDRIVE}" != "x" ]; then
155 cmake_default_prefix=`cmake_fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
156 elif [ "x${SystemDrive}" != "x" ]; then
157 cmake_default_prefix=`cmake_fix_slashes "${SystemDrive}/Program Files/CMake"`
159 cmake_default_prefix="c:/Program Files/CMake"
161 elif ${cmake_system_haiku}; then
162 cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
163 cmake_man_dir="/documentation/man"
164 cmake_doc_dir="/documentation/doc/cmake-${cmake_version}"
166 cmake_default_prefix="/usr/local"
169 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
170 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
171 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
173 CMAKE_PROBLEMATIC_FILES="\
176 CMakeCCompiler.cmake \
177 CMakeCXXCompiler.cmake \
178 */CMakeSystem.cmake \
179 */CMakeCCompiler.cmake \
180 */CMakeCXXCompiler.cmake \
181 Source/cmConfigure.h \
182 Source/CTest/Curl/config.h \
183 Utilities/cmexpat/expatConfig.h \
184 Utilities/cmexpat/expatDllConfig.h \
187 CMAKE_UNUSED_SOURCES="\
188 cmGlobalXCodeGenerator \
189 cmLocalXCodeGenerator \
200 cmCommandArgumentLexer \
201 cmCommandArgumentParser \
202 cmCommandArgumentParserHelper \
206 cmDocumentationFormatter \
207 cmDocumentationFormatterText \
211 cmPropertyDefinition \
212 cmPropertyDefinitionMap \
215 cmExportFileGenerator \
216 cmExportInstallFileGenerator \
217 cmExportTryCompileFileGenerator \
220 cmInstallDirectoryGenerator \
221 cmGeneratedFileStream \
223 cmGeneratorExpressionDAGChecker \
224 cmGeneratorExpressionEvaluator \
225 cmGeneratorExpressionLexer \
226 cmGeneratorExpressionParser \
227 cmGeneratorExpression \
231 cmInstallExportGenerator \
232 cmInstallFilesGenerator \
233 cmInstallScriptGenerator \
234 cmInstallTargetGenerator \
237 cmSourceFileLocation \
241 cmFileTimeComparison \
242 cmGlobalUnixMakefileGenerator3 \
243 cmLocalUnixMakefileGenerator3 \
244 cmMakefileExecutableTargetGenerator \
245 cmMakefileLibraryTargetGenerator \
246 cmMakefileTargetGenerator \
247 cmMakefileUtilityTargetGenerator \
248 cmOSXBundleGenerator \
250 cmBootstrapCommands \
255 cmCustomCommandGenerator \
256 cmDocumentVariables \
259 cmComputeLinkDepends \
260 cmComputeLinkInformation \
262 cmComputeTargetDepends \
263 cmComputeComponentGraph \
267 cmGlobalNinjaGenerator \
268 cmLocalNinjaGenerator \
269 cmNinjaTargetGenerator \
270 cmNinjaNormalTargetGenerator \
271 cmNinjaUtilityTargetGenerator \
274 if ${cmake_system_mingw}; then
275 CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
276 cmGlobalMSYSMakefileGenerator \
277 cmGlobalMinGWMakefileGenerator \
278 cmWin32ProcessExecution"
285 if ${cmake_system_mingw}; then
308 RegularExpression.hxx \
320 # Display CMake bootstrap usage
324 Usage: '"$0"' [<options>...] [-- <cmake-options>...]
325 Options: [defaults in brackets after descriptions]
327 --help print this message
328 --version only print version information
329 --verbose display more information
330 --parallel=n bootstrap cmake in parallel, where n is
332 --enable-ccache Enable ccache when building cmake
333 --init=FILE load FILE as script to populate cache
334 --system-libs use all system-installed third-party libraries
335 (for use only by package maintainers)
336 --no-system-libs use all cmake-provided third-party libraries
338 --system-curl use system-installed curl library
339 --no-system-curl use cmake-provided curl library (default)
340 --system-expat use system-installed expat library
341 --no-system-expat use cmake-provided expat library (default)
342 --system-zlib use system-installed zlib library
343 --no-system-zlib use cmake-provided zlib library (default)
344 --system-bzip2 use system-installed bzip2 library
345 --no-system-bzip2 use cmake-provided bzip2 library (default)
346 --system-libarchive use system-installed libarchive library
347 --no-system-libarchive use cmake-provided libarchive library (default)
349 --qt-gui build the Qt-based GUI (requires Qt >= 4.2)
350 --no-qt-gui do not build the Qt-based GUI (default)
351 --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
353 Directory and file names:
354 --prefix=PREFIX install files in tree rooted at PREFIX
355 [${cmake_default_prefix}]
356 --datadir=DIR install data files in PREFIX/DIR
358 --docdir=DIR install documentation files in PREFIX/DIR
360 --mandir=DIR install man pages files in PREFIX/DIR/manN
366 # Display CMake bootstrap usage
367 cmake_version_display()
369 echo "CMake ${cmake_version}, Copyright 2000-2012 Kitware, Inc."
372 # Display CMake bootstrap error, display the log file and exit
377 echo "---------------------------------------------"
378 echo "Error when bootstrapping CMake:"
380 echo "---------------------------------------------"
381 if [ -f cmake_bootstrap.log ]; then
382 echo "Log of errors: `pwd`/cmake_bootstrap.log"
383 #cat cmake_bootstrap.log
384 echo "---------------------------------------------"
389 # Replace KWSYS_NAMESPACE with cmsys
390 cmake_replace_string ()
396 if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
398 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
399 if [ -f "${OUTFILE}${_tmp}" ]; then
400 if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
401 #echo "Files are the same"
402 rm -f "${OUTFILE}${_tmp}"
404 mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
408 cmake_error 1 "Cannot find file ${INFILE}"
412 cmake_kwsys_config_replace_string ()
418 if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
419 echo "${APPEND}" > "${OUTFILE}${_tmp}"
421 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
422 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
423 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
424 s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
425 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
426 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
427 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
428 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
429 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
430 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
431 s/@KWSYS_IOS_HAVE_BINARY@/${KWSYS_IOS_HAVE_BINARY}/g;
432 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
433 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
434 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
435 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
436 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
437 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
438 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
439 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
440 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
441 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
442 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
443 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
444 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
445 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
446 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
447 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
448 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
449 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}${_tmp}"
450 if [ -f "${OUTFILE}${_tmp}" ]; then
451 if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
452 #echo "Files are the same"
453 rm -f "${OUTFILE}${_tmp}"
455 mv -f "${OUTFILE}${_tmp}" "${OUTFILE}"
459 cmake_error 2 "Cannot find file ${INFILE}"
462 # Write string into a file
470 # Escape spaces in strings
473 echo $1 | sed "s/ /\\\\ /g"
476 # Strip prefix from argument
479 echo "$1" | sed "s/^${2-[^=]*=}//"
482 # Write message to the log
485 echo "$*" >> cmake_bootstrap.log
491 echo "cmake_bootstrap_$$_test"
494 # Run a compiler test. First argument is compiler, second one are compiler
495 # flags, third one is test source file to be compiled
501 if [ ! -f "${TESTFILE}" ]; then
502 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
505 TMPFILE=`cmake_tmp_file`
506 echo "Try: ${COMPILER}"
507 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
508 echo "---------- file -----------------------"
510 echo "------------------------------------------"
511 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
513 if [ "${RES}" -ne "0" ]; then
514 echo "Test failed to compile"
517 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
518 echo "Test failed to produce executable"
524 if [ "${RES}" -ne "0" ]; then
525 echo "Test produced non-zero return code"
532 # Run a make test. First argument is the make interpreter.
537 echo "Try: ${MAKE_PROC}"
538 "${MAKE_PROC}" ${MAKE_FLAGS}
540 if [ "${RES}" -ne "0" ]; then
541 echo "${MAKE_PROC} does not work"
544 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
545 echo "${COMPILER} does not produce output"
551 if [ "${RES}" -ne "0" ]; then
552 echo "${MAKE_PROC} produces strange executable"
555 echo "${MAKE_PROC} works"
562 cmake_ccache_enabled=
563 cmake_prefix_dir="${cmake_default_prefix}"
564 while test $# != 0; do
566 --prefix=*) dir=`cmake_arg "$1"`
567 cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
568 --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
569 --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
570 --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
571 --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
572 --init=*) cmake_init_file=`cmake_arg "$1"` ;;
573 --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
574 --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
575 --system-bzip2|--system-curl|--system-expat|--system-libarchive|--system-zlib)
576 lib=`cmake_arg "$1" "--system-"`
577 cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
578 --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-libarchive|--no-system-zlib)
579 lib=`cmake_arg "$1" "--no-system-"`
580 cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
581 --qt-gui) cmake_bootstrap_qt_gui="1" ;;
582 --no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
583 --qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
584 --help) cmake_usage ;;
585 --version) cmake_version_display ; exit 2 ;;
586 --verbose) cmake_verbose=TRUE ;;
587 --enable-ccache) cmake_ccache_enabled=TRUE ;;
589 *) die "Unknown option: $1" ;;
594 # If verbose, display some information about bootstrap
595 if [ -n "${cmake_verbose}" ]; then
596 echo "---------------------------------------------"
597 echo "Source directory: ${cmake_source_dir}"
598 echo "Binary directory: ${cmake_binary_dir}"
599 echo "Prefix directory: ${cmake_prefix_dir}"
600 echo "System: ${cmake_system}"
601 if [ "x${cmake_parallel_make}" != "x" ]; then
602 echo "Doing parallel make: ${cmake_parallel_make}"
607 echo "---------------------------------------------"
609 echo "`cmake_version_display`"
611 # Check for in-source build
612 cmake_in_source_build=
613 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
614 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
615 if [ -n "${cmake_verbose}" ]; then
616 echo "Warning: This is an in-source build"
618 cmake_in_source_build=TRUE
621 # If this is not an in-source build, then Bootstrap stuff should not exist.
622 if [ -z "${cmake_in_source_build}" ]; then
623 # Did somebody bootstrap in the source tree?
624 if [ -d "${cmake_source_dir}/Bootstrap${_cmk}" ]; then
625 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap${_cmk}\".
626 Looks like somebody did bootstrap CMake in the source tree, but now you are
627 trying to do bootstrap in the binary tree. Please remove Bootstrap${_cmk}
628 directory from the source tree."
630 # Is there a cache in the source tree?
631 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
632 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
633 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
634 Looks like somebody tried to build CMake in the source tree, but now you are
635 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
636 from the source tree."
641 # Make bootstrap directory
642 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
643 if [ ! -d "${cmake_bootstrap_dir}" ]; then
644 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
646 cd "${cmake_bootstrap_dir}"
648 [ -d "cmsys" ] || mkdir "cmsys"
649 if [ ! -d "cmsys" ]; then
650 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
654 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
655 if [ ! -d "cmsys/${a}" ]; then
656 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
660 # Delete all the bootstrap files
661 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
662 rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
663 rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h${_tmp}"
665 # If exist compiler flags, set them
666 cmake_c_flags=${CFLAGS}
667 cmake_cxx_flags=${CXXFLAGS}
668 cmake_ld_flags=${LDFLAGS}
670 # Add Cygwin-specific flags
671 if ${cmake_system_cygwin}; then
672 cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import"
675 # Add CoreFoundation framework on Darwin
676 if ${cmake_system_darwin}; then
677 cmake_ld_flags="${LDFLAGS} -framework CoreFoundation"
680 # Add BeOS toolkits...
681 if ${cmake_system_beos}; then
682 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
685 # Add Haiku toolkits...
686 if ${cmake_system_haiku}; then
687 cmake_ld_flags="${LDFLAGS} -lroot -lbe"
690 if ${cmake_system_linux}; then
691 # avoid binutils problem with large binaries, e.g. when building CMake in debug mode
692 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230
693 if ${cmake_machine_parisc}; then
694 cmake_ld_flags="${LDFLAGS} -Wl,--unique=.text.*"
698 #-----------------------------------------------------------------------------
699 # Detect known toolchains on some platforms.
701 case "${cmake_system}" in
702 *AIX*) cmake_toolchains='XL GNU' ;;
703 *CYGWIN*) cmake_toolchains='GNU' ;;
704 *Darwin*) cmake_toolchains='GNU Clang' ;;
705 *Linux*) cmake_toolchains='GNU Clang XL PGI PathScale' ;;
706 *MINGW*) cmake_toolchains='GNU' ;;
709 # Toolchain compiler name table.
710 cmake_toolchain_Clang_CC='clang'
711 cmake_toolchain_Clang_CXX='clang++'
712 cmake_toolchain_GNU_CC='gcc'
713 cmake_toolchain_GNU_CXX='g++'
714 cmake_toolchain_PGI_CC='pgcc'
715 cmake_toolchain_PGI_CXX='pgCC'
716 cmake_toolchain_PathScale_CC='pathcc'
717 cmake_toolchain_PathScale_CXX='pathCC'
718 cmake_toolchain_XL_CC='xlc'
719 cmake_toolchain_XL_CXX='xlC'
721 cmake_toolchain_try()
724 TMPFILE=`cmake_tmp_file`
726 eval "tc_CC=\${cmake_toolchain_${tc}_CC}"
727 echo 'int main() { return 0; }' > "${TMPFILE}.c"
728 cmake_try_run "$tc_CC" "" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1
731 test "${tc_result_CC}" = "0" || return 1
733 eval "tc_CXX=\${cmake_toolchain_${tc}_CXX}"
734 echo 'int main() { return 0; }' > "${TMPFILE}.cpp"
735 cmake_try_run "$tc_CXX" "" "${TMPFILE}.cpp" >> cmake_bootstrap.log 2>&1
737 rm -f "${TMPFILE}.cpp"
738 test "${tc_result_CXX}" = "0" || return 1
740 cmake_toolchain="$tc"
743 cmake_toolchain_detect()
746 for tc in ${cmake_toolchains}; do
747 echo "Checking for $tc toolchain" >> cmake_bootstrap.log 2>&1
748 cmake_toolchain_try "$tc" &&
749 echo "Found $tc toolchain" &&
754 if [ -z "${CC}" -a -z "${CXX}" ]; then
755 cmake_toolchain_detect
758 #-----------------------------------------------------------------------------
762 # If CC is set, use that for compiler, otherwise use list of known compilers
763 if [ -n "${cmake_toolchain}" ]; then
764 eval cmake_c_compilers="\${cmake_toolchain_${cmake_toolchain}_CC}"
765 elif [ -n "${CC}" ]; then
766 cmake_c_compilers="${CC}"
768 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
771 # Check if C compiler works
772 TMPFILE=`cmake_tmp_file`
775 # error "The CMAKE_C_COMPILER is set to a C++ compiler"
780 #if defined(__CLASSIC_C__)
785 int main(int argc, char* argv[])
788 printf("%d%c", (argv != 0), (char)0x0a);
792 for a in ${cmake_c_compilers}; do
793 if [ -z "${cmake_c_compiler}" ] && \
794 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
795 cmake_c_compiler="${a}"
800 if [ -z "${cmake_c_compiler}" ]; then
801 cmake_error 6 "Cannot find appropriate C compiler on this system.
802 Please specify one using environment variable CC.
803 See cmake_bootstrap.log for compilers attempted.
806 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
808 #-----------------------------------------------------------------------------
812 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
814 # If CC is set, use that for compiler, otherwise use list of known compilers
815 if [ -n "${cmake_toolchain}" ]; then
816 eval cmake_cxx_compilers="\${cmake_toolchain_${cmake_toolchain}_CXX}"
817 elif [ -n "${CXX}" ]; then
818 cmake_cxx_compilers="${CXX}"
820 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
823 # Check if C++ compiler works
824 TMPFILE=`cmake_tmp_file`
829 # include <iostream.h>
835 NeedCXX() { this->Foo = 1; }
836 int GetFoo() { return this->Foo; }
844 cout << c.GetFoo() << endl;
846 std::cout << c.GetFoo() << std::endl;
851 for a in ${cmake_cxx_compilers}; do
853 if [ -z "${cmake_cxx_compiler}" ] && \
854 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
855 cmake_cxx_compiler="${a}"
859 rm -f "${TMPFILE}.cxx"
861 if [ -z "${cmake_cxx_compiler}" ]; then
862 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
863 Please specify one using environment variable CXX.
864 See cmake_bootstrap.log for compilers attempted."
866 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
868 #-----------------------------------------------------------------------------
871 cmake_make_processor=
874 # If MAKE is set, use that for make processor, otherwise use list of known make
875 if [ -n "${MAKE}" ]; then
876 cmake_make_processors="${MAKE}"
878 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
881 TMPFILE="`cmake_tmp_file`_dir"
882 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
883 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
884 cd "${cmake_bootstrap_dir}/${TMPFILE}"
887 "'"${cmake_c_compiler}"'" '"${cmake_ld_flags} ${cmake_c_flags}"' -o test test.c
891 int main(){ printf("1%c", (char)0x0a); return 0; }
893 cmake_original_make_flags="${cmake_make_flags}"
894 if [ "x${cmake_parallel_make}" != "x" ]; then
895 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
897 for a in ${cmake_make_processors}; do
898 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
899 cmake_make_processor="${a}"
902 cmake_full_make_flags="${cmake_make_flags}"
903 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
904 if [ -z "${cmake_make_processor}" ]; then
905 cmake_make_flags="${cmake_original_make_flags}"
906 for a in ${cmake_make_processors}; do
907 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
908 cmake_make_processor="${a}"
913 cd "${cmake_bootstrap_dir}"
915 if [ -z "${cmake_make_processor}" ]; then
916 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
917 Please specify one using environment variable MAKE."
919 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
920 echo "Makefile processor on this system is: ${cmake_make_processor}"
921 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
922 echo "---------------------------------------------"
923 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
924 echo "---------------------------------------------"
927 # Ok, we have CC, CXX, and MAKE.
929 # Test C++ compiler features
933 TMPFILE=`cmake_tmp_file`
935 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
937 int main() { std::cout << "This is GNU" << std::endl; return 0;}
940 cmake_cxx_compiler_is_gnu=0
941 if cmake_try_run "${cmake_cxx_compiler}" \
942 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
943 cmake_cxx_compiler_is_gnu=1
945 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
946 echo "${cmake_cxx_compiler} is GNU compiler"
948 echo "${cmake_cxx_compiler} is not GNU compiler"
950 rm -f "${TMPFILE}.cxx"
952 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
953 # Check for non-GNU compiler flags
955 # If we are on IRIX, check for -LANG:std
956 cmake_test_flags="-LANG:std"
957 if [ "x${cmake_system}" = "xIRIX64" ]; then
958 TMPFILE=`cmake_tmp_file`
961 int main() { std::cout << "No need for '"${cmake_test_flags}"'" << std::endl; return 0;}
963 cmake_need_lang_std=0
964 if cmake_try_run "${cmake_cxx_compiler}" \
965 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
968 if cmake_try_run "${cmake_cxx_compiler}" \
969 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
970 cmake_need_lang_std=1
973 if [ "x${cmake_need_lang_std}" = "x1" ]; then
974 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
975 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
977 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
979 rm -f "${TMPFILE}.cxx"
983 # If we are on OSF, check for -timplicit_local -no_implicit_include
984 cmake_test_flags="-timplicit_local -no_implicit_include"
985 if [ "x${cmake_system}" = "xOSF1" ]; then
986 TMPFILE=`cmake_tmp_file`
989 int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
992 if cmake_try_run "${cmake_cxx_compiler}" \
993 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
998 if [ "x${cmake_need_flags}" = "x1" ]; then
999 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
1000 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
1002 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
1004 rm -f "${TMPFILE}.cxx"
1008 # If we are on OSF, check for -std strict_ansi -nopure_cname
1009 cmake_test_flags="-std strict_ansi -nopure_cname"
1010 if [ "x${cmake_system}" = "xOSF1" ]; then
1011 TMPFILE=`cmake_tmp_file`
1014 int main() { std::cout << "We need '"${cmake_test_flags}"'" << std::endl; return 0;}
1017 if cmake_try_run "${cmake_cxx_compiler}" \
1018 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
1023 if [ "x${cmake_need_flags}" = "x1" ]; then
1024 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
1025 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
1027 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
1029 rm -f "${TMPFILE}.cxx"
1033 # If we are on HP-UX, check for -Ae for the C compiler.
1034 cmake_test_flags="-Ae"
1035 if [ "x${cmake_system}" = "xHP-UX" ]; then
1036 TMPFILE=`cmake_tmp_file`
1038 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
1041 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
1044 if cmake_try_run "${cmake_c_compiler}" \
1045 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
1049 if [ "x${cmake_need_Ae}" = "x1" ]; then
1050 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
1051 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
1053 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
1055 rm -f "${TMPFILE}.c"
1060 # Test for kwsys features
1061 KWSYS_NAME_IS_KWSYS=0
1062 KWSYS_BUILD_SHARED=0
1063 KWSYS_LFS_AVAILABLE=0
1064 KWSYS_LFS_REQUESTED=0
1065 KWSYS_IOS_USE_STRSTREAM_H=0
1066 KWSYS_IOS_USE_STRSTREA_H=0
1067 KWSYS_IOS_HAVE_STD=0
1068 KWSYS_IOS_USE_SSTREAM=0
1069 KWSYS_IOS_USE_ANSI=0
1070 KWSYS_IOS_HAVE_BINARY=0
1071 KWSYS_STL_HAVE_STD=0
1072 KWSYS_STAT_HAS_ST_MTIM=0
1073 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
1074 KWSYS_STL_HAS_ITERATOR_TRAITS=0
1075 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
1076 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
1077 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
1078 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
1079 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
1080 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
1081 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
1082 KWSYS_CXX_HAS_SETENV=0
1083 KWSYS_CXX_HAS_UNSETENV=0
1084 KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
1085 KWSYS_CXX_HAS_CSTDDEF=0
1086 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
1087 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
1088 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
1089 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
1091 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
1092 KWSYS_STL_STRING_HAVE_ISTREAM=1
1093 KWSYS_STL_STRING_HAVE_OSTREAM=1
1095 if cmake_try_run "${cmake_cxx_compiler}" \
1096 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_SETENV" \
1097 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1098 KWSYS_CXX_HAS_SETENV=1
1099 echo "${cmake_cxx_compiler} has setenv"
1101 echo "${cmake_cxx_compiler} does not have setenv"
1104 if cmake_try_run "${cmake_cxx_compiler}" \
1105 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_UNSETENV" \
1106 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1107 KWSYS_CXX_HAS_UNSETENV=1
1108 echo "${cmake_cxx_compiler} has unsetenv"
1110 echo "${cmake_cxx_compiler} does not have unsetenv"
1113 if cmake_try_run "${cmake_cxx_compiler}" \
1114 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H" \
1115 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1116 KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=1
1117 echo "${cmake_cxx_compiler} has environ in stdlib.h"
1119 echo "${cmake_cxx_compiler} does not have environ in stdlib.h"
1122 if cmake_try_run "${cmake_cxx_compiler}" \
1123 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
1124 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1125 KWSYS_STL_HAVE_STD=1
1126 echo "${cmake_cxx_compiler} has STL in std:: namespace"
1128 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
1131 if cmake_try_run "${cmake_cxx_compiler}" \
1132 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
1133 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1134 KWSYS_IOS_USE_ANSI=1
1135 echo "${cmake_cxx_compiler} has ANSI streams"
1137 echo "${cmake_cxx_compiler} does not have ANSI streams"
1140 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1141 if cmake_try_run "${cmake_cxx_compiler}" \
1142 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
1143 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1144 KWSYS_IOS_HAVE_STD=1
1145 echo "${cmake_cxx_compiler} has streams in std:: namespace"
1147 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
1149 if cmake_try_run "${cmake_cxx_compiler}" \
1150 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
1151 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1152 KWSYS_IOS_USE_SSTREAM=1
1153 echo "${cmake_cxx_compiler} has sstream"
1155 echo "${cmake_cxx_compiler} does not have sstream"
1159 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
1160 if cmake_try_run "${cmake_cxx_compiler}" \
1161 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
1162 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1163 KWSYS_IOS_USE_STRSTREAM_H=1
1164 echo "${cmake_cxx_compiler} has strstream.h"
1166 echo "${cmake_cxx_compiler} does not have strstream.h"
1168 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
1169 if cmake_try_run "${cmake_cxx_compiler}" \
1170 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
1171 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1172 KWSYS_IOS_USE_STRSTREA_H=1
1173 echo "${cmake_cxx_compiler} has strstrea.h"
1175 echo "${cmake_cxx_compiler} does not have strstrea.h"
1180 if cmake_try_run "${cmake_cxx_compiler}" \
1181 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1182 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1183 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
1184 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
1186 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
1189 if cmake_try_run "${cmake_cxx_compiler}" \
1190 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1191 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1192 KWSYS_STL_HAS_ITERATOR_TRAITS=1
1193 echo "${cmake_cxx_compiler} has stl iterator_traits"
1195 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
1198 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
1199 if cmake_try_run "${cmake_cxx_compiler}" \
1200 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1201 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1202 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
1203 echo "${cmake_cxx_compiler} has old iterator_category"
1205 echo "${cmake_cxx_compiler} does not have old iterator_category"
1207 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
1208 if cmake_try_run "${cmake_cxx_compiler}" \
1209 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1210 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1211 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
1212 echo "${cmake_cxx_compiler} has old __iterator_category"
1214 echo "${cmake_cxx_compiler} does not have old __iterator_category"
1219 if cmake_try_run "${cmake_cxx_compiler}" \
1220 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1221 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1222 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
1223 echo "${cmake_cxx_compiler} has standard template allocator"
1225 echo "${cmake_cxx_compiler} does not have standard template allocator"
1228 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
1229 if cmake_try_run "${cmake_cxx_compiler}" \
1230 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1231 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1232 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
1233 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
1235 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
1238 if cmake_try_run "${cmake_cxx_compiler}" \
1239 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1240 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1241 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
1242 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
1244 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
1247 if cmake_try_run "${cmake_cxx_compiler}" \
1248 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1249 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1250 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
1251 echo "${cmake_cxx_compiler} has old non-template allocator"
1253 echo "${cmake_cxx_compiler} does not have old non-template allocator"
1257 if cmake_try_run "${cmake_cxx_compiler}" \
1258 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
1259 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1260 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
1261 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
1263 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
1266 if cmake_try_run "${cmake_cxx_compiler}" \
1267 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
1268 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1269 KWSYS_CXX_HAS_CSTDDEF=1
1270 echo "${cmake_cxx_compiler} has header cstddef"
1272 echo "${cmake_cxx_compiler} does not have header cstddef"
1275 if cmake_try_run "${cmake_cxx_compiler}" \
1276 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
1277 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1278 echo "${cmake_cxx_compiler} does not require template friends to use <>"
1280 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
1281 echo "${cmake_cxx_compiler} requires template friends to use <>"
1284 if cmake_try_run "${cmake_cxx_compiler}" \
1285 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
1286 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1287 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
1288 echo "${cmake_cxx_compiler} supports member templates"
1290 echo "${cmake_cxx_compiler} does not support member templates"
1293 if cmake_try_run "${cmake_cxx_compiler}" \
1294 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
1295 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1296 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
1297 echo "${cmake_cxx_compiler} has standard template specialization syntax"
1299 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
1302 if cmake_try_run "${cmake_cxx_compiler}" \
1303 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
1304 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1305 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
1306 echo "${cmake_cxx_compiler} has argument dependent lookup"
1308 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
1311 if cmake_try_run "${cmake_cxx_compiler}" \
1312 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
1313 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1314 KWSYS_STAT_HAS_ST_MTIM=1
1315 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
1317 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
1320 if cmake_try_run "${cmake_cxx_compiler}" \
1321 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_BINARY -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}" \
1322 "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then
1323 KWSYS_IOS_HAVE_BINARY=1
1324 echo "${cmake_cxx_compiler} has ios::binary openmode"
1326 echo "${cmake_cxx_compiler} does not have ios::binary openmode"
1329 # Just to be safe, let us store compiler and flags to the header file
1331 cmake_bootstrap_version='$Revision$'
1332 cmake_compiler_settings_comment="/*
1333 * Generated by ${cmake_source_dir}/bootstrap
1334 * Version: ${cmake_bootstrap_version}
1336 * Source directory: ${cmake_source_dir}
1337 * Binary directory: ${cmake_bootstrap_dir}
1339 * C compiler: ${cmake_c_compiler}
1340 * C flags: ${cmake_c_flags}
1342 * C++ compiler: ${cmake_cxx_compiler}
1343 * C++ flags: ${cmake_cxx_flags}
1345 * Make: ${cmake_make_processor}
1348 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
1350 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
1354 cmake_report cmConfigure.h${_tmp} "${cmake_compiler_settings_comment}"
1356 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
1357 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_STD_NAMESPACE */"
1359 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_STD_NAMESPACE 1"
1362 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
1363 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
1365 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
1368 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
1369 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
1371 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_STRING_STREAM 1"
1374 # Test for ansi FOR scope
1375 if cmake_try_run "${cmake_cxx_compiler}" \
1376 "${cmake_cxx_flags}" \
1377 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
1378 cmake_report cmConfigure.h${_tmp} "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
1379 echo "${cmake_cxx_compiler} has ANSI for scoping"
1381 cmake_report cmConfigure.h${_tmp} "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1382 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1385 # When bootstrapping on MinGW with MSYS we must convert the source
1386 # directory to a windows path.
1387 if ${cmake_system_mingw}; then
1388 cmake_root_dir=`cd "${cmake_source_dir}"; pwd -W`
1390 cmake_root_dir="${cmake_source_dir}"
1393 # Write CMake version
1394 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
1395 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
1396 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
1397 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_TWEAK ${cmake_version_tweak}"
1398 cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
1399 cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
1400 cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1401 cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
1403 # Regenerate configured headers
1404 for h in Configure VersionConfig; do
1405 if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then
1406 rm -f cm${h}.h${_tmp}
1408 mv -f cm${h}.h${_tmp} cm${h}.h
1413 cmake_kwsys_config_replace_string \
1414 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1415 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1416 "${cmake_compiler_settings_comment}"
1417 cmake_kwsys_config_replace_string \
1418 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1419 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1420 "${cmake_compiler_settings_comment}"
1422 for a in ${KWSYS_FILES}; do
1423 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1424 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1427 for a in ${KWSYS_IOS_FILES}; do
1428 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1429 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1432 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1433 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" KWSYS_STL_HEADER_EXTRA ""
1435 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_a" \
1436 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" KWSYS_NAMESPACE cmsys
1438 for a in string vector set map algorithm; do
1439 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx_b" \
1440 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1444 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1446 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
1447 objs="${objs} ${a}.o"
1450 # Generate dependencies for cmBootstrapCommands.cxx
1451 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1452 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1454 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1456 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1457 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1460 if [ "x${cmake_c_flags}" != "x" ]; then
1461 cmake_c_flags="${cmake_c_flags} "
1464 if [ "x${cmake_cxx_flags}" != "x" ]; then
1465 cmake_cxx_flags="${cmake_cxx_flags} "
1468 cmake_c_flags_String="-DKWSYS_STRING_C"
1469 cmake_cxx_flags_SystemTools="-DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} -DKWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} -DKWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}"
1470 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
1471 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1472 cmake_cxx_flags="${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
1473 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1474 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1475 echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1476 for a in ${CMAKE_CXX_SOURCES}; do
1477 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1478 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1479 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1481 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1482 for a in ${CMAKE_C_SOURCES}; do
1483 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1484 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1485 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1487 for a in ${KWSYS_C_SOURCES}; do
1488 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1489 src_flags=`eval echo \\${cmake_c_flags_\${a}}`
1490 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1491 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1493 for a in ${KWSYS_CXX_SOURCES}; do
1494 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1495 src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
1496 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1497 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1501 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1502 ' >> "${cmake_bootstrap_dir}/Makefile"
1504 # Write our default settings to Bootstrap${_cmk}/InitialCacheFlags.cmake.
1506 # Generated by '"${cmake_source_dir}"'/bootstrap
1507 # Default cmake settings. These may be overridden any settings below.
1508 set (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1509 set (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1510 set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1511 set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1512 ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1514 # Suppress -isysroot if user-provided flags already have it.
1515 if echo "${cmake_c_flags}" | grep isysroot >/dev/null 2>&1 &&
1516 echo "${cmake_cxx_flags}" | grep isysroot >/dev/null 2>&1; then
1518 set(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE)
1519 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1522 # Add configuration settings given as command-line options.
1523 if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
1525 set (BUILD_QtDialog '"${cmake_bootstrap_qt_gui}"' CACHE BOOL "Build Qt dialog for CMake" FORCE)
1526 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1528 if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
1530 set (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
1531 ' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1534 # Add user-specified settings. Handle relative-path case for
1535 # specification of cmake_init_file.
1537 cd "${cmake_binary_dir}"
1538 if [ -f "${cmake_init_file}" ]; then
1539 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1543 echo "---------------------------------------------"
1545 # Run make to build bootstrap cmake
1546 if [ "x${cmake_parallel_make}" != "x" ]; then
1547 ${cmake_make_processor} ${cmake_make_flags}
1549 ${cmake_make_processor}
1552 if [ "${RES}" -ne "0" ]; then
1553 cmake_error 9 "Problem while running ${cmake_make_processor}"
1555 cd "${cmake_binary_dir}"
1557 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1558 # build with same compiler and make
1559 CC="${cmake_c_compiler}"
1560 CXX="${cmake_cxx_compiler}"
1561 if [ -n "${cmake_ccache_enabled}" ]; then
1565 MAKE="${cmake_make_processor}"
1570 # Run bootstrap CMake to configure real CMake
1571 cmake_options="-DCMAKE_BOOTSTRAP=1"
1572 if [ -n "${cmake_verbose}" ]; then
1573 cmake_options="${cmake_options} -DCMAKE_VERBOSE_MAKEFILE=1"
1575 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} "$@"
1577 if [ "${RES}" -ne "0" ]; then
1578 cmake_error 11 "Problem while running initial CMake"
1581 echo "---------------------------------------------"
1583 # And we are done. Now just run make
1584 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."