cmakemain.cxx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. // include these first, otherwise there will be problems on Windows
  11. // with GetCurrentDirectory() being redefined
  12. #ifdef CMAKE_BUILD_WITH_CMAKE
  13. #include "cmDynamicLoader.h"
  14. #include "cmDocumentation.h"
  15. #endif
  16. #include "cmake.h"
  17. #include "cmCacheManager.h"
  18. #include "cmListFileCache.h"
  19. #include "cmakewizard.h"
  20. #include "cmSourceFile.h"
  21. #include "cmGlobalGenerator.h"
  22. #include "cmLocalGenerator.h"
  23. #include "cmMakefile.h"
  24. #ifdef CMAKE_BUILD_WITH_CMAKE
  25. //----------------------------------------------------------------------------
  26. static const char * cmDocumentationName[][3] =
  27. {
  28. {0,
  29. " cmake - Cross-Platform Makefile Generator.", 0},
  30. {0,0,0}
  31. };
  32. //----------------------------------------------------------------------------
  33. static const char * cmDocumentationUsage[][3] =
  34. {
  35. {0,
  36. " cmake [options] <path-to-source>\n"
  37. " cmake [options] <path-to-existing-build>", 0},
  38. {0,0,0}
  39. };
  40. //----------------------------------------------------------------------------
  41. static const char * cmDocumentationDescription[][3] =
  42. {
  43. {0,
  44. "The \"cmake\" executable is the CMake command-line interface. It may "
  45. "be used to configure projects in scripts. Project configuration "
  46. "settings "
  47. "may be specified on the command line with the -D option. The -i option "
  48. "will cause cmake to interactively prompt for such settings.", 0},
  49. CMAKE_STANDARD_INTRODUCTION,
  50. {0,0,0}
  51. };
  52. #define CMAKE_BUILD_OPTIONS \
  53. " <dir> = Project binary directory to be built.\n" \
  54. " --target <tgt> = Build <tgt> instead of default targets.\n" \
  55. " --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \
  56. " --clean-first = Build target 'clean' first, then build.\n" \
  57. " (To clean only, use --target 'clean'.)\n" \
  58. " -- = Pass remaining options to the native tool.\n"
  59. //----------------------------------------------------------------------------
  60. static const char * cmDocumentationOptions[][3] =
  61. {
  62. CMAKE_STANDARD_OPTIONS_TABLE,
  63. {"-E", "CMake command mode.",
  64. "For true platform independence, CMake provides a list of commands "
  65. "that can be used on all systems. Run with -E help for the usage "
  66. "information. Commands available are: chdir, copy, copy_if_different "
  67. "copy_directory, compare_files, echo, echo_append, environment, "
  68. "make_directory, md5sum, remove_directory, remove, tar, time, "
  69. "touch, touch_nocreate, write_regv, delete_regv, comspec, "
  70. "create_symlink."},
  71. {"-i", "Run in wizard mode.",
  72. "Wizard mode runs cmake interactively without a GUI. The user is "
  73. "prompted to answer questions about the project configuration. "
  74. "The answers are used to set cmake cache values."},
  75. {"-L[A][H]", "List non-advanced cached variables.",
  76. "List cache variables will run CMake and list all the variables from the "
  77. "CMake cache that are not marked as INTERNAL or ADVANCED. This will "
  78. "effectively display current CMake settings, which can be then changed "
  79. "with -D option. Changing some of the variable may result in more "
  80. "variables being created. If A is specified, then it will display also "
  81. "advanced variables. If H is specified, it will also display help for "
  82. "each variable."},
  83. {"--build <dir>", "Build a CMake-generated project binary tree.",
  84. "This abstracts a native build tool's command-line interface with the "
  85. "following options:\n"
  86. CMAKE_BUILD_OPTIONS
  87. "Run cmake --build with no options for quick help."},
  88. {"-N", "View mode only.",
  89. "Only load the cache. Do not actually run configure and generate steps."},
  90. {"-P <file>", "Process script mode.",
  91. "Process the given cmake file as a script written in the CMake language. "
  92. "No configure or generate step is performed and the cache is not"
  93. " modified. If variables are defined using -D, this must be done "
  94. "before the -P argument."},
  95. {"--graphviz=[file]", "Generate graphviz of dependencies.",
  96. "Generate a graphviz input file that will contain all the library and "
  97. "executable dependencies in the project."},
  98. {"--system-information [file]", "Dump information about this system.",
  99. "Dump a wide range of information about the current system. If run "
  100. "from the top of a binary tree for a CMake project it will dump "
  101. "additional information such as the cache, log files etc."},
  102. {"--debug-trycompile", "Do not delete the try compile directories..",
  103. "Do not delete the files and directories created for try_compile calls. "
  104. "This is useful in debugging failed try_compiles. It may however "
  105. "change the results of the try-compiles as old junk from a previous "
  106. "try-compile may cause a different test to either pass or fail "
  107. "incorrectly. This option is best used for one try-compile at a time, "
  108. "and only when debugging." },
  109. {"--debug-output", "Put cmake in a debug mode.",
  110. "Print extra stuff during the cmake run like stack traces with "
  111. "message(send_error ) calls."},
  112. {"--trace", "Put cmake in trace mode.",
  113. "Print a trace of all calls made and from where with "
  114. "message(send_error ) calls."},
  115. {"--strict-mode", "Put cmake in strict mode.",
  116. "In strict mode cmake will print a warning when an uninitialized variable "
  117. "is used."},
  118. {"--find-unused", "Find unused variables.",
  119. "Find variables that are declared on the command line, but not used."},
  120. {"--find-unused-all", "Find all unused variables.",
  121. "Find variables that are declared, but not used."},
  122. {"--help-command cmd [file]", "Print help for a single command and exit.",
  123. "Full documentation specific to the given command is displayed. "
  124. "If a file is specified, the documentation is written into and the output "
  125. "format is determined depending on the filename suffix. Supported are man "
  126. "page, HTML, DocBook and plain text."},
  127. {"--help-command-list [file]", "List available listfile commands and exit.",
  128. "The list contains all commands for which help may be obtained by using "
  129. "the --help-command argument followed by a command name. "
  130. "If a file is specified, the documentation is written into and the output "
  131. "format is determined depending on the filename suffix. Supported are man "
  132. "page, HTML, DocBook and plain text."},
  133. {"--help-commands [file]", "Print help for all commands and exit.",
  134. "Full documentation specific for all current command is displayed."
  135. "If a file is specified, the documentation is written into and the output "
  136. "format is determined depending on the filename suffix. Supported are man "
  137. "page, HTML, DocBook and plain text."},
  138. {"--help-compatcommands [file]", "Print help for compatibility commands. ",
  139. "Full documentation specific for all compatibility commands is displayed."
  140. "If a file is specified, the documentation is written into and the output "
  141. "format is determined depending on the filename suffix. Supported are man "
  142. "page, HTML, DocBook and plain text."},
  143. {"--help-module module [file]", "Print help for a single module and exit.",
  144. "Full documentation specific to the given module is displayed."
  145. "If a file is specified, the documentation is written into and the output "
  146. "format is determined depending on the filename suffix. Supported are man "
  147. "page, HTML, DocBook and plain text."},
  148. {"--help-module-list [file]", "List available modules and exit.",
  149. "The list contains all modules for which help may be obtained by using "
  150. "the --help-module argument followed by a module name. "
  151. "If a file is specified, the documentation is written into and the output "
  152. "format is determined depending on the filename suffix. Supported are man "
  153. "page, HTML, DocBook and plain text."},
  154. {"--help-modules [file]", "Print help for all modules and exit.",
  155. "Full documentation for all modules is displayed. "
  156. "If a file is specified, the documentation is written into and the output "
  157. "format is determined depending on the filename suffix. Supported are man "
  158. "page, HTML, DocBook and plain text."},
  159. {"--help-custom-modules [file]" , "Print help for all custom modules and "
  160. "exit.",
  161. "Full documentation for all custom modules is displayed. "
  162. "If a file is specified, the documentation is written into and the output "
  163. "format is determined depending on the filename suffix. Supported are man "
  164. "page, HTML, DocBook and plain text."},
  165. {"--help-policy cmp [file]",
  166. "Print help for a single policy and exit.",
  167. "Full documentation specific to the given policy is displayed."
  168. "If a file is specified, the documentation is written into and the output "
  169. "format is determined depending on the filename suffix. Supported are man "
  170. "page, HTML, DocBook and plain text."},
  171. {"--help-policies [file]", "Print help for all policies and exit.",
  172. "Full documentation for all policies is displayed."
  173. "If a file is specified, the documentation is written into and the output "
  174. "format is determined depending on the filename suffix. Supported are man "
  175. "page, HTML, DocBook and plain text."},
  176. {"--help-property prop [file]",
  177. "Print help for a single property and exit.",
  178. "Full documentation specific to the given property is displayed."
  179. "If a file is specified, the documentation is written into and the output "
  180. "format is determined depending on the filename suffix. Supported are man "
  181. "page, HTML, DocBook and plain text."},
  182. {"--help-property-list [file]", "List available properties and exit.",
  183. "The list contains all properties for which help may be obtained by using "
  184. "the --help-property argument followed by a property name. If a file is "
  185. "specified, the help is written into it."
  186. "If a file is specified, the documentation is written into and the output "
  187. "format is determined depending on the filename suffix. Supported are man "
  188. "page, HTML, DocBook and plain text."},
  189. {"--help-properties [file]", "Print help for all properties and exit.",
  190. "Full documentation for all properties is displayed."
  191. "If a file is specified, the documentation is written into and the output "
  192. "format is determined depending on the filename suffix. Supported are man "
  193. "page, HTML, DocBook and plain text."},
  194. {"--help-variable var [file]",
  195. "Print help for a single variable and exit.",
  196. "Full documentation specific to the given variable is displayed."
  197. "If a file is specified, the documentation is written into and the output "
  198. "format is determined depending on the filename suffix. Supported are man "
  199. "page, HTML, DocBook and plain text."},
  200. {"--help-variable-list [file]", "List documented variables and exit.",
  201. "The list contains all variables for which help may be obtained by using "
  202. "the --help-variable argument followed by a variable name. If a file is "
  203. "specified, the help is written into it."
  204. "If a file is specified, the documentation is written into and the output "
  205. "format is determined depending on the filename suffix. Supported are man "
  206. "page, HTML, DocBook and plain text."},
  207. {"--help-variables [file]", "Print help for all variables and exit.",
  208. "Full documentation for all variables is displayed."
  209. "If a file is specified, the documentation is written into and the output "
  210. "format is determined depending on the filename suffix. Supported are man "
  211. "page, HTML, DocBook and plain text."},
  212. {0,0,0}
  213. };
  214. //----------------------------------------------------------------------------
  215. static const char * cmDocumentationSeeAlso[][3] =
  216. {
  217. {0, "ccmake", 0},
  218. {0, "cpack", 0},
  219. {0, "ctest", 0},
  220. {0, "cmakecommands", 0},
  221. {0, "cmakecompat", 0},
  222. {0, "cmakemodules", 0},
  223. {0, "cmakeprops", 0},
  224. {0, "cmakevars", 0},
  225. {0, 0, 0}
  226. };
  227. //----------------------------------------------------------------------------
  228. static const char * cmDocumentationNOTE[][3] =
  229. {
  230. {0,
  231. "CMake no longer configures a project when run with no arguments. "
  232. "In order to configure the project in the current directory, run\n"
  233. " cmake .", 0},
  234. {0,0,0}
  235. };
  236. #endif
  237. int do_cmake(int ac, char** av);
  238. static int do_build(int ac, char** av);
  239. static cmMakefile* cmakemainGetMakefile(void *clientdata)
  240. {
  241. cmake* cm = (cmake *)clientdata;
  242. if(cm && cm->GetDebugOutput())
  243. {
  244. cmGlobalGenerator* gg=cm->GetGlobalGenerator();
  245. if (gg)
  246. {
  247. cmLocalGenerator* lg=gg->GetCurrentLocalGenerator();
  248. if (lg)
  249. {
  250. cmMakefile* mf = lg->GetMakefile();
  251. return mf;
  252. }
  253. }
  254. }
  255. return 0;
  256. }
  257. static std::string cmakemainGetStack(void *clientdata)
  258. {
  259. std::string msg;
  260. cmMakefile* mf=cmakemainGetMakefile(clientdata);
  261. if (mf)
  262. {
  263. msg = mf->GetListFileStack();
  264. if (!msg.empty())
  265. {
  266. msg = "\n Called from: " + msg;
  267. }
  268. }
  269. return msg;
  270. }
  271. static void cmakemainErrorCallback(const char* m, const char*, bool&,
  272. void *clientdata)
  273. {
  274. std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
  275. }
  276. static void cmakemainProgressCallback(const char *m, float prog,
  277. void* clientdata)
  278. {
  279. cmMakefile* mf = cmakemainGetMakefile(clientdata);
  280. std::string dir;
  281. if ((mf) && (strstr(m, "Configuring")==m) && (prog<0))
  282. {
  283. dir = " ";
  284. dir += mf->GetCurrentDirectory();
  285. }
  286. else if ((mf) && (strstr(m, "Generating")==m))
  287. {
  288. dir = " ";
  289. dir += mf->GetCurrentOutputDirectory();
  290. }
  291. if ((prog < 0) || (!dir.empty()))
  292. {
  293. std::cout << "-- " << m << dir << cmakemainGetStack(clientdata)<<std::endl;
  294. }
  295. std::cout.flush();
  296. }
  297. int main(int ac, char** av)
  298. {
  299. cmSystemTools::EnableMSVCDebugHook();
  300. cmSystemTools::FindExecutableDirectory(av[0]);
  301. if(ac > 1 && strcmp(av[1], "--build") == 0)
  302. {
  303. return do_build(ac, av);
  304. }
  305. int ret = do_cmake(ac, av);
  306. #ifdef CMAKE_BUILD_WITH_CMAKE
  307. cmDynamicLoader::FlushCache();
  308. #endif
  309. return ret;
  310. }
  311. int do_cmake(int ac, char** av)
  312. {
  313. int nocwd = 0;
  314. if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
  315. {
  316. std::cerr << "Current working directory cannot be established."
  317. << std::endl;
  318. nocwd = 1;
  319. }
  320. #ifdef CMAKE_BUILD_WITH_CMAKE
  321. cmDocumentation doc;
  322. if(doc.CheckOptions(ac, av, "-E") || nocwd)
  323. {
  324. // Construct and print requested documentation.
  325. cmake hcm;
  326. hcm.AddCMakePaths();
  327. doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
  328. // the command line args are processed here so that you can do
  329. // -DCMAKE_MODULE_PATH=/some/path and have this value accessible here
  330. std::vector<std::string> args;
  331. for(int i =0; i < ac; ++i)
  332. {
  333. args.push_back(av[i]);
  334. }
  335. hcm.SetCacheArgs(args);
  336. const char* modulePath = hcm.GetCacheDefinition("CMAKE_MODULE_PATH");
  337. if (modulePath)
  338. {
  339. doc.SetCMakeModulePath(modulePath);
  340. }
  341. std::vector<cmDocumentationEntry> commands;
  342. std::vector<cmDocumentationEntry> policies;
  343. std::vector<cmDocumentationEntry> compatCommands;
  344. std::vector<cmDocumentationEntry> generators;
  345. std::map<std::string,cmDocumentationSection *> propDocs;
  346. hcm.GetPolicyDocumentation(policies);
  347. hcm.GetCommandDocumentation(commands, true, false);
  348. hcm.GetCommandDocumentation(compatCommands, false, true);
  349. hcm.GetPropertiesDocumentation(propDocs);
  350. hcm.GetGeneratorDocumentation(generators);
  351. doc.SetName("cmake");
  352. doc.SetSection("Name",cmDocumentationName);
  353. doc.SetSection("Usage",cmDocumentationUsage);
  354. doc.SetSection("Description",cmDocumentationDescription);
  355. doc.AppendSection("Generators",generators);
  356. doc.PrependSection("Options",cmDocumentationOptions);
  357. doc.SetSection("Commands",commands);
  358. doc.SetSection("Policies",policies);
  359. doc.AppendSection("Compatibility Commands",compatCommands);
  360. doc.SetSections(propDocs);
  361. cmDocumentationEntry e;
  362. e.Brief =
  363. "variables defined by cmake, that give information about the project, "
  364. "and cmake";
  365. doc.PrependSection("Variables that Provide Information",e);
  366. doc.SetSeeAlsoList(cmDocumentationSeeAlso);
  367. int result = doc.PrintRequestedDocumentation(std::cout)? 0:1;
  368. // If we were run with no arguments, but a CMakeLists.txt file
  369. // exists, the user may have been trying to use the old behavior
  370. // of cmake to build a project in-source. Print a message
  371. // explaining the change to standard error and return an error
  372. // condition in case the program is running from a script.
  373. if((ac == 1) && cmSystemTools::FileExists("CMakeLists.txt"))
  374. {
  375. doc.ClearSections();
  376. doc.SetSection("NOTE", cmDocumentationNOTE);
  377. doc.Print(cmDocumentation::UsageForm, std::cerr);
  378. return 1;
  379. }
  380. return result;
  381. }
  382. #else
  383. if ( nocwd || ac == 1 )
  384. {
  385. std::cout <<
  386. "Bootstrap CMake should not be used outside CMake build process."
  387. << std::endl;
  388. return 0;
  389. }
  390. #endif
  391. bool wiz = false;
  392. bool sysinfo = false;
  393. bool command = false;
  394. bool list_cached = false;
  395. bool list_all_cached = false;
  396. bool list_help = false;
  397. bool view_only = false;
  398. bool script_mode = false;
  399. std::vector<std::string> args;
  400. for(int i =0; i < ac; ++i)
  401. {
  402. if(!command && strcmp(av[i], "-i") == 0)
  403. {
  404. wiz = true;
  405. }
  406. else if(!command && strcmp(av[i], "--system-information") == 0)
  407. {
  408. sysinfo = true;
  409. }
  410. // if command has already been set, then
  411. // do not eat the -E
  412. else if (!command && strcmp(av[i], "-E") == 0)
  413. {
  414. command = true;
  415. }
  416. else if (!command && strcmp(av[i], "-N") == 0)
  417. {
  418. view_only = true;
  419. }
  420. else if (!command && strcmp(av[i], "-L") == 0)
  421. {
  422. list_cached = true;
  423. }
  424. else if (!command && strcmp(av[i], "-LA") == 0)
  425. {
  426. list_all_cached = true;
  427. }
  428. else if (!command && strcmp(av[i], "-LH") == 0)
  429. {
  430. list_cached = true;
  431. list_help = true;
  432. }
  433. else if (!command && strcmp(av[i], "-LAH") == 0)
  434. {
  435. list_all_cached = true;
  436. list_help = true;
  437. }
  438. else if (!command && strncmp(av[i], "-P", strlen("-P")) == 0)
  439. {
  440. if ( i == ac -1 )
  441. {
  442. cmSystemTools::Error("No script specified for argument -P");
  443. }
  444. else
  445. {
  446. script_mode = true;
  447. args.push_back(av[i]);
  448. i++;
  449. args.push_back(av[i]);
  450. }
  451. }
  452. else
  453. {
  454. args.push_back(av[i]);
  455. }
  456. }
  457. if(command)
  458. {
  459. int ret = cmake::ExecuteCMakeCommand(args);
  460. return ret;
  461. }
  462. if (wiz)
  463. {
  464. cmakewizard wizard;
  465. return wizard.RunWizard(args);
  466. }
  467. if (sysinfo)
  468. {
  469. cmake cm;
  470. int ret = cm.GetSystemInformation(args);
  471. return ret;
  472. }
  473. cmake cm;
  474. cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm);
  475. cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
  476. cm.SetScriptMode(script_mode);
  477. int res = cm.Run(args, view_only);
  478. if ( list_cached || list_all_cached )
  479. {
  480. cmCacheManager::CacheIterator it =
  481. cm.GetCacheManager()->GetCacheIterator();
  482. std::cout << "-- Cache values" << std::endl;
  483. for ( it.Begin(); !it.IsAtEnd(); it.Next() )
  484. {
  485. cmCacheManager::CacheEntryType t = it.GetType();
  486. if ( t != cmCacheManager::INTERNAL && t != cmCacheManager::STATIC &&
  487. t != cmCacheManager::UNINITIALIZED )
  488. {
  489. bool advanced = it.PropertyExists("ADVANCED");
  490. if ( list_all_cached || !advanced)
  491. {
  492. if ( list_help )
  493. {
  494. std::cout << "// " << it.GetProperty("HELPSTRING") << std::endl;
  495. }
  496. std::cout << it.GetName() << ":" <<
  497. cmCacheManager::TypeToString(it.GetType())
  498. << "=" << it.GetValue() << std::endl;
  499. if ( list_help )
  500. {
  501. std::cout << std::endl;
  502. }
  503. }
  504. }
  505. }
  506. }
  507. // Always return a non-negative value. Windows tools do not always
  508. // interpret negative return values as errors.
  509. if(res != 0)
  510. {
  511. return 1;
  512. }
  513. else
  514. {
  515. return 0;
  516. }
  517. }
  518. //----------------------------------------------------------------------------
  519. static int do_build(int ac, char** av)
  520. {
  521. #ifndef CMAKE_BUILD_WITH_CMAKE
  522. std::cerr << "This cmake does not support --build\n";
  523. return -1;
  524. #else
  525. std::string target;
  526. std::string config = "Debug";
  527. std::string dir;
  528. std::vector<std::string> nativeOptions;
  529. bool clean = false;
  530. enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
  531. Doing doing = DoingDir;
  532. for(int i=2; i < ac; ++i)
  533. {
  534. if(doing == DoingNative)
  535. {
  536. nativeOptions.push_back(av[i]);
  537. }
  538. else if(strcmp(av[i], "--target") == 0)
  539. {
  540. doing = DoingTarget;
  541. }
  542. else if(strcmp(av[i], "--config") == 0)
  543. {
  544. doing = DoingConfig;
  545. }
  546. else if(strcmp(av[i], "--clean-first") == 0)
  547. {
  548. clean = true;
  549. doing = DoingNone;
  550. }
  551. else if(strcmp(av[i], "--") == 0)
  552. {
  553. doing = DoingNative;
  554. }
  555. else
  556. {
  557. switch (doing)
  558. {
  559. case DoingDir:
  560. dir = av[i];
  561. doing = DoingNone;
  562. break;
  563. case DoingTarget:
  564. target = av[i];
  565. doing = DoingNone;
  566. break;
  567. case DoingConfig:
  568. config = av[i];
  569. doing = DoingNone;
  570. break;
  571. default:
  572. std::cerr << "Unknown argument " << av[i] << std::endl;
  573. dir = "";
  574. break;
  575. }
  576. }
  577. }
  578. if(dir.empty())
  579. {
  580. std::cerr <<
  581. "Usage: cmake --build <dir> [options] [-- [native-options]]\n"
  582. "Options:\n"
  583. CMAKE_BUILD_OPTIONS
  584. ;
  585. return 1;
  586. }
  587. // Hack for vs6 that passes ".\Debug" as "$(IntDir)" value:
  588. //
  589. if (cmSystemTools::StringStartsWith(config.c_str(), ".\\"))
  590. {
  591. config = config.substr(2);
  592. }
  593. cmake cm;
  594. return cm.Build(dir, target, config, nativeOptions, clean);
  595. #endif
  596. }