From ad95a57509380ba9050379a76dec305f4957eab7 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Wed, 13 Feb 2008 14:47:03 -0500
Subject: [PATCH] ENH: Add option to bootstrap script to enable Qt dialog.

  - Add --qt-gui and --no-qt-gui options
  - Add --qt-qmake=<qmake> option to help locate Qt
  - Build more commands during bootstrap to help FindQt4.cmake:
    MATH, GET_DIRECTORY_PROPERTY, EXECUTE_PROCESS,
    SEPARATE_ARGUMENTS
  - Bootstrapping with the cmake-gui is now possible in MSys
---
 Source/cmBootstrapCommands.cxx |  8 ++++++++
 Source/cmCommands.cxx          |  8 --------
 bootstrap                      | 29 +++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/Source/cmBootstrapCommands.cxx b/Source/cmBootstrapCommands.cxx
index ac1471de13..197ee2bcf8 100644
--- a/Source/cmBootstrapCommands.cxx
+++ b/Source/cmBootstrapCommands.cxx
@@ -41,6 +41,7 @@
 #include "cmEndIfCommand.cxx"
 #include "cmEndMacroCommand.cxx"
 #include "cmExecProgramCommand.cxx"
+#include "cmExecuteProcessCommand.cxx"
 #include "cmExternalMakefileProjectGenerator.cxx"
 #include "cmFindBase.cxx"
 #include "cmFindCommon.cxx"
@@ -53,6 +54,7 @@
 #include "cmForEachCommand.cxx"
 #include "cmFunctionCommand.cxx"
 #include "cmGetCMakePropertyCommand.cxx"
+#include "cmGetDirectoryPropertyCommand.cxx"
 #include "cmGetFilenameComponentCommand.cxx"
 #include "cmGetSourceFilePropertyCommand.cxx"
 #include "cmGetTargetPropertyCommand.cxx"
@@ -68,10 +70,12 @@
 #include "cmMacroCommand.cxx"
 #include "cmMakeDirectoryCommand.cxx"
 #include "cmMarkAsAdvancedCommand.cxx"
+#include "cmMathCommand.cxx"
 #include "cmMessageCommand.cxx"
 #include "cmOptionCommand.cxx"
 #include "cmProjectCommand.cxx"
 #include "cmReturnCommand.cxx"
+#include "cmSeparateArgumentsCommand.cxx"
 #include "cmSetCommand.cxx"
 #include "cmSetPropertyCommand.cxx"
 #include "cmSetSourceFilesPropertiesCommand.cxx"
@@ -106,6 +110,7 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
   commands.push_back(new cmEndIfCommand);
   commands.push_back(new cmEndMacroCommand);
   commands.push_back(new cmExecProgramCommand);
+  commands.push_back(new cmExecuteProcessCommand);
   commands.push_back(new cmFileCommand);
   commands.push_back(new cmFindFileCommand);
   commands.push_back(new cmFindLibraryCommand);
@@ -115,6 +120,7 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
   commands.push_back(new cmForEachCommand);
   commands.push_back(new cmFunctionCommand);
   commands.push_back(new cmGetCMakePropertyCommand);
+  commands.push_back(new cmGetDirectoryPropertyCommand);
   commands.push_back(new cmGetFilenameComponentCommand);
   commands.push_back(new cmGetSourceFilePropertyCommand);
   commands.push_back(new cmGetTargetPropertyCommand);
@@ -129,10 +135,12 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
   commands.push_back(new cmMacroCommand);
   commands.push_back(new cmMakeDirectoryCommand);
   commands.push_back(new cmMarkAsAdvancedCommand);
+  commands.push_back(new cmMathCommand);
   commands.push_back(new cmMessageCommand);
   commands.push_back(new cmOptionCommand);
   commands.push_back(new cmProjectCommand);
   commands.push_back(new cmReturnCommand);
+  commands.push_back(new cmSeparateArgumentsCommand);
   commands.push_back(new cmSetCommand);
   commands.push_back(new cmSetPropertyCommand);
   commands.push_back(new cmSetSourceFilesPropertiesCommand);
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 42b215b620..ff733ebf3b 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -22,11 +22,9 @@
 #include "cmElseIfCommand.cxx"
 #include "cmEnableLanguageCommand.cxx"
 #include "cmEndWhileCommand.cxx"
-#include "cmExecuteProcessCommand.cxx"
 #include "cmExportCommand.cxx"
 #include "cmExportLibraryDependencies.cxx"
 #include "cmFLTKWrapUICommand.cxx"
-#include "cmGetDirectoryPropertyCommand.cxx"
 #include "cmGetPropertyCommand.cxx"
 #include "cmGetTestPropertyCommand.cxx"
 #include "cmIncludeExternalMSProjectCommand.cxx"
