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-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-10-18 21:38:36 +04:00
|
|
|
" --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"
|
|
|
|
|
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."},
|
|
|
|
{"-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."},
|
|
|
|
{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
|
|
|
|
2013-10-04 22:22:05 +04:00
|
|
|
static int do_command(int ac, char** av)
|
|
|
|
{
|
|
|
|
std::vector<std::string> args;
|
|
|
|
args.push_back(av[0]);
|
|
|
|
for(int i = 2; i < ac; ++i)
|
|
|
|
{
|
|
|
|
args.push_back(av[i]);
|
|
|
|
}
|
|
|
|
return cmcmd::ExecuteCMakeCommand(args);
|
|
|
|
}
|
|
|
|
|
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();
|
2013-11-08 00:30:59 +04:00
|
|
|
cmSystemTools::FindCMakeResources(av[0]);
|
2013-10-04 22:22:05 +04:00
|
|
|
if(ac > 1)
|
2009-03-04 23:39:27 +03:00
|
|
|
{
|
2013-10-04 22:22:05 +04:00
|
|
|
if(strcmp(av[1], "--build") == 0)
|
|
|
|
{
|
|
|
|
return do_build(ac, av);
|
|
|
|
}
|
|
|
|
else if(strcmp(av[1], "-E") == 0)
|
|
|
|
{
|
|
|
|
return do_command(ac, av);
|
|
|
|
}
|
2009-03-04 23:39:27 +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();
|
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-10-04 22:22:05 +04:00
|
|
|
if(doc.CheckOptions(ac, av))
|
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();
|
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
|
|
|
|
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;
|
|
|
|
for(int i =0; i < ac; ++i)
|
|
|
|
{
|
2013-10-04 22:22:05 +04:00
|
|
|
if(strcmp(av[i], "-i") == 0)
|
2001-12-01 00:48:52 +03:00
|
|
|
{
|
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";
|
|
|
|
return 1;
|
2001-12-01 00:48:52 +03:00
|
|
|
}
|
2013-10-04 22:22:05 +04:00
|
|
|
else if(strcmp(av[i], "--system-information") == 0)
|
2007-02-27 18:10:10 +03:00
|
|
|
{
|
|
|
|
sysinfo = true;
|
|
|
|
}
|
2013-10-04 22:22:05 +04:00
|
|
|
else if (strcmp(av[i], "-N") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
view_only = true;
|
|
|
|
}
|
2013-10-04 22:22:05 +04:00
|
|
|
else if (strcmp(av[i], "-L") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_cached = true;
|
|
|
|
}
|
2013-10-04 22:22:05 +04:00
|
|
|
else if (strcmp(av[i], "-LA") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_all_cached = true;
|
|
|
|
}
|
2013-10-04 22:22:05 +04:00
|
|
|
else if (strcmp(av[i], "-LH") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_cached = true;
|
|
|
|
list_help = true;
|
|
|
|
}
|
2013-10-04 22:22:05 +04:00
|
|
|
else if (strcmp(av[i], "-LAH") == 0)
|
2003-04-29 18:07:30 +04:00
|
|
|
{
|
|
|
|
list_all_cached = true;
|
|
|
|
list_help = true;
|
|
|
|
}
|
2013-11-20 05:12:00 +04:00
|
|
|
else if (cmHasLiteralPrefix(av[i], "-P"))
|
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
|
|
|
}
|
2013-11-20 05:12:00 +04:00
|
|
|
else if (cmHasLiteralPrefix(av[i], "--find-package"))
|
2011-07-02 19:50:05 +04:00
|
|
|
{
|
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
|
|
|
}
|
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;
|
|
|
|
|
|
|
|
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-10-18 21:38:36 +04:00
|
|
|
/* tolerate legacy option */
|
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;
|
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
|
|
|
|
}
|