cmGlobalWatcomWMakeGenerator.cxx 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #include "cmGlobalWatcomWMakeGenerator.h"
  4. #include <ostream>
  5. #include <cm/string_view>
  6. #include <cmext/string_view>
  7. #include "cmGlobalGenerator.h"
  8. #include "cmMakefile.h"
  9. #include "cmState.h"
  10. #include "cmake.h"
  11. cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator(cmake* cm)
  12. : cmGlobalUnixMakefileGenerator3(cm)
  13. {
  14. this->FindMakeProgramFile = "CMakeFindWMake.cmake";
  15. #ifdef _WIN32
  16. this->ForceUnixPaths = false;
  17. #endif
  18. this->ToolSupportsColor = true;
  19. this->NeedSymbolicMark = true;
  20. this->EmptyRuleHackCommand = "@%null";
  21. #ifdef _WIN32
  22. cm->GetState()->SetWindowsShell(true);
  23. #endif
  24. cm->GetState()->SetWatcomWMake(true);
  25. this->IncludeDirective = "!include";
  26. this->LineContinueDirective = "&\n";
  27. this->DefineWindowsNULL = true;
  28. this->UnixCD = false;
  29. this->MakeSilentFlag = "-h";
  30. }
  31. void cmGlobalWatcomWMakeGenerator::EnableLanguage(
  32. std::vector<std::string> const& l, cmMakefile* mf, bool optional)
  33. {
  34. // pick a default
  35. mf->AddDefinition("WATCOM", "1");
  36. mf->AddDefinition("CMAKE_QUOTE_INCLUDE_PATHS", "1");
  37. mf->AddDefinition("CMAKE_MANGLE_OBJECT_FILE_NAMES", "1");
  38. mf->AddDefinition("CMAKE_MAKE_SYMBOLIC_RULE", ".SYMBOLIC");
  39. mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386");
  40. mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386");
  41. this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
  42. }
  43. bool cmGlobalWatcomWMakeGenerator::SetSystemName(std::string const& s,
  44. cmMakefile* mf)
  45. {
  46. if (mf->GetSafeDefinition("CMAKE_SYSTEM_PROCESSOR") == "I86"_s) {
  47. mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl");
  48. mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl");
  49. }
  50. return this->cmGlobalUnixMakefileGenerator3::SetSystemName(s, mf);
  51. }
  52. cmDocumentationEntry cmGlobalWatcomWMakeGenerator::GetDocumentation()
  53. {
  54. return { cmGlobalWatcomWMakeGenerator::GetActualName(),
  55. "Generates Watcom WMake makefiles." };
  56. }
  57. std::vector<cmGlobalGenerator::GeneratedMakeCommand>
  58. cmGlobalWatcomWMakeGenerator::GenerateBuildCommand(
  59. std::string const& makeProgram, std::string const& projectName,
  60. std::string const& projectDir, std::vector<std::string> const& targetNames,
  61. std::string const& config, int /*jobs*/, bool verbose,
  62. cmBuildOptions buildOptions, std::vector<std::string> const& makeOptions)
  63. {
  64. return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
  65. makeProgram, projectName, projectDir, targetNames, config,
  66. cmake::NO_BUILD_PARALLEL_LEVEL, verbose, buildOptions, makeOptions);
  67. }
  68. std::string cmGlobalWatcomWMakeGenerator::GetShortBinaryOutputDir() const
  69. {
  70. return "_o";
  71. }
  72. void cmGlobalWatcomWMakeGenerator::PrintBuildCommandAdvice(std::ostream& os,
  73. int jobs) const
  74. {
  75. if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
  76. // wmake does not support parallel build level
  77. /* clang-format off */
  78. os <<
  79. "Warning: Watcom's WMake does not support parallel builds. "
  80. "Ignoring parallel build command line option.\n";
  81. /* clang-format on */
  82. }
  83. this->cmGlobalUnixMakefileGenerator3::PrintBuildCommandAdvice(
  84. os, cmake::NO_BUILD_PARALLEL_LEVEL);
  85. }