@@ -35,13 +33,11 @@
 #include "cmInstallProgramsCommand.cxx"
 #include "cmLinkLibrariesCommand.cxx"
 #include "cmLoadCacheCommand.cxx"
-#include "cmMathCommand.cxx"
 #include "cmOutputRequiredFilesCommand.cxx"
 #include "cmQTWrapCPPCommand.cxx"
 #include "cmQTWrapUICommand.cxx"
 #include "cmRemoveCommand.cxx"
 #include "cmRemoveDefinitionsCommand.cxx"
-#include "cmSeparateArgumentsCommand.cxx"
 #include "cmSetDirectoryPropertiesCommand.cxx"
 #include "cmSourceGroupCommand.cxx"
 #include "cmSubdirDependsCommand.cxx"
@@ -72,11 +68,9 @@ void GetPredefinedCommands(std::list<cmCommand*>&
   commands.push_back(new cmElseIfCommand);
   commands.push_back(new cmEnableLanguageCommand);
   commands.push_back(new cmEndWhileCommand);
-  commands.push_back(new cmExecuteProcessCommand);
   commands.push_back(new cmExportCommand);
   commands.push_back(new cmExportLibraryDependenciesCommand);
   commands.push_back(new cmFLTKWrapUICommand);
-  commands.push_back(new cmGetDirectoryPropertyCommand);
   commands.push_back(new cmGetPropertyCommand);
   commands.push_back(new cmGetTestPropertyCommand);
   commands.push_back(new cmIncludeExternalMSProjectCommand);
@@ -85,13 +79,11 @@ void GetPredefinedCommands(std::list<cmCommand*>&
   commands.push_back(new cmLinkLibrariesCommand);
   commands.push_back(new cmLoadCacheCommand);
   commands.push_back(new cmLoadCommandCommand);
-  commands.push_back(new cmMathCommand);
   commands.push_back(new cmOutputRequiredFilesCommand);
   commands.push_back(new cmQTWrapCPPCommand);
   commands.push_back(new cmQTWrapUICommand);
   commands.push_back(new cmRemoveCommand);
   commands.push_back(new cmRemoveDefinitionsCommand);
-  commands.push_back(new cmSeparateArgumentsCommand);
   commands.push_back(new cmSetDirectoryPropertiesCommand);
   commands.push_back(new cmSourceGroupCommand);
   commands.push_back(new cmSubdirDependsCommand);
diff --git a/bootstrap b/bootstrap
index ad29da2a53..c4071b915c 100755
--- a/bootstrap
+++ b/bootstrap
@@ -49,6 +49,8 @@ cmake_doc_dir="/doc/cmake-${cmake_version}"
 cmake_man_dir="/man"
 cmake_init_file=""
 cmake_bootstrap_system_libs=""
+cmake_bootstrap_qt_gui=""
+cmake_bootstrap_qt_qmake=""
 
 # Determine whether this is a MinGW environment.
 if echo "${cmake_system}" | grep MINGW >/dev/null 2>&1; then
@@ -172,6 +174,9 @@ CMAKE_CXX_SOURCES="\
   cmOrderRuntimeDirectories \
   cmComputeTargetDepends \
   cmComputeComponentGraph \
+  cmExprLexer \
+  cmExprParser \
+  cmExprParserHelper \
 "
 
 if ${cmake_system_mingw}; then
@@ -244,6 +249,9 @@ Configuration:
                           (for use only by package maintainers)
   --no-system-libs        use cmake-provided third-party libraries
                           (default)
+  --qt-gui                build the Qt-based GUI (requires Qt >= 4.2)
+  --no-qt-gui             do not build the Qt-based GUI (default)
+  --qt-qmake=<qmake>      use <qmake> as the qmake executable to find Qt
 
 Directory and file names:
   --prefix=PREFIX         install files in tree rooted at PREFIX
@@ -482,6 +490,15 @@ for a in "$@"; do
   if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then
     cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0"
   fi
+  if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then
+    cmake_bootstrap_qt_gui="1"
+  fi
+  if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then
+    cmake_bootstrap_qt_gui="0"
+  fi
+  if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then
+    cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"`
+  fi
   if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
     cmake_usage
   fi
@@ -1302,6 +1319,18 @@ SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages
 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
 EOF
 
+# Add configuration settings given as command-line options.
+if [ "x${cmake_bootstrap_qt_gui}" != "x" ]; then
+  cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
+SET (BUILD_QtDialog ${cmake_bootstrap_qt_gui} CACHE BOOL "Build Qt dialog for CMake" FORCE)
+EOF
+fi
+if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
+  cat >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
+SET (QT_QMAKE_EXECUTABLE "${cmake_bootstrap_qt_qmake}" CACHE FILEPATH "Location of Qt qmake" FORCE)
+EOF
+fi
+
 # Add user-specified settings.  Handle relative-path case for
 # specification of cmake_init_file.
 (
-- 
GitLab