From 8617479061039e2b357b7efc922f1b88648dce42 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 29 Sep 2020 10:17:10 -0400 Subject: CMake: Add presets functionality --- Source/cmCMakePresetsFile.cxx | 4 +- Source/cmCMakePresetsFile.h | 8 +- Source/cmake.cxx | 339 +++++++++++++-- Source/cmake.h | 54 ++- Source/cmakemain.cxx | 7 +- Tests/RunCMake/CMakeLists.txt | 1 + .../CMakeGeneratorConfigDefault-result.txt | 1 + .../CMakeGeneratorConfigDefault-stderr.txt | 11 + .../CMakePresets/CMakeGeneratorConfigIgnore.cmake | 0 .../CMakeGeneratorConfigNone-result.txt | 1 + .../CMakeGeneratorConfigNone-stderr.txt | 11 + Tests/RunCMake/CMakePresets/CMakeLists.txt.in | 4 + Tests/RunCMake/CMakePresets/CMakePresets.json.in | 481 +++++++++++++++++++++ Tests/RunCMake/CMakePresets/CacheOverride.cmake | 2 + .../CMakePresets/CyclicInheritance0-result.txt | 1 + .../CMakePresets/CyclicInheritance0-stderr.txt | 2 + .../CMakePresets/CyclicInheritance0.json.in | 13 + .../CMakePresets/CyclicInheritance1-result.txt | 1 + .../CMakePresets/CyclicInheritance1-stderr.txt | 2 + .../CMakePresets/CyclicInheritance1.json.in | 21 + .../CMakePresets/CyclicInheritance2-result.txt | 1 + .../CMakePresets/CyclicInheritance2-stderr.txt | 2 + .../CMakePresets/CyclicInheritance2.json.in | 29 ++ Tests/RunCMake/CMakePresets/Debug-stderr.txt | 1 + Tests/RunCMake/CMakePresets/Debug-stdout.txt | 4 + Tests/RunCMake/CMakePresets/Debug.cmake | 4 + Tests/RunCMake/CMakePresets/Debug.json.in | 19 + Tests/RunCMake/CMakePresets/DebugBase.cmake | 3 + .../CMakePresets/DisableWarningFlags.cmake | 1 + .../CMakePresets/DuplicatePresets-result.txt | 1 + .../CMakePresets/DuplicatePresets-stderr.txt | 2 + .../RunCMake/CMakePresets/DuplicatePresets.json.in | 15 + .../CMakePresets/EmptyPresetName-result.txt | 1 + .../CMakePresets/EmptyPresetName-stderr.txt | 2 + .../RunCMake/CMakePresets/EmptyPresetName.json.in | 10 + Tests/RunCMake/CMakePresets/EnvCycle-result.txt | 1 + Tests/RunCMake/CMakePresets/EnvCycle-stderr.txt | 1 + .../CMakePresets/ErrorDeprecated-result.txt | 1 + .../CMakePresets/ErrorDeprecated-stderr.txt | 7 + Tests/RunCMake/CMakePresets/ErrorDeprecated.cmake | 1 + Tests/RunCMake/CMakePresets/ErrorDev-result.txt | 1 + Tests/RunCMake/CMakePresets/ErrorDev-stderr.txt | 8 + Tests/RunCMake/CMakePresets/ErrorDev.cmake | 1 + .../ErrorNoWarningDeprecated-result.txt | 1 + .../ErrorNoWarningDeprecated-stderr.txt | 2 + .../CMakePresets/ErrorNoWarningDeprecated.json.in | 16 + .../CMakePresets/ErrorNoWarningDev-result.txt | 1 + .../CMakePresets/ErrorNoWarningDev-stderr.txt | 2 + .../CMakePresets/ErrorNoWarningDev.json.in | 16 + .../CMakePresets/ExtraPresetField-result.txt | 1 + .../CMakePresets/ExtraPresetField-stderr.txt | 2 + .../RunCMake/CMakePresets/ExtraPresetField.json.in | 11 + .../CMakePresets/ExtraRootField-result.txt | 1 + .../CMakePresets/ExtraRootField-stderr.txt | 2 + Tests/RunCMake/CMakePresets/ExtraRootField.json.in | 11 + .../CMakePresets/ExtraVariableField-result.txt | 1 + .../CMakePresets/ExtraVariableField-stderr.txt | 2 + .../CMakePresets/ExtraVariableField.json.in | 16 + Tests/RunCMake/CMakePresets/Good-stdout.txt | 46 ++ Tests/RunCMake/CMakePresets/Good.cmake | 45 ++ Tests/RunCMake/CMakePresets/GoodBOM.cmake | 0 Tests/RunCMake/CMakePresets/GoodBOM.json.in | 10 + .../RunCMake/CMakePresets/GoodBinaryCmdLine.cmake | 4 + .../RunCMake/CMakePresets/GoodBinaryRelative.cmake | 3 + Tests/RunCMake/CMakePresets/GoodBinaryUp.cmake | 4 + .../CMakePresets/GoodGeneratorCmdLine.cmake | 3 + .../CMakePresets/GoodInheritanceChild.cmake | 6 + .../CMakePresets/GoodInheritanceMacro.cmake | 3 + .../CMakePresets/GoodInheritanceMulti.cmake | 10 + .../CMakePresets/GoodInheritanceMultiSecond.cmake | 3 + .../CMakePresets/GoodInheritanceOverride.cmake | 18 + .../CMakePresets/GoodInheritanceParent.cmake | 6 + Tests/RunCMake/CMakePresets/GoodNoArgs.cmake | 0 Tests/RunCMake/CMakePresets/GoodNoS.cmake | 4 + Tests/RunCMake/CMakePresets/GoodSpaces.cmake | 0 Tests/RunCMake/CMakePresets/GoodUserFromMain.cmake | 0 .../RunCMake/CMakePresets/GoodUserFromMain.json.in | 10 + .../CMakePresets/GoodUserFromMainUser.json.in | 4 + Tests/RunCMake/CMakePresets/GoodUserFromUser.cmake | 0 .../RunCMake/CMakePresets/GoodUserFromUser.json.in | 4 + .../CMakePresets/GoodUserFromUserUser.json.in | 10 + Tests/RunCMake/CMakePresets/GoodUserOnly.cmake | 0 .../RunCMake/CMakePresets/GoodUserOnlyUser.json.in | 10 + .../CMakePresets/GoodWindowsBackslash.cmake | 0 Tests/RunCMake/CMakePresets/HighVersion-result.txt | 1 + Tests/RunCMake/CMakePresets/HighVersion-stderr.txt | 2 + Tests/RunCMake/CMakePresets/HighVersion.json.in | 4 + .../InvalidCMakeGeneratorConfig-result.txt | 1 + .../InvalidCMakeGeneratorConfig-stderr.txt | 2 + .../InvalidCMakeGeneratorConfig.json.in | 11 + .../CMakePresets/InvalidGenerator-result.txt | 1 + .../CMakePresets/InvalidGenerator-stderr.txt | 3 + .../InvalidGeneratorCmdLine-result.txt | 1 + .../InvalidGeneratorCmdLine-stderr.txt | 3 + .../CMakePresets/InvalidInheritance-result.txt | 1 + .../CMakePresets/InvalidInheritance-stderr.txt | 2 + .../CMakePresets/InvalidInheritance.json.in | 13 + .../CMakePresets/InvalidPresetBinaryDir-result.txt | 1 + .../CMakePresets/InvalidPresetBinaryDir-stderr.txt | 2 + .../CMakePresets/InvalidPresetBinaryDir.json.in | 10 + .../CMakePresets/InvalidPresetGenerator-result.txt | 1 + .../CMakePresets/InvalidPresetGenerator-stderr.txt | 2 + .../CMakePresets/InvalidPresetGenerator.json.in | 10 + .../CMakePresets/InvalidPresetName-result.txt | 1 + .../CMakePresets/InvalidPresetName-stderr.txt | 2 + .../CMakePresets/InvalidPresetName.json.in | 10 + .../CMakePresets/InvalidPresetVendor-result.txt | 1 + .../CMakePresets/InvalidPresetVendor-stderr.txt | 2 + .../CMakePresets/InvalidPresetVendor.json.in | 11 + .../CMakePresets/InvalidPresets-result.txt | 1 + .../CMakePresets/InvalidPresets-stderr.txt | 2 + Tests/RunCMake/CMakePresets/InvalidPresets.json.in | 4 + Tests/RunCMake/CMakePresets/InvalidRoot-result.txt | 1 + Tests/RunCMake/CMakePresets/InvalidRoot-stderr.txt | 2 + Tests/RunCMake/CMakePresets/InvalidRoot.json.in | 1 + .../CMakePresets/InvalidVariableValue-result.txt | 1 + .../CMakePresets/InvalidVariableValue-stderr.txt | 2 + .../CMakePresets/InvalidVariableValue.json.in | 15 + .../CMakePresets/InvalidVariables-result.txt | 1 + .../CMakePresets/InvalidVariables-stderr.txt | 2 + .../RunCMake/CMakePresets/InvalidVariables.json.in | 11 + .../RunCMake/CMakePresets/InvalidVendor-result.txt | 1 + .../RunCMake/CMakePresets/InvalidVendor-stderr.txt | 2 + Tests/RunCMake/CMakePresets/InvalidVendor.json.in | 5 + .../CMakePresets/InvalidVersion-result.txt | 1 + .../CMakePresets/InvalidVersion-stderr.txt | 2 + Tests/RunCMake/CMakePresets/InvalidVersion.json.in | 4 + .../CMakePresets/JSONParseError-result.txt | 1 + .../CMakePresets/JSONParseError-stderr.txt | 2 + Tests/RunCMake/CMakePresets/JSONParseError.json.in | 0 Tests/RunCMake/CMakePresets/ListPresets-stdout.txt | 6 + Tests/RunCMake/CMakePresets/ListPresets.json.in | 36 ++ .../CMakePresets/ListPresetsHidden-result.txt | 1 + .../CMakePresets/ListPresetsHidden-stderr.txt | 2 + .../CMakePresets/ListPresetsHidden-stdout.txt | 6 + .../ListPresetsNoSuchPreset-result.txt | 1 + .../ListPresetsNoSuchPreset-stderr.txt | 2 + .../ListPresetsNoSuchPreset-stdout.txt | 6 + .../CMakePresets/ListPresetsWorkingDir-stdout.txt | 6 + Tests/RunCMake/CMakePresets/LowVersion-result.txt | 1 + Tests/RunCMake/CMakePresets/LowVersion-stderr.txt | 2 + Tests/RunCMake/CMakePresets/LowVersion.json.in | 4 + .../CMakePresets/MinimumRequiredEmpty.cmake | 0 .../CMakePresets/MinimumRequiredEmpty.json.in | 11 + .../CMakePresets/MinimumRequiredInvalid-result.txt | 1 + .../CMakePresets/MinimumRequiredInvalid-stderr.txt | 2 + .../CMakePresets/MinimumRequiredInvalid.json.in | 11 + .../CMakePresets/MinimumRequiredMajor-result.txt | 1 + .../CMakePresets/MinimumRequiredMajor-stderr.txt | 2 + .../CMakePresets/MinimumRequiredMajor.json.in | 13 + .../CMakePresets/MinimumRequiredMinor-result.txt | 1 + .../CMakePresets/MinimumRequiredMinor-stderr.txt | 2 + .../CMakePresets/MinimumRequiredMinor.json.in | 14 + .../CMakePresets/MinimumRequiredPatch-result.txt | 1 + .../CMakePresets/MinimumRequiredPatch-stderr.txt | 2 + .../CMakePresets/MinimumRequiredPatch.json.in | 15 + .../CMakePresets/NoCMakePresets-result.txt | 1 + .../CMakePresets/NoCMakePresets-stderr.txt | 2 + Tests/RunCMake/CMakePresets/NoDebug-stdout.txt | 2 + Tests/RunCMake/CMakePresets/NoDebug.cmake | 4 + .../CMakePresets/NoPresetArgument-result.txt | 1 + .../CMakePresets/NoPresetArgument-stderr.txt | 1 + .../CMakePresets/NoPresetBinaryDir-result.txt | 1 + .../CMakePresets/NoPresetBinaryDir-stderr.txt | 2 + .../CMakePresets/NoPresetBinaryDir.json.in | 9 + .../CMakePresets/NoPresetGenerator-result.txt | 1 + .../CMakePresets/NoPresetGenerator-stderr.txt | 2 + .../CMakePresets/NoPresetGenerator.json.in | 9 + .../RunCMake/CMakePresets/NoPresetName-result.txt | 1 + .../RunCMake/CMakePresets/NoPresetName-stderr.txt | 2 + Tests/RunCMake/CMakePresets/NoPresetName.json.in | 9 + Tests/RunCMake/CMakePresets/NoPresets-result.txt | 1 + Tests/RunCMake/CMakePresets/NoPresets-stderr.txt | 2 + Tests/RunCMake/CMakePresets/NoPresets-stdout.txt | 1 + Tests/RunCMake/CMakePresets/NoPresets.json.in | 3 + Tests/RunCMake/CMakePresets/NoSuchMacro-result.txt | 1 + Tests/RunCMake/CMakePresets/NoSuchMacro-stderr.txt | 1 + .../RunCMake/CMakePresets/NoSuchPreset-result.txt | 1 + .../RunCMake/CMakePresets/NoSuchPreset-stderr.txt | 2 + .../CMakePresets/NoVariableValue-result.txt | 1 + .../CMakePresets/NoVariableValue-stderr.txt | 2 + .../RunCMake/CMakePresets/NoVariableValue.json.in | 13 + Tests/RunCMake/CMakePresets/NoVersion-result.txt | 1 + Tests/RunCMake/CMakePresets/NoVersion-stderr.txt | 2 + Tests/RunCMake/CMakePresets/NoVersion.json.in | 3 + .../CMakePresets/NoWarningFlags-stderr.txt | 23 + Tests/RunCMake/CMakePresets/NoWarningFlags.cmake | 1 + .../CMakePresets/PresetNotObject-result.txt | 1 + .../CMakePresets/PresetNotObject-stderr.txt | 2 + .../RunCMake/CMakePresets/PresetNotObject.json.in | 6 + Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 212 +++++++++ Tests/RunCMake/CMakePresets/TestVariable.cmake | 25 ++ .../RunCMake/CMakePresets/UnclosedMacro-result.txt | 1 + .../RunCMake/CMakePresets/UnclosedMacro-stderr.txt | 1 + .../UnknownCMakeGeneratorConfig-result.txt | 1 + .../UnknownCMakeGeneratorConfig-stderr.txt | 2 + .../UnknownCMakeGeneratorConfig.json.in | 11 + .../CMakePresets/UseHiddenPreset-result.txt | 1 + .../CMakePresets/UseHiddenPreset-stderr.txt | 2 + .../CMakePresets/UserDuplicateCross-result.txt | 1 + .../CMakePresets/UserDuplicateCross-stderr.txt | 2 + .../CMakePresets/UserDuplicateCross.json.in | 10 + .../CMakePresets/UserDuplicateCrossUser.json.in | 10 + .../CMakePresets/UserDuplicateInUser-result.txt | 1 + .../CMakePresets/UserDuplicateInUser-stderr.txt | 2 + .../CMakePresets/UserDuplicateInUserUser.json.in | 15 + .../CMakePresets/UserInheritance-result.txt | 1 + .../CMakePresets/UserInheritance-stderr.txt | 2 + .../RunCMake/CMakePresets/UserInheritance.json.in | 13 + .../CMakePresets/UserInheritanceUser.json.in | 10 + .../CMakePresets/VariableNotObject-result.txt | 1 + .../CMakePresets/VariableNotObject-stderr.txt | 2 + .../CMakePresets/VariableNotObject.json.in | 13 + Tests/RunCMake/CMakePresets/VendorMacro-result.txt | 1 + Tests/RunCMake/CMakePresets/VendorMacro-stderr.txt | 1 + .../VisualStudioGeneratorArch-result.txt | 1 + .../VisualStudioGeneratorArch-stderr.txt | 5 + .../VisualStudioInheritanceChild.cmake | 4 + .../VisualStudioInheritanceMulti.cmake | 4 + .../VisualStudioInheritanceMultiSecond.cmake | 4 + .../VisualStudioInheritanceOverride.cmake | 4 + .../VisualStudioInheritanceParent.cmake | 4 + .../CMakePresets/VisualStudioToolset.cmake | 3 + .../CMakePresets/VisualStudioToolsetOverride.cmake | 3 + .../RunCMake/CMakePresets/VisualStudioWin32.cmake | 3 + .../CMakePresets/VisualStudioWin32Override.cmake | 3 + .../RunCMake/CMakePresets/VisualStudioWin64.cmake | 3 + .../RunCMake/CMakePresets/WarningFlags-stderr.txt | 34 ++ Tests/RunCMake/CMakePresets/WarningFlags.cmake | 1 + Tests/RunCMake/CMakePresets/Warnings.json.in | 50 +++ Tests/RunCMake/CMakePresets/WarningsBase.cmake | 3 + Tests/RunCMake/CMakePresets/main.c | 4 + Tests/RunCMake/CommandLine/NoArgs-stdout.txt | 1 + 233 files changed, 2219 insertions(+), 46 deletions(-) create mode 100644 Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-result.txt create mode 100644 Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/CMakeGeneratorConfigIgnore.cmake create mode 100644 Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-result.txt create mode 100644 Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/CMakeLists.txt.in create mode 100644 Tests/RunCMake/CMakePresets/CMakePresets.json.in create mode 100644 Tests/RunCMake/CMakePresets/CacheOverride.cmake create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance0-result.txt create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance0-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance0.json.in create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance1-result.txt create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance1-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance1.json.in create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance2-result.txt create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance2-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/CyclicInheritance2.json.in create mode 100644 Tests/RunCMake/CMakePresets/Debug-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/Debug-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/Debug.cmake create mode 100644 Tests/RunCMake/CMakePresets/Debug.json.in create mode 100644 Tests/RunCMake/CMakePresets/DebugBase.cmake create mode 100644 Tests/RunCMake/CMakePresets/DisableWarningFlags.cmake create mode 100644 Tests/RunCMake/CMakePresets/DuplicatePresets-result.txt create mode 100644 Tests/RunCMake/CMakePresets/DuplicatePresets-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/DuplicatePresets.json.in create mode 100644 Tests/RunCMake/CMakePresets/EmptyPresetName-result.txt create mode 100644 Tests/RunCMake/CMakePresets/EmptyPresetName-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/EmptyPresetName.json.in create mode 100644 Tests/RunCMake/CMakePresets/EnvCycle-result.txt create mode 100644 Tests/RunCMake/CMakePresets/EnvCycle-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorDeprecated-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorDeprecated-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorDeprecated.cmake create mode 100644 Tests/RunCMake/CMakePresets/ErrorDev-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorDev-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorDev.cmake create mode 100644 Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated.json.in create mode 100644 Tests/RunCMake/CMakePresets/ErrorNoWarningDev-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorNoWarningDev-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ErrorNoWarningDev.json.in create mode 100644 Tests/RunCMake/CMakePresets/ExtraPresetField-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ExtraPresetField-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ExtraPresetField.json.in create mode 100644 Tests/RunCMake/CMakePresets/ExtraRootField-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ExtraRootField-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ExtraRootField.json.in create mode 100644 Tests/RunCMake/CMakePresets/ExtraVariableField-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ExtraVariableField-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ExtraVariableField.json.in create mode 100644 Tests/RunCMake/CMakePresets/Good-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/Good.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodBOM.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodBOM.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodBinaryCmdLine.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodBinaryRelative.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodBinaryUp.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodGeneratorCmdLine.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInheritanceChild.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInheritanceMacro.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInheritanceMulti.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInheritanceMultiSecond.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInheritanceOverride.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInheritanceParent.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodNoArgs.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodNoS.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodSpaces.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodUserFromMain.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodUserFromMain.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodUserFromMainUser.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodUserFromUser.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodUserFromUser.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodUserFromUserUser.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodUserOnly.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodUserOnlyUser.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodWindowsBackslash.cmake create mode 100644 Tests/RunCMake/CMakePresets/HighVersion-result.txt create mode 100644 Tests/RunCMake/CMakePresets/HighVersion-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/HighVersion.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidGenerator-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidGenerator-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidInheritance-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidInheritance-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidInheritance.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetGenerator-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetGenerator-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetGenerator.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetName-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetName-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetName.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetVendor-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetVendor-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresetVendor.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresets-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresets-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidPresets.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidRoot-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidRoot-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidRoot.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidVariableValue-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVariableValue-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVariableValue.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidVariables-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVariables-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVariables.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidVendor-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVendor-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVendor.json.in create mode 100644 Tests/RunCMake/CMakePresets/InvalidVersion-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVersion-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidVersion.json.in create mode 100644 Tests/RunCMake/CMakePresets/JSONParseError-result.txt create mode 100644 Tests/RunCMake/CMakePresets/JSONParseError-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/JSONParseError.json.in create mode 100644 Tests/RunCMake/CMakePresets/ListPresets-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/ListPresets.json.in create mode 100644 Tests/RunCMake/CMakePresets/ListPresetsHidden-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ListPresetsHidden-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ListPresetsHidden-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/ListPresetsWorkingDir-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/LowVersion-result.txt create mode 100644 Tests/RunCMake/CMakePresets/LowVersion-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/LowVersion.json.in create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.cmake create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.json.in create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-result.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredInvalid.json.in create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredMajor-result.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredMajor-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredMajor.json.in create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredMinor-result.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredMinor-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredMinor.json.in create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredPatch-result.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredPatch-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/MinimumRequiredPatch.json.in create mode 100644 Tests/RunCMake/CMakePresets/NoCMakePresets-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoCMakePresets-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoDebug-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/NoDebug.cmake create mode 100644 Tests/RunCMake/CMakePresets/NoPresetArgument-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetArgument-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetBinaryDir-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetBinaryDir-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetBinaryDir.json.in create mode 100644 Tests/RunCMake/CMakePresets/NoPresetGenerator-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetGenerator-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetGenerator.json.in create mode 100644 Tests/RunCMake/CMakePresets/NoPresetName-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetName-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresetName.json.in create mode 100644 Tests/RunCMake/CMakePresets/NoPresets-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresets-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresets-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/NoPresets.json.in create mode 100644 Tests/RunCMake/CMakePresets/NoSuchMacro-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoSuchMacro-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoSuchPreset-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoSuchPreset-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoVariableValue-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoVariableValue-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoVariableValue.json.in create mode 100644 Tests/RunCMake/CMakePresets/NoVersion-result.txt create mode 100644 Tests/RunCMake/CMakePresets/NoVersion-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoVersion.json.in create mode 100644 Tests/RunCMake/CMakePresets/NoWarningFlags-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/NoWarningFlags.cmake create mode 100644 Tests/RunCMake/CMakePresets/PresetNotObject-result.txt create mode 100644 Tests/RunCMake/CMakePresets/PresetNotObject-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/PresetNotObject.json.in create mode 100644 Tests/RunCMake/CMakePresets/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CMakePresets/TestVariable.cmake create mode 100644 Tests/RunCMake/CMakePresets/UnclosedMacro-result.txt create mode 100644 Tests/RunCMake/CMakePresets/UnclosedMacro-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-result.txt create mode 100644 Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig.json.in create mode 100644 Tests/RunCMake/CMakePresets/UseHiddenPreset-result.txt create mode 100644 Tests/RunCMake/CMakePresets/UseHiddenPreset-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/UserDuplicateCross-result.txt create mode 100644 Tests/RunCMake/CMakePresets/UserDuplicateCross-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/UserDuplicateCross.json.in create mode 100644 Tests/RunCMake/CMakePresets/UserDuplicateCrossUser.json.in create mode 100644 Tests/RunCMake/CMakePresets/UserDuplicateInUser-result.txt create mode 100644 Tests/RunCMake/CMakePresets/UserDuplicateInUser-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/UserDuplicateInUserUser.json.in create mode 100644 Tests/RunCMake/CMakePresets/UserInheritance-result.txt create mode 100644 Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/UserInheritance.json.in create mode 100644 Tests/RunCMake/CMakePresets/UserInheritanceUser.json.in create mode 100644 Tests/RunCMake/CMakePresets/VariableNotObject-result.txt create mode 100644 Tests/RunCMake/CMakePresets/VariableNotObject-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/VariableNotObject.json.in create mode 100644 Tests/RunCMake/CMakePresets/VendorMacro-result.txt create mode 100644 Tests/RunCMake/CMakePresets/VendorMacro-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-result.txt create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioInheritanceChild.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioInheritanceMulti.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioInheritanceMultiSecond.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioInheritanceOverride.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioInheritanceParent.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioToolset.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioToolsetOverride.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioWin32.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioWin32Override.cmake create mode 100644 Tests/RunCMake/CMakePresets/VisualStudioWin64.cmake create mode 100644 Tests/RunCMake/CMakePresets/WarningFlags-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/WarningFlags.cmake create mode 100644 Tests/RunCMake/CMakePresets/Warnings.json.in create mode 100644 Tests/RunCMake/CMakePresets/WarningsBase.cmake create mode 100644 Tests/RunCMake/CMakePresets/main.c diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index 0c77768..25997fd 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -94,7 +94,7 @@ ReadFileResult VariableHelper(cm::optional& out, return ReadFileResult::READ_OK; } if (value->isObject()) { - out = CacheVariable{}; + out.emplace(); return VariableObjectHelper(*out, value); } if (value->isNull()) { @@ -701,7 +701,7 @@ cmCMakePresetsFile::ExpandMacros(const UnexpandedPreset& preset) const } } - return retval; + return cm::make_optional(retval); } cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsFile.h index 17f6a88..70ec4c5 100644 --- a/Source/cmCMakePresetsFile.h +++ b/Source/cmCMakePresetsFile.h @@ -30,16 +30,16 @@ public: public: #if __cplusplus < 201703L && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L) Preset() = default; - Preset(const Preset& other) = default; - Preset(Preset&& other) = default; + Preset(const Preset& /*other*/) = default; + Preset(Preset&& /*other*/) = default; - Preset& operator=(const Preset& other) = default; + Preset& operator=(const Preset& /*other*/) = default; // The move assignment operators for several STL classes did not become // noexcept until C++17, which causes some tools to warn about this move // assignment operator throwing an exception when it shouldn't. Disable the // move assignment operator until C++17 is enabled. - Preset& operator=(Preset&& other) = delete; + Preset& operator=(Preset&& /*other*/) = delete; #endif std::string Name; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9f84378..74701cf 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -13,6 +13,7 @@ #include #include +#include #include #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) # include @@ -27,6 +28,7 @@ #include "cm_sys_stat.h" +#include "cmCMakePresetsFile.h" #include "cmCommands.h" #include "cmDocumentation.h" #include "cmDocumentationEntry.h" @@ -286,6 +288,97 @@ void cmake::CleanupCommandsAndMacros() this->CurrentSnapshot.SetDefaultDefinitions(); } +#ifndef CMAKE_BOOTSTRAP +void cmake::SetWarningFromPreset(const std::string& name, + const cm::optional& warning, + const cm::optional& error) +{ + if (warning) { + if (*warning) { + this->DiagLevels[name] = std::max(this->DiagLevels[name], DIAG_WARN); + } else { + this->DiagLevels[name] = DIAG_IGNORE; + } + } + if (error) { + if (*error) { + this->DiagLevels[name] = DIAG_ERROR; + } else { + this->DiagLevels[name] = std::min(this->DiagLevels[name], DIAG_WARN); + } + } +} + +void cmake::ProcessPresetVariables() +{ + for (auto const& var : this->UnprocessedPresetVariables) { + if (!var.second) { + continue; + } + cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED; + if (!var.second->Type.empty()) { + type = cmState::StringToCacheEntryType(var.second->Type); + } + this->ProcessCacheArg(var.first, var.second->Value, type); + } +} + +void cmake::PrintPresetVariables() +{ + bool first = true; + for (auto const& var : this->UnprocessedPresetVariables) { + if (!var.second) { + continue; + } + cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED; + if (!var.second->Type.empty()) { + type = cmState::StringToCacheEntryType(var.second->Type); + } + if (first) { + std::cout << "Preset CMake variables:\n\n"; + first = false; + } + std::cout << " " << var.first; + if (type != cmStateEnums::UNINITIALIZED) { + std::cout << ':' << cmState::CacheEntryTypeToString(type); + } + std::cout << "=\"" << var.second->Value << "\"\n"; + } + if (!first) { + std::cout << '\n'; + } + this->UnprocessedPresetVariables.clear(); +} + +void cmake::ProcessPresetEnvironment() +{ + for (auto const& var : this->UnprocessedPresetEnvironment) { + if (var.second) { + cmSystemTools::PutEnv(cmStrCat(var.first, '=', *var.second)); + } + } +} + +void cmake::PrintPresetEnvironment() +{ + bool first = true; + for (auto const& var : this->UnprocessedPresetEnvironment) { + if (!var.second) { + continue; + } + if (first) { + std::cout << "Preset environment variables:\n\n"; + first = false; + } + std::cout << " " << var.first << "=\"" << *var.second << "\"\n"; + } + if (!first) { + std::cout << '\n'; + } + this->UnprocessedPresetEnvironment.clear(); +} +#endif + // Parse the args bool cmake::SetCacheArgs(const std::vector& args) { @@ -308,28 +401,10 @@ bool cmake::SetCacheArgs(const std::vector& args) std::string value; cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED; if (cmState::ParseCacheEntry(entry, var, value, type)) { - // The value is transformed if it is a filepath for example, so - // we can't compare whether the value is already in the cache until - // after we call AddCacheEntry. - bool haveValue = false; - std::string cachedValue; - if (this->WarnUnusedCli) { - if (cmProp v = this->State->GetInitializedCacheValue(var)) { - haveValue = true; - cachedValue = *v; - } - } - - this->AddCacheEntry(var, value.c_str(), - "No help, variable specified on the command line.", - type); - - if (this->WarnUnusedCli) { - if (!haveValue || - cachedValue != *this->State->GetInitializedCacheValue(var)) { - this->WatchUnusedCli(var); - } - } +#ifndef CMAKE_BOOTSTRAP + this->UnprocessedPresetVariables.erase(var); +#endif + this->ProcessCacheArg(var, value, type); } else { cmSystemTools::Error("Parse error in command line argument: " + arg + "\n" + "Should be: VAR:type=value\n"); @@ -409,6 +484,9 @@ bool cmake::SetCacheArgs(const std::vector& args) // now remove them from the cache for (std::string const& currentEntry : entriesToDelete) { +#ifndef CMAKE_BOOTSTRAP + this->UnprocessedPresetVariables.erase(currentEntry); +#endif this->State->RemoveCacheEntry(currentEntry); } } else if (cmHasLiteralPrefix(arg, "-C")) { @@ -462,6 +540,33 @@ bool cmake::SetCacheArgs(const std::vector& args) return true; } +void cmake::ProcessCacheArg(const std::string& var, const std::string& value, + cmStateEnums::CacheEntryType type) +{ + // The value is transformed if it is a filepath for example, so + // we can't compare whether the value is already in the cache until + // after we call AddCacheEntry. + bool haveValue = false; + std::string cachedValue; + if (this->WarnUnusedCli) { + if (cmProp v = this->State->GetInitializedCacheValue(var)) { + haveValue = true; + cachedValue = *v; + } + } + + this->AddCacheEntry(var, value.c_str(), + "No help, variable specified on the command line.", + type); + + if (this->WarnUnusedCli) { + if (!haveValue || + cachedValue != *this->State->GetInitializedCacheValue(var)) { + this->WatchUnusedCli(var); + } + } +} + void cmake::ReadListFile(const std::vector& args, const std::string& path) { @@ -625,6 +730,8 @@ void cmake::SetArgs(const std::vector& args) #if !defined(CMAKE_BOOTSTRAP) std::string profilingFormat; std::string profilingOutput; + std::string presetName; + bool listPresets = false; #endif for (unsigned int i = 1; i < args.size(); ++i) { std::string const& arg = args[i]; @@ -830,19 +937,9 @@ void cmake::SetArgs(const std::vector& args) } value = args[i]; } - auto gen = this->CreateGlobalGenerator(value); - if (!gen) { - std::string kdevError; - if (value.find("KDevelop3", 0) != std::string::npos) { - kdevError = "\nThe KDevelop3 generator is not supported anymore."; - } - - cmSystemTools::Error( - cmStrCat("Could not create named generator ", value, kdevError)); - this->PrintGeneratorList(); + if (!this->CreateAndSetGlobalGenerator(value, true)) { return; } - this->SetGlobalGenerator(std::move(gen)); #if !defined(CMAKE_BOOTSTRAP) } else if (cmHasLiteralPrefix(arg, "--profiling-format")) { profilingFormat = arg.substr(strlen("--profiling-format=")); @@ -856,6 +953,13 @@ void cmake::SetArgs(const std::vector& args) if (profilingOutput.empty()) { cmSystemTools::Error("No path specified for --profiling-output"); } + } else if (cmHasLiteralPrefix(arg, "--preset")) { + presetName = arg.substr(strlen("--preset=")); + if (presetName.empty()) { + cmSystemTools::Error("No preset specified for --preset"); + } + } else if (cmHasLiteralPrefix(arg, "--list-presets")) { + listPresets = true; #endif } // no option assume it is the path to the source or an existing build @@ -915,6 +1019,91 @@ void cmake::SetArgs(const std::vector& args) if (!haveBinaryDir) { this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); } + +#if !defined(CMAKE_BOOTSTRAP) + if (listPresets || !presetName.empty()) { + cmCMakePresetsFile settingsFile; + auto result = settingsFile.ReadProjectPresets(this->GetHomeDirectory()); + if (result != cmCMakePresetsFile::ReadFileResult::READ_OK) { + cmSystemTools::Error( + cmStrCat("Could not read presets from ", this->GetHomeDirectory(), + ": ", cmCMakePresetsFile::ResultToString(result))); + return; + } + if (listPresets) { + this->PrintPresetList(settingsFile); + return; + } + auto preset = settingsFile.Presets.find(presetName); + if (preset == settingsFile.Presets.end()) { + cmSystemTools::Error(cmStrCat("No such preset in ", + this->GetHomeDirectory(), ": \"", + presetName, '"')); + this->PrintPresetList(settingsFile); + return; + } + if (preset->second.Hidden) { + cmSystemTools::Error(cmStrCat("Cannot use hidden preset in ", + this->GetHomeDirectory(), ": \"", + presetName, '"')); + this->PrintPresetList(settingsFile); + return; + } + auto expandedPreset = settingsFile.ExpandMacros(preset->second); + if (!expandedPreset) { + cmSystemTools::Error(cmStrCat("Could not evaluate preset \"", + preset->second.Name, + "\": Invalid macro expansion")); + return; + } + + if (!haveBinaryDir) { + this->SetHomeOutputDirectory(expandedPreset->BinaryDir); + } + if (!this->GlobalGenerator) { + if (!this->CreateAndSetGlobalGenerator(expandedPreset->Generator, + false)) { + return; + } + } + this->UnprocessedPresetVariables = expandedPreset->CacheVariables; + this->UnprocessedPresetEnvironment = expandedPreset->Environment; + + if (!expandedPreset->GeneratorConfig || + expandedPreset->GeneratorConfig == + cmCMakePresetsFile::CMakeGeneratorConfig::Default) { + if (!this->GeneratorPlatformSet) { + this->SetGeneratorPlatform(expandedPreset->Architecture); + } + if (!this->GeneratorToolsetSet) { + this->SetGeneratorToolset(expandedPreset->Toolset); + } + } + + this->SetWarningFromPreset("dev", expandedPreset->WarnDev, + expandedPreset->ErrorDev); + this->SetWarningFromPreset("deprecated", expandedPreset->WarnDeprecated, + expandedPreset->ErrorDeprecated); + if (expandedPreset->WarnUninitialized == true) { + this->SetWarnUninitialized(true); + } + if (expandedPreset->WarnUnusedCli == false) { + this->SetWarnUnusedCli(false); + } + if (expandedPreset->WarnSystemVars == true) { + this->SetCheckSystemVars(true); + } + if (expandedPreset->DebugOutput == true) { + this->SetDebugOutputOn(true); + } + if (expandedPreset->DebugTryCompile == true) { + this->DebugTryCompileOn(); + } + if (expandedPreset->DebugFind == true) { + this->SetDebugFindOutputOn(true); + } + } +#endif } cmake::LogLevel cmake::StringToLogLevel(const std::string& levelStr) @@ -1240,6 +1429,79 @@ std::unique_ptr cmake::CreateGlobalGenerator( return generator; } +bool cmake::CreateAndSetGlobalGenerator(const std::string& name, + bool allowArch) +{ + auto gen = this->CreateGlobalGenerator(name, allowArch); + if (!gen) { + std::string kdevError; + std::string vsError; + if (name.find("KDevelop3", 0) != std::string::npos) { + kdevError = "\nThe KDevelop3 generator is not supported anymore."; + } + if (!allowArch && cmHasLiteralPrefix(name, "Visual Studio ") && + name.length() >= cmStrLen("Visual Studio xx xxxx ")) { + vsError = "\nUsing platforms in Visual Studio generator names is not " + "supported in CMakePresets.json."; + } + + cmSystemTools::Error( + cmStrCat("Could not create named generator ", name, kdevError, vsError)); + this->PrintGeneratorList(); + return false; + } + + this->SetGlobalGenerator(std::move(gen)); + return true; +} + +#ifndef CMAKE_BOOTSTRAP +void cmake::PrintPresetList(const cmCMakePresetsFile& file) const +{ + std::vector generators; + this->GetRegisteredGenerators(generators, false); + + std::vector presets; + for (auto const& p : file.PresetOrder) { + auto const& preset = file.Presets.at(p); + if (!preset.Hidden && + std::find_if(generators.begin(), generators.end(), + [&preset](const GeneratorInfo& info) { + return info.name == preset.Generator; + }) != generators.end() && + file.ExpandMacros(preset)) { + presets.push_back(preset); + } + } + + if (presets.empty()) { + return; + } + + std::cout << "Available presets:\n\n"; + + auto longestPresetName = + std::max_element(presets.begin(), presets.end(), + [](const cmCMakePresetsFile::UnexpandedPreset& a, + const cmCMakePresetsFile::UnexpandedPreset& b) { + return a.Name.length() < b.Name.length(); + }); + auto longestLength = longestPresetName->Name.length(); + + for (auto const& preset : presets) { + std::cout << " \"" << preset.Name << '"'; + auto const& description = preset.DisplayName; + if (!description.empty()) { + for (std::size_t i = 0; i < longestLength - preset.Name.length(); ++i) { + std::cout << ' '; + } + std::cout << " - " << description; + } + std::cout << '\n'; + } +} +#endif + void cmake::SetHomeDirectory(const std::string& dir) { this->State->SetSourceDirectory(dir); @@ -1801,6 +2063,9 @@ int cmake::Run(const std::vector& args, bool noconfigure) if (cmSystemTools::GetErrorOccuredFlag()) { return -1; } + if (this->GetWorkingMode() == HELP_MODE) { + return 0; + } // Log the trace format version to the desired output if (this->GetTrace()) { @@ -1829,11 +2094,19 @@ int cmake::Run(const std::vector& args, bool noconfigure) this->AddCMakePaths(); } +#ifndef CMAKE_BOOTSTRAP + this->ProcessPresetVariables(); + this->ProcessPresetEnvironment(); +#endif // Add any cache args if (!this->SetCacheArgs(args)) { cmSystemTools::Error("Problem processing arguments. Aborting.\n"); return -1; } +#ifndef CMAKE_BOOTSTRAP + this->PrintPresetVariables(); + this->PrintPresetEnvironment(); +#endif // In script mode we terminate after running the script. if (this->GetWorkingMode() != NORMAL_MODE) { diff --git a/Source/cmake.h b/Source/cmake.h index 525af32..262d673 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -27,7 +27,11 @@ #include "cmStateTypes.h" #if !defined(CMAKE_BOOTSTRAP) +# include + # include + +# include "cmCMakePresetsFile.h" #endif class cmExternalMakefileProjectGeneratorFactory; @@ -88,13 +92,22 @@ public: enum WorkingMode { NORMAL_MODE, ///< Cmake runs to create project files - /** \brief Script mode (started by using -P). - * - * In script mode there is no generator and no cache. Also, - * languages are not enabled, so add_executable and things do - * nothing. - */ + + /** \brief Script mode (started by using -P). + * + * In script mode there is no generator and no cache. Also, + * languages are not enabled, so add_executable and things do + * nothing. + */ SCRIPT_MODE, + + /** \brief Help mode + * + * Used to print help for things that can only be determined after finding + * the source directory, for example, the list of presets. + */ + HELP_MODE, + /** \brief A pkg-config like mode * * In this mode cmake just searches for a package and prints the results to @@ -221,6 +234,14 @@ public: std::unique_ptr CreateGlobalGenerator( const std::string& name, bool allowArch = true); + //! Create a GlobalGenerator and set it as our own + bool CreateAndSetGlobalGenerator(const std::string& name, bool allowArch); + +#ifndef CMAKE_BOOTSTRAP + //! Print list of presets + void PrintPresetList(const cmCMakePresetsFile& file) const; +#endif + //! Return the global generator assigned to this instance of cmake cmGlobalGenerator* GetGlobalGenerator() { @@ -329,9 +350,22 @@ public: bool GetIsInTryCompile() const; void SetIsInTryCompile(bool b); +#ifndef CMAKE_BOOTSTRAP + void SetWarningFromPreset(const std::string& name, + const cm::optional& warning, + const cm::optional& error); + void ProcessPresetVariables(); + void PrintPresetVariables(); + void ProcessPresetEnvironment(); + void PrintPresetEnvironment(); +#endif + //! Parse command line arguments that might set cache values bool SetCacheArgs(const std::vector&); + void ProcessCacheArg(const std::string& var, const std::string& value, + cmStateEnums::CacheEntryType type); + using ProgressCallbackType = std::function; /** * Set the function used by GUIs to receive progress updates @@ -625,6 +659,12 @@ private: std::unique_ptr FileTimeCache; std::string GraphVizFile; InstalledFilesMap InstalledFiles; +#ifndef CMAKE_BOOTSTRAP + std::map> + UnprocessedPresetVariables; + std::map> + UnprocessedPresetEnvironment; +#endif #if !defined(CMAKE_BOOTSTRAP) std::unique_ptr VariableWatch; @@ -664,6 +704,8 @@ private: #define CMAKE_STANDARD_OPTIONS_TABLE \ { "-S ", "Explicitly specify a source directory." }, \ { "-B ", "Explicitly specify a build directory." }, \ + { "--preset=", "Explicitly specify a preset." }, \ + { "--list-presets", "List available presets." }, \ { "-C ", "Pre-load a script to populate the cache." }, \ { "-D [:]=", "Create or update a cmake cache entry." }, \ { "-U ", "Remove matching entries from CMake cache." }, \ diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 4600fc5..c769227 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -49,7 +49,8 @@ const char* cmDocumentationUsage[][2] = { { nullptr, " cmake [options] \n" " cmake [options] \n" - " cmake [options] -S -B " }, + " cmake [options] -S -B \n" + " cmake [options] -S --preset=" }, { nullptr, "Specify a source directory to (re-)generate a build system for " "it in the current working directory. Specify an existing build " @@ -253,6 +254,9 @@ int do_cmake(int ac, char const* const* av) } else if (cmHasLiteralPrefix(av[i], "--find-package")) { workingMode = cmake::FIND_PACKAGE_MODE; args.emplace_back(av[i]); + } else if (strcmp(av[i], "--list-presets") == 0) { + workingMode = cmake::HELP_MODE; + args.emplace_back(av[i]); } else { args.emplace_back(av[i]); } @@ -269,6 +273,7 @@ int do_cmake(int ac, char const* const* av) cmState::Mode mode = cmState::Unknown; switch (workingMode) { case cmake::NORMAL_MODE: + case cmake::HELP_MODE: mode = cmState::Project; break; case cmake::SCRIPT_MODE: diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c70eb75..aa44abf 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -757,6 +757,7 @@ add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}) add_RunCMake_test("UnityBuild") +add_RunCMake_test(CMakePresets) if(WIN32) add_RunCMake_test(Win32GenEx) diff --git a/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-result.txt b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-stderr.txt b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-stderr.txt new file mode 100644 index 0000000..a3b79b6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigDefault-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists\.txt:[0-9]+ \(project\): + Generator + + [^ +]* + + does not support platform specification, but platform + + a + + was specified\.$ diff --git a/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigIgnore.cmake b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigIgnore.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-result.txt b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-stderr.txt b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-stderr.txt new file mode 100644 index 0000000..a3b79b6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CMakeGeneratorConfigNone-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists\.txt:[0-9]+ \(project\): + Generator + + [^ +]* + + does not support platform specification, but platform + + a + + was specified\.$ diff --git a/Tests/RunCMake/CMakePresets/CMakeLists.txt.in b/Tests/RunCMake/CMakePresets/CMakeLists.txt.in new file mode 100644 index 0000000..67c2d48 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CMakeLists.txt.in @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.18) +project(${RunCMake_TEST} NONE) +set(RunCMake_SOURCE_DIR [==[@RunCMake_SOURCE_DIR@]==]) +include("${RunCMake_SOURCE_DIR}/${RunCMake_TEST}.cmake") diff --git a/Tests/RunCMake/CMakePresets/CMakePresets.json.in b/Tests/RunCMake/CMakePresets/CMakePresets.json.in new file mode 100644 index 0000000..78e31c6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CMakePresets.json.in @@ -0,0 +1,481 @@ +/* + * Block comment + */ +{ + // Inline comment + "version": 1, + "cmakeMinimumRequired": { + "major": 3, + "minor": 18, + "patch": 0 + }, + "vendor": { + "example.com/ExampleIDE/1.0": true + }, + "configurePresets": [ + { + "name": "Good", + "displayName": "Good Preset", + "description": "This preset is meant to test most of the fields when set correctly.", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cmakeExecutable": "/path/does/not/exist/cmake", + "vendor": { + "example.com/ExampleIDE/1.0": { + "transmogrify": true + } + }, + "cacheVariables": { + "TEST_SOURCE_DIR": { + "type": "PATH", + "value": "${sourceDir}" + }, + "TEST_SOURCE_PARENT_DIR": { + "type": "PATH", + "value": "${sourceParentDir}" + }, + "TEST_SOURCE_LIST": { + "type": "FILEPATH", + "value": "${sourceDir}/CMakeLists.txt" + }, + "TEST_TRUE": { + "type": "BOOL", + "value": "TRUE" + }, + "TEST_OFF": { + "type": "BOOL", + "value": "OFF" + }, + "TEST_PRESET_NAME": { + "type": "STRING", + "value": "x${presetName}x" + }, + "TEST_GENERATOR": { + "value": "x${generator}x" + }, + "TEST_DOLLAR": { + "value": "${dollar}" + }, + "TEST_ENV_REF": "$env{TEST_ENV_REF}", + "TEST_ENV": "$env{TEST_ENV}", + "TEST_D_ENV_REF": "$env{TEST_D_ENV_REF}", + "TEST_ENV_OVERRIDE": "$env{TEST_ENV_OVERRIDE}", + "TEST_PENV": "$env{TEST_PENV}", + "TEST_ENV_REF_PENV": "$env{TEST_ENV_REF_PENV}", + "TEST_ENV_REF_P": "$penv{TEST_ENV_REF}", + "TEST_ENV_P": "$penv{TEST_ENV}", + "TEST_D_ENV_REF_P": "$penv{TEST_D_ENV_REF}", + "TEST_ENV_OVERRIDE_P": "$penv{TEST_ENV_OVERRIDE}", + "TEST_PENV_P": "$penv{TEST_PENV}", + "TEST_ENV_REF_PENV_P": "$penv{TEST_ENV_REF_PENV}", + "TEST_MULTIPLE_MACROS": "${presetName} ${generator}", + "TEST_EXPANSION": "\\${presetName} ${dollar}{dollar} $unknown{namespace} $en{NOT_ENV} $enve{NOT_ENV} $ \\$ $a", + "TEST_TRAILING_DOLLAR": "a $", + "TEST_TRAILING_BACKSLASH": "a \\", + "TEST_TRAILING_UNKNOWN_NAMESPACE": "$unknown{namespace", + "TEST_OVERRIDE_1": { + "type": "STRING", + "value": "Default value" + }, + "TEST_OVERRIDE_2": "Default value", + "TEST_OVERRIDE_3": { + "type": "STRING", + "value": "Default value" + }, + "TEST_OVERRIDE_4": { + "type": "STRING", + "value": "Default value" + }, + "TEST_UNDEF": "undef" + }, + "environment": { + "TEST_ENV_REF": "$env{TEST_ENV}", + "TEST_ENV": "Environment variable", + "TEST_D_ENV_REF": "x$env{TEST_ENV_REF}x", + "TEST_ENV_OVERRIDE": "Overridden environment variable", + "TEST_ENV_REF_PENV": "prefix+$penv{TEST_ENV_REF_PENV}", + "TEST_PENV": null + } + }, + { + "name": "GoodNoArgs", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "GoodBinaryUp", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/../GoodBinaryUp-build" + }, + { + "name": "GoodBinaryRelative", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "build" + }, + { + "name": "Good Spaces", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "GoodWindowsBackslash", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}\\build" + }, + { + "name": "GoodBinaryCmdLine", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "GoodGeneratorCmdLine", + "generator": "Invalid Generator", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "InvalidGeneratorCmdLine", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "GoodNoS", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "GoodInheritanceParentBase", + "hidden": true, + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_VARIABLE": { + "type": "STRING", + "value": "Some string" + } + }, + "environment": { + "TEST_ENV": "Some environment variable" + } + }, + { + "name": "GoodInheritanceParent", + "inherits": "GoodInheritanceParentBase" + }, + { + "name": "GoodInheritanceChildBase", + "hidden": true + }, + { + "name": "GoodInheritanceChild", + "inherits": "GoodInheritanceChildBase", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_VARIABLE": { + "type": "STRING", + "value": "Some string" + } + }, + "environment": { + "TEST_ENV": "Some environment variable" + } + }, + { + "name": "GoodInheritanceOverrideBase", + "hidden": true, + "generator": "Invalid Generator", + "binaryDir": "${sourceDir}/../GoodInheritanceBase-build", + "cacheVariables": { + "PARENT_VARIABLE": { + "type": "STRING", + "value": "Parent variable" + }, + "OVERRIDDEN_VARIABLE": { + "type": "BOOL", + "value": "ON" + }, + "DELETED_VARIABLE": "This variable will be deleted" + }, + "environment": { + "PARENT_ENV": "Parent environment variable", + "OVERRIDDEN_ENV": "This environment variable will be overridden", + "DELETED_ENV": "This environment variable will be deleted" + } + }, + { + "name": "GoodInheritanceOverride", + "inherits": "GoodInheritanceOverrideBase", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "OVERRIDDEN_VARIABLE": { + "type": "STRING", + "value": "Overridden variable" + }, + "CHILD_VARIABLE": { + "type": "STRING", + "value": "Child variable" + }, + "DELETED_VARIABLE": null + }, + "environment": { + "OVERRIDDEN_ENV": "Overridden environment variable", + "CHILD_ENV": "Child environment variable", + "DELETED_ENV": null + } + }, + { + "name": "GoodInheritanceOverrideDummy", + "inherits": "GoodInheritanceOverride" + }, + { + "name": "GoodInheritanceMulti1", + "hidden": true, + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "FIRST_VARIABLE": { + "type": "STRING", + "value": "First variable" + }, + "OVERRIDDEN_VARIABLE": { + "type": "STRING", + "value": "Overridden variable" + } + }, + "environment": { + "FIRST_ENV": "First environment variable", + "OVERRIDDEN_ENV": "Overridden environment variable" + } + }, + { + "name": "GoodInheritanceMulti2", + "hidden": true, + "generator": "Invalid Generator", + "binaryDir": "${sourceDir}/../GoodInheritanceMulti2-build", + "cacheVariables": { + "SECOND_VARIABLE": { + "type": "STRING", + "value": "Second variable" + }, + "OVERRIDDEN_VARIABLE": { + "type": "BOOL", + "value": "ON" + } + }, + "environment": { + "SECOND_ENV": "Second environment variable", + "OVERRIDDEN_ENV": "This will be overridden" + } + }, + { + "name": "GoodInheritanceMulti", + "inherits": [ + "GoodInheritanceMulti1", + "GoodInheritanceMulti2" + ] + }, + { + "name": "GoodInheritanceMultiSecond1", + "hidden": true + }, + { + "name": "GoodInheritanceMultiSecond2", + "hidden": true, + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "GoodInheritanceMultiSecond", + "inherits": [ + "GoodInheritanceMultiSecond1", + "GoodInheritanceMultiSecond2" + ] + }, + { + "name": "GoodInheritanceMacroBase", + "hidden": true, + "cacheVariables": { + "PRESET_NAME": "${presetName}" + } + }, + { + "name": "GoodInheritanceMacro", + "inherits": "GoodInheritanceMacroBase", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "UnclosedMacro", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir" + }, + { + "name": "NoSuchMacro", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${noexist}" + }, + { + "name": "VendorMacro", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "$vendor{unknown.unknownMacro}" + }, + { + "name": "InvalidGenerator", + "generator": "Invalid Generator", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "EnvCycle", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "environment": { + "ENV_1": "$env{ENV_2}", + "ENV_2": "$env{ENV_1}" + } + }, + { + "name": "UseHiddenPreset", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "hidden": true + }, + { + "name": "VisualStudioGeneratorArch", + "generator": "@RunCMake_GENERATOR@ Win64", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "VisualStudioWin32", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": "Win32" + }, + { + "name": "VisualStudioWin64", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": "x64" + }, + { + "name": "VisualStudioWin32Override", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": "Win32" + }, + { + "name": "VisualStudioToolset", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "toolset": "Test Toolset" + }, + { + "name": "VisualStudioToolsetOverride", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "toolset": "Invalid Toolset" + }, + { + "name": "VisualStudioInheritanceParentBase", + "hidden": true, + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": "Test Platform", + "toolset": "Test Toolset" + }, + { + "name": "VisualStudioInheritanceParent", + "inherits": "VisualStudioInheritanceParentBase" + }, + { + "name": "VisualStudioInheritanceChildBase", + "hidden": true + }, + { + "name": "VisualStudioInheritanceChild", + "inherits": "VisualStudioInheritanceChildBase", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": "Test Platform", + "toolset": "Test Toolset" + }, + { + "name": "VisualStudioInheritanceOverrideBase", + "hidden": true, + "architecture": "Invalid Platform", + "toolset": "Invalid Toolset" + }, + { + "name": "VisualStudioInheritanceOverride", + "inherits": "VisualStudioInheritanceOverrideBase", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": "Test Platform", + "toolset": "Test Toolset" + }, + { + "name": "VisualStudioInheritanceMulti1", + "hidden": true, + "architecture": "Test Platform", + "toolset": "Test Toolset" + }, + { + "name": "VisualStudioInheritanceMulti2", + "hidden": true, + "architecture": "Invalid Platform", + "toolset": "Invalid Toolset" + }, + { + "name": "VisualStudioInheritanceMulti", + "inherits": [ + "VisualStudioInheritanceMulti1", + "VisualStudioInheritanceMulti2" + ], + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "VisualStudioInheritanceMultiSecond1", + "hidden": true + }, + { + "name": "VisualStudioInheritanceMultiSecond2", + "hidden": true, + "architecture": "Test Platform", + "toolset": "Test Toolset" + }, + { + "name": "VisualStudioInheritanceMultiSecond", + "inherits": [ + "VisualStudioInheritanceMultiSecond1", + "VisualStudioInheritanceMultiSecond2" + ], + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "CMakeGeneratorConfigNone", + "generator": "@RunCMake_GENERATOR@", + "architecture": "a", + "toolset": "a", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "CMakeGeneratorConfigBase", + "generator": "@RunCMake_GENERATOR@", + "architecture": "a", + "toolset": "a", + "cmakeGeneratorConfig": "ignore", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "CMakeGeneratorConfigDefault", + "inherits": "CMakeGeneratorConfigBase", + "cmakeGeneratorConfig": "default" + }, + { + "name": "CMakeGeneratorConfigIgnore", + "inherits": "CMakeGeneratorConfigBase" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/CacheOverride.cmake b/Tests/RunCMake/CMakePresets/CacheOverride.cmake new file mode 100644 index 0000000..d0ebe17 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CacheOverride.cmake @@ -0,0 +1,2 @@ +set(TEST_OVERRIDE_3 "Overridden value" CACHE STRING "") +set(TEST_OVERRIDE_4 "Overridden value" CACHE INTERNAL "") diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance0-result.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance0-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance0-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance0-stderr.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance0-stderr.txt new file mode 100644 index 0000000..895afcb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance0-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/CyclicInheritance0: Cyclic preset inheritance$ diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance0.json.in b/Tests/RunCMake/CMakePresets/CyclicInheritance0.json.in new file mode 100644 index 0000000..3468936 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance0.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "CyclicInheritance0", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "CyclicInheritance0" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance1-result.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance1-stderr.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance1-stderr.txt new file mode 100644 index 0000000..1e59e92 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance1-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/CyclicInheritance1: Cyclic preset inheritance$ diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance1.json.in b/Tests/RunCMake/CMakePresets/CyclicInheritance1.json.in new file mode 100644 index 0000000..fabd4af --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance1.json.in @@ -0,0 +1,21 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "CyclicInheritance0", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "CyclicInheritance1" + ] + }, + { + "name": "CyclicInheritance1", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "CyclicInheritance0" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance2-result.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance2-stderr.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance2-stderr.txt new file mode 100644 index 0000000..56e630b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance2-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/CyclicInheritance2: Cyclic preset inheritance$ diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance2.json.in b/Tests/RunCMake/CMakePresets/CyclicInheritance2.json.in new file mode 100644 index 0000000..0e1d7d4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance2.json.in @@ -0,0 +1,29 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "CyclicInheritance0", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "CyclicInheritance1" + ] + }, + { + "name": "CyclicInheritance1", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "CyclicInheritance2" + ] + }, + { + "name": "CyclicInheritance2", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "CyclicInheritance0" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/Debug-stderr.txt b/Tests/RunCMake/CMakePresets/Debug-stderr.txt new file mode 100644 index 0000000..7fdb8b3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Debug-stderr.txt @@ -0,0 +1 @@ + find_package considered the following locations for the Config module: diff --git a/Tests/RunCMake/CMakePresets/Debug-stdout.txt b/Tests/RunCMake/CMakePresets/Debug-stdout.txt new file mode 100644 index 0000000..7d1f388 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Debug-stdout.txt @@ -0,0 +1,4 @@ +-- Generating [^ +]*/Tests/RunCMake/CMakePresets/Debug/build + Called from: \[1\][^ +]*/Tests/RunCMake/CMakePresets/Debug/CMakeLists\.txt diff --git a/Tests/RunCMake/CMakePresets/Debug.cmake b/Tests/RunCMake/CMakePresets/Debug.cmake new file mode 100644 index 0000000..19c7db2 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Debug.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/DebugBase.cmake) +if(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeLists.txt") + message(SEND_ERROR "Debugging try_compile() did not work") +endif() diff --git a/Tests/RunCMake/CMakePresets/Debug.json.in b/Tests/RunCMake/CMakePresets/Debug.json.in new file mode 100644 index 0000000..500700e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Debug.json.in @@ -0,0 +1,19 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "NoDebug", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "Debug", + "inherits": "NoDebug", + "debug": { + "output": true, + "find": true, + "tryCompile": true + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/DebugBase.cmake b/Tests/RunCMake/CMakePresets/DebugBase.cmake new file mode 100644 index 0000000..870f31c --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DebugBase.cmake @@ -0,0 +1,3 @@ +enable_language(C) +try_compile(_result ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR}/main.c) +find_package(ThisPackageHopefullyDoesNotExist CONFIG) diff --git a/Tests/RunCMake/CMakePresets/DisableWarningFlags.cmake b/Tests/RunCMake/CMakePresets/DisableWarningFlags.cmake new file mode 100644 index 0000000..5de7687 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DisableWarningFlags.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/WarningsBase.cmake) diff --git a/Tests/RunCMake/CMakePresets/DuplicatePresets-result.txt b/Tests/RunCMake/CMakePresets/DuplicatePresets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DuplicatePresets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/DuplicatePresets-stderr.txt b/Tests/RunCMake/CMakePresets/DuplicatePresets-stderr.txt new file mode 100644 index 0000000..c9361ae --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DuplicatePresets-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/DuplicatePresets: Duplicate presets$ diff --git a/Tests/RunCMake/CMakePresets/DuplicatePresets.json.in b/Tests/RunCMake/CMakePresets/DuplicatePresets.json.in new file mode 100644 index 0000000..cf388e7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DuplicatePresets.json.in @@ -0,0 +1,15 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "DuplicatePresets", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "DuplicatePresets", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/EmptyPresetName-result.txt b/Tests/RunCMake/CMakePresets/EmptyPresetName-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyPresetName-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/EmptyPresetName-stderr.txt b/Tests/RunCMake/CMakePresets/EmptyPresetName-stderr.txt new file mode 100644 index 0000000..6970674 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyPresetName-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/EmptyPresetName: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/EmptyPresetName.json.in b/Tests/RunCMake/CMakePresets/EmptyPresetName.json.in new file mode 100644 index 0000000..fd4bedd --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyPresetName.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/EnvCycle-result.txt b/Tests/RunCMake/CMakePresets/EnvCycle-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EnvCycle-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/EnvCycle-stderr.txt b/Tests/RunCMake/CMakePresets/EnvCycle-stderr.txt new file mode 100644 index 0000000..c8568f1 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EnvCycle-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Could not evaluate preset "EnvCycle": Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/ErrorDeprecated-result.txt b/Tests/RunCMake/CMakePresets/ErrorDeprecated-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorDeprecated-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ErrorDeprecated-stderr.txt b/Tests/RunCMake/CMakePresets/ErrorDeprecated-stderr.txt new file mode 100644 index 0000000..964a504 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorDeprecated-stderr.txt @@ -0,0 +1,7 @@ +^CMake Deprecation Error at [^ +]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\): + Deprecation warning +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakePresets/ErrorDeprecated\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMakePresets/ErrorDeprecated.cmake b/Tests/RunCMake/CMakePresets/ErrorDeprecated.cmake new file mode 100644 index 0000000..5de7687 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorDeprecated.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/WarningsBase.cmake) diff --git a/Tests/RunCMake/CMakePresets/ErrorDev-result.txt b/Tests/RunCMake/CMakePresets/ErrorDev-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorDev-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ErrorDev-stderr.txt b/Tests/RunCMake/CMakePresets/ErrorDev-stderr.txt new file mode 100644 index 0000000..f76478c --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorDev-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error \(dev\) at [^ +]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\): + Dev warning +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakePresets/ErrorDev\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) +This error is for project developers\. Use -Wno-error=dev to suppress it\.$ diff --git a/Tests/RunCMake/CMakePresets/ErrorDev.cmake b/Tests/RunCMake/CMakePresets/ErrorDev.cmake new file mode 100644 index 0000000..5de7687 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorDev.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/WarningsBase.cmake) diff --git a/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-result.txt b/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-stderr.txt b/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-stderr.txt new file mode 100644 index 0000000..3221345 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated.json.in b/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated.json.in new file mode 100644 index 0000000..664b3ee --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated.json.in @@ -0,0 +1,16 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ErrorNoWarningDeprecated", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "warnings": { + "deprecated": false + }, + "errors": { + "deprecated": true + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/ErrorNoWarningDev-result.txt b/Tests/RunCMake/CMakePresets/ErrorNoWarningDev-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorNoWarningDev-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ErrorNoWarningDev-stderr.txt b/Tests/RunCMake/CMakePresets/ErrorNoWarningDev-stderr.txt new file mode 100644 index 0000000..d2ddb90 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorNoWarningDev-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/ErrorNoWarningDev: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/ErrorNoWarningDev.json.in b/Tests/RunCMake/CMakePresets/ErrorNoWarningDev.json.in new file mode 100644 index 0000000..d681b2a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ErrorNoWarningDev.json.in @@ -0,0 +1,16 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ErrorNoWarningDev", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "warnings": { + "dev": false + }, + "errors": { + "dev": true + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/ExtraPresetField-result.txt b/Tests/RunCMake/CMakePresets/ExtraPresetField-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraPresetField-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ExtraPresetField-stderr.txt b/Tests/RunCMake/CMakePresets/ExtraPresetField-stderr.txt new file mode 100644 index 0000000..559e3c2 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraPresetField-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/ExtraPresetField: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/ExtraPresetField.json.in b/Tests/RunCMake/CMakePresets/ExtraPresetField.json.in new file mode 100644 index 0000000..b529758 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraPresetField.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ExtraPresetField", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "invalid": true + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/ExtraRootField-result.txt b/Tests/RunCMake/CMakePresets/ExtraRootField-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraRootField-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ExtraRootField-stderr.txt b/Tests/RunCMake/CMakePresets/ExtraRootField-stderr.txt new file mode 100644 index 0000000..bb281be --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraRootField-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/ExtraRootField: Invalid root object$ diff --git a/Tests/RunCMake/CMakePresets/ExtraRootField.json.in b/Tests/RunCMake/CMakePresets/ExtraRootField.json.in new file mode 100644 index 0000000..bcfa68b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraRootField.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ExtraRootField", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ], + "invalid": true +} diff --git a/Tests/RunCMake/CMakePresets/ExtraVariableField-result.txt b/Tests/RunCMake/CMakePresets/ExtraVariableField-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraVariableField-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ExtraVariableField-stderr.txt b/Tests/RunCMake/CMakePresets/ExtraVariableField-stderr.txt new file mode 100644 index 0000000..9b346e7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraVariableField-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/ExtraVariableField: Invalid CMake variable definition$ diff --git a/Tests/RunCMake/CMakePresets/ExtraVariableField.json.in b/Tests/RunCMake/CMakePresets/ExtraVariableField.json.in new file mode 100644 index 0000000..a810560 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ExtraVariableField.json.in @@ -0,0 +1,16 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ExtraVariableField", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "EXTRA": { + "value": "", + "invalid": true + } + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/Good-stdout.txt b/Tests/RunCMake/CMakePresets/Good-stdout.txt new file mode 100644 index 0000000..ce6189e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Good-stdout.txt @@ -0,0 +1,46 @@ +Preset CMake variables: + + TEST_DOLLAR="\$" + TEST_D_ENV_REF="xEnvironment variablex" + TEST_D_ENV_REF_P="" + TEST_ENV="Environment variable" + TEST_ENV_OVERRIDE="Overridden environment variable" + TEST_ENV_OVERRIDE_P="This environment variable will be overridden" + TEST_ENV_P="" + TEST_ENV_REF="Environment variable" + TEST_ENV_REF_P="" + TEST_ENV_REF_PENV="prefix\+suffix" + TEST_ENV_REF_PENV_P="suffix" + TEST_EXPANSION="\\Good \${dollar} \$unknown{namespace} \$en{NOT_ENV} \$enve{NOT_ENV} \$ \\\$ \$a" + TEST_GENERATOR="x[^ +]*x" + TEST_MULTIPLE_MACROS="Good [^ +]*" + TEST_OFF:BOOL="OFF" + TEST_OVERRIDE_3:STRING="Default value" + TEST_OVERRIDE_4:STRING="Default value" + TEST_PENV="Process environment variable" + TEST_PENV_P="Process environment variable" + TEST_PRESET_NAME:STRING="xGoodx" + TEST_SOURCE_DIR:PATH="[^ +]*/Tests/RunCMake/CMakePresets/Good" + TEST_SOURCE_LIST:FILEPATH="[^ +]*/Tests/RunCMake/CMakePresets/Good/CMakeLists\.txt" + TEST_SOURCE_PARENT_DIR:PATH="[^ +]*/Tests/RunCMake/CMakePresets" + TEST_TRAILING_BACKSLASH="a \\" + TEST_TRAILING_DOLLAR="a \$" + TEST_TRAILING_UNKNOWN_NAMESPACE="\$unknown{namespace" + TEST_TRUE:BOOL="TRUE" + +Preset environment variables: + + TEST_D_ENV_REF="xEnvironment variablex" + TEST_ENV="Environment variable" + TEST_ENV_OVERRIDE="Overridden environment variable" + TEST_ENV_REF="Environment variable" + TEST_ENV_REF_PENV="prefix\+suffix" + +(-- Selecting Windows SDK version [^ +]* +)?-- Configuring done diff --git a/Tests/RunCMake/CMakePresets/Good.cmake b/Tests/RunCMake/CMakePresets/Good.cmake new file mode 100644 index 0000000..d8e3e2d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Good.cmake @@ -0,0 +1,45 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +get_filename_component(_parent_dir "${CMAKE_SOURCE_DIR}" DIRECTORY) +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") +test_variable(CMAKE_GENERATOR "" "${RunCMake_GENERATOR}") +test_variable(TEST_SOURCE_DIR "PATH" "${CMAKE_SOURCE_DIR}") +test_variable(TEST_SOURCE_PARENT_DIR "PATH" "${_parent_dir}") +test_variable(TEST_SOURCE_LIST "FILEPATH" "${CMAKE_SOURCE_DIR}/CMakeLists.txt") +test_variable(TEST_TRUE "BOOL" "TRUE") +test_variable(TEST_OFF "BOOL" "OFF") +test_variable(TEST_PRESET_NAME "STRING" "xGoodx") +test_variable(TEST_GENERATOR "UNINITIALIZED" "x${CMAKE_GENERATOR}x") +test_variable(TEST_DOLLAR "UNINITIALIZED" "$") +test_variable(TEST_ENV_REF "UNINITIALIZED" "Environment variable") +test_variable(TEST_ENV "UNINITIALIZED" "Environment variable") +test_variable(TEST_D_ENV_REF "UNINITIALIZED" "xEnvironment variablex") +test_variable(TEST_ENV_OVERRIDE "UNINITIALIZED" "Overridden environment variable") +test_variable(TEST_PENV "UNINITIALIZED" "Process environment variable") +test_variable(TEST_ENV_REF_PENV "UNINITIALIZED" "prefix+suffix") +test_variable(TEST_ENV_REF_P "UNINITIALIZED" "") +test_variable(TEST_ENV_P "UNINITIALIZED" "") +test_variable(TEST_D_ENV_REF_P "UNINITIALIZED" "") +test_variable(TEST_ENV_OVERRIDE_P "UNINITIALIZED" "This environment variable will be overridden") +test_variable(TEST_PENV_P "UNINITIALIZED" "Process environment variable") +test_variable(TEST_ENV_REF_PENV_P "UNINITIALIZED" "suffix") +test_variable(TEST_MULTIPLE_MACROS "UNINITIALIZED" "Good ${CMAKE_GENERATOR}") +test_variable(TEST_EXPANSION "UNINITIALIZED" "\\Good \${dollar} \$unknown{namespace} \$en{NOT_ENV} \$enve{NOT_ENV} $ \\$ $a") +test_variable(TEST_TRAILING_DOLLAR "UNINITIALIZED" "a $") +test_variable(TEST_TRAILING_BACKSLASH "UNINITIALIZED" "a \\") +test_variable(TEST_TRAILING_UNKNOWN_NAMESPACE "UNINITIALIZED" "\$unknown{namespace") +test_variable(TEST_OVERRIDE_1 "UNINITIALIZED" "Overridden value") +test_variable(TEST_OVERRIDE_2 "STRING" "Overridden value") +test_variable(TEST_OVERRIDE_3 "STRING" "Default value") +test_variable(TEST_OVERRIDE_4 "INTERNAL" "Overridden value") + +if(DEFINED TEST_UNDEF OR DEFINED CACHE{TEST_UNDEF}) + message(SEND_ERROR "TEST_UNDEF should not be defined") +endif() + +test_environment_variable(TEST_ENV_REF "Environment variable") +test_environment_variable(TEST_ENV "Environment variable") +test_environment_variable(TEST_D_ENV_REF "xEnvironment variablex") +test_environment_variable(TEST_ENV_OVERRIDE "Overridden environment variable") +test_environment_variable(TEST_PENV "Process environment variable") +test_environment_variable(TEST_ENV_REF_PENV "prefix+suffix") diff --git a/Tests/RunCMake/CMakePresets/GoodBOM.cmake b/Tests/RunCMake/CMakePresets/GoodBOM.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/GoodBOM.json.in b/Tests/RunCMake/CMakePresets/GoodBOM.json.in new file mode 100644 index 0000000..2152511 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodBOM.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "GoodBOM", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/GoodBinaryCmdLine.cmake b/Tests/RunCMake/CMakePresets/GoodBinaryCmdLine.cmake new file mode 100644 index 0000000..9f928fe --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodBinaryCmdLine.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +get_filename_component(_parent "${CMAKE_SOURCE_DIR}" DIRECTORY) +test_variable(CMAKE_BINARY_DIR "" "${_parent}/GoodBinaryCmdLine-build") diff --git a/Tests/RunCMake/CMakePresets/GoodBinaryRelative.cmake b/Tests/RunCMake/CMakePresets/GoodBinaryRelative.cmake new file mode 100644 index 0000000..49e7a25 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodBinaryRelative.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") diff --git a/Tests/RunCMake/CMakePresets/GoodBinaryUp.cmake b/Tests/RunCMake/CMakePresets/GoodBinaryUp.cmake new file mode 100644 index 0000000..f7fb224 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodBinaryUp.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +get_filename_component(_parent "${CMAKE_SOURCE_DIR}" DIRECTORY) +test_variable(CMAKE_BINARY_DIR "" "${_parent}/GoodBinaryUp-build") diff --git a/Tests/RunCMake/CMakePresets/GoodGeneratorCmdLine.cmake b/Tests/RunCMake/CMakePresets/GoodGeneratorCmdLine.cmake new file mode 100644 index 0000000..4319e72 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodGeneratorCmdLine.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_GENERATOR "" "${RunCMake_GENERATOR}") diff --git a/Tests/RunCMake/CMakePresets/GoodInheritanceChild.cmake b/Tests/RunCMake/CMakePresets/GoodInheritanceChild.cmake new file mode 100644 index 0000000..cfc93be --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInheritanceChild.cmake @@ -0,0 +1,6 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") +test_variable(TEST_VARIABLE "STRING" "Some string") + +test_environment_variable(TEST_ENV "Some environment variable") diff --git a/Tests/RunCMake/CMakePresets/GoodInheritanceMacro.cmake b/Tests/RunCMake/CMakePresets/GoodInheritanceMacro.cmake new file mode 100644 index 0000000..96fede0 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInheritanceMacro.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(PRESET_NAME "UNINITIALIZED" "GoodInheritanceMacro") diff --git a/Tests/RunCMake/CMakePresets/GoodInheritanceMulti.cmake b/Tests/RunCMake/CMakePresets/GoodInheritanceMulti.cmake new file mode 100644 index 0000000..6430f4d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInheritanceMulti.cmake @@ -0,0 +1,10 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") +test_variable(FIRST_VARIABLE "STRING" "First variable") +test_variable(SECOND_VARIABLE "STRING" "Second variable") +test_variable(OVERRIDDEN_VARIABLE "STRING" "Overridden variable") + +test_environment_variable(FIRST_ENV "First environment variable") +test_environment_variable(SECOND_ENV "Second environment variable") +test_environment_variable(OVERRIDDEN_ENV "Overridden environment variable") diff --git a/Tests/RunCMake/CMakePresets/GoodInheritanceMultiSecond.cmake b/Tests/RunCMake/CMakePresets/GoodInheritanceMultiSecond.cmake new file mode 100644 index 0000000..49e7a25 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInheritanceMultiSecond.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") diff --git a/Tests/RunCMake/CMakePresets/GoodInheritanceOverride.cmake b/Tests/RunCMake/CMakePresets/GoodInheritanceOverride.cmake new file mode 100644 index 0000000..5231803 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInheritanceOverride.cmake @@ -0,0 +1,18 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") +test_variable(PARENT_VARIABLE "STRING" "Parent variable") +test_variable(OVERRIDDEN_VARIABLE "STRING" "Overridden variable") +test_variable(CHILD_VARIABLE "STRING" "Child variable") + +if(DEFINED DELETED_VARIABLE OR DEFINED CACHE{DELETED_VARIABLE}) + message(SEND_ERROR "DELETED_VARIABLE should not be defined") +endif() + +test_environment_variable(PARENT_ENV "Parent environment variable") +test_environment_variable(CHILD_ENV "Child environment variable") +test_environment_variable(OVERRIDDEN_ENV "Overridden environment variable") + +if(DEFINED ENV{DELETED_ENV}) + message(SEND_ERROR "DELETED_ENV should not be defined") +endif() diff --git a/Tests/RunCMake/CMakePresets/GoodInheritanceParent.cmake b/Tests/RunCMake/CMakePresets/GoodInheritanceParent.cmake new file mode 100644 index 0000000..cfc93be --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInheritanceParent.cmake @@ -0,0 +1,6 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") +test_variable(TEST_VARIABLE "STRING" "Some string") + +test_environment_variable(TEST_ENV "Some environment variable") diff --git a/Tests/RunCMake/CMakePresets/GoodNoArgs.cmake b/Tests/RunCMake/CMakePresets/GoodNoArgs.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/GoodNoS.cmake b/Tests/RunCMake/CMakePresets/GoodNoS.cmake new file mode 100644 index 0000000..1d3b2ff --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodNoS.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +get_filename_component(_parent "${CMAKE_SOURCE_DIR}" DIRECTORY) +test_variable(CMAKE_BINARY_DIR "" "${_parent}/GoodNoS-build") diff --git a/Tests/RunCMake/CMakePresets/GoodSpaces.cmake b/Tests/RunCMake/CMakePresets/GoodSpaces.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromMain.cmake b/Tests/RunCMake/CMakePresets/GoodUserFromMain.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromMain.json.in b/Tests/RunCMake/CMakePresets/GoodUserFromMain.json.in new file mode 100644 index 0000000..348443e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserFromMain.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "GoodUserFromMain", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromMainUser.json.in b/Tests/RunCMake/CMakePresets/GoodUserFromMainUser.json.in new file mode 100644 index 0000000..77b4ef6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserFromMainUser.json.in @@ -0,0 +1,4 @@ +{ + "version": 1, + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromUser.cmake b/Tests/RunCMake/CMakePresets/GoodUserFromUser.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromUser.json.in b/Tests/RunCMake/CMakePresets/GoodUserFromUser.json.in new file mode 100644 index 0000000..77b4ef6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserFromUser.json.in @@ -0,0 +1,4 @@ +{ + "version": 1, + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromUserUser.json.in b/Tests/RunCMake/CMakePresets/GoodUserFromUserUser.json.in new file mode 100644 index 0000000..83196be --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserFromUserUser.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "GoodUserFromUser", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/GoodUserOnly.cmake b/Tests/RunCMake/CMakePresets/GoodUserOnly.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/GoodUserOnlyUser.json.in b/Tests/RunCMake/CMakePresets/GoodUserOnlyUser.json.in new file mode 100644 index 0000000..274f4c7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserOnlyUser.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "GoodUserOnly", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/GoodWindowsBackslash.cmake b/Tests/RunCMake/CMakePresets/GoodWindowsBackslash.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/HighVersion-result.txt b/Tests/RunCMake/CMakePresets/HighVersion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HighVersion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/HighVersion-stderr.txt b/Tests/RunCMake/CMakePresets/HighVersion-stderr.txt new file mode 100644 index 0000000..d8622f2 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HighVersion-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/HighVersion: Unrecognized "version" field$ diff --git a/Tests/RunCMake/CMakePresets/HighVersion.json.in b/Tests/RunCMake/CMakePresets/HighVersion.json.in new file mode 100644 index 0000000..8107842 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HighVersion.json.in @@ -0,0 +1,4 @@ +{ + "version": 1000, + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-result.txt b/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-stderr.txt new file mode 100644 index 0000000..72a20d5 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig.json.in b/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig.json.in new file mode 100644 index 0000000..1479c66 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidCMakeGeneratorConfig.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidCMakeGeneratorConfig", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cmakeGeneratorConfig": {} + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidGenerator-result.txt b/Tests/RunCMake/CMakePresets/InvalidGenerator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidGenerator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidGenerator-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidGenerator-stderr.txt new file mode 100644 index 0000000..c7dd19b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidGenerator-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error: Could not create named generator Invalid Generator + +Generators diff --git a/Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-result.txt b/Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-stderr.txt new file mode 100644 index 0000000..c7dd19b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidGeneratorCmdLine-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error: Could not create named generator Invalid Generator + +Generators diff --git a/Tests/RunCMake/CMakePresets/InvalidInheritance-result.txt b/Tests/RunCMake/CMakePresets/InvalidInheritance-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidInheritance-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidInheritance-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidInheritance-stderr.txt new file mode 100644 index 0000000..97f3876 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidInheritance-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidInheritance: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidInheritance.json.in b/Tests/RunCMake/CMakePresets/InvalidInheritance.json.in new file mode 100644 index 0000000..77bd9a3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidInheritance.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidInheritance", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "NoExist" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-result.txt b/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-stderr.txt new file mode 100644 index 0000000..2fe8c66 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir.json.in b/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir.json.in new file mode 100644 index 0000000..2bb95d9 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetBinaryDir.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidPresetBinaryDir", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": [] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetGenerator-result.txt b/Tests/RunCMake/CMakePresets/InvalidPresetGenerator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetGenerator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetGenerator-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidPresetGenerator-stderr.txt new file mode 100644 index 0000000..9572875 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetGenerator-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidPresetGenerator: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetGenerator.json.in b/Tests/RunCMake/CMakePresets/InvalidPresetGenerator.json.in new file mode 100644 index 0000000..95e6e65 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetGenerator.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidPresetGenerator", + "generator": [], + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetName-result.txt b/Tests/RunCMake/CMakePresets/InvalidPresetName-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetName-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetName-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidPresetName-stderr.txt new file mode 100644 index 0000000..8f6ff7c --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetName-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidPresetName: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetName.json.in b/Tests/RunCMake/CMakePresets/InvalidPresetName.json.in new file mode 100644 index 0000000..08361da --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetName.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": [], + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetVendor-result.txt b/Tests/RunCMake/CMakePresets/InvalidPresetVendor-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetVendor-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetVendor-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidPresetVendor-stderr.txt new file mode 100644 index 0000000..89a424a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetVendor-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidPresetVendor: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidPresetVendor.json.in b/Tests/RunCMake/CMakePresets/InvalidPresetVendor.json.in new file mode 100644 index 0000000..2a5d9ba --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresetVendor.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidPresetVendor", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "vendor": true + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidPresets-result.txt b/Tests/RunCMake/CMakePresets/InvalidPresets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidPresets-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidPresets-stderr.txt new file mode 100644 index 0000000..2b0f560 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresets-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidPresets: Invalid "configurePresets" field$ diff --git a/Tests/RunCMake/CMakePresets/InvalidPresets.json.in b/Tests/RunCMake/CMakePresets/InvalidPresets.json.in new file mode 100644 index 0000000..facfd57 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidPresets.json.in @@ -0,0 +1,4 @@ +{ + "version": 1, + "configurePresets": {} +} diff --git a/Tests/RunCMake/CMakePresets/InvalidRoot-result.txt b/Tests/RunCMake/CMakePresets/InvalidRoot-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidRoot-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidRoot-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidRoot-stderr.txt new file mode 100644 index 0000000..e5c434d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidRoot-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidRoot: Invalid root object$ diff --git a/Tests/RunCMake/CMakePresets/InvalidRoot.json.in b/Tests/RunCMake/CMakePresets/InvalidRoot.json.in new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidRoot.json.in @@ -0,0 +1 @@ +[] diff --git a/Tests/RunCMake/CMakePresets/InvalidVariableValue-result.txt b/Tests/RunCMake/CMakePresets/InvalidVariableValue-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVariableValue-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidVariableValue-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidVariableValue-stderr.txt new file mode 100644 index 0000000..0ab07c3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVariableValue-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidVariableValue: Invalid CMake variable definition$ diff --git a/Tests/RunCMake/CMakePresets/InvalidVariableValue.json.in b/Tests/RunCMake/CMakePresets/InvalidVariableValue.json.in new file mode 100644 index 0000000..55c7644 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVariableValue.json.in @@ -0,0 +1,15 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidVariableValue", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "VAR": { + "value": [] + } + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidVariables-result.txt b/Tests/RunCMake/CMakePresets/InvalidVariables-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVariables-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidVariables-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidVariables-stderr.txt new file mode 100644 index 0000000..6d9102a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVariables-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidVariables: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidVariables.json.in b/Tests/RunCMake/CMakePresets/InvalidVariables.json.in new file mode 100644 index 0000000..30dcaf0 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVariables.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidVariables", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": [] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidVendor-result.txt b/Tests/RunCMake/CMakePresets/InvalidVendor-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVendor-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidVendor-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidVendor-stderr.txt new file mode 100644 index 0000000..af923f0 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVendor-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidVendor: Invalid root object$ diff --git a/Tests/RunCMake/CMakePresets/InvalidVendor.json.in b/Tests/RunCMake/CMakePresets/InvalidVendor.json.in new file mode 100644 index 0000000..2315b72 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVendor.json.in @@ -0,0 +1,5 @@ +{ + "version": 1, + "vendor": true, + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidVersion-result.txt b/Tests/RunCMake/CMakePresets/InvalidVersion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVersion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidVersion-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidVersion-stderr.txt new file mode 100644 index 0000000..7e0fcfd --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVersion-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidVersion: Invalid "version" field$ diff --git a/Tests/RunCMake/CMakePresets/InvalidVersion.json.in b/Tests/RunCMake/CMakePresets/InvalidVersion.json.in new file mode 100644 index 0000000..e6e19bc --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidVersion.json.in @@ -0,0 +1,4 @@ +{ + "version": "1.0", + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/JSONParseError-result.txt b/Tests/RunCMake/CMakePresets/JSONParseError-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/JSONParseError-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/JSONParseError-stderr.txt b/Tests/RunCMake/CMakePresets/JSONParseError-stderr.txt new file mode 100644 index 0000000..a43bf77 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/JSONParseError-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/JSONParseError: JSON parse error$ diff --git a/Tests/RunCMake/CMakePresets/JSONParseError.json.in b/Tests/RunCMake/CMakePresets/JSONParseError.json.in new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/ListPresets-stdout.txt b/Tests/RunCMake/CMakePresets/ListPresets-stdout.txt new file mode 100644 index 0000000..1758f33 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresets-stdout.txt @@ -0,0 +1,6 @@ +^Not searching for unused variables given on the command line\. +Available presets: + + "zzzzzz" - Sleepy + "aaaaaaaa" - Screaming + "mmmmmm"$ diff --git a/Tests/RunCMake/CMakePresets/ListPresets.json.in b/Tests/RunCMake/CMakePresets/ListPresets.json.in new file mode 100644 index 0000000..c7646c6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresets.json.in @@ -0,0 +1,36 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "zzzzzz", + "displayName": "Sleepy", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/zzzzzz" + }, + { + "name": "aaaaaaaa", + "displayName": "Screaming", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/aaaaaaaa" + }, + { + "name": "mmmmmm", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/mmmmmm" + }, + { + "name": "invalid-generator", + "generator": "Invalid Generator", + "binaryDir": "${sourceDir}/build/invalid" + }, + { + "name": "invalid-macro", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${noexist}" + }, + { + "name": "ListPresetsHidden", + "hidden": true + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/ListPresetsHidden-result.txt b/Tests/RunCMake/CMakePresets/ListPresetsHidden-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsHidden-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ListPresetsHidden-stderr.txt b/Tests/RunCMake/CMakePresets/ListPresetsHidden-stderr.txt new file mode 100644 index 0000000..1403814 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsHidden-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Cannot use hidden preset in [^ +]*/Tests/RunCMake/CMakePresets/ListPresetsHidden: "ListPresetsHidden"$ diff --git a/Tests/RunCMake/CMakePresets/ListPresetsHidden-stdout.txt b/Tests/RunCMake/CMakePresets/ListPresetsHidden-stdout.txt new file mode 100644 index 0000000..1758f33 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsHidden-stdout.txt @@ -0,0 +1,6 @@ +^Not searching for unused variables given on the command line\. +Available presets: + + "zzzzzz" - Sleepy + "aaaaaaaa" - Screaming + "mmmmmm"$ diff --git a/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-result.txt b/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stderr.txt b/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stderr.txt new file mode 100644 index 0000000..eea1b99 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: No such preset in [^ +]*/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset: "ListPresetsNoSuchPreset"$ diff --git a/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stdout.txt b/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stdout.txt new file mode 100644 index 0000000..1758f33 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsNoSuchPreset-stdout.txt @@ -0,0 +1,6 @@ +^Not searching for unused variables given on the command line\. +Available presets: + + "zzzzzz" - Sleepy + "aaaaaaaa" - Screaming + "mmmmmm"$ diff --git a/Tests/RunCMake/CMakePresets/ListPresetsWorkingDir-stdout.txt b/Tests/RunCMake/CMakePresets/ListPresetsWorkingDir-stdout.txt new file mode 100644 index 0000000..1758f33 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListPresetsWorkingDir-stdout.txt @@ -0,0 +1,6 @@ +^Not searching for unused variables given on the command line\. +Available presets: + + "zzzzzz" - Sleepy + "aaaaaaaa" - Screaming + "mmmmmm"$ diff --git a/Tests/RunCMake/CMakePresets/LowVersion-result.txt b/Tests/RunCMake/CMakePresets/LowVersion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/LowVersion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/LowVersion-stderr.txt b/Tests/RunCMake/CMakePresets/LowVersion-stderr.txt new file mode 100644 index 0000000..92b3723 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/LowVersion-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/LowVersion: Unrecognized "version" field$ diff --git a/Tests/RunCMake/CMakePresets/LowVersion.json.in b/Tests/RunCMake/CMakePresets/LowVersion.json.in new file mode 100644 index 0000000..e03afa9 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/LowVersion.json.in @@ -0,0 +1,4 @@ +{ + "version": 0, + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.cmake b/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.json.in b/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.json.in new file mode 100644 index 0000000..37740ef --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "cmakeMinimumRequired": {}, + "configurePresets": [ + { + "name": "MinimumRequiredEmpty", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-result.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-stderr.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-stderr.txt new file mode 100644 index 0000000..6548caf --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid: Invalid "cmakeMinimumRequired" field$ diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid.json.in b/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid.json.in new file mode 100644 index 0000000..da79603 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredInvalid.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "cmakeMinimumRequired": "3.18", + "configurePresets": [ + { + "name": "MinimumRequiredInvalid", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredMajor-result.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredMajor-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredMajor-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredMajor-stderr.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredMajor-stderr.txt new file mode 100644 index 0000000..6036fe3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredMajor-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/MinimumRequiredMajor: "cmakeMinimumRequired" version too new$ diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredMajor.json.in b/Tests/RunCMake/CMakePresets/MinimumRequiredMajor.json.in new file mode 100644 index 0000000..a17cdf6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredMajor.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "cmakeMinimumRequired": { + "major": 1000 + }, + "configurePresets": [ + { + "name": "MinimumRequiredMajor", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredMinor-result.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredMinor-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredMinor-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredMinor-stderr.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredMinor-stderr.txt new file mode 100644 index 0000000..bdee4cd --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredMinor-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/MinimumRequiredMinor: "cmakeMinimumRequired" version too new$ diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredMinor.json.in b/Tests/RunCMake/CMakePresets/MinimumRequiredMinor.json.in new file mode 100644 index 0000000..33a8816 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredMinor.json.in @@ -0,0 +1,14 @@ +{ + "version": 1, + "cmakeMinimumRequired": { + "major": @CMAKE_MAJOR_VERSION@, + "minor": 1000 + }, + "configurePresets": [ + { + "name": "MinimumRequiredMinor", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredPatch-result.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredPatch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredPatch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredPatch-stderr.txt b/Tests/RunCMake/CMakePresets/MinimumRequiredPatch-stderr.txt new file mode 100644 index 0000000..b5d3a39 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredPatch-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/MinimumRequiredPatch: "cmakeMinimumRequired" version too new$ diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredPatch.json.in b/Tests/RunCMake/CMakePresets/MinimumRequiredPatch.json.in new file mode 100644 index 0000000..4a53f8d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredPatch.json.in @@ -0,0 +1,15 @@ +{ + "version": 1, + "cmakeMinimumRequired": { + "major": @CMAKE_MAJOR_VERSION@, + "minor": @CMAKE_MINOR_VERSION@, + "patch": 50000000 + }, + "configurePresets": [ + { + "name": "MinimumRequiredPatch", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/NoCMakePresets-result.txt b/Tests/RunCMake/CMakePresets/NoCMakePresets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoCMakePresets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoCMakePresets-stderr.txt b/Tests/RunCMake/CMakePresets/NoCMakePresets-stderr.txt new file mode 100644 index 0000000..c807ffc --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoCMakePresets-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/NoCMakePresets: File not found$ diff --git a/Tests/RunCMake/CMakePresets/NoDebug-stdout.txt b/Tests/RunCMake/CMakePresets/NoDebug-stdout.txt new file mode 100644 index 0000000..c23ab89 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoDebug-stdout.txt @@ -0,0 +1,2 @@ +-- Configuring done +-- Generating done diff --git a/Tests/RunCMake/CMakePresets/NoDebug.cmake b/Tests/RunCMake/CMakePresets/NoDebug.cmake new file mode 100644 index 0000000..f2b3d4a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoDebug.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/DebugBase.cmake) +if(EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeLists.txt") + message(SEND_ERROR "Not debugging try_compile() did not work") +endif() diff --git a/Tests/RunCMake/CMakePresets/NoPresetArgument-result.txt b/Tests/RunCMake/CMakePresets/NoPresetArgument-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetArgument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoPresetArgument-stderr.txt b/Tests/RunCMake/CMakePresets/NoPresetArgument-stderr.txt new file mode 100644 index 0000000..aef30d2 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetArgument-stderr.txt @@ -0,0 +1 @@ +^CMake Error: No preset specified for --preset$ diff --git a/Tests/RunCMake/CMakePresets/NoPresetBinaryDir-result.txt b/Tests/RunCMake/CMakePresets/NoPresetBinaryDir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetBinaryDir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoPresetBinaryDir-stderr.txt b/Tests/RunCMake/CMakePresets/NoPresetBinaryDir-stderr.txt new file mode 100644 index 0000000..b525fc3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetBinaryDir-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/NoPresetBinaryDir: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/NoPresetBinaryDir.json.in b/Tests/RunCMake/CMakePresets/NoPresetBinaryDir.json.in new file mode 100644 index 0000000..8989cfd --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetBinaryDir.json.in @@ -0,0 +1,9 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "NoPresetBinaryDir", + "generator": "@RunCMake_GENERATOR@" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/NoPresetGenerator-result.txt b/Tests/RunCMake/CMakePresets/NoPresetGenerator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetGenerator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoPresetGenerator-stderr.txt b/Tests/RunCMake/CMakePresets/NoPresetGenerator-stderr.txt new file mode 100644 index 0000000..6c0c9f7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetGenerator-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/NoPresetGenerator: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/NoPresetGenerator.json.in b/Tests/RunCMake/CMakePresets/NoPresetGenerator.json.in new file mode 100644 index 0000000..74f83b7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetGenerator.json.in @@ -0,0 +1,9 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "NoPresetGenerator", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/NoPresetName-result.txt b/Tests/RunCMake/CMakePresets/NoPresetName-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetName-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoPresetName-stderr.txt b/Tests/RunCMake/CMakePresets/NoPresetName-stderr.txt new file mode 100644 index 0000000..0ee338a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetName-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/NoPresetName: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/NoPresetName.json.in b/Tests/RunCMake/CMakePresets/NoPresetName.json.in new file mode 100644 index 0000000..373591d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresetName.json.in @@ -0,0 +1,9 @@ +{ + "version": 1, + "configurePresets": [ + { + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/NoPresets-result.txt b/Tests/RunCMake/CMakePresets/NoPresets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoPresets-stderr.txt b/Tests/RunCMake/CMakePresets/NoPresets-stderr.txt new file mode 100644 index 0000000..5ff3d33 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresets-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: No such preset in [^ +]*/Tests/RunCMake/CMakePresets/NoPresets: "NoPresets"$ diff --git a/Tests/RunCMake/CMakePresets/NoPresets-stdout.txt b/Tests/RunCMake/CMakePresets/NoPresets-stdout.txt new file mode 100644 index 0000000..cb01a02 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresets-stdout.txt @@ -0,0 +1 @@ +^Not searching for unused variables given on the command line\.$ diff --git a/Tests/RunCMake/CMakePresets/NoPresets.json.in b/Tests/RunCMake/CMakePresets/NoPresets.json.in new file mode 100644 index 0000000..61a2092 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoPresets.json.in @@ -0,0 +1,3 @@ +{ + "version": 1 +} diff --git a/Tests/RunCMake/CMakePresets/NoSuchMacro-result.txt b/Tests/RunCMake/CMakePresets/NoSuchMacro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoSuchMacro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoSuchMacro-stderr.txt b/Tests/RunCMake/CMakePresets/NoSuchMacro-stderr.txt new file mode 100644 index 0000000..08fa87b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoSuchMacro-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Could not evaluate preset "NoSuchMacro": Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/NoSuchPreset-result.txt b/Tests/RunCMake/CMakePresets/NoSuchPreset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoSuchPreset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoSuchPreset-stderr.txt b/Tests/RunCMake/CMakePresets/NoSuchPreset-stderr.txt new file mode 100644 index 0000000..9a2d0d5 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoSuchPreset-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: No such preset in [^ +]*/Tests/RunCMake/CMakePresets/NoSuchPreset: "NoSuchPreset"$ diff --git a/Tests/RunCMake/CMakePresets/NoVariableValue-result.txt b/Tests/RunCMake/CMakePresets/NoVariableValue-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoVariableValue-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoVariableValue-stderr.txt b/Tests/RunCMake/CMakePresets/NoVariableValue-stderr.txt new file mode 100644 index 0000000..cdab32f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoVariableValue-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/NoVariableValue: Invalid CMake variable definition$ diff --git a/Tests/RunCMake/CMakePresets/NoVariableValue.json.in b/Tests/RunCMake/CMakePresets/NoVariableValue.json.in new file mode 100644 index 0000000..482700d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoVariableValue.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "NoVariableValue", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "VAR": {} + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/NoVersion-result.txt b/Tests/RunCMake/CMakePresets/NoVersion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoVersion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/NoVersion-stderr.txt b/Tests/RunCMake/CMakePresets/NoVersion-stderr.txt new file mode 100644 index 0000000..d4f07e4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoVersion-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/NoVersion: No "version" field$ diff --git a/Tests/RunCMake/CMakePresets/NoVersion.json.in b/Tests/RunCMake/CMakePresets/NoVersion.json.in new file mode 100644 index 0000000..3fe8332 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoVersion.json.in @@ -0,0 +1,3 @@ +{ + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/NoWarningFlags-stderr.txt b/Tests/RunCMake/CMakePresets/NoWarningFlags-stderr.txt new file mode 100644 index 0000000..a16d362 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoWarningFlags-stderr.txt @@ -0,0 +1,23 @@ +^CMake Warning \(dev\) at [^ +]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\): + Dev warning +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakePresets/NoWarningFlags\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\. + +CMake Deprecation Warning at [^ +]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\): + Deprecation warning +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakePresets/NoWarningFlags\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) + + +CMake Warning: + Manually-specified variables were not used by the project: + + RunCMake_GENERATOR + UNUSED_VARIABLE$ diff --git a/Tests/RunCMake/CMakePresets/NoWarningFlags.cmake b/Tests/RunCMake/CMakePresets/NoWarningFlags.cmake new file mode 100644 index 0000000..5de7687 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoWarningFlags.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/WarningsBase.cmake) diff --git a/Tests/RunCMake/CMakePresets/PresetNotObject-result.txt b/Tests/RunCMake/CMakePresets/PresetNotObject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PresetNotObject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/PresetNotObject-stderr.txt b/Tests/RunCMake/CMakePresets/PresetNotObject-stderr.txt new file mode 100644 index 0000000..6604a14 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PresetNotObject-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/PresetNotObject: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/PresetNotObject.json.in b/Tests/RunCMake/CMakePresets/PresetNotObject.json.in new file mode 100644 index 0000000..d5892fc --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PresetNotObject.json.in @@ -0,0 +1,6 @@ +{ + "version": 1, + "configurePresets": [ + [] + ] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake new file mode 100644 index 0000000..f591964 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -0,0 +1,212 @@ +include(RunCMake) + +# Fix Visual Studio generator name +if(RunCMake_GENERATOR MATCHES "^(Visual Studio [0-9]+ [0-9]+) ") + set(RunCMake_GENERATOR "${CMAKE_MATCH_1}") +endif() + +function(run_cmake_presets name) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}") + set(_source_arg "${RunCMake_TEST_SOURCE_DIR}") + if(CMakePresets_RELATIVE_SOURCE) + set(_source_arg "../${name}") + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}") + configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt.in" "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" @ONLY) + + if(NOT CMakePresets_FILE) + set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/${name}.json.in") + endif() + if(EXISTS "${CMakePresets_FILE}") + configure_file("${CMakePresets_FILE}" "${RunCMake_TEST_SOURCE_DIR}/CMakePresets.json" @ONLY) + endif() + + if(NOT CMakeUserPresets_FILE) + set(CMakeUserPresets_FILE "${RunCMake_SOURCE_DIR}/${name}User.json.in") + endif() + if(EXISTS "${CMakeUserPresets_FILE}") + configure_file("${CMakeUserPresets_FILE}" "${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json" @ONLY) + endif() + + set(_s_arg -S) + if(CMakePresets_NO_S_ARG) + set(_s_arg) + endif() + set(_source_args ${_s_arg} ${_source_arg}) + if(CMakePresets_NO_SOURCE_ARGS) + set(_source_args) + endif() + set(_unused_cli --no-warn-unused-cli) + if(CMakePresets_WARN_UNUSED_CLI) + set(_unused_cli) + endif() + + set(RunCMake_TEST_COMMAND ${CMAKE_COMMAND} + ${_source_args} + -DRunCMake_TEST=${name} + -DRunCMake_GENERATOR=${RunCMake_GENERATOR} + -DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM} + ${_unused_cli} + --preset=${name} + ${ARGN} + ) + run_cmake(${name}) +endfunction() + +# Test CMakePresets.json errors +run_cmake_presets(NoCMakePresets) +run_cmake_presets(JSONParseError) +run_cmake_presets(InvalidRoot) +run_cmake_presets(NoVersion) +run_cmake_presets(InvalidVersion) +run_cmake_presets(LowVersion) +run_cmake_presets(HighVersion) +run_cmake_presets(InvalidVendor) +run_cmake_presets(NoPresets) +run_cmake_presets(InvalidPresets) +run_cmake_presets(PresetNotObject) +run_cmake_presets(NoPresetName) +run_cmake_presets(InvalidPresetName) +run_cmake_presets(EmptyPresetName) +run_cmake_presets(NoPresetGenerator) +run_cmake_presets(InvalidPresetGenerator) +run_cmake_presets(NoPresetBinaryDir) +run_cmake_presets(InvalidPresetBinaryDir) +run_cmake_presets(InvalidVariables) +run_cmake_presets(VariableNotObject) +run_cmake_presets(NoVariableValue) +run_cmake_presets(InvalidVariableValue) +run_cmake_presets(ExtraRootField) +run_cmake_presets(ExtraPresetField) +run_cmake_presets(ExtraVariableField) +run_cmake_presets(InvalidPresetVendor) +run_cmake_presets(DuplicatePresets) +run_cmake_presets(CyclicInheritance0) +run_cmake_presets(CyclicInheritance1) +run_cmake_presets(CyclicInheritance2) +run_cmake_presets(InvalidInheritance) +run_cmake_presets(ErrorNoWarningDev) +run_cmake_presets(ErrorNoWarningDeprecated) +run_cmake_presets(InvalidCMakeGeneratorConfig) +run_cmake_presets(UnknownCMakeGeneratorConfig) + +# Test cmakeMinimumRequired field +run_cmake_presets(MinimumRequiredInvalid) +run_cmake_presets(MinimumRequiredEmpty) +run_cmake_presets(MinimumRequiredMajor) +run_cmake_presets(MinimumRequiredMinor) +run_cmake_presets(MinimumRequiredPatch) + +# Test properly working CMakePresets.json +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/CMakePresets.json.in") +unset(ENV{TEST_ENV}) +unset(ENV{TEST_ENV_REF}) +unset(ENV{TEST_D_ENV_REF}) +set(ENV{TEST_ENV_OVERRIDE} "This environment variable will be overridden") +set(ENV{TEST_PENV} "Process environment variable") +set(ENV{TEST_ENV_REF_PENV} "suffix") +run_cmake_presets(Good "-DTEST_OVERRIDE_1=Overridden value" "-DTEST_OVERRIDE_2:STRING=Overridden value" -C "${RunCMake_SOURCE_DIR}/CacheOverride.cmake" "-UTEST_UNDEF") +unset(ENV{TEST_ENV_OVERRIDE}) +unset(ENV{TEST_PENV}) +unset(ENV{TEST_ENV_REF_PENV}) +run_cmake_presets(GoodNoArgs) +file(REMOVE_RECURSE ${RunCMake_BINARY_DIR}/GoodBinaryUp-build) +run_cmake_presets(GoodBinaryUp) +set(CMakePresets_RELATIVE_SOURCE TRUE) +run_cmake_presets(GoodBinaryRelative) +unset(CMakePresets_RELATIVE_SOURCE) +run_cmake_presets(GoodSpaces "--preset=Good Spaces") +if(WIN32) + run_cmake_presets(GoodWindowsBackslash) +endif() +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/GoodBOM.json.in") +run_cmake_presets(GoodBOM) +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/CMakePresets.json.in") +file(REMOVE_RECURSE ${RunCMake_BINARY_DIR}/GoodBinaryCmdLine-build) +run_cmake_presets(GoodBinaryCmdLine -B ${RunCMake_BINARY_DIR}/GoodBinaryCmdLine-build) +run_cmake_presets(GoodGeneratorCmdLine -G ${RunCMake_GENERATOR}) +run_cmake_presets(InvalidGeneratorCmdLine -G "Invalid Generator") +set(CMakePresets_NO_S_ARG TRUE) +run_cmake_presets(GoodNoS) +unset(CMakePresets_NO_S_ARG) +run_cmake_presets(GoodInheritanceParent) +run_cmake_presets(GoodInheritanceChild) +run_cmake_presets(GoodInheritanceOverride) +run_cmake_presets(GoodInheritanceMulti) +run_cmake_presets(GoodInheritanceMultiSecond) +run_cmake_presets(GoodInheritanceMacro) + +# Test bad preset arguments +run_cmake_presets(UnclosedMacro) +run_cmake_presets(NoSuchMacro) +run_cmake_presets(VendorMacro) +run_cmake_presets(InvalidGenerator) +run_cmake_presets(EnvCycle) + +# Test Visual Studio-specific stuff +if(RunCMake_GENERATOR MATCHES "^Visual Studio ") + run_cmake_presets(VisualStudioGeneratorArch) + run_cmake_presets(VisualStudioWin32) + run_cmake_presets(VisualStudioWin64) + run_cmake_presets(VisualStudioWin32Override -A x64) + if(NOT RunCMake_GENERATOR STREQUAL "Visual Studio 9 2008") + run_cmake_presets(VisualStudioToolset) + run_cmake_presets(VisualStudioToolsetOverride -T "Test Toolset") + run_cmake_presets(VisualStudioInheritanceParent) + run_cmake_presets(VisualStudioInheritanceChild) + run_cmake_presets(VisualStudioInheritanceOverride) + run_cmake_presets(VisualStudioInheritanceMulti) + run_cmake_presets(VisualStudioInheritanceMultiSecond) + endif() +else() + run_cmake_presets(CMakeGeneratorConfigNone) + run_cmake_presets(CMakeGeneratorConfigDefault) + run_cmake_presets(CMakeGeneratorConfigIgnore) +endif() + +# Test bad command line arguments +run_cmake_presets(NoSuchPreset) +run_cmake_presets(NoPresetArgument --preset=) +run_cmake_presets(UseHiddenPreset) + +# Test CMakeUserPresets.json +unset(CMakePresets_FILE) +run_cmake_presets(GoodUserOnly) +run_cmake_presets(GoodUserFromMain) +run_cmake_presets(GoodUserFromUser) + +# Test CMakeUserPresets.json errors +run_cmake_presets(UserDuplicateInUser) +run_cmake_presets(UserDuplicateCross) +run_cmake_presets(UserInheritance) + +# Test listing presets +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/ListPresets.json.in") +run_cmake_presets(ListPresets --list-presets) + +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ListPresetsWorkingDir") +set(RunCMake_TEST_NO_CLEAN 1) +set(CMakePresets_NO_SOURCE_ARGS 1) +run_cmake_presets(ListPresetsWorkingDir --list-presets) +unset(CMakePresets_NO_SOURCE_ARGS) +unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_TEST_BINARY_DIR) + +run_cmake_presets(ListPresetsNoSuchPreset) +run_cmake_presets(ListPresetsHidden) + +# Test warning and error flags +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Warnings.json.in") +set(CMakePresets_WARN_UNUSED_CLI 1) +run_cmake_presets(NoWarningFlags) +run_cmake_presets(WarningFlags) +run_cmake_presets(DisableWarningFlags) +run_cmake_presets(ErrorDev) +run_cmake_presets(ErrorDeprecated) +unset(CMakePresets_WARN_UNUSED_CLI) + +# Test debug +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Debug.json.in") +run_cmake_presets(NoDebug) +run_cmake_presets(Debug) diff --git a/Tests/RunCMake/CMakePresets/TestVariable.cmake b/Tests/RunCMake/CMakePresets/TestVariable.cmake new file mode 100644 index 0000000..934af52 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/TestVariable.cmake @@ -0,0 +1,25 @@ +function(test_variable name expected_type expected_value) + if(NOT DEFINED "${name}") + message(SEND_ERROR "${name} is not defined") + elseif(NOT "${${name}}" STREQUAL expected_value) + message(SEND_ERROR "Expected value of ${name}: \"${expected_value}\"\nActual value: \"${${name}}\"") + endif() + if(expected_type) + if(NOT DEFINED "CACHE{${name}}") + message(SEND_ERROR "Cache entry ${name} does not exist") + else() + get_property(type CACHE ${name} PROPERTY TYPE) + if(NOT type STREQUAL expected_type) + message(SEND_ERROR "Expected type of ${name}: \"${expected_type}\"\nActual type: \"${type}\"") + endif() + endif() + endif() +endfunction() + +function(test_environment_variable name expected_value) + if(NOT DEFINED "ENV{${name}}") + message(SEND_ERROR "Environment variable ${name} is not defined") + elseif(NOT "$ENV{${name}}" STREQUAL expected_value) + message(SEND_ERROR "Expected value of environment variable ${name}: \"${expected_value}\"\nActual value: \"$ENV{${name}}\"") + endif() +endfunction() diff --git a/Tests/RunCMake/CMakePresets/UnclosedMacro-result.txt b/Tests/RunCMake/CMakePresets/UnclosedMacro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnclosedMacro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UnclosedMacro-stderr.txt b/Tests/RunCMake/CMakePresets/UnclosedMacro-stderr.txt new file mode 100644 index 0000000..248510d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnclosedMacro-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Could not evaluate preset "UnclosedMacro": Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-result.txt b/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-stderr.txt b/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-stderr.txt new file mode 100644 index 0000000..b1759b0 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig.json.in b/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig.json.in new file mode 100644 index 0000000..900c6df --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownCMakeGeneratorConfig.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UnknownCMakeGeneratorConfig", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cmakeGeneratorConfig": "unknown" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UseHiddenPreset-result.txt b/Tests/RunCMake/CMakePresets/UseHiddenPreset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UseHiddenPreset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UseHiddenPreset-stderr.txt b/Tests/RunCMake/CMakePresets/UseHiddenPreset-stderr.txt new file mode 100644 index 0000000..45b4cd4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UseHiddenPreset-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Cannot use hidden preset in [^ +]*/Tests/RunCMake/CMakePresets/UseHiddenPreset: "UseHiddenPreset"$ diff --git a/Tests/RunCMake/CMakePresets/UserDuplicateCross-result.txt b/Tests/RunCMake/CMakePresets/UserDuplicateCross-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserDuplicateCross-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UserDuplicateCross-stderr.txt b/Tests/RunCMake/CMakePresets/UserDuplicateCross-stderr.txt new file mode 100644 index 0000000..125265f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserDuplicateCross-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/UserDuplicateCross: Duplicate presets$ diff --git a/Tests/RunCMake/CMakePresets/UserDuplicateCross.json.in b/Tests/RunCMake/CMakePresets/UserDuplicateCross.json.in new file mode 100644 index 0000000..172cfba --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserDuplicateCross.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UserDuplicateCross", + "generator": "@RunCMake_GENERATOR", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UserDuplicateCrossUser.json.in b/Tests/RunCMake/CMakePresets/UserDuplicateCrossUser.json.in new file mode 100644 index 0000000..172cfba --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserDuplicateCrossUser.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UserDuplicateCross", + "generator": "@RunCMake_GENERATOR", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UserDuplicateInUser-result.txt b/Tests/RunCMake/CMakePresets/UserDuplicateInUser-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserDuplicateInUser-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UserDuplicateInUser-stderr.txt b/Tests/RunCMake/CMakePresets/UserDuplicateInUser-stderr.txt new file mode 100644 index 0000000..1071b17 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserDuplicateInUser-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/UserDuplicateInUser: Duplicate presets$ diff --git a/Tests/RunCMake/CMakePresets/UserDuplicateInUserUser.json.in b/Tests/RunCMake/CMakePresets/UserDuplicateInUserUser.json.in new file mode 100644 index 0000000..365fafe --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserDuplicateInUserUser.json.in @@ -0,0 +1,15 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UserDuplicateInUser", + "generator": "@RunCMake_GENERATOR", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "UserDuplicateInUser", + "generator": "@RunCMake_GENERATOR", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UserInheritance-result.txt b/Tests/RunCMake/CMakePresets/UserInheritance-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserInheritance-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt b/Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt new file mode 100644 index 0000000..213215a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserInheritance-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/UserInheritance: Project preset inherits from user preset$ diff --git a/Tests/RunCMake/CMakePresets/UserInheritance.json.in b/Tests/RunCMake/CMakePresets/UserInheritance.json.in new file mode 100644 index 0000000..d9973d7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserInheritance.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UserInheritance", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "inherits": [ + "UserInheritanceUser" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UserInheritanceUser.json.in b/Tests/RunCMake/CMakePresets/UserInheritanceUser.json.in new file mode 100644 index 0000000..1321a73 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UserInheritanceUser.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UserInheritanceUser", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/VariableNotObject-result.txt b/Tests/RunCMake/CMakePresets/VariableNotObject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VariableNotObject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/VariableNotObject-stderr.txt b/Tests/RunCMake/CMakePresets/VariableNotObject-stderr.txt new file mode 100644 index 0000000..8cacb0a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VariableNotObject-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/VariableNotObject: Invalid CMake variable definition$ diff --git a/Tests/RunCMake/CMakePresets/VariableNotObject.json.in b/Tests/RunCMake/CMakePresets/VariableNotObject.json.in new file mode 100644 index 0000000..51298f5 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VariableNotObject.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "VariableNotObject", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "VAR": [] + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/VendorMacro-result.txt b/Tests/RunCMake/CMakePresets/VendorMacro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VendorMacro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/VendorMacro-stderr.txt b/Tests/RunCMake/CMakePresets/VendorMacro-stderr.txt new file mode 100644 index 0000000..2e98019 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VendorMacro-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Could not evaluate preset "VendorMacro": Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-result.txt b/Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-stderr.txt b/Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-stderr.txt new file mode 100644 index 0000000..a311321 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioGeneratorArch-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error: Could not create named generator Visual Studio [^ +]* Win64 +Using platforms in Visual Studio generator names is not supported in CMakePresets\.json\. + +Generators diff --git a/Tests/RunCMake/CMakePresets/VisualStudioInheritanceChild.cmake b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceChild.cmake new file mode 100644 index 0000000..d485ab3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceChild.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "Test Platform") +test_variable(CMAKE_VS_PLATFORM_TOOLSET "" "Test Toolset") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioInheritanceMulti.cmake b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceMulti.cmake new file mode 100644 index 0000000..d485ab3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceMulti.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "Test Platform") +test_variable(CMAKE_VS_PLATFORM_TOOLSET "" "Test Toolset") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioInheritanceMultiSecond.cmake b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceMultiSecond.cmake new file mode 100644 index 0000000..d485ab3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceMultiSecond.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "Test Platform") +test_variable(CMAKE_VS_PLATFORM_TOOLSET "" "Test Toolset") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioInheritanceOverride.cmake b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceOverride.cmake new file mode 100644 index 0000000..d485ab3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceOverride.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "Test Platform") +test_variable(CMAKE_VS_PLATFORM_TOOLSET "" "Test Toolset") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioInheritanceParent.cmake b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceParent.cmake new file mode 100644 index 0000000..d485ab3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioInheritanceParent.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "Test Platform") +test_variable(CMAKE_VS_PLATFORM_TOOLSET "" "Test Toolset") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioToolset.cmake b/Tests/RunCMake/CMakePresets/VisualStudioToolset.cmake new file mode 100644 index 0000000..722e976 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioToolset.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_TOOLSET "" "Test Toolset") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioToolsetOverride.cmake b/Tests/RunCMake/CMakePresets/VisualStudioToolsetOverride.cmake new file mode 100644 index 0000000..722e976 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioToolsetOverride.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_TOOLSET "" "Test Toolset") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioWin32.cmake b/Tests/RunCMake/CMakePresets/VisualStudioWin32.cmake new file mode 100644 index 0000000..a1c61b4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioWin32.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "Win32") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioWin32Override.cmake b/Tests/RunCMake/CMakePresets/VisualStudioWin32Override.cmake new file mode 100644 index 0000000..b3464d6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioWin32Override.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "x64") diff --git a/Tests/RunCMake/CMakePresets/VisualStudioWin64.cmake b/Tests/RunCMake/CMakePresets/VisualStudioWin64.cmake new file mode 100644 index 0000000..b3464d6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/VisualStudioWin64.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_VS_PLATFORM_NAME "" "x64") diff --git a/Tests/RunCMake/CMakePresets/WarningFlags-stderr.txt b/Tests/RunCMake/CMakePresets/WarningFlags-stderr.txt new file mode 100644 index 0000000..6e488a9 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/WarningFlags-stderr.txt @@ -0,0 +1,34 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/[^/ +]*:[0-9]+ \([a-zA-Z_][a-zA-Z0-9_]*\): + uninitialized variable '[^ +]*' +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(project\) +This warning is for project developers\. Use -Wno-dev to suppress it\..* +CMake Warning \(dev\) at [^ +]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\): + Dev warning +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakePresets/WarningFlags\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\. + +CMake Deprecation Warning at [^ +]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\): + Deprecation warning +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakePresets/WarningFlags\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) + + +CMake Warning \(dev\) at [^ +]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(set\): + uninitialized variable 'UNINITIALIZED_VARIABLE' +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakePresets/WarningFlags\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/CMakePresets/WarningFlags.cmake b/Tests/RunCMake/CMakePresets/WarningFlags.cmake new file mode 100644 index 0000000..5de7687 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/WarningFlags.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/WarningsBase.cmake) diff --git a/Tests/RunCMake/CMakePresets/Warnings.json.in b/Tests/RunCMake/CMakePresets/Warnings.json.in new file mode 100644 index 0000000..40ec6ce --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Warnings.json.in @@ -0,0 +1,50 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "NoWarningFlags", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "UNUSED_VARIABLE": "Unused" + } + }, + { + "name": "WarningFlags", + "inherits": "NoWarningFlags", + "warnings": { + "dev": true, + "deprecated": true, + "uninitialized": true, + "unusedCli": false, + "systemVars": true + } + }, + { + "name": "DisableWarningFlags", + "inherits": "NoWarningFlags", + "warnings": { + "dev": false, + "deprecated": false, + "unusedCli": false + } + }, + { + "name": "ErrorDev", + "inherits": "NoWarningFlags", + "errors": { + "dev": true + } + }, + { + "name": "ErrorDeprecated", + "inherits": "NoWarningFlags", + "warnings": { + "dev": false + }, + "errors": { + "deprecated": true + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/WarningsBase.cmake b/Tests/RunCMake/CMakePresets/WarningsBase.cmake new file mode 100644 index 0000000..1a434dc --- /dev/null +++ b/Tests/RunCMake/CMakePresets/WarningsBase.cmake @@ -0,0 +1,3 @@ +message(AUTHOR_WARNING "Dev warning") +message(DEPRECATION "Deprecation warning") +set(_uninitialized "${UNINITIALIZED_VARIABLE}") diff --git a/Tests/RunCMake/CMakePresets/main.c b/Tests/RunCMake/CMakePresets/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/CommandLine/NoArgs-stdout.txt b/Tests/RunCMake/CommandLine/NoArgs-stdout.txt index f1dafc8..50f7d9d 100644 --- a/Tests/RunCMake/CommandLine/NoArgs-stdout.txt +++ b/Tests/RunCMake/CommandLine/NoArgs-stdout.txt @@ -3,6 +3,7 @@ cmake \[options\] cmake \[options\] cmake \[options\] -S -B + cmake \[options\] -S --preset= Specify a source directory to \(re-\)generate a build system for it in the current working directory. Specify an existing build directory to -- cgit v0.12