2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2012-06-22 01:02:55 +04:00
|
|
|
// include these first, otherwise there will be problems on Windows
|
|
|
|
// with GetCurrentDirectory() being redefined
|
2007-07-17 20:01:39 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
|
|
|
#include "cmDocumentation.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmDynamicLoader.h"
|
2007-07-17 20:01:39 +04:00
|
|
|
#endif
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmDocumentationEntry.h"
|
2007-07-17 17:25:08 +04:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmState.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmSystemTools.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmcmd.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
|
|
|
|
#include <cmConfigure.h>
|
2013-12-19 01:38:56 +04:00
|
|
|
#include <cmsys/Encoding.hxx>
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <iostream>
|
|
|
|
#include <string.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2004-10-27 18:47:14 +04:00
|
|
|
|
2016-08-25 21:12:42 +03:00
|
|
|
#ifdef CMAKE_USE_LIBUV
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <cm_uv.h>
|
2016-08-25 21:12:42 +03:00
|
|
|
#endif
|
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationName[][2] = {
|
2016-06-27 23:44:16 +03:00
|
|
|
{ CM_NULLPTR, " cmake - Cross-Platform Makefile Generator." },
|
|
|
|
{ CM_NULLPTR, CM_NULLPTR }
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationUsage[][2] = {
|
2016-06-27 23:44:16 +03:00
|
|
|
{ CM_NULLPTR, " cmake [options] <path-to-source>\n"
|
|
|
|
" cmake [options] <path-to-existing-build>" },
|
|
|
|
{ CM_NULLPTR,
|
|
|
|
"Specify a source directory to (re-)generate a build system for "
|
|
|
|
"it in the current working directory. Specify an existing build "
|
|
|
|
"directory to re-generate its build system." },
|
|
|
|
{ CM_NULLPTR, CM_NULLPTR }
|
2014-06-13 00:18:32 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationUsageNote[][2] = {
|
2016-06-27 23:44:16 +03:00
|
|
|
{ CM_NULLPTR, "Run 'cmake --help' for more information." },
|
|
|
|
{ CM_NULLPTR, CM_NULLPTR }
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define CMAKE_BUILD_OPTIONS \
|
|
|
|
" <dir> = Project binary directory to be built.\n" \
|
|
|
|
" --target <tgt> = Build <tgt> instead of default targets.\n" \
|
|
|
|
" May only be specified once.\n" \
|
|
|
|
" --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \
|
|
|
|
" --clean-first = Build target 'clean' first, then build.\n" \
|
|
|
|
" (To clean only, use --target 'clean'.)\n" \
|
|
|
|
" --use-stderr = Ignored. Behavior is default in CMake >= 3.0.\n" \
|
2009-03-04 23:39:27 +03:00
|
|
|
" -- = Pass remaining options to the native tool.\n"
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationOptions[][2] = {
|
2003-04-03 07:48:12 +04:00
|
|
|
CMAKE_STANDARD_OPTIONS_TABLE,
|
2016-05-16 17:34:04 +03:00
|
|
|
{ "-E", "CMake command mode." },
|
|
|
|
{ "-L[A][H]", "List non-advanced cached variables." },
|
|
|
|
{ "--build <dir>", "Build a CMake-generated project binary tree." },
|
|
|
|
{ "-N", "View mode only." },
|
|
|
|
{ "-P <file>", "Process script mode." },
|
|
|
|
{ "--find-package", "Run in pkg-config like mode." },
|
|
|
|
{ "--graphviz=[file]", "Generate graphviz of dependencies, see "
|
|
|
|
"CMakeGraphVizOptions.cmake for more." },
|
|
|
|
{ "--system-information [file]", "Dump information about this system." },
|
|
|
|
{ "--debug-trycompile", "Do not delete the try_compile build tree. Only "
|
|
|
|
"useful on one try_compile at a time." },
|
|
|
|
{ "--debug-output", "Put cmake in a debug mode." },
|
|
|
|
{ "--trace", "Put cmake in trace mode." },
|
|
|
|
{ "--trace-expand", "Put cmake in trace mode with variable expansion." },
|
2016-06-13 22:27:58 +03:00
|
|
|
{ "--trace-source=<file>",
|
|
|
|
"Trace only this CMake file/module. Multiple options allowed." },
|
2016-05-16 17:34:04 +03:00
|
|
|
{ "--warn-uninitialized", "Warn about uninitialized values." },
|
|
|
|
{ "--warn-unused-vars", "Warn about unused variables." },
|
|
|
|
{ "--no-warn-unused-cli", "Don't warn about command line options." },
|
|
|
|
{ "--check-system-vars", "Find problems with variable usage in system "
|
|
|
|
"files." },
|
2016-06-27 23:44:16 +03:00
|
|
|
{ CM_NULLPTR, CM_NULLPTR }
|
2003-04-03 07:48:12 +04:00
|
|
|
};
|
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2003-02-17 17:42:26 +03:00
|
|
|
|
2013-12-19 01:38:56 +04:00
|
|
|
static int do_command(int ac, char const* const* av)
|
2013-10-04 22:22:05 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> args;
|
2015-01-18 20:05:28 +03:00
|
|
|
args.reserve(ac - 1);
|
2013-10-04 22:22:05 +04:00
|
|
|
args.push_back(av[0]);
|
2015-01-18 20:05:28 +03:00
|
|
|
args.insert(args.end(), av + 2, av + ac);
|
2013-10-04 22:22:05 +04:00
|
|
|
return cmcmd::ExecuteCMakeCommand(args);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:38:56 +04:00
|
|
|
int do_cmake(int ac, char const* const* av);
|
|
|
|
static int do_build(int ac, char const* const* av);
|
2007-07-17 17:25:08 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static cmMakefile* cmakemainGetMakefile(void* clientdata)
|
2007-07-17 17:25:08 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmake* cm = (cmake*)clientdata;
|
|
|
|
if (cm && cm->GetDebugOutput()) {
|
|
|
|
cmGlobalGenerator* gg = cm->GetGlobalGenerator();
|
|
|
|
if (gg) {
|
2015-05-31 00:50:28 +03:00
|
|
|
return gg->GetCurrentMakefile();
|
2007-07-17 17:25:08 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2007-07-17 17:25:08 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static std::string cmakemainGetStack(void* clientdata)
|
2007-07-17 17:25:08 +04:00
|
|
|
{
|
|
|
|
std::string msg;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakefile* mf = cmakemainGetMakefile(clientdata);
|
|
|
|
if (mf) {
|
2015-05-16 08:30:33 +03:00
|
|
|
msg = mf->FormatListFileStack();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!msg.empty()) {
|
2007-07-19 19:13:01 +04:00
|
|
|
msg = "\n Called from: " + msg;
|
2007-07-17 17:25:08 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-07-17 17:25:08 +04:00
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2016-08-17 02:49:57 +03:00
|
|
|
static void cmakemainMessageCallback(const char* m, const char* /*unused*/,
|
|
|
|
bool& /*unused*/, void* clientdata)
|
2007-07-17 17:25:08 +04:00
|
|
|
{
|
|
|
|
std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void cmakemainProgressCallback(const char* m, float prog,
|
2007-07-17 18:44:09 +04:00
|
|
|
void* clientdata)
|
2007-07-17 17:25:08 +04:00
|
|
|
{
|
|
|
|
cmMakefile* mf = cmakemainGetMakefile(clientdata);
|
|
|
|
std::string dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((mf) && (strstr(m, "Configuring") == m) && (prog < 0)) {
|
2007-07-17 17:25:08 +04:00
|
|
|
dir = " ";
|
2015-04-16 22:17:41 +03:00
|
|
|
dir += mf->GetCurrentSourceDirectory();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((mf) && (strstr(m, "Generating") == m)) {
|
2007-07-17 17:25:08 +04:00
|
|
|
dir = " ";
|
2015-04-16 22:33:09 +03:00
|
|
|
dir += mf->GetCurrentBinaryDirectory();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-07-17 17:25:08 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((prog < 0) || (!dir.empty())) {
|
|
|
|
std::cout << "-- " << m << dir << cmakemainGetStack(clientdata)
|
|
|
|
<< std::endl;
|
|
|
|
}
|
2007-07-17 17:25:08 +04:00
|
|
|
|
|
|
|
std::cout.flush();
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:38:56 +04:00
|
|
|
int main(int ac, char const* const* av)
|
2002-10-01 00:25:02 +04:00
|
|
|
{
|
2013-12-19 01:38:56 +04:00
|
|
|
cmsys::Encoding::CommandLineArguments args =
|
|
|
|
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
|
|
|
ac = args.argc();
|
|
|
|
av = args.argv();
|
|
|
|
|
2002-12-11 19:49:08 +03:00
|
|
|
cmSystemTools::EnableMSVCDebugHook();
|
2013-11-08 00:30:59 +04:00
|
|
|
cmSystemTools::FindCMakeResources(av[0]);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ac > 1) {
|
|
|
|
if (strcmp(av[1], "--build") == 0) {
|
2013-10-04 22:22:05 +04:00
|
|
|
return do_build(ac, av);
|
2016-08-18 21:36:29 +03:00
|
|
|
}
|
|
|
|
if (strcmp(av[1], "-E") == 0) {
|
2013-10-04 22:22:05 +04:00
|
|
|
return do_command(ac, av);
|
2009-03-04 23:39:27 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-10-01 00:25:02 +04:00
|
|
|
int ret = do_cmake(ac, av);
|
2002-10-01 15:28:34 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2002-10-01 00:25:02 +04:00
|
|
|
cmDynamicLoader::FlushCache();
|
2016-08-25 21:12:42 +03:00
|
|
|
#endif
|
|
|
|
#ifdef CMAKE_USE_LIBUV
|
|
|
|
uv_loop_close(uv_default_loop());
|
2002-10-01 15:28:34 +04:00
|
|
|
#endif
|
2002-10-01 00:25:02 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:38:56 +04:00
|
|
|
int do_cmake(int ac, char const* const* av)
|
2001-05-30 23:56:17 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
|
2012-06-22 01:02:55 +04:00
|
|
|
std::cerr << "Current working directory cannot be established."
|
2006-03-10 21:54:57 +03:00
|
|
|
<< std::endl;
|
2013-02-07 17:53:50 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-21 18:34:08 +04:00
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2008-08-12 15:01:44 +04:00
|
|
|
cmDocumentation doc;
|
2011-11-14 01:44:53 +04:00
|
|
|
doc.addCMakeStandardDocSections();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (doc.CheckOptions(ac, av)) {
|
2003-04-03 07:48:12 +04:00
|
|
|
// Construct and print requested documentation.
|
2003-02-14 18:53:37 +03:00
|
|
|
cmake hcm;
|
2015-05-05 00:01:29 +03:00
|
|
|
hcm.SetHomeDirectory("");
|
|
|
|
hcm.SetHomeOutputDirectory("");
|
2007-12-14 01:56:50 +03:00
|
|
|
hcm.AddCMakePaths();
|
2007-09-19 21:14:25 +04:00
|
|
|
|
2012-06-22 01:02:55 +04:00
|
|
|
// the command line args are processed here so that you can do
|
2007-09-19 21:14:25 +04:00
|
|
|
// -DCMAKE_MODULE_PATH=/some/path and have this value accessible here
|
2015-01-18 20:18:54 +03:00
|
|
|
std::vector<std::string> args(av, av + ac);
|
2007-09-19 21:14:25 +04:00
|
|
|
hcm.SetCacheArgs(args);
|
|
|
|
|
2007-10-22 23:33:19 +04:00
|
|
|
std::vector<cmDocumentationEntry> generators;
|
2007-07-11 23:53:58 +04:00
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
hcm.GetGeneratorDocumentation(generators);
|
2007-10-22 20:49:09 +04:00
|
|
|
|
2003-08-06 22:49:52 +04:00
|
|
|
doc.SetName("cmake");
|
2016-05-16 17:34:04 +03:00
|
|
|
doc.SetSection("Name", cmDocumentationName);
|
|
|
|
doc.SetSection("Usage", cmDocumentationUsage);
|
|
|
|
if (ac == 1) {
|
|
|
|
doc.AppendSection("Usage", cmDocumentationUsageNote);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
doc.AppendSection("Generators", generators);
|
|
|
|
doc.PrependSection("Options", cmDocumentationOptions);
|
|
|
|
|
|
|
|
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
|
|
|
|
}
|
2004-10-27 19:26:49 +04:00
|
|
|
#else
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ac == 1) {
|
|
|
|
std::cout
|
|
|
|
<< "Bootstrap CMake should not be used outside CMake build process."
|
|
|
|
<< std::endl;
|
2004-10-27 19:26:49 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2012-06-22 01:02:55 +04:00
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
bool sysinfo = false;
|
2003-04-29 18:07:30 +04:00
|
|
|
bool list_cached = false;
|
|
|
|
bool list_all_cached = false;
|
|
|
|
bool list_help = false;
|
|
|
|
bool view_only = false;
|
2011-07-13 20:59:51 +04:00
|
|
|
cmake::WorkingMode workingMode = cmake::NORMAL_MODE;
|
2001-05-30 23:56:17 +04:00
|
|
|
std::vector<std::string> args;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 0; i < ac; ++i) {
|
|
|
|
if (strcmp(av[i], "-i") == 0) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2013-10-18 21:30:43 +04:00
|
|
|
std::cerr <<
|
|
|
|
"The \"cmake -i\" wizard mode is no longer supported.\n"
|
|
|
|
"Use the -D option to set cache values on the command line.\n"
|
|
|
|
"Use cmake-gui or ccmake for an interactive dialog.\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2013-10-18 21:30:43 +04:00
|
|
|
return 1;
|
2016-08-18 21:36:29 +03:00
|
|
|
}
|
|
|
|
if (strcmp(av[i], "--system-information") == 0) {
|
2007-02-27 18:10:10 +03:00
|
|
|
sysinfo = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "-N") == 0) {
|
2003-04-29 18:07:30 +04:00
|
|
|
view_only = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "-L") == 0) {
|
2003-04-29 18:07:30 +04:00
|
|
|
list_cached = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "-LA") == 0) {
|
2003-04-29 18:07:30 +04:00
|
|
|
list_all_cached = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "-LH") == 0) {
|
2003-04-29 18:07:30 +04:00
|
|
|
list_cached = true;
|
|
|
|
list_help = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "-LAH") == 0) {
|
2003-04-29 18:07:30 +04:00
|
|
|
list_all_cached = true;
|
|
|
|
list_help = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cmHasLiteralPrefix(av[i], "-P")) {
|
|
|
|
if (i == ac - 1) {
|
2004-02-20 22:46:33 +03:00
|
|
|
cmSystemTools::Error("No script specified for argument -P");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2011-07-13 20:59:51 +04:00
|
|
|
workingMode = cmake::SCRIPT_MODE;
|
2006-05-19 07:24:00 +04:00
|
|
|
args.push_back(av[i]);
|
|
|
|
i++;
|
|
|
|
args.push_back(av[i]);
|
2003-10-29 17:45:26 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cmHasLiteralPrefix(av[i], "--find-package")) {
|
2011-07-13 20:59:51 +04:00
|
|
|
workingMode = cmake::FIND_PACKAGE_MODE;
|
2011-07-02 19:50:05 +04:00
|
|
|
args.push_back(av[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2003-02-14 18:53:37 +03:00
|
|
|
args.push_back(av[i]);
|
2001-05-30 23:56:17 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (sysinfo) {
|
2007-02-27 18:10:10 +03:00
|
|
|
cmake cm;
|
2015-05-05 00:01:29 +03:00
|
|
|
cm.SetHomeDirectory("");
|
|
|
|
cm.SetHomeOutputDirectory("");
|
2007-02-27 18:10:10 +03:00
|
|
|
int ret = cm.GetSystemInformation(args);
|
2012-06-22 01:02:55 +04:00
|
|
|
return ret;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-06-22 01:02:55 +04:00
|
|
|
cmake cm;
|
2015-05-05 00:01:29 +03:00
|
|
|
cm.SetHomeDirectory("");
|
|
|
|
cm.SetHomeOutputDirectory("");
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
|
|
|
|
cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm);
|
2011-07-13 20:59:51 +04:00
|
|
|
cm.SetWorkingMode(workingMode);
|
2007-07-17 17:25:08 +04:00
|
|
|
|
2003-04-29 18:07:30 +04:00
|
|
|
int res = cm.Run(args, view_only);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (list_cached || list_all_cached) {
|
2003-04-29 18:07:30 +04:00
|
|
|
std::cout << "-- Cache values" << std::endl;
|
2015-04-07 23:45:54 +03:00
|
|
|
std::vector<std::string> keys = cm.GetState()->GetCacheEntryKeys();
|
2015-04-05 11:48:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator it = keys.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != keys.end(); ++it) {
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::CacheEntryType t = cm.GetState()->GetCacheEntryType(*it);
|
|
|
|
if (t != cmState::INTERNAL && t != cmState::STATIC &&
|
2016-05-16 17:34:04 +03:00
|
|
|
t != cmState::UNINITIALIZED) {
|
2015-04-05 11:48:04 +03:00
|
|
|
const char* advancedProp =
|
2016-05-16 17:34:04 +03:00
|
|
|
cm.GetState()->GetCacheEntryProperty(*it, "ADVANCED");
|
|
|
|
if (list_all_cached || !advancedProp) {
|
|
|
|
if (list_help) {
|
2015-04-05 11:48:04 +03:00
|
|
|
std::cout << "// "
|
2015-04-06 11:52:45 +03:00
|
|
|
<< cm.GetState()->GetCacheEntryProperty(*it,
|
2016-05-16 17:34:04 +03:00
|
|
|
"HELPSTRING")
|
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
std::cout << *it << ":" << cmState::CacheEntryTypeToString(t) << "="
|
|
|
|
<< cm.GetState()->GetCacheEntryValue(*it) << std::endl;
|
|
|
|
if (list_help) {
|
2003-04-29 18:07:30 +04:00
|
|
|
std::cout << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-19 21:42:54 +03:00
|
|
|
|
|
|
|
// Always return a non-negative value. Windows tools do not always
|
|
|
|
// interpret negative return values as errors.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res != 0) {
|
2007-11-19 21:42:54 +03:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-08-18 21:36:29 +03:00
|
|
|
return 0;
|
2001-05-30 23:56:17 +04:00
|
|
|
}
|
2002-11-15 01:12:38 +03:00
|
|
|
|
2013-12-19 01:38:56 +04:00
|
|
|
static int do_build(int ac, char const* const* av)
|
2009-03-04 23:39:27 +03:00
|
|
|
{
|
|
|
|
#ifndef CMAKE_BUILD_WITH_CMAKE
|
|
|
|
std::cerr << "This cmake does not support --build\n";
|
|
|
|
return -1;
|
|
|
|
#else
|
|
|
|
std::string target;
|
|
|
|
std::string config = "Debug";
|
|
|
|
std::string dir;
|
|
|
|
std::vector<std::string> nativeOptions;
|
|
|
|
bool clean = false;
|
2016-02-04 14:36:44 +03:00
|
|
|
bool hasTarget = false;
|
2009-03-04 23:39:27 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
enum Doing
|
|
|
|
{
|
|
|
|
DoingNone,
|
|
|
|
DoingDir,
|
|
|
|
DoingTarget,
|
|
|
|
DoingConfig,
|
|
|
|
DoingNative
|
|
|
|
};
|
2009-03-04 23:39:27 +03:00
|
|
|
Doing doing = DoingDir;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 2; i < ac; ++i) {
|
|
|
|
if (doing == DoingNative) {
|
2009-03-04 23:39:27 +03:00
|
|
|
nativeOptions.push_back(av[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "--target") == 0) {
|
|
|
|
if (!hasTarget) {
|
2016-02-04 14:36:44 +03:00
|
|
|
doing = DoingTarget;
|
|
|
|
hasTarget = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-02-04 14:36:44 +03:00
|
|
|
std::cerr << "'--target' may not be specified more than once.\n\n";
|
|
|
|
dir = "";
|
|
|
|
break;
|
2009-03-04 23:39:27 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "--config") == 0) {
|
2009-03-04 23:39:27 +03:00
|
|
|
doing = DoingConfig;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "--clean-first") == 0) {
|
2009-03-04 23:39:27 +03:00
|
|
|
clean = true;
|
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "--use-stderr") == 0) {
|
2013-10-18 21:38:36 +04:00
|
|
|
/* tolerate legacy option */
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(av[i], "--") == 0) {
|
2009-03-04 23:39:27 +03:00
|
|
|
doing = DoingNative;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
switch (doing) {
|
2009-03-04 23:39:27 +03:00
|
|
|
case DoingDir:
|
2015-06-11 22:01:12 +03:00
|
|
|
dir = cmSystemTools::CollapseFullPath(av[i]);
|
2009-03-04 23:39:27 +03:00
|
|
|
doing = DoingNone;
|
|
|
|
break;
|
|
|
|
case DoingTarget:
|
|
|
|
target = av[i];
|
|
|
|
doing = DoingNone;
|
|
|
|
break;
|
|
|
|
case DoingConfig:
|
|
|
|
config = av[i];
|
|
|
|
doing = DoingNone;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
std::cerr << "Unknown argument " << av[i] << std::endl;
|
|
|
|
dir = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (dir.empty()) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2009-03-04 23:39:27 +03:00
|
|
|
std::cerr <<
|
|
|
|
"Usage: cmake --build <dir> [options] [-- [native-options]]\n"
|
|
|
|
"Options:\n"
|
|
|
|
CMAKE_BUILD_OPTIONS
|
|
|
|
;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-03-04 23:39:27 +03:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-03-04 23:39:27 +03:00
|
|
|
|
|
|
|
cmake cm;
|
2013-10-18 21:38:36 +04:00
|
|
|
return cm.Build(dir, target, config, nativeOptions, clean);
|
2009-03-04 23:39:27 +03:00
|
|
|
#endif
|
|
|
|
}
|