QtDialog: Clean up and document -S and -B options
This commit is contained in:
parent
40628b2519
commit
ad0853b3d4
@ -10,6 +10,7 @@ Synopsis
|
|||||||
|
|
||||||
cmake-gui [<options>]
|
cmake-gui [<options>]
|
||||||
cmake-gui [<options>] {<path-to-source> | <path-to-existing-build>}
|
cmake-gui [<options>] {<path-to-source> | <path-to-existing-build>}
|
||||||
|
cmake-gui [<options>] -S <path-to-source> -B <path-to-build>
|
||||||
|
|
||||||
Description
|
Description
|
||||||
===========
|
===========
|
||||||
@ -27,6 +28,14 @@ native tool on their platform.
|
|||||||
Options
|
Options
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
``-S <path-to-source>``
|
||||||
|
Path to root directory of the CMake project to build.
|
||||||
|
|
||||||
|
``-B <path-to-build>``
|
||||||
|
Path to directory which CMake will use as the root of build directory.
|
||||||
|
|
||||||
|
If the directory doesn't already exist CMake will make it.
|
||||||
|
|
||||||
.. include:: OPTIONS_HELP.txt
|
.. include:: OPTIONS_HELP.txt
|
||||||
|
|
||||||
See Also
|
See Also
|
||||||
|
5
Help/release/dev/cmake-gui-s-b.rst
Normal file
5
Help/release/dev/cmake-gui-s-b.rst
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
cmake-gui-s-b
|
||||||
|
-------------
|
||||||
|
|
||||||
|
* The :manual:`cmake-gui(1)` dialog gained new ``-S`` and ``-B`` arguments to
|
||||||
|
explicitly specify source and build directories.
|
@ -30,7 +30,8 @@ static const char* cmDocumentationUsage[][2] = {
|
|||||||
{ nullptr,
|
{ nullptr,
|
||||||
" cmake-gui [options]\n"
|
" cmake-gui [options]\n"
|
||||||
" cmake-gui [options] <path-to-source>\n"
|
" cmake-gui [options] <path-to-source>\n"
|
||||||
" cmake-gui [options] <path-to-existing-build>" },
|
" cmake-gui [options] <path-to-existing-build>\n"
|
||||||
|
" cmake-gui [options] -S <path-to-source> -B <path-to-build>\n" },
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,23 +143,53 @@ int main(int argc, char** argv)
|
|||||||
CMakeSetupDialog dialog;
|
CMakeSetupDialog dialog;
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
cmsys::CommandLineArguments arg;
|
QStringList args = QApplication::arguments();
|
||||||
arg.Initialize(argc2, argv2);
|
|
||||||
std::string binaryDirectory;
|
std::string binaryDirectory;
|
||||||
std::string sourceDirectory;
|
std::string sourceDirectory;
|
||||||
typedef cmsys::CommandLineArguments argT;
|
for (int i = 1; i < args.size(); ++i) {
|
||||||
arg.AddArgument("-B", argT::CONCAT_ARGUMENT, &binaryDirectory,
|
const QString& arg = args[i];
|
||||||
"Binary Directory");
|
if (arg.startsWith("-S")) {
|
||||||
arg.AddArgument("-S", argT::CONCAT_ARGUMENT, &sourceDirectory,
|
QString path = arg.mid(2);
|
||||||
"Source Directory");
|
if (path.isEmpty()) {
|
||||||
// do not complain about unknown options
|
++i;
|
||||||
arg.StoreUnusedArguments(true);
|
if (i >= args.size()) {
|
||||||
arg.Parse();
|
std::cerr << "No source directory specified for -S" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
path = args[i];
|
||||||
|
if (path[0] == '-') {
|
||||||
|
std::cerr << "No source directory specified for -S" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceDirectory =
|
||||||
|
cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
|
||||||
|
cmSystemTools::ConvertToUnixSlashes(sourceDirectory);
|
||||||
|
} else if (arg.startsWith("-B")) {
|
||||||
|
QString path = arg.mid(2);
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
++i;
|
||||||
|
if (i >= args.size()) {
|
||||||
|
std::cerr << "No build directory specified for -B" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
path = args[i];
|
||||||
|
if (path[0] == '-') {
|
||||||
|
std::cerr << "No build directory specified for -B" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binaryDirectory =
|
||||||
|
cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
|
||||||
|
cmSystemTools::ConvertToUnixSlashes(binaryDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!sourceDirectory.empty() && !binaryDirectory.empty()) {
|
if (!sourceDirectory.empty() && !binaryDirectory.empty()) {
|
||||||
dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str()));
|
dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str()));
|
||||||
dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str()));
|
dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str()));
|
||||||
} else {
|
} else {
|
||||||
QStringList args = QApplication::arguments();
|
|
||||||
if (args.count() == 2) {
|
if (args.count() == 2) {
|
||||||
std::string filePath =
|
std::string filePath =
|
||||||
cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
|
cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
|
||||||
|
Loading…
Reference in New Issue
Block a user