parent
e6453c200e
commit
31c0e0de49
@ -267,6 +267,17 @@ that may contain the following fields:
|
||||
:variable:`CMAKE_TOOLCHAIN_FILE` value. It is allowed in preset files
|
||||
specifying version ``3`` or above.
|
||||
|
||||
``graphviz``
|
||||
An optional string representing the path to the graphviz input file,
|
||||
that will contain all the library and executable dependencies
|
||||
in the project. See the documentation for :module:`CMakeGraphVizOptions`
|
||||
for more details.
|
||||
|
||||
This field supports `macro expansion`_. If a relative path is specified,
|
||||
it is calculated relative to the build directory, and if not found,
|
||||
relative to the source directory. It is allowed in preset files
|
||||
specifying version ``10`` or above.
|
||||
|
||||
``binaryDir``
|
||||
An optional string representing the path to the output binary directory.
|
||||
This field supports `macro expansion`_. If a relative path is specified,
|
||||
|
@ -491,6 +491,10 @@
|
||||
"properties": {
|
||||
"$comment": { "$ref": "#/definitions/$comment" }
|
||||
}
|
||||
},
|
||||
"graphviz": {
|
||||
"type": "string",
|
||||
"description": "An optional string specifying the path to graphviz dot file. Available in version 10 and higher."
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -743,6 +747,7 @@
|
||||
"architecture": { "$ref": "#/definitions/configurePresetsArchitectureV10" },
|
||||
"toolset": { "$ref": "#/definitions/configurePresetsToolsetV10" },
|
||||
"toolchainFile": {},
|
||||
"graphviz": {},
|
||||
"binaryDir": {},
|
||||
"installDir": {},
|
||||
"cmakeExecutable": {},
|
||||
|
@ -177,6 +177,12 @@ void TOOLCHAIN_FILE_UNSUPPORTED(cmJSONState* state)
|
||||
"support");
|
||||
}
|
||||
|
||||
void GRAPHVIZ_FILE_UNSUPPORTED(cmJSONState* state)
|
||||
{
|
||||
state->AddError(
|
||||
"File version must be 10 or higher for graphviz preset support");
|
||||
}
|
||||
|
||||
void CYCLIC_INCLUDE(const std::string& file, cmJSONState* state)
|
||||
{
|
||||
state->AddError(cmStrCat("Cyclic include among preset files: ", file));
|
||||
|
@ -70,6 +70,8 @@ void CONDITION_UNSUPPORTED(cmJSONState* state);
|
||||
|
||||
void TOOLCHAIN_FILE_UNSUPPORTED(cmJSONState* state);
|
||||
|
||||
void GRAPHVIZ_FILE_UNSUPPORTED(cmJSONState* state);
|
||||
|
||||
void CYCLIC_INCLUDE(const std::string& file, cmJSONState* state);
|
||||
|
||||
void TEST_OUTPUT_TRUNCATION_UNSUPPORTED(cmJSONState* state);
|
||||
|
@ -293,6 +293,12 @@ bool ExpandMacros(const cmCMakePresetsGraph& graph,
|
||||
out->ToolchainFile = toolchain;
|
||||
}
|
||||
|
||||
if (!preset.GraphVizFile.empty()) {
|
||||
std::string graphVizFile = preset.GraphVizFile;
|
||||
CHECK_EXPAND(out, graphVizFile, macroExpanders, graph.GetVersion(preset));
|
||||
out->GraphVizFile = graphVizFile;
|
||||
}
|
||||
|
||||
for (auto& variable : out->CacheVariables) {
|
||||
if (variable.second) {
|
||||
CHECK_EXPAND(out, variable.second->Value, macroExpanders,
|
||||
@ -775,6 +781,7 @@ bool cmCMakePresetsGraph::ConfigurePreset::VisitPresetInherit(
|
||||
InheritString(preset.BinaryDir, parent.BinaryDir);
|
||||
InheritString(preset.InstallDir, parent.InstallDir);
|
||||
InheritString(preset.ToolchainFile, parent.ToolchainFile);
|
||||
InheritString(preset.GraphVizFile, parent.GraphVizFile);
|
||||
InheritOptionalValue(preset.WarnDev, parent.WarnDev);
|
||||
InheritOptionalValue(preset.ErrorDev, parent.ErrorDev);
|
||||
InheritOptionalValue(preset.WarnDeprecated, parent.WarnDeprecated);
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
std::string Toolset;
|
||||
cm::optional<ArchToolsetStrategy> ToolsetStrategy;
|
||||
std::string ToolchainFile;
|
||||
std::string GraphVizFile;
|
||||
std::string BinaryDir;
|
||||
std::string InstallDir;
|
||||
|
||||
|
@ -611,6 +611,12 @@ bool cmCMakePresetsGraph::ReadJSONFile(const std::string& filename,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Support for graphviz argument added in version 10.
|
||||
if (v < 10 && !preset.GraphVizFile.empty()) {
|
||||
cmCMakePresetsErrors::GRAPHVIZ_FILE_UNSUPPORTED(&this->parseState);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->ConfigurePresetOrder.push_back(preset.Name);
|
||||
}
|
||||
|
||||
|
@ -272,6 +272,8 @@ auto const ConfigurePresetHelper =
|
||||
.Bind("toolset"_s, ToolsetHelper, false)
|
||||
.Bind("toolchainFile"_s, &ConfigurePreset::ToolchainFile,
|
||||
cmCMakePresetsGraphInternal::PresetStringHelper, false)
|
||||
.Bind("graphviz"_s, &ConfigurePreset::GraphVizFile,
|
||||
cmCMakePresetsGraphInternal::PresetStringHelper, false)
|
||||
.Bind("binaryDir"_s, &ConfigurePreset::BinaryDir,
|
||||
cmCMakePresetsGraphInternal::PresetStringHelper, false)
|
||||
.Bind("installDir"_s, &ConfigurePreset::InstallDir,
|
||||
|
@ -1075,10 +1075,7 @@ void cmake::SetArgs(const std::vector<std::string>& args)
|
||||
CommandArgument{ "--graphviz", "No file specified for --graphviz",
|
||||
CommandArgument::Values::One,
|
||||
[](std::string const& value, cmake* state) -> bool {
|
||||
std::string path =
|
||||
cmSystemTools::CollapseFullPath(value);
|
||||
cmSystemTools::ConvertToUnixSlashes(path);
|
||||
state->GraphVizFile = path;
|
||||
state->SetGraphVizFile(value);
|
||||
return true;
|
||||
} },
|
||||
|
||||
@ -1590,6 +1587,12 @@ void cmake::SetArgs(const std::vector<std::string>& args)
|
||||
}
|
||||
}
|
||||
|
||||
if (!expandedPreset->GraphVizFile.empty()) {
|
||||
if (this->GraphVizFile.empty()) {
|
||||
this->SetGraphVizFile(expandedPreset->GraphVizFile);
|
||||
}
|
||||
}
|
||||
|
||||
this->SetWarningFromPreset("dev", expandedPreset->WarnDev,
|
||||
expandedPreset->ErrorDev);
|
||||
this->SetWarningFromPreset("deprecated", expandedPreset->WarnDeprecated,
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmValue.h"
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
@ -298,6 +299,14 @@ public:
|
||||
this->GeneratorToolsetSet = true;
|
||||
}
|
||||
|
||||
//! Set the name of the graphviz file.
|
||||
void SetGraphVizFile(std::string const& ts)
|
||||
{
|
||||
std::string path = cmSystemTools::CollapseFullPath(ts);
|
||||
cmSystemTools::ConvertToUnixSlashes(path);
|
||||
this->GraphVizFile = path;
|
||||
}
|
||||
|
||||
bool IsAKnownSourceExtension(cm::string_view ext) const
|
||||
{
|
||||
return this->CLikeSourceFileExtensions.Test(ext) ||
|
||||
|
1
Tests/RunCMake/CMakePresets/GraphvizValid-result.txt
Normal file
1
Tests/RunCMake/CMakePresets/GraphvizValid-result.txt
Normal file
@ -0,0 +1 @@
|
||||
0
|
2
Tests/RunCMake/CMakePresets/GraphvizValid-stdout.txt
Normal file
2
Tests/RunCMake/CMakePresets/GraphvizValid-stdout.txt
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
Generate graphviz: .+[\\/]my_graphviz\.dot
|
0
Tests/RunCMake/CMakePresets/GraphvizValid.cmake
Normal file
0
Tests/RunCMake/CMakePresets/GraphvizValid.cmake
Normal file
11
Tests/RunCMake/CMakePresets/GraphvizValid.json.in
Normal file
11
Tests/RunCMake/CMakePresets/GraphvizValid.json.in
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": 10,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "GraphvizValid",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"graphviz": "${sourceDir}/my_graphviz.dot",
|
||||
"binaryDir": "${sourceDir}/build"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,2 @@
|
||||
^CMake Error: Could not read presets from .*
|
||||
File version must be 10 or higher for graphviz preset support
|
11
Tests/RunCMake/CMakePresets/GraphvizValidOldSchema.json.in
Normal file
11
Tests/RunCMake/CMakePresets/GraphvizValidOldSchema.json.in
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": 9,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "GraphvizValid",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"graphviz": "${sourceDir}/my_graphviz.dot",
|
||||
"binaryDir": "${sourceDir}/build"
|
||||
}
|
||||
]
|
||||
}
|
1
Tests/RunCMake/CMakePresets/NoGraphvizValid-result.txt
Normal file
1
Tests/RunCMake/CMakePresets/NoGraphvizValid-result.txt
Normal file
@ -0,0 +1 @@
|
||||
0
|
0
Tests/RunCMake/CMakePresets/NoGraphvizValid.cmake
Normal file
0
Tests/RunCMake/CMakePresets/NoGraphvizValid.cmake
Normal file
10
Tests/RunCMake/CMakePresets/NoGraphvizValid.json.in
Normal file
10
Tests/RunCMake/CMakePresets/NoGraphvizValid.json.in
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": 10,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "NoGraphvizValid",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"binaryDir": "${sourceDir}/build"
|
||||
}
|
||||
]
|
||||
}
|
@ -98,6 +98,11 @@ run_cmake_presets(CommentValid)
|
||||
run_cmake_presets(CommentValidFull)
|
||||
set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
|
||||
run_cmake_presets(CommentValidOldSchema)
|
||||
set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
|
||||
run_cmake_presets(NoGraphvizValid)
|
||||
run_cmake_presets(GraphvizValid)
|
||||
set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
|
||||
run_cmake_presets(GraphvizValidOldSchema)
|
||||
run_cmake_presets(JSONParseError)
|
||||
run_cmake_presets(InvalidRoot)
|
||||
run_cmake_presets(NoVersion)
|
||||
|
Loading…
Reference in New Issue
Block a user