summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab/ci/configure_fedora37_makefiles.cmake2
-rw-r--r--.gitlab/ci/env_fedora37_makefiles.sh5
-rw-r--r--Help/manual/cmake-presets.7.rst49
-rw-r--r--Help/manual/presets/schema.json107
-rw-r--r--Modules/CMakeFindBinUtils.cmake10
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCMakePresetErrors.h3
-rw-r--r--Source/cmCMakePresetsGraph.h13
-rw-r--r--Source/cmCMakePresetsGraphReadJSON.cxx10
-rw-r--r--Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx68
-rw-r--r--Source/cmGeneratorTarget.cxx4
-rw-r--r--Source/cmGlobalGenerator.cxx29
-rw-r--r--Source/cmGlobalGenerator.h11
-rw-r--r--Source/cmInstallRuntimeDependencySetGenerator.cxx3
-rw-r--r--Source/cmInstallTargetGenerator.cxx17
-rw-r--r--Source/cmMakefile.cxx8
-rw-r--r--Source/cmStateTypes.h11
-rw-r--r--Source/cmake.cxx104
-rw-r--r--Source/cmake.h10
-rw-r--r--Tests/FindHDF5/CMakeLists.txt3
-rw-r--r--Tests/FindHDF5/Test/CMakeLists.txt48
-rw-r--r--Tests/FindHDF5/Test/test_C.c12
-rw-r--r--Tests/FindHDF5/Test/test_CXX.cxx14
-rw-r--r--Tests/FindHDF5/Test/test_Fortran.f906
-rw-r--r--Tests/RunCMake/CMakePresets/ExplicitNoTrace.cmake0
-rw-r--r--Tests/RunCMake/CMakePresets/NoTrace.cmake0
-rw-r--r--Tests/RunCMake/CMakePresets/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/CMakePresets/Trace-stderr.txt4
-rw-r--r--Tests/RunCMake/CMakePresets/Trace.cmake0
-rw-r--r--Tests/RunCMake/CMakePresets/Trace.json.in69
-rw-r--r--Tests/RunCMake/CMakePresets/TraceAll.cmake4
-rw-r--r--Tests/RunCMake/CMakePresets/TraceExpand-stderr.txt4
-rw-r--r--Tests/RunCMake/CMakePresets/TraceExpand.cmake0
-rw-r--r--Tests/RunCMake/CMakePresets/TraceFormatHuman-stderr.txt4
-rw-r--r--Tests/RunCMake/CMakePresets/TraceFormatHuman.cmake0
-rw-r--r--Tests/RunCMake/CMakePresets/TraceFormatJSON-stderr.txt3
-rw-r--r--Tests/RunCMake/CMakePresets/TraceFormatJSON.cmake0
-rw-r--r--Tests/RunCMake/CMakePresets/TraceNotSupported-result.txt1
-rw-r--r--Tests/RunCMake/CMakePresets/TraceNotSupported-stderr.txt3
-rw-r--r--Tests/RunCMake/CMakePresets/TraceNotSupported.json.in13
-rw-r--r--Tests/RunCMake/CMakePresets/TraceRedirect.cmake0
-rw-r--r--Tests/RunCMake/CMakePresets/TraceSource.cmake0
42 files changed, 607 insertions, 60 deletions
diff --git a/.gitlab/ci/configure_fedora37_makefiles.cmake b/.gitlab/ci/configure_fedora37_makefiles.cmake
index 0a271bf..c2f9982 100644
--- a/.gitlab/ci/configure_fedora37_makefiles.cmake
+++ b/.gitlab/ci/configure_fedora37_makefiles.cmake
@@ -36,7 +36,7 @@ set(CMake_TEST_FindHDF5_MPICH_Fortran_COMPILER "/usr/lib64/mpich/bin/h5pfc" CACH
set(CMake_TEST_FindHDF5_OpenMPI_C_COMPILER "/usr/lib64/openmpi/bin/h5pcc" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_OpenMPI_ENVMOD "PATH=path_list_prepend:/usr/lib64/openmpi/bin;LD_LIBRARY_PATH=path_list_prepend:/usr/lib64/openmpi/lib" CACHE STRING "")
# set(CMake_TEST_FindHDF5_OpenMPI_CXX_COMPILER "/usr/lib64/openmpi/bin/h5pc++" CACHE FILEPATH "") # h5pc++ does not exist
-# set(CMake_TEST_FindHDF5_OpenMPI_Fortran_COMPILER "/usr/lib64/openmpi/bin/h5pfc" CACHE FILEPATH "") # cannot find its own hdf5.mod
+set(CMake_TEST_FindHDF5_OpenMPI_Fortran_COMPILER "/usr/lib64/openmpi/bin/h5pfc" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_Serial_C_COMPILER "/usr/bin/h5cc" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_Serial_CXX_COMPILER "/usr/bin/h5c++" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_Serial_Fortran_COMPILER "/usr/bin/h5fc" CACHE FILEPATH "")
diff --git a/.gitlab/ci/env_fedora37_makefiles.sh b/.gitlab/ci/env_fedora37_makefiles.sh
index 217ff30..c482642 100644
--- a/.gitlab/ci/env_fedora37_makefiles.sh
+++ b/.gitlab/ci/env_fedora37_makefiles.sh
@@ -1,3 +1,8 @@
if test "$CMAKE_CI_NIGHTLY" = "true"; then
source .gitlab/ci/ispc-env.sh
fi
+
+# Patch HDF5 Fortran compiler wrappers to work around Fedora bug.
+# https://bugzilla.redhat.com/show_bug.cgi?id=2183289
+sed -i '/^includedir=/ s|/mpich-x86_64||' /usr/lib64/mpich/bin/h5pfc
+sed -i '/^includedir=/ s|/openmpi-x86_64||' /usr/lib64/openmpi/bin/h5pfc
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst
index da699d8..7794e45 100644
--- a/Help/manual/cmake-presets.7.rst
+++ b/Help/manual/cmake-presets.7.rst
@@ -63,6 +63,9 @@ The root object recognizes the following fields:
``6``
.. versionadded:: 3.25
+ ``7``
+ .. versionadded:: 3.27
+
``cmakeMinimumRequired``
An optional object representing the minimum version of CMake needed to
build this project. This object consists of the following fields:
@@ -359,6 +362,52 @@ that may contain the following fields:
An optional boolean. Setting this to ``true`` is equivalent to passing
:option:`--debug-find <cmake --debug-find>` on the command line.
+``trace``
+ An optional object specifying trace options. This is allowed in preset
+ files specifying version ``7``. The object may contain the following fields:
+
+ ``mode``
+ An optional string that specifies the trace mode. Valid values are:
+
+ ``on``
+ Causes a trace of all calls made and from where to be printed.
+ Equivalent to passing :option:`--trace <cmake --trace>` on the command
+ line.
+
+ ``off``
+ A trace of all calls will not be printed.
+
+ ``expand``
+ Causes a trace with variables expanded of all calls made and from where
+ to be printed. Equivalent to passing :option:`--trace-expand <cmake --trace-expand>`
+ on the command line.
+
+ ``format``
+ An optional string that specifies the format output of the trace.
+ Valid values are:
+
+ ``human``
+ Prints each trace line in a human-readable format.
+ This is the default format. Equivalent to passing
+ :option:`--trace-format=human <cmake --trace-format>`
+ on the command line.
+
+ ``json-v1``
+ Prints each line as a separate JSON document. Equivalent to passing
+ :option:`--trace-format=json-v1 <cmake --trace-format>`
+ on the command line.
+
+ ``source``
+ An optional array of strings representing the paths of source files to
+ be traced. This field can also be a string, which is equivalent to an
+ array containing one string. Equivalent to passing
+ :option:`--trace-source <cmake --trace-source>` on the command line.
+
+ ``redirect``
+ An optional string specifying a path to a trace output file. Equivalent
+ to passing :option:`--trace-redirect <cmake --trace-redirect>`
+ on the command line.
+
Build Preset
^^^^^^^^^^^^
diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json
index 348116b..adfb1cb 100644
--- a/Help/manual/presets/schema.json
+++ b/Help/manual/presets/schema.json
@@ -89,6 +89,23 @@
"include": { "$ref": "#/definitions/include"}
},
"additionalProperties": false
+ },
+ {
+ "properties": {
+ "version": {
+ "const": 7,
+ "description": "A required integer representing the version of the JSON schema."
+ },
+ "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"},
+ "vendor": { "$ref": "#/definitions/vendor" },
+ "configurePresets": { "$ref": "#/definitions/configurePresetsV7"},
+ "buildPresets": { "$ref": "#/definitions/buildPresetsV4"},
+ "testPresets": { "$ref": "#/definitions/testPresetsV6"},
+ "packagePresets": { "$ref": "#/definitions/packagePresetsV6"},
+ "workflowPresets": { "$ref": "#/definitions/workflowPresetsV6" },
+ "include": { "$ref": "#/definitions/include"}
+ },
+ "additionalProperties": false
}
],
"required": [
@@ -119,6 +136,59 @@
"description": "An optional map containing vendor-specific information. CMake does not interpret the contents of this field except to verify that it is a map if it does exist. However, the keys should be a vendor-specific domain name followed by a /-separated path. For example, the Example IDE 1.0 could use example.com/ExampleIDE/1.0. The value of each field can be anything desired by the vendor, though will typically be a map.",
"properties": {}
},
+ "configurePresetsItemsV7": {
+ "type": "array",
+ "description": "A configure preset object.",
+ "items": {
+ "type": "object",
+ "description": "A configure preset object.",
+ "properties": {
+ "trace": {
+ "type": "object",
+ "description": "An optional object specifying trace options.",
+ "properties": {
+ "mode": {
+ "type": "string",
+ "description": "An optional string that specifies the trace mode.",
+ "enum": [
+ "on", "off", "expand"
+ ]
+ },
+ "format": {
+ "type": "string",
+ "description": "An optional string that specifies the trace output format.",
+ "enum": [
+ "human", "json-v1"
+ ]
+ },
+ "source": {
+ "anyOf": [
+ {
+ "type": "string",
+ "description": "An optional string representing the path to one source file to be traced.",
+ "minLength": 1
+ },
+ {
+ "type": "array",
+ "description": "An optional array of strings representing the paths to source files to be traced.",
+ "items": {
+ "type": "string",
+ "description": "A string representing the path to one source file to be traced.",
+ "minLength": 1
+ }
+ }
+ ]
+ },
+ "redirect": {
+ "type": "string",
+ "description": "An optional string specifying a path to a trace output file."
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ }
+ },
"configurePresetsItemsV3": {
"type": "array",
"description": "A configure preset object.",
@@ -393,6 +463,43 @@
}
}
},
+ "configurePresetsV7": {
+ "type": "array",
+ "description": "An optional array of configure preset objects.",
+ "allOf": [
+ { "$ref": "#/definitions/configurePresetsItemsV1" },
+ { "$ref": "#/definitions/configurePresetsItemsV3" },
+ { "$ref": "#/definitions/configurePresetsItemsV7" }
+ ],
+ "items": {
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "generator": {},
+ "architecture": {},
+ "toolset": {},
+ "toolchainFile": {},
+ "binaryDir": {},
+ "installDir": {},
+ "cmakeExecutable": {},
+ "cacheVariables": {},
+ "environment": {},
+ "warnings": {},
+ "errors": {},
+ "debug": {},
+ "condition": {},
+ "trace": {}
+ },
+ "required": [
+ "name"
+ ],
+ "additionalProperties": false
+ }
+ },
"configurePresetsV3": {
"type": "array",
"description": "An optional array of configure preset objects.",
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index 190117c..10e8ff3 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -186,7 +186,15 @@ else()
list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib")
if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}" VERSION_GREATER_EQUAL 11)
# llvm-strip versions prior to 11 require additional flags we do not yet add.
- list(PREPEND _CMAKE_STRIP_NAMES "llvm-strip")
+ if(APPLE)
+ # llvm-strip does not seem to support chained fixup format correctly.
+ # FIXME(#23333): We still need to consider 'llvm-strip' as a fallback
+ # because the 'APPLE' definition may be based on the host in this context,
+ # and a cross-compiling toolchain may not have 'strip'.
+ list(APPEND _CMAKE_STRIP_NAMES "llvm-strip")
+ else()
+ list(PREPEND _CMAKE_STRIP_NAMES "llvm-strip")
+ endif()
endif()
list(PREPEND _CMAKE_NM_NAMES "llvm-nm")
if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}" VERSION_GREATER_EQUAL 9)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 281a8a9..5706762 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 26)
-set(CMake_VERSION_PATCH 20230330)
+set(CMake_VERSION_PATCH 20230331)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmCMakePresetErrors.h b/Source/cmCMakePresetErrors.h
index c669cb1..0db391e 100644
--- a/Source/cmCMakePresetErrors.h
+++ b/Source/cmCMakePresetErrors.h
@@ -176,6 +176,9 @@ const auto CTEST_JUNIT_UNSUPPORTED = [](cmJSONState* state) -> void {
state->AddError(
"File version must be 6 or higher for CTest JUnit output support");
};
+const auto TRACE_UNSUPPORTED = [](cmJSONState* state) -> void {
+ state->AddError("File version must be 7 or higher for trace preset support");
+};
const auto UNRECOGNIZED_CMAKE_VERSION = [](const std::string& version,
int current, int required) {
return [version, current, required](const Json::Value* value,
diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h
index 9d7e5fa..7844624 100644
--- a/Source/cmCMakePresetsGraph.h
+++ b/Source/cmCMakePresetsGraph.h
@@ -15,6 +15,7 @@
#include <cm/optional>
#include "cmJSONState.h"
+#include "cmStateTypes.h"
#include "CTest/cmCTestTypes.h"
@@ -32,6 +33,13 @@ public:
External,
};
+ enum class TraceEnableMode
+ {
+ Disable,
+ Default,
+ Expand,
+ };
+
class CacheVariable
{
public:
@@ -129,6 +137,11 @@ public:
cm::optional<bool> DebugTryCompile;
cm::optional<bool> DebugFind;
+ cm::optional<TraceEnableMode> TraceMode;
+ cm::optional<cmTraceEnums::TraceOutputFormat> TraceFormat;
+ std::vector<std::string> TraceSource;
+ std::string TraceRedirect;
+
bool VisitPresetInherit(const Preset& parent) override;
bool VisitPresetBeforeInherit() override;
bool VisitPresetAfterInherit(int version, cmJSONState* state) override;
diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx
index 93c5f7d..bc829f3 100644
--- a/Source/cmCMakePresetsGraphReadJSON.cxx
+++ b/Source/cmCMakePresetsGraphReadJSON.cxx
@@ -35,7 +35,7 @@ using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy;
using JSONHelperBuilder = cmJSONHelperBuilder;
constexpr int MIN_VERSION = 1;
-constexpr int MAX_VERSION = 6;
+constexpr int MAX_VERSION = 7;
struct CMakeVersion
{
@@ -557,6 +557,14 @@ bool cmCMakePresetsGraph::ReadJSONFile(const std::string& filename,
return false;
}
+ // Support for trace presets added in version 7.
+ if (v < 7 &&
+ (preset.TraceMode.has_value() || preset.TraceFormat.has_value() ||
+ !preset.TraceRedirect.empty() || !preset.TraceSource.empty())) {
+ cmCMakePresetErrors::TRACE_UNSUPPORTED(&this->parseState);
+ return false;
+ }
+
this->ConfigurePresetOrder.push_back(preset.Name);
}
diff --git a/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx b/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
index a1774be..66ec6a4 100644
--- a/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
+++ b/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
@@ -17,12 +17,15 @@
#include "cmCMakePresetsGraphInternal.h"
#include "cmJSONHelpers.h"
#include "cmJSONState.h"
+#include "cmStateTypes.h"
namespace {
using CacheVariable = cmCMakePresetsGraph::CacheVariable;
using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset;
using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy;
using JSONHelperBuilder = cmJSONHelperBuilder;
+using TraceEnableMode = cmCMakePresetsGraph::TraceEnableMode;
+using TraceOutputFormat = cmTraceEnums::TraceOutputFormat;
bool ArchToolsetStrategyHelper(cm::optional<ArchToolsetStrategy>& out,
const Json::Value* value, cmJSONState* state)
@@ -91,6 +94,58 @@ auto const ArchitectureHelper = ArchToolsetHelper(
auto const ToolsetHelper = ArchToolsetHelper(
&ConfigurePreset::Toolset, &ConfigurePreset::ToolsetStrategy);
+bool TraceEnableModeHelper(cm::optional<TraceEnableMode>& out,
+ const Json::Value* value, cmJSONState* state)
+{
+ if (!value) {
+ out = cm::nullopt;
+ return true;
+ }
+
+ if (!value->isString()) {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ if (value->asString() == "on") {
+ out = TraceEnableMode::Default;
+ } else if (value->asString() == "off") {
+ out = TraceEnableMode::Disable;
+ } else if (value->asString() == "expand") {
+ out = TraceEnableMode::Expand;
+ } else {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ return true;
+}
+
+bool TraceOutputFormatHelper(cm::optional<TraceOutputFormat>& out,
+ const Json::Value* value, cmJSONState* state)
+{
+ if (!value) {
+ out = cm::nullopt;
+ return true;
+ }
+
+ if (!value->isString()) {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ if (value->asString() == "human") {
+ out = TraceOutputFormat::Human;
+ } else if (value->asString() == "json-v1") {
+ out = TraceOutputFormat::JSONv1;
+ } else {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ return true;
+}
+
auto const VariableStringHelper = JSONHelperBuilder::String();
bool VariableValueHelper(std::string& out, const Json::Value* value,
@@ -180,6 +235,18 @@ auto const PresetDebugHelper =
.Bind("find"_s, &ConfigurePreset::DebugFind,
cmCMakePresetsGraphInternal::PresetOptionalBoolHelper, false);
+auto const PresetTraceHelper =
+ JSONHelperBuilder::Object<ConfigurePreset>(
+ cmCMakePresetErrors::INVALID_PRESET_OBJECT, false)
+ .Bind("mode"_s, &ConfigurePreset::TraceMode, TraceEnableModeHelper, false)
+ .Bind("format"_s, &ConfigurePreset::TraceFormat, TraceOutputFormatHelper,
+ false)
+ .Bind("source"_s, &ConfigurePreset::TraceSource,
+ cmCMakePresetsGraphInternal::PresetVectorOneOrMoreStringHelper,
+ false)
+ .Bind("redirect"_s, &ConfigurePreset::TraceRedirect,
+ cmCMakePresetsGraphInternal::PresetStringHelper, false);
+
auto const ConfigurePresetHelper =
JSONHelperBuilder::Object<ConfigurePreset>(
cmCMakePresetErrors::INVALID_PRESET_OBJECT, false)
@@ -217,6 +284,7 @@ auto const ConfigurePresetHelper =
.Bind("warnings"_s, PresetWarningsHelper, false)
.Bind("errors"_s, PresetErrorsHelper, false)
.Bind("debug"_s, PresetDebugHelper, false)
+ .Bind("trace"_s, PresetTraceHelper, false)
.Bind("condition"_s, &ConfigurePreset::ConditionEvaluator,
cmCMakePresetsGraphInternal::PresetConditionHelper, false);
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 8a14eaf..bc5505f 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3626,7 +3626,7 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
for (CudaArchitecture& architecture : architectures) {
flags +=
- " --generate-code=arch=compute_" + architecture.name + ",code=[";
+ " \"--generate-code=arch=compute_" + architecture.name + ",code=[";
if (architecture.virtual_) {
flags += "compute_" + architecture.name;
@@ -3646,7 +3646,7 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
flags += "sm_" + architecture.name;
}
- flags += "]";
+ flags += "]\"";
}
} else if (compiler == "Clang") {
for (CudaArchitecture& architecture : architectures) {
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 0e9f78e..08022b3 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -3542,3 +3542,32 @@ cmInstallRuntimeDependencySet* cmGlobalGenerator::GetNamedRuntimeDependencySet(
}
return it->second;
}
+
+cmGlobalGenerator::StripCommandStyle cmGlobalGenerator::GetStripCommandStyle(
+ std::string const& strip)
+{
+#ifdef __APPLE__
+ auto i = this->StripCommandStyleMap.find(strip);
+ if (i == this->StripCommandStyleMap.end()) {
+ StripCommandStyle style = StripCommandStyle::Default;
+
+ // Try running strip tool with Apple-specific options.
+ std::vector<std::string> cmd{ strip, "-u", "-r" };
+ std::string out;
+ std::string err;
+ int ret;
+ if (cmSystemTools::RunSingleCommand(cmd, &out, &err, &ret, nullptr,
+ cmSystemTools::OUTPUT_NONE) &&
+ // Check for Apple-specific output.
+ ret != 0 && cmHasLiteralPrefix(err, "fatal error: /") &&
+ err.find("/usr/bin/strip: no files specified") != std::string::npos) {
+ style = StripCommandStyle::Apple;
+ }
+ i = this->StripCommandStyleMap.emplace(strip, style).first;
+ }
+ return i->second;
+#else
+ static_cast<void>(strip);
+ return StripCommandStyle::Default;
+#endif
+}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 4d321b5..4bbbdfa 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -607,6 +607,13 @@ public:
cmInstallRuntimeDependencySet* GetNamedRuntimeDependencySet(
const std::string& name);
+ enum class StripCommandStyle
+ {
+ Default,
+ Apple,
+ };
+ StripCommandStyle GetStripCommandStyle(std::string const& strip);
+
protected:
// for a project collect all its targets by following depend
// information, and also collect all the targets
@@ -737,6 +744,10 @@ private:
std::map<std::string, int> LanguageToLinkerPreference;
std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
+#ifdef __APPLE__
+ std::map<std::string, StripCommandStyle> StripCommandStyleMap;
+#endif
+
mutable bool DiagnosedCxxModuleSupport = false;
// Deferral id generation.
diff --git a/Source/cmInstallRuntimeDependencySetGenerator.cxx b/Source/cmInstallRuntimeDependencySetGenerator.cxx
index 44f03e1..1e2e663 100644
--- a/Source/cmInstallRuntimeDependencySetGenerator.cxx
+++ b/Source/cmInstallRuntimeDependencySetGenerator.cxx
@@ -256,8 +256,7 @@ void cmInstallRuntimeDependencySetGenerator::GenerateStripFixup(
if (!strip.empty()) {
os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n"
<< indent.Next() << "execute_process(COMMAND \"" << strip << "\" ";
- if (this->LocalGenerator->GetMakefile()->GetSafeDefinition(
- "CMAKE_HOST_SYSTEM_NAME") == "Darwin") {
+ if (this->LocalGenerator->GetMakefile()->IsOn("APPLE")) {
os << "-x ";
}
os << "\""
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 9220123..3ac100d 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -828,26 +828,29 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent,
return;
}
- if (!this->Target->Target->GetMakefile()->IsSet("CMAKE_STRIP")) {
+ std::string const& strip =
+ this->Target->Target->GetMakefile()->GetSafeDefinition("CMAKE_STRIP");
+ if (strip.empty()) {
return;
}
std::string stripArgs;
-
- // macOS 'strip' is picky, executables need '-u -r' and dylibs need '-x'.
if (this->Target->IsApple()) {
if (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) {
+ // Strip tools need '-x' to strip Apple dylibs correctly.
stripArgs = "-x ";
- } else if (this->Target->GetType() == cmStateEnums::EXECUTABLE) {
+ } else if (this->Target->GetType() == cmStateEnums::EXECUTABLE &&
+ this->Target->GetGlobalGenerator()->GetStripCommandStyle(
+ strip) == cmGlobalGenerator::StripCommandStyle::Apple) {
+ // Apple's strip tool needs '-u -r' to strip executables correctly.
stripArgs = "-u -r ";
}
}
os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n";
- os << indent << " execute_process(COMMAND \""
- << this->Target->Target->GetMakefile()->GetSafeDefinition("CMAKE_STRIP")
- << "\" " << stripArgs << "\"" << toDestDirPath << "\")\n";
+ os << indent << " execute_process(COMMAND \"" << strip << "\" " << stripArgs
+ << "\"" << toDestDirPath << "\")\n";
os << indent << "endif()\n";
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index fc82c14..3a69b2e 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -340,7 +340,7 @@ void cmMakefile::PrintCommandTrace(cmListFileFunction const& lff,
cm::optional<std::string> const& deferId = bt.Top().DeferId;
switch (this->GetCMakeInstance()->GetTraceFormat()) {
- case cmake::TraceFormat::TRACE_JSON_V1: {
+ case cmake::TraceFormat::JSONv1: {
#ifndef CMAKE_BOOTSTRAP
Json::Value val;
Json::StreamWriterBuilder builder;
@@ -367,7 +367,7 @@ void cmMakefile::PrintCommandTrace(cmListFileFunction const& lff,
#endif
break;
}
- case cmake::TraceFormat::TRACE_HUMAN:
+ case cmake::TraceFormat::Human:
msg << full_path << "(" << lff.Line() << "):";
if (deferId) {
msg << "DEFERRED:" << *deferId << ":";
@@ -379,8 +379,8 @@ void cmMakefile::PrintCommandTrace(cmListFileFunction const& lff,
}
msg << ")";
break;
- case cmake::TraceFormat::TRACE_UNDEFINED:
- msg << "INTERNAL ERROR: Trace format is TRACE_UNDEFINED";
+ case cmake::TraceFormat::Undefined:
+ msg << "INTERNAL ERROR: Trace format is Undefined";
break;
}
diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h
index 010d7e3..24b809b 100644
--- a/Source/cmStateTypes.h
+++ b/Source/cmStateTypes.h
@@ -60,3 +60,14 @@ enum ArtifactType
ImportLibraryArtifact
};
}
+
+namespace cmTraceEnums {
+
+/** \brief Define supported trace formats **/
+enum class TraceOutputFormat
+{
+ Undefined,
+ Human,
+ JSONv1
+};
+};
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index f943415..8dee5cc 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1143,49 +1143,64 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::cout << ".\n";
return true;
} },
- CommandArgument{ "--trace-expand", CommandArgument::Values::Zero,
+ CommandArgument{ "--trace", CommandArgument::Values::Zero,
[](std::string const&, cmake* state) -> bool {
- std::cout << "Running with expanded trace output on.\n";
+ std::cout << "Put cmake in trace mode.\n";
state->SetTrace(true);
- state->SetTraceExpand(true);
+ state->SetTraceExpand(false);
return true;
} },
- CommandArgument{ "--trace-format", CommandArgument::Values::One,
- [](std::string const& value, cmake* state) -> bool {
+ CommandArgument{ "--trace-expand", CommandArgument::Values::Zero,
+ [](std::string const&, cmake* state) -> bool {
+ std::cout << "Put cmake in trace mode, but with "
+ "variables expanded.\n";
state->SetTrace(true);
- const auto traceFormat = StringToTraceFormat(value);
- if (traceFormat == TraceFormat::TRACE_UNDEFINED) {
- cmSystemTools::Error(
- "Invalid format specified for --trace-format. "
- "Valid formats are human, json-v1.");
- return false;
- }
- state->SetTraceFormat(traceFormat);
+ state->SetTraceExpand(true);
return true;
} },
- CommandArgument{ "--trace-source", CommandArgument::Values::One,
- [](std::string const& value, cmake* state) -> bool {
- std::string file(value);
- cmSystemTools::ConvertToUnixSlashes(file);
- state->AddTraceSource(file);
+ CommandArgument{
+ "--trace-format", "Invalid format specified for --trace-format",
+ CommandArgument::Values::One,
+ [](std::string const& value, cmake* state) -> bool {
+ std::cout << "Put cmake in trace mode and sets the "
+ "trace output format.\n";
+ state->SetTrace(true);
+ const auto traceFormat = StringToTraceFormat(value);
+ if (traceFormat == TraceFormat::Undefined) {
+ cmSystemTools::Error("Invalid format specified for --trace-format. "
+ "Valid formats are human, json-v1.");
+ return false;
+ }
+ state->SetTraceFormat(traceFormat);
+ return true;
+ } },
+ CommandArgument{ "--trace-source", "No file specified for --trace-source",
+ CommandArgument::Values::OneOrMore,
+ [](std::string const& values, cmake* state) -> bool {
+ std::cout << "Put cmake in trace mode, but output only "
+ "lines of a specified file. Multiple "
+ "options are allowed.\n";
+ for (auto file :
+ cmSystemTools::SplitString(values, ';')) {
+ cmSystemTools::ConvertToUnixSlashes(file);
+ state->AddTraceSource(file);
+ }
state->SetTrace(true);
return true;
} },
- CommandArgument{ "--trace-redirect", CommandArgument::Values::One,
+ CommandArgument{ "--trace-redirect",
+ "No file specified for --trace-redirect",
+ CommandArgument::Values::One,
[](std::string const& value, cmake* state) -> bool {
+ std::cout
+ << "Put cmake in trace mode and redirect trace "
+ "output to a file instead of stderr.\n";
std::string file(value);
cmSystemTools::ConvertToUnixSlashes(file);
state->SetTraceFile(file);
state->SetTrace(true);
return true;
} },
- CommandArgument{ "--trace", CommandArgument::Values::Zero,
- [](std::string const&, cmake* state) -> bool {
- std::cout << "Running with trace output on.\n";
- state->SetTrace(true);
- state->SetTraceExpand(false);
- return true;
- } },
CommandArgument{ "--warn-uninitialized", CommandArgument::Values::Zero,
[](std::string const&, cmake* state) -> bool {
std::cout << "Warn about uninitialized values.\n";
@@ -1530,6 +1545,29 @@ void cmake::SetArgs(const std::vector<std::string>& args)
if (expandedPreset->DebugFind == true) {
this->SetDebugFindOutput(true);
}
+ if (expandedPreset->TraceMode &&
+ expandedPreset->TraceMode !=
+ cmCMakePresetsGraph::TraceEnableMode::Disable) {
+ this->SetTrace(true);
+ if (expandedPreset->TraceMode ==
+ cmCMakePresetsGraph::TraceEnableMode::Expand) {
+ this->SetTraceExpand(true);
+ }
+ }
+ if (expandedPreset->TraceFormat) {
+ this->SetTrace(true);
+ this->SetTraceFormat(*expandedPreset->TraceFormat);
+ }
+ if (!expandedPreset->TraceSource.empty()) {
+ this->SetTrace(true);
+ for (std::string const& filePaths : expandedPreset->TraceSource) {
+ this->AddTraceSource(filePaths);
+ }
+ }
+ if (!expandedPreset->TraceRedirect.empty()) {
+ this->SetTrace(true);
+ this->SetTraceFile(expandedPreset->TraceRedirect);
+ }
}
#endif
}
@@ -1586,8 +1624,8 @@ cmake::TraceFormat cmake::StringToTraceFormat(const std::string& traceStr)
{
using TracePair = std::pair<std::string, TraceFormat>;
static const std::vector<TracePair> levels = {
- { "human", TraceFormat::TRACE_HUMAN },
- { "json-v1", TraceFormat::TRACE_JSON_V1 },
+ { "human", TraceFormat::Human },
+ { "json-v1", TraceFormat::JSONv1 },
};
const auto traceStrLowCase = cmSystemTools::LowerCase(traceStr);
@@ -1596,7 +1634,7 @@ cmake::TraceFormat cmake::StringToTraceFormat(const std::string& traceStr)
[&traceStrLowCase](const TracePair& p) {
return p.first == traceStrLowCase;
});
- return (it != levels.cend()) ? it->second : TraceFormat::TRACE_UNDEFINED;
+ return (it != levels.cend()) ? it->second : TraceFormat::Undefined;
}
void cmake::SetTraceFile(const std::string& file)
@@ -1622,7 +1660,7 @@ void cmake::PrintTraceFormatVersion()
std::string msg;
switch (this->GetTraceFormat()) {
- case TraceFormat::TRACE_JSON_V1: {
+ case TraceFormat::JSONv1: {
#ifndef CMAKE_BOOTSTRAP
Json::Value val;
Json::Value version;
@@ -1635,11 +1673,11 @@ void cmake::PrintTraceFormatVersion()
#endif
break;
}
- case TraceFormat::TRACE_HUMAN:
+ case TraceFormat::Human:
msg = "";
break;
- case TraceFormat::TRACE_UNDEFINED:
- msg = "INTERNAL ERROR: Trace format is TRACE_UNDEFINED";
+ case TraceFormat::Undefined:
+ msg = "INTERNAL ERROR: Trace format is Undefined";
break;
}
diff --git a/Source/cmake.h b/Source/cmake.h
index d1f388a..0f8f642 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -118,13 +118,7 @@ public:
FIND_PACKAGE_MODE
};
- /** \brief Define supported trace formats **/
- enum TraceFormat
- {
- TRACE_UNDEFINED,
- TRACE_HUMAN,
- TRACE_JSON_V1,
- };
+ using TraceFormat = cmTraceEnums::TraceOutputFormat;
struct GeneratorInfo
{
@@ -719,7 +713,7 @@ private:
bool DebugFindOutput = false;
bool Trace = false;
bool TraceExpand = false;
- TraceFormat TraceFormatVar = TRACE_HUMAN;
+ TraceFormat TraceFormatVar = TraceFormat::Human;
cmGeneratedFileStream TraceFile;
cmake* TraceRedirect = nullptr;
#ifndef CMAKE_BOOTSTRAP
diff --git a/Tests/FindHDF5/CMakeLists.txt b/Tests/FindHDF5/CMakeLists.txt
index 373759e..6bc551a 100644
--- a/Tests/FindHDF5/CMakeLists.txt
+++ b/Tests/FindHDF5/CMakeLists.txt
@@ -25,6 +25,7 @@ add_test(NAME FindHDF5.Default COMMAND
${build_generator_args}
--build-project TestFindHDF5
--build-options ${build_options} -DTEST_SERIAL=1 "-DTEST_LANGS=${test_langs}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
foreach(variant Serial OpenMPI MPICH)
@@ -60,6 +61,7 @@ foreach(variant Serial OpenMPI MPICH)
${build_generator_args}
--build-project TestFindHDF5
--build-options ${build_options} ${test_kind} "-DTEST_LANGS=${wrapper_langs}" ${wrapper}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
if(CMake_TEST_FindHDF5_${variant}_ENVMOD)
set_property(TEST FindHDF5.${variant} PROPERTY ENVIRONMENT_MODIFICATION ${CMake_TEST_FindHDF5_${variant}_ENVMOD})
@@ -76,6 +78,7 @@ foreach(variant Serial OpenMPI MPICH)
${build_generator_args}
--build-project TestFindHDF5
--build-options ${build_options} ${test_kind} "-DTEST_LANGS=${wrapper_langs}" -D TEST_WRAPPER_AS_COMPILER=1 ${wrapper_as_compiler}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
if(CMake_TEST_FindHDF5_${variant}_ENVMOD)
set_property(TEST FindHDF5.${variant}-Wrapper PROPERTY ENVIRONMENT_MODIFICATION ${CMake_TEST_FindHDF5_${variant}_ENVMOD})
diff --git a/Tests/FindHDF5/Test/CMakeLists.txt b/Tests/FindHDF5/Test/CMakeLists.txt
index 53ad633..da1b369 100644
--- a/Tests/FindHDF5/Test/CMakeLists.txt
+++ b/Tests/FindHDF5/Test/CMakeLists.txt
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.26)
project(TestFindHDF5 LANGUAGES ${TEST_LANGS})
+include(CTest)
message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
if(TEST_PARALLEL)
@@ -56,3 +57,50 @@ if(TEST_PARALLEL)
message(SEND_ERROR "HDF5_IS_PARALLEL is false in parallel test.")
endif()
endif()
+
+if(TEST_PARALLEL)
+ set(MPI_CXX_SKIP_MPICXX TRUE)
+ set(MPI_CXX_VALIDATE_SKIP_MPICXX TRUE)
+ find_package(MPI REQUIRED)
+ set(mpi_C_tgt MPI::MPI_C)
+ set(mpi_C_inc ${MPI_C_INCLUDE_PATH})
+ set(mpi_C_lib ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES})
+ set(mpi_Fortran_tgt MPI::MPI_Fortran)
+ set(mpi_Fortran_inc ${MPI_Fortran_INCLUDE_PATH})
+ set(mpi_Fortran_lib ${MPI_Fortran_LIBRARIES})
+endif()
+
+if(CMAKE_C_COMPILER_LOADED)
+ add_executable(test_C_tgt test_C.c)
+ target_link_libraries(test_C_tgt PRIVATE hdf5::hdf5 ${mpi_C_tgt})
+ add_test(NAME test_C_tgt COMMAND test_C_tgt test_C_tgt.h5)
+
+ add_executable(test_C_var test_C.c)
+ target_include_directories(test_C_var PRIVATE ${HDF5_C_INCLUDE_DIRS} ${mpi_C_inc})
+ target_link_libraries(test_C_var PRIVATE ${HDF5_C_LIBRARIES} ${mpi_C_lib})
+ add_test(NAME test_C_var COMMAND test_C_var test_C_var.h5)
+endif()
+
+if(CMAKE_CXX_COMPILER_LOADED)
+ add_executable(test_CXX_tgt test_CXX.cxx)
+ target_link_libraries(test_CXX_tgt PRIVATE hdf5::hdf5_cpp
+ hdf5::hdf5 # FIXME: hdf5::hdf5_cpp should link hdf5::hdf5 automatically.
+ ${mpi_C_tgt})
+ add_test(NAME test_CXX_tgt COMMAND test_CXX_tgt test_CXX_tgt.h5)
+
+ add_executable(test_CXX_var test_CXX.cxx)
+ target_include_directories(test_CXX_var PRIVATE ${HDF5_CXX_INCLUDE_DIRS} ${mpi_C_inc})
+ target_link_libraries(test_CXX_var PRIVATE ${HDF5_CXX_LIBRARIES} ${mpi_C_lib})
+ add_test(NAME test_CXX_var COMMAND test_CXX_var test_CXX_var.h5)
+endif()
+
+if(CMAKE_Fortran_COMPILER_LOADED)
+ add_executable(test_Fortran_tgt test_Fortran.f90)
+ target_link_libraries(test_Fortran_tgt PRIVATE hdf5::hdf5_fortran ${mpi_Fortran_tgt})
+ add_test(NAME test_Fortran_tgt COMMAND test_Fortran_tgt)
+
+ add_executable(test_Fortran_var test_Fortran.f90)
+ target_include_directories(test_Fortran_var PRIVATE ${HDF5_Fortran_INCLUDE_DIRS} ${mpi_Fortran_inc})
+ target_link_libraries(test_Fortran_var PRIVATE ${HDF5_Fortran_LIBRARIES} ${mpi_Fortran_lib})
+ add_test(NAME test_Fortran_var COMMAND test_Fortran_var)
+endif()
diff --git a/Tests/FindHDF5/Test/test_C.c b/Tests/FindHDF5/Test/test_C.c
new file mode 100644
index 0000000..4c18364
--- /dev/null
+++ b/Tests/FindHDF5/Test/test_C.c
@@ -0,0 +1,12 @@
+#include <hdf5.h>
+
+int main(int argc, const char* argv[])
+{
+ hid_t fid;
+ if (argc != 2) {
+ return 1;
+ }
+ fid = H5Fcreate(argv[1], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ H5Fclose(fid);
+ return 0;
+}
diff --git a/Tests/FindHDF5/Test/test_CXX.cxx b/Tests/FindHDF5/Test/test_CXX.cxx
new file mode 100644
index 0000000..93fb462
--- /dev/null
+++ b/Tests/FindHDF5/Test/test_CXX.cxx
@@ -0,0 +1,14 @@
+#include <H5Cpp.h>
+
+#ifndef H5_NO_NAMESPACE
+using namespace H5;
+#endif
+
+int main(int argc, const char* argv[])
+{
+ if (argc != 2) {
+ return 1;
+ }
+ H5File f(argv[1], H5F_ACC_TRUNC);
+ return 0;
+}
diff --git a/Tests/FindHDF5/Test/test_Fortran.f90 b/Tests/FindHDF5/Test/test_Fortran.f90
new file mode 100644
index 0000000..4c12c8c
--- /dev/null
+++ b/Tests/FindHDF5/Test/test_Fortran.f90
@@ -0,0 +1,6 @@
+program hdf5_hello
+ use hdf5
+ integer error
+ call h5open_f(error)
+ call h5close_f(error)
+end
diff --git a/Tests/RunCMake/CMakePresets/ExplicitNoTrace.cmake b/Tests/RunCMake/CMakePresets/ExplicitNoTrace.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/ExplicitNoTrace.cmake
diff --git a/Tests/RunCMake/CMakePresets/NoTrace.cmake b/Tests/RunCMake/CMakePresets/NoTrace.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/NoTrace.cmake
diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
index efa838e..d67e8b1 100644
--- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
@@ -150,6 +150,7 @@ run_cmake_presets(InvalidRegex)
set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
run_cmake_presets(ConditionFuture)
run_cmake_presets(SubConditionNull)
+run_cmake_presets(TraceNotSupported)
# Test cmakeMinimumRequired field
run_cmake_presets(MinimumRequiredInvalid)
@@ -326,6 +327,18 @@ set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Debug.json.in")
run_cmake_presets(NoDebug)
run_cmake_presets(Debug)
+# Test trace
+set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Trace.json.in")
+run_cmake_presets(NoTrace)
+run_cmake_presets(ExplicitNoTrace)
+run_cmake_presets(Trace)
+run_cmake_presets(TraceExpand)
+run_cmake_presets(TraceFormatJSON)
+run_cmake_presets(TraceFormatHuman)
+run_cmake_presets(TraceSource)
+run_cmake_presets(TraceRedirect)
+run_cmake_presets(TraceAll)
+
# Test ${hostSystemName} macro
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/HostSystemName.json.in")
run_cmake_presets(HostSystemName)
diff --git a/Tests/RunCMake/CMakePresets/Trace-stderr.txt b/Tests/RunCMake/CMakePresets/Trace-stderr.txt
new file mode 100644
index 0000000..5ed769c
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/Trace-stderr.txt
@@ -0,0 +1,4 @@
+^[^
+]*/Tests/RunCMake/CMakePresets/Trace/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.18 \)
+[^
+]*/Tests/RunCMake/CMakePresets/Trace/CMakeLists.txt\(2\): project\(\${RunCMake_TEST} NONE \)
diff --git a/Tests/RunCMake/CMakePresets/Trace.cmake b/Tests/RunCMake/CMakePresets/Trace.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/Trace.cmake
diff --git a/Tests/RunCMake/CMakePresets/Trace.json.in b/Tests/RunCMake/CMakePresets/Trace.json.in
new file mode 100644
index 0000000..f50a6f2
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/Trace.json.in
@@ -0,0 +1,69 @@
+{
+ "version": 7,
+ "configurePresets": [
+ {
+ "name": "NoTrace",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build"
+ },
+ {
+ "name": "ExplicitNoTrace",
+ "inherits": "NoTrace",
+ "trace": {
+ "mode": "off"
+ }
+ },
+ {
+ "name": "Trace",
+ "inherits": "NoTrace",
+ "trace": {
+ "mode": "on"
+ }
+ },
+ {
+ "name": "TraceExpand",
+ "inherits": "NoTrace",
+ "trace": {
+ "mode": "expand"
+ }
+ },
+ {
+ "name": "TraceFormatJSON",
+ "inherits": "NoTrace",
+ "trace": {
+ "format": "json-v1"
+ }
+ },
+ {
+ "name": "TraceFormatHuman",
+ "inherits": "NoTrace",
+ "trace": {
+ "format": "human"
+ }
+ },
+ {
+ "name": "TraceSource",
+ "inherits": "NoTrace",
+ "trace": {
+ "source": "TraceSourceFile.txt"
+ }
+ },
+ {
+ "name": "TraceRedirect",
+ "inherits": "NoTrace",
+ "trace": {
+ "redirect": "TraceRedirectFile.txt"
+ }
+ },
+ {
+ "name": "TraceAll",
+ "inherits": "NoTrace",
+ "trace": {
+ "mode": "expand",
+ "format": "json-v1",
+ "source": "TraceSourceFile.txt",
+ "redirect": "TraceRedirectFile.json"
+ }
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresets/TraceAll.cmake b/Tests/RunCMake/CMakePresets/TraceAll.cmake
new file mode 100644
index 0000000..9896ec0
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceAll.cmake
@@ -0,0 +1,4 @@
+include(${CMAKE_CURRENT_LIST_DIR}/TraceExpand.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/TraceFormatJSON.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/TraceSource.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/TraceRedirect.cmake)
diff --git a/Tests/RunCMake/CMakePresets/TraceExpand-stderr.txt b/Tests/RunCMake/CMakePresets/TraceExpand-stderr.txt
new file mode 100644
index 0000000..7ee4fea
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceExpand-stderr.txt
@@ -0,0 +1,4 @@
+^[^
+]*/Tests/RunCMake/CMakePresets/TraceExpand/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.18 \)
+[^
+]*/Tests/RunCMake/CMakePresets/TraceExpand/CMakeLists.txt\(2\): project\(TraceExpand NONE \)
diff --git a/Tests/RunCMake/CMakePresets/TraceExpand.cmake b/Tests/RunCMake/CMakePresets/TraceExpand.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceExpand.cmake
diff --git a/Tests/RunCMake/CMakePresets/TraceFormatHuman-stderr.txt b/Tests/RunCMake/CMakePresets/TraceFormatHuman-stderr.txt
new file mode 100644
index 0000000..1d3450d
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceFormatHuman-stderr.txt
@@ -0,0 +1,4 @@
+^[^
+]*/Tests/RunCMake/CMakePresets/TraceFormatHuman/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.18 \)
+[^
+]*/Tests/RunCMake/CMakePresets/TraceFormatHuman/CMakeLists.txt\(2\): project\(\${RunCMake_TEST} NONE \)
diff --git a/Tests/RunCMake/CMakePresets/TraceFormatHuman.cmake b/Tests/RunCMake/CMakePresets/TraceFormatHuman.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceFormatHuman.cmake
diff --git a/Tests/RunCMake/CMakePresets/TraceFormatJSON-stderr.txt b/Tests/RunCMake/CMakePresets/TraceFormatJSON-stderr.txt
new file mode 100644
index 0000000..edf044c
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceFormatJSON-stderr.txt
@@ -0,0 +1,3 @@
+^{"version":{"major":1,"minor":2}}
+{"args":\["VERSION","3\.18"\],"cmd":"cmake_minimum_required","file":"[^"]*/Tests/RunCMake/CMakePresets/TraceFormatJSON/CMakeLists\.txt","frame":1,"global_frame":1,"line":1,"time":[0-9.]+}
+{"args":\["\${RunCMake_TEST}","NONE"\],"cmd":"project","file":"[^"]*/Tests/RunCMake/CMakePresets/TraceFormatJSON/CMakeLists\.txt","frame":1,"global_frame":1,"line":2,"time":[0-9.]+}
diff --git a/Tests/RunCMake/CMakePresets/TraceFormatJSON.cmake b/Tests/RunCMake/CMakePresets/TraceFormatJSON.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceFormatJSON.cmake
diff --git a/Tests/RunCMake/CMakePresets/TraceNotSupported-result.txt b/Tests/RunCMake/CMakePresets/TraceNotSupported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceNotSupported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePresets/TraceNotSupported-stderr.txt b/Tests/RunCMake/CMakePresets/TraceNotSupported-stderr.txt
new file mode 100644
index 0000000..de19a8c
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceNotSupported-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Error: Could not read presets from [^
+]*/Tests/RunCMake/CMakePresets/TraceNotSupported:
+File version must be 7 or higher for trace preset support$
diff --git a/Tests/RunCMake/CMakePresets/TraceNotSupported.json.in b/Tests/RunCMake/CMakePresets/TraceNotSupported.json.in
new file mode 100644
index 0000000..f3d3fbd
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceNotSupported.json.in
@@ -0,0 +1,13 @@
+{
+ "version": 6,
+ "configurePresets": [
+ {
+ "name": "TraceNotSupported",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build",
+ "trace": {
+ "mode": "expand"
+ }
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresets/TraceRedirect.cmake b/Tests/RunCMake/CMakePresets/TraceRedirect.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceRedirect.cmake
diff --git a/Tests/RunCMake/CMakePresets/TraceSource.cmake b/Tests/RunCMake/CMakePresets/TraceSource.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/TraceSource.cmake