1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmGlobalJOMMakefileGenerator.h"
7 #include <cmext/algorithm>
9 #include "cmDocumentationEntry.h"
10 #include "cmGlobalGenerator.h"
11 #include "cmMakefile.h"
15 cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator(cmake* cm)
16 : cmGlobalUnixMakefileGenerator3(cm)
18 this->FindMakeProgramFile = "CMakeJOMFindMake.cmake";
19 this->ForceUnixPaths = false;
20 this->ToolSupportsColor = true;
21 this->UseLinkScript = false;
22 cm->GetState()->SetWindowsShell(true);
23 cm->GetState()->SetNMake(true);
24 this->DefineWindowsNULL = true;
25 this->PassMakeflags = true;
27 this->MakeSilentFlag = "/nologo";
30 void cmGlobalJOMMakefileGenerator::EnableLanguage(
31 std::vector<std::string> const& l, cmMakefile* mf, bool optional)
34 mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
35 mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
36 this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
39 void cmGlobalJOMMakefileGenerator::GetDocumentation(
40 cmDocumentationEntry& entry)
42 entry.Name = cmGlobalJOMMakefileGenerator::GetActualName();
43 entry.Brief = "Generates JOM makefiles.";
46 void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
47 std::string const& lang,
50 if (lang == "CXX" || lang == "C") {
51 /* clang-format off */
53 "To use the JOM generator with Visual C++, cmake must be run from a "
54 "shell that can use the compiler cl from the command line. This "
55 "environment is unable to invoke the cl compiler. To fix this problem, "
56 "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n";
59 this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
62 std::vector<cmGlobalGenerator::GeneratedMakeCommand>
63 cmGlobalJOMMakefileGenerator::GenerateBuildCommand(
64 const std::string& makeProgram, const std::string& projectName,
65 const std::string& projectDir, std::vector<std::string> const& targetNames,
66 const std::string& config, int jobs, bool verbose,
67 const cmBuildOptions& buildOptions,
68 std::vector<std::string> const& makeOptions)
70 std::vector<std::string> jomMakeOptions;
72 // Since we have full control over the invocation of JOM, let us
74 jomMakeOptions.push_back(this->MakeSilentFlag);
75 cm::append(jomMakeOptions, makeOptions);
77 // JOM does parallel builds by default, the -j is only needed if a specific
79 // see https://github.com/qt-labs/jom/blob/v1.1.2/src/jomlib/options.cpp
80 if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
81 jobs = cmake::NO_BUILD_PARALLEL_LEVEL;
84 return cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
85 makeProgram, projectName, projectDir, targetNames, config, jobs, verbose,
86 buildOptions, jomMakeOptions);