1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
13 #include <unordered_set>
17 #include <cm/string_view>
18 #include <cmext/string_view>
20 #include "cmDocumentationEntry.h" // IWYU pragma: keep
21 #include "cmGeneratedFileStream.h"
22 #include "cmGlobalGeneratorFactory.h"
23 #include "cmInstalledFile.h"
24 #include "cmListFileCache.h"
25 #include "cmMessageType.h"
27 #include "cmStateSnapshot.h"
28 #include "cmStateTypes.h"
31 #if !defined(CMAKE_BOOTSTRAP)
32 # include <cm/optional>
34 # include <cm3p/json/value.h>
36 # include "cmCMakePresetsGraph.h"
37 # include "cmMakefileProfilingData.h"
42 #ifdef CMake_ENABLE_DEBUGGER
43 namespace cmDebugger
{
44 class cmDebuggerAdapter
;
48 class cmExternalMakefileProjectGeneratorFactory
;
50 class cmFileTimeCache
;
51 class cmGlobalGenerator
;
54 class cmVariableWatch
;
55 struct cmBuildOptions
;
56 struct cmGlobCacheEntry
;
58 /** \brief Represents a cmake invocation.
60 * This class represents a cmake invocation. It is the top level class when
61 * running cmake. Most cmake based GUIs should primarily create an instance
62 * of this class and communicate with it.
64 * The basic process for a GUI is as follows:
66 * -# Create a cmake instance
67 * -# Set the Home directories, generator, and cmake command. this
68 * can be done using the Set methods or by using SetArgs and passing in
69 * command line arguments.
70 * -# Load the cache by calling LoadCache (duh)
71 * -# if you are using command line arguments with -D or -C flags then
72 * call SetCacheArgs (or if for some other reason you want to modify the
74 * -# Finally call Configure
75 * -# Let the user change values and go back to step 5
78 * If your GUI allows the user to change the home directories then
79 * you must at a minimum redo steps 2 through 7.
87 RoleInternal
, // no commands
88 RoleScript
, // script commands
89 RoleProject
// all commands
99 /** \brief Describes the working modes of cmake */
102 NORMAL_MODE
, ///< Cmake runs to create project files
104 /** \brief Script mode (started by using -P).
106 * In script mode there is no generator and no cache. Also,
107 * languages are not enabled, so add_executable and things do
114 * Used to print help for things that can only be determined after finding
115 * the source directory, for example, the list of presets.
119 /** \brief A pkg-config like mode
121 * In this mode cmake just searches for a package and prints the results to
122 * stdout. This is similar to SCRIPT_MODE, but commands like add_library()
123 * work too, since they may be used e.g. in exported target files. Started
124 * via --find-package.
129 using TraceFormat
= cmTraceEnums::TraceOutputFormat
;
134 std::string baseName
;
135 std::string extraName
;
136 bool supportsToolset
;
137 bool supportsPlatform
;
138 std::vector
<std::string
> supportedPlatforms
;
139 std::string defaultPlatform
;
143 struct FileExtensions
145 bool Test(cm::string_view ext
) const
147 return (this->unordered
.find(ext
) != this->unordered
.end());
150 std::vector
<std::string
> ordered
;
151 std::unordered_set
<cm::string_view
> unordered
;
154 using InstalledFilesMap
= std::map
<std::string
, cmInstalledFile
>;
156 static const int NO_BUILD_PARALLEL_LEVEL
= -1;
157 static const int DEFAULT_BUILD_PARALLEL_LEVEL
= 0;
159 /// Default constructor
160 cmake(Role role
, cmState::Mode mode
,
161 cmState::ProjectKind projectKind
= cmState::ProjectKind::Normal
);
165 cmake(cmake
const&) = delete;
166 cmake
& operator=(cmake
const&) = delete;
168 #if !defined(CMAKE_BOOTSTRAP)
169 Json::Value
ReportVersionJson() const;
170 Json::Value
ReportCapabilitiesJson() const;
172 std::string
ReportCapabilities() const;
175 * Set the home directory from `-S` or from a known location
176 * that contains a CMakeLists.txt. Will generate warnings
177 * when overriding an existing source directory.
179 * | args | src dir| warning |
180 * | ----------------- | ------ | -------------- |
181 * | `dirA dirA` | dirA | N/A |
182 * | `-S dirA -S dirA` | dirA | N/A |
183 * | `-S dirA -S dirB` | dirB | Ignoring dirA |
184 * | `-S dirA dirB` | dirB | Ignoring dirA |
185 * | `dirA -S dirB` | dirB | Ignoring dirA |
186 * | `dirA dirB` | dirB | Ignoring dirA |
188 void SetHomeDirectoryViaCommandLine(std::string
const& path
);
192 * Set/Get the home directory (or output directory) in the project. The
193 * home directory is the top directory of the project. It is the
194 * path-to-source cmake was run with.
196 void SetHomeDirectory(const std::string
& dir
);
197 std::string
const& GetHomeDirectory() const;
198 void SetHomeOutputDirectory(const std::string
& dir
);
199 std::string
const& GetHomeOutputDirectory() const;
203 * Working directory at CMake launch
205 std::string
const& GetCMakeWorkingDirectory() const
207 return this->CMakeWorkingDirectory
;
211 * Handle a command line invocation of cmake.
213 int Run(const std::vector
<std::string
>& args
)
215 return this->Run(args
, false);
217 int Run(const std::vector
<std::string
>& args
, bool noconfigure
);
220 * Run the global generator Generate step.
225 * Configure the cmMakefiles. This routine will create a GlobalGenerator if
226 * one has not already been set. It will then Call Configure on the
227 * GlobalGenerator. This in turn will read in an process all the CMakeList
228 * files for the tree. It will not produce any actual Makefiles, or
229 * workspaces. Generate does that. */
231 int ActualConfigure();
233 //! Break up a line like VAR:type="value" into var, type and value
234 static bool ParseCacheEntry(const std::string
& entry
, std::string
& var
,
236 cmStateEnums::CacheEntryType
& type
);
239 bool LoadCache(const std::string
& path
);
240 bool LoadCache(const std::string
& path
, bool internal
,
241 std::set
<std::string
>& excludes
,
242 std::set
<std::string
>& includes
);
243 bool SaveCache(const std::string
& path
);
244 bool DeleteCache(const std::string
& path
);
245 void PreLoadCMakeFiles();
247 //! Create a GlobalGenerator
248 std::unique_ptr
<cmGlobalGenerator
> CreateGlobalGenerator(
249 const std::string
& name
, bool allowArch
= true);
251 //! Create a GlobalGenerator and set it as our own
252 bool CreateAndSetGlobalGenerator(const std::string
& name
, bool allowArch
);
254 #ifndef CMAKE_BOOTSTRAP
255 //! Print list of configure presets
256 void PrintPresetList(const cmCMakePresetsGraph
& graph
) const;
259 //! Return the global generator assigned to this instance of cmake
260 cmGlobalGenerator
* GetGlobalGenerator()
262 return this->GlobalGenerator
.get();
264 //! Return the global generator assigned to this instance of cmake, const
265 const cmGlobalGenerator
* GetGlobalGenerator() const
267 return this->GlobalGenerator
.get();
270 //! Return the full path to where the CMakeCache.txt file should be.
271 static std::string
FindCacheFile(const std::string
& binaryDir
);
273 //! Return the global generator assigned to this instance of cmake
274 void SetGlobalGenerator(std::unique_ptr
<cmGlobalGenerator
>);
276 //! Get the names of the current registered generators
277 void GetRegisteredGenerators(std::vector
<GeneratorInfo
>& generators
,
278 bool includeNamesWithPlatform
= true) const;
280 //! Set the name of the selected generator-specific instance.
281 void SetGeneratorInstance(std::string
const& instance
)
283 this->GeneratorInstance
= instance
;
284 this->GeneratorInstanceSet
= true;
287 //! Set the name of the selected generator-specific platform.
288 void SetGeneratorPlatform(std::string
const& ts
)
290 this->GeneratorPlatform
= ts
;
291 this->GeneratorPlatformSet
= true;
294 //! Set the name of the selected generator-specific toolset.
295 void SetGeneratorToolset(std::string
const& ts
)
297 this->GeneratorToolset
= ts
;
298 this->GeneratorToolsetSet
= true;
301 bool IsAKnownSourceExtension(cm::string_view ext
) const
303 return this->CLikeSourceFileExtensions
.Test(ext
) ||
304 this->CudaFileExtensions
.Test(ext
) ||
305 this->FortranFileExtensions
.Test(ext
) ||
306 this->HipFileExtensions
.Test(ext
) || this->ISPCFileExtensions
.Test(ext
);
309 bool IsACLikeSourceExtension(cm::string_view ext
) const
311 return this->CLikeSourceFileExtensions
.Test(ext
);
314 bool IsAKnownExtension(cm::string_view ext
) const
316 return this->IsAKnownSourceExtension(ext
) || this->IsAHeaderExtension(ext
);
319 std::vector
<std::string
> GetAllExtensions() const;
321 const std::vector
<std::string
>& GetHeaderExtensions() const
323 return this->HeaderFileExtensions
.ordered
;
326 bool IsAHeaderExtension(cm::string_view ext
) const
328 return this->HeaderFileExtensions
.Test(ext
);
331 // Strips the extension (if present and known) from a filename
332 std::string
StripExtension(const std::string
& file
) const;
335 * Given a variable name, return its value (as a string).
337 cmValue
GetCacheDefinition(const std::string
&) const;
338 //! Add an entry into the cache
339 void AddCacheEntry(const std::string
& key
, const std::string
& value
,
340 const std::string
& helpString
, int type
)
342 this->AddCacheEntry(key
, cmValue
{ value
}, cmValue
{ helpString
}, type
);
344 void AddCacheEntry(const std::string
& key
, cmValue value
,
345 const std::string
& helpString
, int type
)
347 this->AddCacheEntry(key
, value
, cmValue
{ helpString
}, type
);
349 void AddCacheEntry(const std::string
& key
, cmValue value
, cmValue helpString
,
352 bool DoWriteGlobVerifyTarget() const;
353 std::string
const& GetGlobVerifyScript() const;
354 std::string
const& GetGlobVerifyStamp() const;
355 void AddGlobCacheEntry(const cmGlobCacheEntry
& entry
,
356 const std::string
& variable
,
357 cmListFileBacktrace
const& bt
);
358 std::vector
<cmGlobCacheEntry
> GetGlobCacheEntries() const;
361 * Get the system information and write it to the file specified
363 int GetSystemInformation(std::vector
<std::string
>&);
365 //! Parse environment variables
366 void LoadEnvironmentPresets();
368 //! Parse command line arguments
369 void SetArgs(const std::vector
<std::string
>& args
);
371 //! Is this cmake running as a result of a TRY_COMPILE command
372 bool GetIsInTryCompile() const;
374 #ifndef CMAKE_BOOTSTRAP
375 void SetWarningFromPreset(const std::string
& name
,
376 const cm::optional
<bool>& warning
,
377 const cm::optional
<bool>& error
);
378 void ProcessPresetVariables();
379 void PrintPresetVariables();
380 void ProcessPresetEnvironment();
381 void PrintPresetEnvironment();
384 //! Parse command line arguments that might set cache values
385 bool SetCacheArgs(const std::vector
<std::string
>&);
387 void ProcessCacheArg(const std::string
& var
, const std::string
& value
,
388 cmStateEnums::CacheEntryType type
);
390 using ProgressCallbackType
= std::function
<void(const std::string
&, float)>;
392 * Set the function used by GUIs to receive progress updates
393 * Function gets passed: message as a const char*, a progress
394 * amount ranging from 0 to 1.0 and client data. The progress
395 * number provided may be negative in cases where a message is
396 * to be displayed without any progress percentage.
398 void SetProgressCallback(ProgressCallbackType f
);
400 //! this is called by generators to update the progress
401 void UpdateProgress(const std::string
& msg
, float prog
);
403 #if !defined(CMAKE_BOOTSTRAP)
404 //! Get the variable watch object
405 cmVariableWatch
* GetVariableWatch() { return this->VariableWatch
.get(); }
408 std::vector
<cmDocumentationEntry
> GetGeneratorsDocumentation();
410 //! Set/Get a property of this target file
411 void SetProperty(const std::string
& prop
, cmValue value
);
412 void SetProperty(const std::string
& prop
, std::nullptr_t
)
414 this->SetProperty(prop
, cmValue
{ nullptr });
416 void SetProperty(const std::string
& prop
, const std::string
& value
)
418 this->SetProperty(prop
, cmValue(value
));
420 void AppendProperty(const std::string
& prop
, const std::string
& value
,
421 bool asString
= false);
422 cmValue
GetProperty(const std::string
& prop
);
423 bool GetPropertyAsBool(const std::string
& prop
);
425 //! Get or create an cmInstalledFile instance and return a pointer to it
426 cmInstalledFile
* GetOrCreateInstalledFile(cmMakefile
* mf
,
427 const std::string
& name
);
429 cmInstalledFile
const* GetInstalledFile(const std::string
& name
) const;
431 InstalledFilesMap
const& GetInstalledFiles() const
433 return this->InstalledFiles
;
436 //! Do all the checks before running configure
437 int DoPreConfigureChecks();
439 void SetWorkingMode(WorkingMode mode
) { this->CurrentWorkingMode
= mode
; }
440 WorkingMode
GetWorkingMode() { return this->CurrentWorkingMode
; }
442 //! Debug the try compile stuff by not deleting the files
443 bool GetDebugTryCompile() const { return this->DebugTryCompile
; }
444 void DebugTryCompileOn() { this->DebugTryCompile
= true; }
447 * Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
452 * Get the file comparison class
454 cmFileTimeCache
* GetFileTimeCache() { return this->FileTimeCache
.get(); }
456 bool WasLogLevelSetViaCLI() const { return this->LogLevelWasSetViaCLI
; }
458 //! Get the selected log level for `message()` commands during the cmake run.
459 Message::LogLevel
GetLogLevel() const { return this->MessageLogLevel
; }
460 void SetLogLevel(Message::LogLevel level
) { this->MessageLogLevel
= level
; }
461 static Message::LogLevel
StringToLogLevel(cm::string_view levelStr
);
462 static std::string
LogLevelToString(Message::LogLevel level
);
463 static TraceFormat
StringToTraceFormat(const std::string
& levelStr
);
465 bool HasCheckInProgress() const
467 return !this->CheckInProgressMessages
.empty();
469 std::size_t GetCheckInProgressSize() const
471 return this->CheckInProgressMessages
.size();
473 std::string
GetTopCheckInProgressMessage()
475 auto message
= this->CheckInProgressMessages
.back();
476 this->CheckInProgressMessages
.pop_back();
479 void PushCheckInProgressMessage(std::string message
)
481 this->CheckInProgressMessages
.emplace_back(std::move(message
));
483 std::vector
<std::string
> const& GetCheckInProgressMessages() const
485 return this->CheckInProgressMessages
;
488 //! Should `message` command display context.
489 bool GetShowLogContext() const { return this->LogContext
; }
490 void SetShowLogContext(bool b
) { this->LogContext
= b
; }
492 //! Do we want debug output during the cmake run.
493 bool GetDebugOutput() const { return this->DebugOutput
; }
494 void SetDebugOutputOn(bool b
) { this->DebugOutput
= b
; }
496 //! Do we want debug output from the find commands during the cmake run.
497 bool GetDebugFindOutput() const { return this->DebugFindOutput
; }
498 bool GetDebugFindOutput(std::string
const& var
) const;
499 bool GetDebugFindPkgOutput(std::string
const& pkg
) const;
500 void SetDebugFindOutput(bool b
) { this->DebugFindOutput
= b
; }
501 void SetDebugFindOutputPkgs(std::string
const& args
);
502 void SetDebugFindOutputVars(std::string
const& args
);
504 //! Do we want trace output during the cmake run.
505 bool GetTrace() const { return this->Trace
; }
506 void SetTrace(bool b
) { this->Trace
= b
; }
507 bool GetTraceExpand() const { return this->TraceExpand
; }
508 void SetTraceExpand(bool b
) { this->TraceExpand
= b
; }
509 TraceFormat
GetTraceFormat() const { return this->TraceFormatVar
; }
510 void SetTraceFormat(TraceFormat f
) { this->TraceFormatVar
= f
; }
511 void AddTraceSource(std::string
const& file
)
513 this->TraceOnlyThisSources
.push_back(file
);
515 std::vector
<std::string
> const& GetTraceSources() const
517 return this->TraceOnlyThisSources
;
519 cmGeneratedFileStream
& GetTraceFile()
521 if (this->TraceRedirect
) {
522 return this->TraceRedirect
->GetTraceFile();
524 return this->TraceFile
;
526 void SetTraceFile(std::string
const& file
);
527 void PrintTraceFormatVersion();
529 #ifndef CMAKE_BOOTSTRAP
530 cmConfigureLog
* GetConfigureLog() const { return this->ConfigureLog
.get(); }
533 //! Use trace from another ::cmake instance.
534 void SetTraceRedirect(cmake
* other
);
536 bool GetWarnUninitialized() const { return this->WarnUninitialized
; }
537 void SetWarnUninitialized(bool b
) { this->WarnUninitialized
= b
; }
538 bool GetWarnUnusedCli() const { return this->WarnUnusedCli
; }
539 void SetWarnUnusedCli(bool b
) { this->WarnUnusedCli
= b
; }
540 bool GetCheckSystemVars() const { return this->CheckSystemVars
; }
541 void SetCheckSystemVars(bool b
) { this->CheckSystemVars
= b
; }
542 bool GetIgnoreWarningAsError() const { return this->IgnoreWarningAsError
; }
543 void SetIgnoreWarningAsError(bool b
) { this->IgnoreWarningAsError
= b
; }
545 void MarkCliAsUsed(const std::string
& variable
);
547 /** Get the list of configurations (in upper case) considered to be
548 debugging configurations.*/
549 std::vector
<std::string
> GetDebugConfigs();
551 void SetCMakeEditCommand(std::string
const& s
)
553 this->CMakeEditCommand
= s
;
555 std::string
const& GetCMakeEditCommand() const
557 return this->CMakeEditCommand
;
560 cmMessenger
* GetMessenger() const { return this->Messenger
.get(); }
563 * Get the state of the suppression of developer (author) warnings.
564 * Returns false, by default, if developer warnings should be shown, true
567 bool GetSuppressDevWarnings() const;
569 * Set the state of the suppression of developer (author) warnings.
571 void SetSuppressDevWarnings(bool v
);
574 * Get the state of the suppression of deprecated warnings.
575 * Returns false, by default, if deprecated warnings should be shown, true
578 bool GetSuppressDeprecatedWarnings() const;
580 * Set the state of the suppression of deprecated warnings.
582 void SetSuppressDeprecatedWarnings(bool v
);
585 * Get the state of treating developer (author) warnings as errors.
586 * Returns false, by default, if warnings should not be treated as errors,
589 bool GetDevWarningsAsErrors() const;
591 * Set the state of treating developer (author) warnings as errors.
593 void SetDevWarningsAsErrors(bool v
);
596 * Get the state of treating deprecated warnings as errors.
597 * Returns false, by default, if warnings should not be treated as errors,
600 bool GetDeprecatedWarningsAsErrors() const;
602 * Set the state of treating developer (author) warnings as errors.
604 void SetDeprecatedWarningsAsErrors(bool v
);
606 /** Display a message to the user. */
608 MessageType t
, std::string
const& text
,
609 cmListFileBacktrace
const& backtrace
= cmListFileBacktrace()) const;
611 //! run the --build option
612 int Build(int jobs
, std::string dir
, std::vector
<std::string
> targets
,
613 std::string config
, std::vector
<std::string
> nativeOptions
,
614 cmBuildOptions
& buildOptions
, bool verbose
,
615 const std::string
& presetName
, bool listPresets
);
617 //! run the --open option
618 bool Open(const std::string
& dir
, bool dryRun
);
620 //! run the --workflow option
621 enum class WorkflowListPresets
626 enum class WorkflowFresh
631 int Workflow(const std::string
& presetName
, WorkflowListPresets listPresets
,
632 WorkflowFresh fresh
);
634 void UnwatchUnusedCli(const std::string
& var
);
635 void WatchUnusedCli(const std::string
& var
);
637 #if !defined(CMAKE_BOOTSTRAP)
638 cmFileAPI
* GetFileAPI() const { return this->FileAPI
.get(); }
641 cmState
* GetState() const { return this->State
.get(); }
642 void SetCurrentSnapshot(cmStateSnapshot
const& snapshot
)
644 this->CurrentSnapshot
= snapshot
;
646 cmStateSnapshot
GetCurrentSnapshot() const { return this->CurrentSnapshot
; }
648 bool GetRegenerateDuringBuild() const { return this->RegenerateDuringBuild
; }
650 #if !defined(CMAKE_BOOTSTRAP)
651 cmMakefileProfilingData
& GetProfilingOutput();
652 bool IsProfilingEnabled() const;
654 cm::optional
<cmMakefileProfilingData::RAII
> CreateProfilingEntry(
655 const std::string
& category
, const std::string
& name
)
657 return this->CreateProfilingEntry(
658 category
, name
, []() -> cm::nullopt_t
{ return cm::nullopt
; });
661 template <typename ArgsFunc
>
662 cm::optional
<cmMakefileProfilingData::RAII
> CreateProfilingEntry(
663 const std::string
& category
, const std::string
& name
, ArgsFunc
&& argsFunc
)
665 if (this->IsProfilingEnabled()) {
666 return cm::make_optional
<cmMakefileProfilingData::RAII
>(
667 this->GetProfilingOutput(), category
, name
, argsFunc());
673 #ifdef CMake_ENABLE_DEBUGGER
674 bool GetDebuggerOn() const { return this->DebuggerOn
; }
675 std::string
GetDebuggerPipe() const { return this->DebuggerPipe
; }
676 std::string
GetDebuggerDapLogFile() const
678 return this->DebuggerDapLogFile
;
680 void SetDebuggerOn(bool b
) { this->DebuggerOn
= b
; }
681 bool StartDebuggerIfEnabled();
682 void StopDebuggerIfNeeded(int exitCode
);
683 std::shared_ptr
<cmDebugger::cmDebuggerAdapter
> GetDebugAdapter()
686 return this->DebugAdapter
;
691 void RunCheckForUnusedVariables();
692 int HandleDeleteCacheVariables(const std::string
& var
);
694 using RegisteredGeneratorsVector
=
695 std::vector
<std::unique_ptr
<cmGlobalGeneratorFactory
>>;
696 RegisteredGeneratorsVector Generators
;
697 using RegisteredExtraGeneratorsVector
=
698 std::vector
<cmExternalMakefileProjectGeneratorFactory
*>;
699 RegisteredExtraGeneratorsVector ExtraGenerators
;
700 void AddScriptingCommands() const;
701 void AddProjectCommands() const;
702 void AddDefaultGenerators();
703 void AddDefaultExtraGenerators();
705 std::map
<std::string
, DiagLevel
> DiagLevels
;
706 std::string GeneratorInstance
;
707 std::string GeneratorPlatform
;
708 std::string GeneratorToolset
;
709 bool GeneratorInstanceSet
= false;
710 bool GeneratorPlatformSet
= false;
711 bool GeneratorToolsetSet
= false;
713 //! read in a cmake list file to initialize the cache
714 void ReadListFile(const std::vector
<std::string
>& args
,
715 const std::string
& path
);
716 bool FindPackage(const std::vector
<std::string
>& args
);
718 //! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file.
719 /// If it is set, truncate it to 50kb
720 void TruncateOutputLog(const char* fname
);
723 * Method called to check build system integrity at build time.
724 * Returns 1 if CMake should rerun and 0 otherwise.
726 int CheckBuildSystem();
728 bool SetDirectoriesFromFile(const std::string
& arg
);
730 //! Make sure all commands are what they say they are and there is no
732 void CleanupCommandsAndMacros();
734 void GenerateGraphViz(const std::string
& fileName
) const;
737 std::string CMakeWorkingDirectory
;
738 ProgressCallbackType ProgressCallback
;
739 WorkingMode CurrentWorkingMode
= NORMAL_MODE
;
740 bool DebugOutput
= false;
741 bool DebugFindOutput
= false;
743 bool TraceExpand
= false;
744 TraceFormat TraceFormatVar
= TraceFormat::Human
;
745 cmGeneratedFileStream TraceFile
;
746 cmake
* TraceRedirect
= nullptr;
747 #ifndef CMAKE_BOOTSTRAP
748 std::unique_ptr
<cmConfigureLog
> ConfigureLog
;
750 bool WarnUninitialized
= false;
751 bool WarnUnusedCli
= true;
752 bool CheckSystemVars
= false;
753 bool IgnoreWarningAsError
= false;
754 std::map
<std::string
, bool> UsedCliVariables
;
755 std::string CMakeEditCommand
;
756 std::string CXXEnvironment
;
757 std::string CCEnvironment
;
758 std::string CheckBuildSystemArgument
;
759 std::string CheckStampFile
;
760 std::string CheckStampList
;
761 std::string VSSolutionFile
;
762 std::string EnvironmentGenerator
;
763 FileExtensions CLikeSourceFileExtensions
;
764 FileExtensions HeaderFileExtensions
;
765 FileExtensions CudaFileExtensions
;
766 FileExtensions ISPCFileExtensions
;
767 FileExtensions FortranFileExtensions
;
768 FileExtensions HipFileExtensions
;
769 bool ClearBuildSystem
= false;
770 bool DebugTryCompile
= false;
771 bool FreshCache
= false;
772 bool RegenerateDuringBuild
= false;
773 std::unique_ptr
<cmFileTimeCache
> FileTimeCache
;
774 std::string GraphVizFile
;
775 InstalledFilesMap InstalledFiles
;
776 #ifndef CMAKE_BOOTSTRAP
777 std::map
<std::string
, cm::optional
<cmCMakePresetsGraph::CacheVariable
>>
778 UnprocessedPresetVariables
;
779 std::map
<std::string
, cm::optional
<std::string
>>
780 UnprocessedPresetEnvironment
;
783 #if !defined(CMAKE_BOOTSTRAP)
784 std::unique_ptr
<cmVariableWatch
> VariableWatch
;
785 std::unique_ptr
<cmFileAPI
> FileAPI
;
788 std::unique_ptr
<cmState
> State
;
789 cmStateSnapshot CurrentSnapshot
;
790 std::unique_ptr
<cmMessenger
> Messenger
;
792 std::vector
<std::string
> TraceOnlyThisSources
;
794 std::set
<std::string
> DebugFindPkgs
;
795 std::set
<std::string
> DebugFindVars
;
797 Message::LogLevel MessageLogLevel
= Message::LogLevel::LOG_STATUS
;
798 bool LogLevelWasSetViaCLI
= false;
799 bool LogContext
= false;
801 std::vector
<std::string
> CheckInProgressMessages
;
803 std::unique_ptr
<cmGlobalGenerator
> GlobalGenerator
;
805 void UpdateConversionPathTable();
807 //! Print a list of valid generators to stderr.
808 void PrintGeneratorList();
810 std::unique_ptr
<cmGlobalGenerator
> EvaluateDefaultGlobalGenerator();
811 void CreateDefaultGlobalGenerator();
813 void AppendGlobalGeneratorsDocumentation(std::vector
<cmDocumentationEntry
>&);
814 void AppendExtraGeneratorsDocumentation(std::vector
<cmDocumentationEntry
>&);
816 #if !defined(CMAKE_BOOTSTRAP)
817 template <typename T
>
818 const T
* FindPresetForWorkflow(
819 cm::static_string_view type
,
820 const std::map
<std::string
, cmCMakePresetsGraph::PresetPair
<T
>>& presets
,
821 const cmCMakePresetsGraph::WorkflowPreset::WorkflowStep
& step
);
823 std::function
<int()> BuildWorkflowStep(const std::vector
<std::string
>& args
);
826 #if !defined(CMAKE_BOOTSTRAP)
827 std::unique_ptr
<cmMakefileProfilingData
> ProfilingOutput
;
830 #ifdef CMake_ENABLE_DEBUGGER
831 std::shared_ptr
<cmDebugger::cmDebuggerAdapter
> DebugAdapter
;
832 bool DebuggerOn
= false;
833 std::string DebuggerPipe
;
834 std::string DebuggerDapLogFile
;
837 cm::optional
<int> ScriptModeExitCode
;
840 bool HasScriptModeExitCode() const { return ScriptModeExitCode
.has_value(); }
841 void SetScriptModeExitCode(int code
) { ScriptModeExitCode
= code
; }
842 int GetScriptModeExitCode() const { return ScriptModeExitCode
.value_or(-1); }
844 static cmDocumentationEntry CMAKE_STANDARD_OPTIONS_TABLE
[18];
847 #define FOR_EACH_C90_FEATURE(F) F(c_function_prototypes)
849 #define FOR_EACH_C99_FEATURE(F) \
853 #define FOR_EACH_C11_FEATURE(F) F(c_static_assert)
855 #define FOR_EACH_C_FEATURE(F) \
861 FOR_EACH_C90_FEATURE(F) \
862 FOR_EACH_C99_FEATURE(F) \
863 FOR_EACH_C11_FEATURE(F)
865 #define FOR_EACH_CXX98_FEATURE(F) F(cxx_template_template_parameters)
867 #define FOR_EACH_CXX11_FEATURE(F) \
868 F(cxx_alias_templates) \
875 F(cxx_decltype_incomplete_return_types) \
876 F(cxx_default_function_template_args) \
877 F(cxx_defaulted_functions) \
878 F(cxx_defaulted_move_initializers) \
879 F(cxx_delegating_constructors) \
880 F(cxx_deleted_functions) \
881 F(cxx_enum_forward_declarations) \
882 F(cxx_explicit_conversions) \
883 F(cxx_extended_friend_declarations) \
884 F(cxx_extern_templates) \
886 F(cxx_func_identifier) \
887 F(cxx_generalized_initializers) \
888 F(cxx_inheriting_constructors) \
889 F(cxx_inline_namespaces) \
891 F(cxx_local_type_template_args) \
892 F(cxx_long_long_type) \
894 F(cxx_nonstatic_member_init) \
898 F(cxx_raw_string_literals) \
899 F(cxx_reference_qualified_functions) \
900 F(cxx_right_angle_brackets) \
901 F(cxx_rvalue_references) \
902 F(cxx_sizeof_member) \
903 F(cxx_static_assert) \
904 F(cxx_strong_enums) \
905 F(cxx_thread_local) \
906 F(cxx_trailing_return_types) \
907 F(cxx_unicode_literals) \
908 F(cxx_uniform_initialization) \
909 F(cxx_unrestricted_unions) \
910 F(cxx_user_literals) \
911 F(cxx_variadic_macros) \
912 F(cxx_variadic_templates)
914 #define FOR_EACH_CXX14_FEATURE(F) \
915 F(cxx_aggregate_default_initializers) \
916 F(cxx_attribute_deprecated) \
917 F(cxx_binary_literals) \
918 F(cxx_contextual_conversions) \
919 F(cxx_decltype_auto) \
920 F(cxx_digit_separators) \
921 F(cxx_generic_lambdas) \
922 F(cxx_lambda_init_captures) \
923 F(cxx_relaxed_constexpr) \
924 F(cxx_return_type_deduction) \
925 F(cxx_variable_templates)
927 #define FOR_EACH_CXX_FEATURE(F) \
935 FOR_EACH_CXX98_FEATURE(F) \
936 FOR_EACH_CXX11_FEATURE(F) \
937 FOR_EACH_CXX14_FEATURE(F)
939 #define FOR_EACH_CUDA_FEATURE(F) \
948 #define FOR_EACH_HIP_FEATURE(F) \