resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmGlobalJOMMakefileGenerator.cxx
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"
4
5 #include <ostream>
6
7 #include <cmext/algorithm>
8
9 #include "cmDocumentationEntry.h"
10 #include "cmGlobalGenerator.h"
11 #include "cmMakefile.h"
12 #include "cmState.h"
13 #include "cmake.h"
14
15 cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator(cmake* cm)
16   : cmGlobalUnixMakefileGenerator3(cm)
17 {
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;
26   this->UnixCD = false;
27   this->MakeSilentFlag = "/nologo";
28 }
29
30 void cmGlobalJOMMakefileGenerator::EnableLanguage(
31   std::vector<std::string> const& l, cmMakefile* mf, bool optional)
32 {
33   // pick a default
34   mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
35   mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
36   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
37 }
38
39 void cmGlobalJOMMakefileGenerator::GetDocumentation(
40   cmDocumentationEntry& entry)
41 {
42   entry.Name = cmGlobalJOMMakefileGenerator::GetActualName();
43   entry.Brief = "Generates JOM makefiles.";
44 }
45
46 void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
47                                                        std::string const& lang,
48                                                        cmValue envVar) const
49 {
50   if (lang == "CXX" || lang == "C") {
51     /* clang-format off */
52     os <<
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";
57     /* clang-format on */
58   }
59   this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
60 }
61
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)
69 {
70   std::vector<std::string> jomMakeOptions;
71
72   // Since we have full control over the invocation of JOM, let us
73   // make it quiet.
74   jomMakeOptions.push_back(this->MakeSilentFlag);
75   cm::append(jomMakeOptions, makeOptions);
76
77   // JOM does parallel builds by default, the -j is only needed if a specific
78   // number is given
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;
82   }
83
84   return cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
85     makeProgram, projectName, projectDir, targetNames, config, jobs, verbose,
86     buildOptions, jomMakeOptions);
87 }