cmakemain.cxx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. {"--warn-uninitialized", "Warn about uninitialized values.",
  116. "Print a warning when an uninitialized variable is used."},
  117. {"--warn-unused-all", "Warn about unused variables.",
  118. "Find variables that are declared or set, but not used."},
  119. {"--warn-unused-cli", "Warn about command line options.",
  120. "Find variables that are declared on the command line, but not used."},
  121. {"--help-command cmd [file]", "Print help for a single command and exit.",
  122. "Full documentation specific to the given command is displayed. "
  123. "If a file is specified, the documentation is written into and the output "
  124. "format is determined depending on the filename suffix. Supported are man "
  125. "page, HTML, DocBook and plain text."},
  126. {"--help-command-list [file]", "List available listfile commands and exit.",
  127. "The list contains all commands for which help may be obtained by using "
  128. "the --help-command argument followed by a command name. "
  129. "If a file is specified, the documentation is written into and the output "
  130. "format is determined depending on the filename suffix. Supported are man "
  131. "page, HTML, DocBook and plain text."},
  132. {"--help-commands [file]", "Print help for all commands and exit.",
  133. "Full documentation specific for all current command is displayed."
  134. "If a file is specified, the documentation is written into and the output "
  135. "format is determined depending on the filename suffix. Supported are man "
  136. "page, HTML, DocBook and plain text."},
  137. {"--help-compatcommands [file]", "Print help for compatibility commands. ",
  138. "Full documentation specific for all compatibility commands is displayed."
  139. "If a file is specified, the documentation is written into and the output "
  140. "format is determined depending on the filename suffix. Supported are man "
  141. "page, HTML, DocBook and plain text."},
  142. {"--help-module module [file]", "Print help for a single module and exit.",
  143. "Full documentation specific to the given module is displayed."
  144. "If a file is specified, the documentation is written into and the output "
  145. "format is determined depending on the filename suffix. Supported are man "
  146. "page, HTML, DocBook and plain text."},
  147. {"--help-module-list [file]", "List available modules and exit.",
  148. "The list contains all modules for which help may be obtained by using "
  149. "the --help-module argument followed by a module name. "
  150. "If a file is specified, the documentation is written into and the output "
  151. "format is determined depending on the filename suffix. Supported are man "
  152. "page, HTML, DocBook and plain text."},
  153. {"--help-modules [file]", "Print help for all modules and exit.",
  154. "Full documentation for all modules is displayed. "
  155. "If a file is specified, the documentation is written into and the output "
  156. "format is determined depending on the filename suffix. Supported are man "
  157. "page, HTML, DocBook and plain text."},
  158. {"--help-custom-modules [file]" , "Print help for all custom modules and "
  159. "exit.",
  160. "Full documentation for all custom modules is displayed. "
  161. "If a file is specified, the documentation is written into and the output "
  162. "format is determined depending on the filename suffix. Supported are man "
  163. "page, HTML, DocBook and plain text."},
  164. {"--help-policy cmp [file]",
  165. "Print help for a single policy and exit.",
  166. "Full documentation specific to the given policy is displayed."
  167. "If a file is specified, the documentation is written into and the output "
  168. "format is determined depending on the filename suffix. Supported are man "
  169. "page, HTML, DocBook and plain text."},
  170. {"--help-policies [file]", "Print help for all policies and exit.",
  171. "Full documentation for all policies is displayed."
  172. "If a file is specified, the documentation is written into and the output "
  173. "format is determined depending on the filename suffix. Supported are man "
  174. "page, HTML, DocBook and plain text."},
  175. {"--help-property prop [file]",
  176. "Print help for a single property and exit.",
  177. "Full documentation specific to the given property is displayed."
  178. "If a file is specified, the documentation is written into and the output "
  179. "format is determined depending on the filename suffix. Supported are man "
  180. "page, HTML, DocBook and plain text."},
  181. {"--help-property-list [file]", "List available properties and exit.",
  182. "The list contains all properties for which help may be obtained by using "
  183. "the --help-property argument followed by a property name. If a file is "
  184. "specified, the help is written into it."
  185. "If a file is specified, the documentation is written into and the output "
  186. "format is determined depending on the filename suffix. Supported are man "
  187. "page, HTML, DocBook and plain text."},
  188. {"--help-properties [file]", "Print help for all properties and exit.",
  189. "Full documentation for all properties is displayed."
  190. "If a file is specified, the documentation is written into and the output "
  191. "format is determined depending on the filename suffix. Supported are man "
  192. "page, HTML, DocBook and plain text."},
  193. {"--help-variable var [file]",
  194. "Print help for a single variable and exit.",
  195. "Full documentation specific to the given variable is displayed."
  196. "If a file is specified, the documentation is written into and the output "
  197. "format is determined depending on the filename suffix. Supported are man "
  198. "page, HTML, DocBook and plain text."},
  199. {"--help-variable-list [file]", "List documented variables and exit.",
  200. "The list contains all variables for which help may be obtained by using "
  201. "the --help-variable argument followed by a variable name. If a file is "
  202. "specified, the help is written into it."
  203. "If a file is specified, the documentation is written into and the output "
  204. "format is determined depending on the filename suffix. Supported are man "
  205. "page, HTML, DocBook and plain text."},
  206. {"--help-variables [file]", "Print help for all variables and exit.",
  207. "Full documentation for all variables is displayed."
  208. "If a file is specified, the documentation is written into and the output "
  209. "format is determined depending on the filename suffix. Supported are man "
  210. "page, HTML, DocBook and plain text."},
  211. {0,0,0}
  212. };
  213. //----------------------------------------------------------------------------
  214. static const char * cmDocumentationSeeAlso[][3] =
  215. {
  216. {0, "ccmake", 0},
  217. {0, "cpack", 0},
  218. {0, "ctest", 0},
  219. {0, "cmakecommands", 0},
  220. {0, "cmakecompat", 0},
  221. {0, "cmakemodules", 0},
  222. {0, "cmakeprops", 0},
  223. {0, "cmakevars", 0},
  224. {0, 0, 0}
  225. };
  226. //----------------------------------------------------------------------------
  227. static const char * cmDocumentationNOTE[][3] =
  228. {
  229. {0,
  230. "CMake no longer configures a project when run with no arguments. "
  231. "In order to configure the project in the current directory, run\n"
  232. " cmake .", 0},
  233. {0,0,0}
  234. };
  235. #endif
  236. int do_cmake(int ac, char** av);
  237. static int do_build(int ac, char** av);
  238. static cmMakefile* cmakemainGetMakefile(void *clientdata)
  239. {
  240. cmake* cm = (cmake *)clientdata;
  241. if(cm && cm->GetDebugOutput())
  242. {
  243. cmGlobalGenerator* gg=cm->GetGlobalGenerator();
  244. if (gg)
  245. {
  246. cmLocalGenerator* lg=gg->GetCurrentLocalGenerator();
  247. if (lg)
  248. {
  249. cmMakefile* mf = lg->GetMakefile();
  250. return mf;
  251. }
  252. }
  253. }
  254. return 0;
  255. }
  256. static std::string cmakemainGetStack(void *clientdata)
  257. {
  258. std::string msg;
  259. cmMakefile* mf=cmakemainGetMakefile(clientdata);
  260. if (mf)
  261. {
  262. msg = mf->GetListFileStack();
  263. if (!msg.empty())
  264. {
  265. msg = "\n Called from: " + msg;
  266. }
  267. }
  268. return msg;
  269. }
  270. static void cmakemainErrorCallback(const char* m, const char*, bool&,
  271. void *clientdata)
  272. {
  273. std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
  274. }
  275. static void cmakemainProgressCallback(const char *m, float prog,
  276. void* clientdata)
  277. {
  278. cmMakefile* mf = cmakemainGetMakefile(clientdata);
  279. std::string dir;
  280. if ((mf) && (strstr(m, "Configuring")==m) && (prog<0))
  281. {
  282. dir = " ";
  283. dir += mf->GetCurrentDirectory();
  284. }
  285. else if ((mf) && (strstr(m, "Generating")==m))
  286. {
  287. dir = " ";
  288. dir += mf->GetCurrentOutputDirectory();
  289. }
  290. if ((prog < 0) || (!dir.empty()))
  291. {
  292. std::cout << "-- " << m << dir << cmakemainGetStack(clientdata)<<std::endl;
  293. }
  294. std::cout.flush();
  295. }
  296. int main(int ac, char** av)
  297. {
  298. cmSystemTools::EnableMSVCDebugHook();
  299. cmSystemTools::FindExecutableDirectory(av[0]);
  300. if(ac > 1 && strcmp(av[1], "--build") == 0)
  301. {
  302. return do_build(ac, av);
  303. }
  304. int ret = do_cmake(ac, av);
  305. #ifdef CMAKE_BUILD_WITH_CMAKE
  306. cmDynamicLoader::FlushCache();
  307. #endif
  308. return ret;
  309. }
  310. int do_cmake(int ac, char** av)
  311. {
  312. int nocwd = 0;
  313. if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
  314. {
  315. std::cerr << "Current working directory cannot be established."
  316. << std::endl;
  317. nocwd = 1;
  318. }
  319. #ifdef CMAKE_BUILD_WITH_CMAKE
  320. cmDocumentation doc;
  321. if(doc.CheckOptions(ac, av, "-E") || nocwd)
  322. {
  323. // Construct and print requested documentation.
  324. cmake hcm;
  325. hcm.AddCMakePaths();
  326. doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
  327. // the command line args are processed here so that you can do
  328. // -DCMAKE_MODULE_PATH=/some/path and have this value accessible here
  329. std::vector<std::string> args;
  330. for(int i =0; i < ac; ++i)
  331. {
  332. args.push_back(av[i]);
  333. }
  334. hcm.SetCacheArgs(args);
  335. const char* modulePath = hcm.GetCacheDefinition("CMAKE_MODULE_PATH");
  336. if (modulePath)
  337. {
  338. doc.SetCMakeModulePath(modulePath);
  339. }
  340. std::vector<cmDocumentationEntry> commands;
  341. std::vector<cmDocumentationEntry> policies;
  342. std::vector<cmDocumentationEntry> compatCommands;
  343. std::vector<cmDocumentationEntry> generators;
  344. std::map<std::string,cmDocumentationSection *> propDocs;
  345. hcm.GetPolicyDocumentation(policies);
  346. hcm.GetCommandDocumentation(commands, true, false);
  347. hcm.GetCommandDocumentation(compatCommands, false, true);
  348. hcm.GetPropertiesDocumentation(propDocs);
  349. hcm.GetGeneratorDocumentation(generators);
  350. doc.SetName("cmake");
  351. doc.SetSection("Name",cmDocumentationName);
  352. doc.SetSection("Usage",cmDocumentationUsage);
  353. doc.SetSection("Description",cmDocumentationDescription);
  354. doc.AppendSection("Generators",generators);
  355. doc.PrependSection("Options",cmDocumentationOptions);
  356. doc.SetSection("Commands",commands);
  357. doc.SetSection("Policies",policies);
  358. doc.AppendSection("Compatibility Commands",compatCommands);
  359. doc.SetSections(propDocs);
  360. cmDocumentationEntry e;
  361. e.Brief =
  362. "variables defined by cmake, that give information about the project, "
  363. "and cmake";
  364. doc.PrependSection("Variables that Provide Information",e);
  365. doc.SetSeeAlsoList(cmDocumentationSeeAlso);
  366. int result = doc.PrintRequestedDocumentation(std::cout)? 0:1;
  367. // If we were run with no arguments, but a CMakeLists.txt file
  368. // exists, the user may have been trying to use the old behavior
  369. // of cmake to build a project in-source. Print a message
  370. // explaining the change to standard error and return an error
  371. // condition in case the program is running from a script.
  372. if((ac == 1) && cmSystemTools::FileExists("CMakeLists.txt"))
  373. {
  374. doc.ClearSections();
  375. doc.SetSection("NOTE", cmDocumentationNOTE);
  376. doc.Print(cmDocumentation::UsageForm, std::cerr);
  377. return 1;
  378. }
  379. return result;
  380. }
  381. #else
  382. if ( nocwd || ac == 1 )
  383. {
  384. std::cout <<
  385. "Bootstrap CMake should not be used outside CMake build process."
  386. << std::endl;
  387. return 0;
  388. }
  389. #endif
  390. bool wiz = false;
  391. bool sysinfo = false;
  392. bool command = false;
  393. bool list_cached = false;
  394. bool list_all_cached = false;
  395. bool list_help = false;
  396. bool view_only = false;
  397. bool script_mode = false;
  398. std::vector<std::string> args;
  399. for(int i =0; i < ac; ++i)
  400. {
  401. if(!command && strcmp(av[i], "-i") == 0)
  402. {
  403. wiz = true;
  404. }
  405. else if(!command && strcmp(av[i], "--system-information") == 0)
  406. {
  407. sysinfo = true;
  408. }
  409. // if command has already been set, then
  410. // do not eat the -E
  411. else if (!command && strcmp(av[i], "-E") == 0)
  412. {
  413. command = true;
  414. }
  415. else if (!command && strcmp(av[i], "-N") == 0)
  416. {
  417. view_only = true;
  418. }
  419. else if (!command && strcmp(av[i], "-L") == 0)
  420. {
  421. list_cached = true;
  422. }
  423. else if (!command && strcmp(av[i], "-LA") == 0)
  424. {
  425. list_all_cached = true;
  426. }
  427. else if (!command && strcmp(av[i], "-LH") == 0)
  428. {
  429. list_cached = true;
  430. list_help = true;
  431. }
  432. else if (!command && strcmp(av[i], "-LAH") == 0)
  433. {
  434. list_all_cached = true;
  435. list_help = true;
  436. }
  437. else if (!command && strncmp(av[i], "-P", strlen("-P")) == 0)
  438. {
  439. if ( i == ac -1 )
  440. {
  441. cmSystemTools::Error("No script specified for argument -P");
  442. }
  443. else
  444. {
  445. script_mode = true;
  446. args.push_back(av[i]);
  447. i++;
  448. args.push_back(av[i]);
  449. }
  450. }
  451. else
  452. {
  453. args.push_back(av[i]);
  454. }
  455. }
  456. if(command)
  457. {
  458. int ret = cmake::ExecuteCMakeCommand(args);
  459. return ret;
  460. }
  461. if (wiz)
  462. {
  463. cmakewizard wizard;
  464. return wizard.RunWizard(args);
  465. }
  466. if (sysinfo)
  467. {
  468. cmake cm;
  469. int ret = cm.GetSystemInformation(args);
  470. return ret;
  471. }
  472. cmake cm;
  473. cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm);
  474. cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
  475. cm.SetScriptMode(script_mode);
  476. int res = cm.Run(args, view_only);
  477. if ( list_cached || list_all_cached )
  478. {
  479. cmCacheManager::CacheIterator it =
  480. cm.GetCacheManager()->GetCacheIterator();
  481. std::cout << "-- Cache values" << std::endl;
  482. for ( it.Begin(); !it.IsAtEnd(); it.Next() )
  483. {
  484. cmCacheManager::CacheEntryType t = it.GetType();
  485. if ( t != cmCacheManager::INTERNAL && t != cmCacheManager::STATIC &&
  486. t != cmCacheManager::UNINITIALIZED )
  487. {
  488. bool advanced = it.PropertyExists("ADVANCED");
  489. if ( list_all_cached || !advanced)
  490. {
  491. if ( list_help )
  492. {
  493. std::cout << "// " << it.GetProperty("HELPSTRING") << std::endl;
  494. }
  495. std::cout << it.GetName() << ":" <<
  496. cmCacheManager::TypeToString(it.GetType())
  497. << "=" << it.GetValue() << std::endl;
  498. if ( list_help )
  499. {
  500. std::cout << std::endl;
  501. }
  502. }
  503. }
  504. }
  505. }
  506. // Always return a non-negative value. Windows tools do not always
  507. // interpret negative return values as errors.
  508. if(res != 0)
  509. {
  510. return 1;
  511. }
  512. else
  513. {
  514. return 0;
  515. }
  516. }
  517. //----------------------------------------------------------------------------
  518. static int do_build(int ac, char** av)
  519. {
  520. #ifndef CMAKE_BUILD_WITH_CMAKE
  521. std::cerr << "This cmake does not support --build\n";
  522. return -1;
  523. #else
  524. std::string target;
  525. std::string config = "Debug";
  526. std::string dir;
  527. std::vector<std::string> nativeOptions;
  528. bool clean = false;
  529. enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
  530. Doing doing = DoingDir;
  531. for(int i=2; i < ac; ++i)
  532. {
  533. if(doing == DoingNative)
  534. {
  535. nativeOptions.push_back(av[i]);
  536. }
  537. else if(strcmp(av[i], "--target") == 0)
  538. {
  539. doing = DoingTarget;
  540. }
  541. else if(strcmp(av[i], "--config") == 0)
  542. {
  543. doing = DoingConfig;
  544. }
  545. else if(strcmp(av[i], "--clean-first") == 0)
  546. {
  547. clean = true;
  548. doing = DoingNone;
  549. }
  550. else if(strcmp(av[i], "--") == 0)
  551. {
  552. doing = DoingNative;
  553. }
  554. else
  555. {
  556. switch (doing)
  557. {
  558. case DoingDir:
  559. dir = av[i];
  560. doing = DoingNone;
  561. break;
  562. case DoingTarget:
  563. target = av[i];
  564. doing = DoingNone;
  565. break;
  566. case DoingConfig:
  567. config = av[i];
  568. doing = DoingNone;
  569. break;
  570. default:
  571. std::cerr << "Unknown argument " << av[i] << std::endl;
  572. dir = "";
  573. break;
  574. }
  575. }
  576. }
  577. if(dir.empty())
  578. {
  579. std::cerr <<
  580. "Usage: cmake --build <dir> [options] [-- [native-options]]\n"
  581. "Options:\n"
  582. CMAKE_BUILD_OPTIONS
  583. ;
  584. return 1;
  585. }
  586. // Hack for vs6 that passes ".\Debug" as "$(IntDir)" value:
  587. //
  588. if (cmSystemTools::StringStartsWith(config.c_str(), ".\\"))
  589. {
  590. config = config.substr(2);
  591. }
  592. cmake cm;
  593. return cm.Build(dir, target, config, nativeOptions, clean);
  594. #endif
  595. }