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 "cmDynamicLoader.h"
|
|
|
|
#include "cmDocumentation.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-30 23:56:17 +04:00
|
|
|
#include "cmake.h"
|
2013-10-04 01:28:00 +04:00
|
|
|
#include "cmcmd.h"
|
2002-08-23 21:46:32 +04:00
|
|
|
#include "cmCacheManager.h"
|
2002-10-01 00:25:02 +04:00
|
|
|
#include "cmListFileCache.h"
|
2006-03-31 22:17:23 +04:00
|
|
|
#include "cmakewizard.h"
|
2006-12-07 17:45:32 +03:00
|
|
|
#include "cmSourceFile.h"
|
2007-07-17 17:25:08 +04:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
2004-10-27 18:47:14 +04:00
|
|
|
|
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2013-09-16 22:04:39 +04:00
|
|
|
static const char * cmDocumentationName[][2] =
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2013-09-16 22:04:39 +04:00
|
|
|
" cmake - Cross-Platform Makefile Generator."},
|
|
|
|
{0,0}
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2013-09-16 22:04:39 +04:00
|
|
|
static const char * cmDocumentationUsage[][2] =
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2003-08-20 21:00:46 +04:00
|
|
|
" cmake [options] <path-to-source>\n"
|
2013-09-16 22:04:39 +04:00
|
|
|
" cmake [options] <path-to-existing-build>"},
|
|
|
|
{0,0}
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
2009-03-04 23:39:27 +03:00
|
|
|
#define CMAKE_BUILD_OPTIONS \
|
|
|
|
" <dir> = Project binary directory to be built.\n" \
|
|
|
|
" --target <tgt> = Build <tgt> instead of default targets.\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" \
|
2013-07-29 10:52:54 +04:00
|
|
|
" --use-stderr = Don't merge stdout/stderr output and pass the\n" \
|
|
|
|
" original stdout/stderr handles to the native\n" \
|
|
|
|
" tool so it can use the capabilities of the\n" \
|
|
|
|
" calling terminal (e.g. colored output).\n" \
|
2009-03-04 23:39:27 +03:00
|
|
|
" -- = Pass remaining options to the native tool.\n"
|
|
|
|
|
2003-02-17 17:42:26 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2013-09-16 22:04:39 +04:00
|
|
|
static const char * cmDocumentationOptions[][2] =
|
2003-02-17 17:42:26 +03:00
|
|
|
{
|
2003-04-03 07:48:12 +04:00
|
|
|
CMAKE_STANDARD_OPTIONS_TABLE,
|
2013-09-16 22:04:39 +04:00
|
|
|
{"-E", "CMake command mode."},
|
|
|
|
{"-i", "Run in wizard 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."},
|
2013-07-27 00:43:42 +04:00
|
|
|
{"--graphviz=[file]", "Generate graphviz of dependencies, see "
|
2013-09-16 22:04:39 +04:00
|
|
|
"CMakeGraphVizOptions.cmake for more."},
|
|
|
|
{"--system-information [file]", "Dump information about this system."},
|
2011-04-13 00:21:54 +04:00
|
|
|
{"--debug-trycompile", "Do not delete the try_compile build tree. Only "
|
2013-09-16 22:04:39 +04:00
|
|
|
"useful on one try_compile at a time."},
|
|
|
|
{"--debug-output", "Put cmake in a debug mode."},
|
|
|
|
{"--trace", "Put cmake in trace mode."},
|
|
|
|
{"--warn-uninitialized", "Warn about uninitialized values."},
|
|
|
|
{"--warn-unused-vars", "Warn about unused variables."},
|
|
|
|
{"--no-warn-unused-cli", "Don't warn about command line options."},
|
2010-09-16 19:49:58 +04:00
|
|
|
{"--check-system-vars", "Find problems with variable usage in system "
|
2013-09-16 22:04:39 +04:00
|
|
|
"files."},
|
|
|
|
{"--help-command cmd [file]", "Print help for a single command and exit."},
|
|
|
|
{"--help-command-list [file]", "List available listfile commands and exit."},
|
|
|
|
{"--help-commands [file]", "Print help for all commands and exit."},
|
|
|
|
{"--help-compatcommands [file]", "Print help for compatibility commands. "},
|
|
|
|
{"--help-module module [file]", "Print help for a single module and exit."},
|
|
|
|
{"--help-module-list [file]", "List available modules and exit."},
|
|
|
|
{"--help-modules [file]", "Print help for all modules and exit."},
|
2007-09-19 21:14:25 +04:00
|
|
|
{"--help-custom-modules [file]" , "Print help for all custom modules and "
|
2013-09-16 22:04:39 +04:00
|
|
|
"exit."},
|
2012-06-22 01:02:55 +04:00
|
|
|
{"--help-policy cmp [file]",
|
2013-09-16 22:04:39 +04:00
|
|
|
"Print help for a single policy and exit."},
|
|
|
|
{"--help-policy-list [file]", "List available policies and exit."},
|
|
|
|
{"--help-policies [file]", "Print help for all policies and exit."},
|
2012-06-22 01:02:55 +04:00
|
|
|
{"--help-property prop [file]",
|
2013-09-16 22:04:39 +04:00
|
|
|
"Print help for a single property and exit."},
|
|
|
|
{"--help-property-list [file]", "List available properties and exit."},
|
|
|
|
{"--help-properties [file]", "Print help for all properties and exit."},
|
2012-06-22 01:02:55 +04:00
|
|
|
{"--help-variable var [file]",
|
2013-09-16 22:04:39 +04:00
|
|
|
"Print help for a single variable and exit."},
|
|
|
|
{"--help-variable-list [file]", "List documented variables and exit."},
|
|
|
|
{"--help-variables [file]", "Print help for all variables and exit."},
|
|
|
|
{0,0}
|
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
|
|
|
|
2002-10-01 00:25:02 +04:00
|
|
|
int do_cmake(int ac, char** av);
|
2009-03-04 23:39:27 +03:00
|
|
|
static int do_build(int ac, char** av);
|
2007-07-17 17:25:08 +04:00
|
|
|
|
|
|
|
static cmMakefile* cmakemainGetMakefile(void *clientdata)
|
|
|
|
{
|
|
|
|
cmake* cm = (cmake *)clientdata;
|
|
|
|
if(cm && cm->GetDebugOutput())
|
|
|
|
{
|
|
|
|
cmGlobalGenerator* gg=cm->GetGlobalGenerator();
|
|
|
|
if (gg)
|
|
|
|
{
|
|
|
|
cmLocalGenerator* lg=gg->GetCurrentLocalGenerator();
|
|
|
|
if (lg)
|
|
|
|
{
|
|
|
|
cmMakefile* mf = lg->GetMakefile();
|
|
|
|
return mf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string cmakemainGetStack(void *clientdata)
|
|
|
|
{
|
|
|
|
std::string msg;
|
|
|
|
cmMakefile* mf=cmakemainGetMakefile(clientdata);
|
|
|
|
if (mf)
|
|
|
|
{
|
|
|
|
msg = mf->GetListFileStack();
|
|
|
|
if (!msg.empty())
|
|
|
|
{
|
2007-07-19 19:13:01 +04:00
|
|
|
msg = "\n Called from: " + msg;
|
2007-07-17 17:25:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2012-06-22 01:02:55 +04:00
|
|
|
static void cmakemainErrorCallback(const char* m, const char*, bool&,
|
2007-07-17 21:10:17 +04:00
|
|
|
void *clientdata)
|
2007-07-17 17:25:08 +04:00
|
|
|
{
|
|
|
|
std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
|
|
|
|
}
|
|
|
|
|
2012-06-22 01:02:55 +04: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;
|
2007-07-19 19:13:01 +04:00
|
|
|
if ((mf) && (strstr(m, "Configuring")==m) && (prog<0))
|
2007-07-17 17:25:08 +04:00
|
|
|
{
|
|
|
|
dir = " ";
|
|
|
|
dir += mf->GetCurrentDirectory();
|
|
|
|
}
|
|
|
|
else if ((mf) && (strstr(m, "Generating")==m))
|
|
|
|
{
|
|
|
|
dir = " ";
|
|
|
|
dir += mf->GetCurrentOutputDirectory();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((prog < 0) || (!dir.empty()))
|
|
|
|
{
|
2007-07-17 18:44:09 +04:00
|
|
|
std::cout << "-- " << m << dir << cmakemainGetStack(clientdata)<<std::endl;
|
2007-07-17 17:25:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout.flush();
|
|
|
|
}
|
|
|
|
|
2001-05-30 23:56:17 +04:00
|
|
|
|
|
|
|
int main(int ac, char** av)
|
2002-10-01 00:25:02 +04:00
|
|
|
{
|
2002-12-11 19:49:08 +03:00
|
|
|
cmSystemTools::EnableMSVCDebugHook();
|
2007-12-14 01:56:50 +03:00
|
|
|
cmSystemTools::FindExecutableDirectory(av[0]);
|
2009-03-04 23:39:27 +03:00
|
|
|
if(ac > 1 && strcmp(av[1], "--build") == 0)
|
|
|
|
{
|
|
|
|
return do_build(ac, av);
|
|
|
|
}
|
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();
|
2002-10-01 15:28:34 +04:00
|
|
|
#endif
|
2002-10-01 00:25:02 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int do_cmake(int ac, char** av)
|
2001-05-30 23:56:17 +04:00
|
|
|
{
|
2004-04-21 18:34:08 +04:00
|
|
|
if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
|
|
|
|
{
|
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;
|
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();
|
2013-02-07 17:53:50 +04:00
|
|
|
if(doc.CheckOptions(ac, av, "-E"))
|
2012-06-22 01:02:55 +04:00
|
|
|
{
|
2003-04-03 07:48:12 +04:00
|
|
|
// Construct and print requested documentation.
|
2003-02-14 18:53:37 +03:00
|
|
|
cmake hcm;
|
2007-12-14 01:56:50 +03:00
|
|
|
hcm.AddCMakePaths();
|
2006-04-14 07:15:48 +04:00
|
|
|
doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
|
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
|
|
|
|
std::vector<std::string> args;
|
|
|
|
for(int i =0; i < ac; ++i)
|
|
|
|
{
|
|
|
|
args.push_back(av[i]);
|
|
|
|
}
|
|
|
|
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");
|
2007-10-22 20:49:09 +04:00
|
|
|
doc.SetSection("Name",cmDocumentationName);
|
|
|
|
doc.SetSection("Usage",cmDocumentationUsage);
|
2007-10-22 23:33:19 +04:00
|
|
|
doc.AppendSection("Generators",generators);
|
|
|
|
doc.PrependSection("Options",cmDocumentationOptions);
|
2007-07-11 23:53:58 +04:00
|
|
|
|
2013-09-14 00:31:29 +04:00
|
|
|
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2004-10-27 19:26:49 +04:00
|
|
|
#else
|
2013-02-07 17:53:50 +04:00
|
|
|
if ( ac == 1 )
|
2004-10-27 19:26:49 +04:00
|
|
|
{
|
2012-06-22 01:02:55 +04:00
|
|
|
std::cout <<
|
2006-03-10 21:54:57 +03:00
|
|
|
"Bootstrap CMake should not be used outside CMake build process."
|
|
|
|
<< std::endl;
|
2004-10-27 19:26:49 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2012-06-22 01:02:55 +04:00
|
|
|
|
2001-12-01 00:48:52 +03:00
|
|
|
bool wiz = false;
|
2007-02-27 18:10:10 +03:00
|
|
|
bool sysinfo = false;
|
2002-06-03 21:08:52 +04:00
|
|
|
bool command = 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;
|
|
|
|
for(int i =0; i < ac; ++i)
|
|
|
|
{
|
2009-11-25 04:13:29 +03:00
|
|
|
if(!command && strcmp(av[i], "-i") == 0)
|
2001-12-01 00:48:52 +03:00
|
|
|
{
|
|
|
|
wiz = true;
|
|
|
|
}
|
2007-02-27 18:10:10 +03:00
|
|
|
else if(!command && strcmp(av[i], "--system-information") == 0)
|
|
|
|
{
|
|
|
|
sysinfo = true;
|
|
|
|
}
|
2005-02-16 21:15:25 +03:00
|
|
|
// if command has already been set, then
|
2012-06-22 01:02:55 +04:00
|
|
|
// do not eat the -E
|
2006-03-31 22:17:23 +04:00
|
|
|
else if (!command && strcmp(av[i], "-E") == 0)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
|
|
|
command = true;
|
|
|
|
}
|
2008-08-19 23:42:48 +04:00
|
|
|
else if (!command && strcmp(av[i], "-N") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
view_only = true;
|
|
|
|
}
|
2008-08-19 23:42:48 +04:00
|
|
|
else if (!command && strcmp(av[i], "-L") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_cached = true;
|
|
|
|
}
|
2008-08-19 23:42:48 +04:00
|
|
|
else if (!command && strcmp(av[i], "-LA") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_all_cached = true;
|
|
|
|
}
|
2008-08-19 23:42:48 +04:00
|
|
|
else if (!command && strcmp(av[i], "-LH") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_cached = true;
|
|
|
|
list_help = true;
|
|
|
|
}
|
2008-08-19 23:42:48 +04:00
|
|
|
else if (!command && strcmp(av[i], "-LAH") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_all_cached = true;
|
|
|
|
list_help = true;
|
|
|
|
}
|
2008-08-19 23:42:48 +04:00
|
|
|
else if (!command && strncmp(av[i], "-P", strlen("-P")) == 0)
|
2003-10-29 17:45:26 +03:00
|
|
|
{
|
2004-02-20 22:46:33 +03:00
|
|
|
if ( i == ac -1 )
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("No script specified for argument -P");
|
|
|
|
}
|
2006-05-19 07:24:00 +04: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
|
|
|
}
|
2011-07-02 19:50:05 +04:00
|
|
|
else if (!command && strncmp(av[i], "--find-package",
|
|
|
|
strlen("--find-package")) == 0)
|
|
|
|
{
|
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]);
|
|
|
|
}
|
2012-06-22 01:02:55 +04:00
|
|
|
else
|
2001-12-01 00:48:52 +03:00
|
|
|
{
|
2003-02-14 18:53:37 +03:00
|
|
|
args.push_back(av[i]);
|
2001-12-01 00:48:52 +03:00
|
|
|
}
|
2001-05-30 23:56:17 +04:00
|
|
|
}
|
2002-06-03 21:08:52 +04:00
|
|
|
if(command)
|
2001-12-01 00:48:52 +03:00
|
|
|
{
|
2013-10-04 01:28:00 +04:00
|
|
|
int ret = cmcmd::ExecuteCMakeCommand(args);
|
2001-12-01 00:48:52 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2002-06-03 21:08:52 +04:00
|
|
|
if (wiz)
|
|
|
|
{
|
|
|
|
cmakewizard wizard;
|
2012-06-22 01:02:55 +04:00
|
|
|
return wizard.RunWizard(args);
|
2002-06-03 21:08:52 +04:00
|
|
|
}
|
2007-02-27 18:10:10 +03:00
|
|
|
if (sysinfo)
|
|
|
|
{
|
|
|
|
cmake cm;
|
|
|
|
int ret = cm.GetSystemInformation(args);
|
2012-06-22 01:02:55 +04:00
|
|
|
return ret;
|
2007-02-27 18:10:10 +03:00
|
|
|
}
|
2012-06-22 01:02:55 +04:00
|
|
|
cmake cm;
|
2007-07-17 17:25:08 +04:00
|
|
|
cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (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);
|
|
|
|
if ( list_cached || list_all_cached )
|
|
|
|
{
|
2012-06-22 01:02:55 +04:00
|
|
|
cmCacheManager::CacheIterator it =
|
2006-03-10 21:54:57 +03:00
|
|
|
cm.GetCacheManager()->GetCacheIterator();
|
2003-04-29 18:07:30 +04:00
|
|
|
std::cout << "-- Cache values" << std::endl;
|
|
|
|
for ( it.Begin(); !it.IsAtEnd(); it.Next() )
|
|
|
|
{
|
|
|
|
cmCacheManager::CacheEntryType t = it.GetType();
|
|
|
|
if ( t != cmCacheManager::INTERNAL && t != cmCacheManager::STATIC &&
|
2003-10-30 03:49:50 +03:00
|
|
|
t != cmCacheManager::UNINITIALIZED )
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
bool advanced = it.PropertyExists("ADVANCED");
|
|
|
|
if ( list_all_cached || !advanced)
|
|
|
|
{
|
|
|
|
if ( list_help )
|
|
|
|
{
|
|
|
|
std::cout << "// " << it.GetProperty("HELPSTRING") << std::endl;
|
|
|
|
}
|
2012-06-22 01:02:55 +04:00
|
|
|
std::cout << it.GetName() << ":" <<
|
|
|
|
cmCacheManager::TypeToString(it.GetType())
|
2003-04-29 18:07:30 +04:00
|
|
|
<< "=" << it.GetValue() << std::endl;
|
|
|
|
if ( list_help )
|
|
|
|
{
|
|
|
|
std::cout << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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.
|
|
|
|
if(res != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2001-05-30 23:56:17 +04:00
|
|
|
}
|
2002-11-15 01:12:38 +03:00
|
|
|
|
2009-03-04 23:39:27 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static int do_build(int ac, char** av)
|
|
|
|
{
|
|
|
|
#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;
|
2011-07-26 11:36:40 +04:00
|
|
|
cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_MERGE;
|
2009-03-04 23:39:27 +03:00
|
|
|
|
|
|
|
enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
|
|
|
|
Doing doing = DoingDir;
|
|
|
|
for(int i=2; i < ac; ++i)
|
|
|
|
{
|
|
|
|
if(doing == DoingNative)
|
|
|
|
{
|
|
|
|
nativeOptions.push_back(av[i]);
|
|
|
|
}
|
|
|
|
else if(strcmp(av[i], "--target") == 0)
|
|
|
|
{
|
|
|
|
doing = DoingTarget;
|
|
|
|
}
|
|
|
|
else if(strcmp(av[i], "--config") == 0)
|
|
|
|
{
|
|
|
|
doing = DoingConfig;
|
|
|
|
}
|
|
|
|
else if(strcmp(av[i], "--clean-first") == 0)
|
|
|
|
{
|
|
|
|
clean = true;
|
|
|
|
doing = DoingNone;
|
|
|
|
}
|
2011-07-26 11:36:40 +04:00
|
|
|
else if(strcmp(av[i], "--use-stderr") == 0)
|
|
|
|
{
|
2013-07-29 10:52:54 +04:00
|
|
|
outputflag = cmSystemTools::OUTPUT_PASSTHROUGH;
|
2011-07-26 11:36:40 +04:00
|
|
|
}
|
2009-03-04 23:39:27 +03:00
|
|
|
else if(strcmp(av[i], "--") == 0)
|
|
|
|
{
|
|
|
|
doing = DoingNative;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (doing)
|
|
|
|
{
|
|
|
|
case DoingDir:
|
|
|
|
dir = av[i];
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(dir.empty())
|
|
|
|
{
|
|
|
|
std::cerr <<
|
|
|
|
"Usage: cmake --build <dir> [options] [-- [native-options]]\n"
|
|
|
|
"Options:\n"
|
|
|
|
CMAKE_BUILD_OPTIONS
|
|
|
|
;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hack for vs6 that passes ".\Debug" as "$(IntDir)" value:
|
|
|
|
//
|
|
|
|
if (cmSystemTools::StringStartsWith(config.c_str(), ".\\"))
|
|
|
|
{
|
|
|
|
config = config.substr(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmake cm;
|
2011-07-26 11:36:40 +04:00
|
|
|
return cm.Build(dir, target, config, nativeOptions, clean, outputflag);
|
2009-03-04 23:39:27 +03:00
|
|
|
#endif
|
|
|
|
}
|