diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:20:25 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:20:25 +0900 |
commit | 50e508f0913d5580aa156327527da3d29a66b90c (patch) | |
tree | d581ffbad59a2becc33bc79e75e504de500a8e93 /Tests | |
parent | 37869418c616f7e57c34b9287c4c8f3671df20de (diff) | |
download | cmake-50e508f0913d5580aa156327527da3d29a66b90c.tar.gz cmake-50e508f0913d5580aa156327527da3d29a66b90c.tar.bz2 cmake-50e508f0913d5580aa156327527da3d29a66b90c.zip |
Imported Upstream version 3.19.0upstream/3.19.0
Diffstat (limited to 'Tests')
1700 files changed, 16623 insertions, 1073 deletions
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt index a3c99466e..a574c4e1f 100644 --- a/Tests/Assembler/CMakeLists.txt +++ b/Tests/Assembler/CMakeLists.txt @@ -8,7 +8,7 @@ set(SRCS) # (at least) the following toolchains can process assembler files directly # and also generate assembler files from C: if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode|Ninja" AND - NOT CMAKE_OSX_ARCHITECTURES) + NOT CMAKE_OSX_ARCHITECTURES MATCHES ";") if((CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND UNIX) AND NOT (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")) set(C_FLAGS "${CMAKE_C_FLAGS}") @@ -16,6 +16,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode|Ninja" AND if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};") list(APPEND C_FLAGS ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}) endif() + if(CMAKE_OSX_ARCHITECTURES) + list(APPEND C_FLAGS -arch ${CMAKE_OSX_ARCHITECTURES}) + elseif("${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + list(APPEND C_FLAGS -arch arm64) + endif() # Clang on OS X, and perhaps other compilers, do not support -g # for both generating and assembling, so drop it from generating. list(REMOVE_ITEM C_FLAGS -g) diff --git a/Tests/BootstrapTest.cmake b/Tests/BootstrapTest.cmake index 07a65bfd6..137de78bc 100644 --- a/Tests/BootstrapTest.cmake +++ b/Tests/BootstrapTest.cmake @@ -1,12 +1,15 @@ file(MAKE_DIRECTORY "${bin_dir}") include(ProcessorCount) ProcessorCount(nproc) +if(generator MATCHES "Ninja") + set(ninja_arg --generator=Ninja) +endif() if(NOT nproc EQUAL 0) set(parallel_arg --parallel=${nproc}) endif() -message(STATUS "running bootstrap: ${bootstrap} ${parallel_arg}") +message(STATUS "running bootstrap: ${bootstrap} ${ninja_arg} ${parallel_arg}") execute_process( - COMMAND ${bootstrap} ${parallel_arg} + COMMAND ${bootstrap} ${ninja_arg} ${parallel_arg} WORKING_DIRECTORY "${bin_dir}" RESULT_VARIABLE result ) diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 83583c98c..c438e1dde 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -59,6 +59,10 @@ add_executable(bar bar.cxx ${CMAKE_CURRENT_BINARY_DIR}/noregen.h ) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + target_compile_definitions(bar PRIVATE XCODE_NEW_BUILD_SYSTEM) +endif() + #----------------------------------------------------------------------------- if("${CMAKE_GENERATOR}" MATCHES "Make") # Test the IMPLICIT_DEPENDS feature. diff --git a/Tests/BuildDepends/Project/bar.cxx b/Tests/BuildDepends/Project/bar.cxx index ec7aa65e2..825d6610c 100644 --- a/Tests/BuildDepends/Project/bar.cxx +++ b/Tests/BuildDepends/Project/bar.cxx @@ -7,8 +7,14 @@ int main(int argc, char** argv) { /* Make sure the noregen header was not regenerated. */ if (strcmp("foo", noregen_string) != 0) { +#ifdef XCODE_NEW_BUILD_SYSTEM + fprintf(stderr, + "Known limitation: noregen.h was regenerated " + "but we cannot stop Xcode from doing this!\n"); +#else printf("FAILED: noregen.h was regenerated!\n"); return 1; +#endif } /* Print out the string that should have been regenerated. */ diff --git a/Tests/CMakeGUI/CMakeGUITest.cmake b/Tests/CMakeGUI/CMakeGUITest.cmake new file mode 100644 index 000000000..2c6baf3ab --- /dev/null +++ b/Tests/CMakeGUI/CMakeGUITest.cmake @@ -0,0 +1,158 @@ +function(run_cmake_gui_test name) + if(DEFINED ENV{CMakeGUITest_TEST_FILTER} AND NOT name MATCHES "$ENV{CMakeGUITest_TEST_FILTER}") + return() + endif() + + set(_fail) + + cmake_parse_arguments(_rcgt + "DO_CONFIGURE" + "GENERATOR" + "ARGS;CONFIGURE_ARGS" + ${ARGN} + ) + + string(REPLACE ":" "-" _file_name "${name}") + set(_srcdir "${CMakeGUITest_SOURCE_DIR}/${_file_name}") + set(_workdir "${CMakeGUITest_BINARY_DIR}/${_file_name}") + + file(REMOVE_RECURSE "${_workdir}") + file(MAKE_DIRECTORY "${_workdir}") + + set(_ini_in "${_srcdir}/CMakeSetup.ini.in") + if(EXISTS "${_ini_in}") + configure_file("${_ini_in}" "${_workdir}/config/Kitware/CMakeSetup.ini" @ONLY) + endif() + set(_cmakelists_in "${_srcdir}/CMakeLists.txt.in") + if(EXISTS "${_cmakelists_in}") + configure_file("${_cmakelists_in}" "${_workdir}/src/CMakeLists.txt" @ONLY) + endif() + set(_cmakepresets_in "${_srcdir}/CMakePresets.json.in") + if(EXISTS "${_cmakepresets_in}") + configure_file("${_cmakepresets_in}" "${_workdir}/src/CMakePresets.json" @ONLY) + endif() + if(_rcgt_DO_CONFIGURE) + if(NOT _rcgt_GENERATOR) + set(_rcgt_GENERATOR "${CMakeGUITest_GENERATOR}") + endif() + execute_process( + COMMAND "${CMAKE_COMMAND}" + -S "${_workdir}/src" + -B "${_workdir}/build" + -G "${_rcgt_GENERATOR}" + ${_rcgt_CONFIGURE_ARGS} + RESULT_VARIABLE _result + OUTPUT_VARIABLE _output + ERROR_VARIABLE _error + ) + if(_result) + set(_fail 1) + string(REPLACE "\n" "\n " _formatted_output "${_output}") + string(REPLACE "\n" "\n " _formatted_error "${_error}") + message(SEND_ERROR + "Configuring ${_workdir}/src failed with exit code ${_result}, should be 0\n" + "stdout:\n ${_formatted_output}\n" + "stderr:\n ${_formatted_error}" + ) + endif() + endif() + + set(ENV{CMake_GUI_TEST_NAME} "${name}") + set(ENV{CMake_GUI_CONFIG_DIR} "${_workdir}/config") + execute_process( + COMMAND "${CMakeGUITest_COMMAND}" ${_rcgt_ARGS} + WORKING_DIRECTORY "${_workdir}" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _output + ERROR_VARIABLE _error + ) + if(_result) + set(_fail 1) + string(REPLACE "\n" "\n " _formatted_output "${_output}") + string(REPLACE "\n" "\n " _formatted_error "${_error}") + message(SEND_ERROR "CMake GUI test ${name} failed with exit code ${_result}, should be 0\n" + "stdout:\n ${_formatted_output}\n" + "stderr:\n ${_formatted_error}" + ) + endif() + + if(NOT _fail) + message(STATUS "${name} -- passed") + endif() +endfunction() + +run_cmake_gui_test(sourceBinaryArgs:sourceAndBinaryDir + ARGS + -S "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-sourceAndBinaryDir/src" + -B "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-sourceAndBinaryDir/build" + ) +run_cmake_gui_test(sourceBinaryArgs:sourceAndBinaryDirRelative + ARGS + "-Ssrc" + "-Bbuild" + ) +run_cmake_gui_test(sourceBinaryArgs:sourceDir + ARGS + "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-sourceDir/src" + ) +run_cmake_gui_test(sourceBinaryArgs:binaryDir + DO_CONFIGURE + ARGS + "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-binaryDir/build" + ) +run_cmake_gui_test(sourceBinaryArgs:noExist + ARGS + "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-noExist/noexist" + ) +run_cmake_gui_test(sourceBinaryArgs:noExistConfig + ARGS + "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-noExistConfig/noexist" + ) +run_cmake_gui_test(sourceBinaryArgs:noExistConfigExists + DO_CONFIGURE + ARGS + "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-noExistConfigExists/noexist" + ) + +run_cmake_gui_test(simpleConfigure:success) +run_cmake_gui_test(simpleConfigure:fail) + +unset(ENV{ADDED_VARIABLE}) +set(ENV{KEPT_VARIABLE} "Kept variable") +set(ENV{CHANGED_VARIABLE} "This variable will be changed") +set(ENV{REMOVED_VARIABLE} "Removed variable") +run_cmake_gui_test(environment) + +run_cmake_gui_test(presetArg:preset + ARGS + -S "${CMakeGUITest_BINARY_DIR}/presetArg-preset/src" + "--preset=ninja" + ) +run_cmake_gui_test(presetArg:presetBinary + ARGS + -S "${CMakeGUITest_BINARY_DIR}/presetArg-presetBinary/src" + -B "${CMakeGUITest_BINARY_DIR}/presetArg-presetBinary/build" + "--preset=ninja" + ) +run_cmake_gui_test(presetArg:presetBinaryChange + ARGS + -S "${CMakeGUITest_BINARY_DIR}/presetArg-presetBinaryChange/src" + -B "${CMakeGUITest_BINARY_DIR}/presetArg-presetBinaryChange/build" + "--preset=ninja" + ) +run_cmake_gui_test(presetArg:noPresetBinaryChange + ARGS + -S "${CMakeGUITest_BINARY_DIR}/presetArg-noPresetBinaryChange/src" + -B "${CMakeGUITest_BINARY_DIR}/presetArg-noPresetBinaryChange/build" + ) +run_cmake_gui_test(presetArg:presetConfigExists + ARGS + -S "${CMakeGUITest_BINARY_DIR}/presetArg-presetConfigExists/src" + "--preset=ninja" + ) +run_cmake_gui_test(presetArg:noExist + ARGS + -S "${CMakeGUITest_BINARY_DIR}/presetArg-noExist/src" + "--preset=noExist" + ) +run_cmake_gui_test(changingPresets) diff --git a/Tests/CMakeGUI/CMakeGUITest.cxx b/Tests/CMakeGUI/CMakeGUITest.cxx new file mode 100644 index 000000000..2b5d9730f --- /dev/null +++ b/Tests/CMakeGUI/CMakeGUITest.cxx @@ -0,0 +1,449 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "CMakeGUITest.h" + +#include "QCMake.h" +#include <QApplication> +#include <QEventLoop> +#include <QFile> +#include <QJsonArray> +#include <QJsonDocument> +#include <QJsonObject> +#include <QMessageBox> +#include <QSettings> +#include <QString> +#include <QStringList> +#include <QTimer> +#include <QtGlobal> +#include <QtTest> + +#include "CMakeSetupDialog.h" + +#include "CatchShow.h" +#include "FirstConfigure.h" + +using WindowSetupHelper = std::function<void(CMakeSetupDialog*)>; +Q_DECLARE_METATYPE(WindowSetupHelper) + +namespace { +void loopSleep(int msecs = 500) +{ + QEventLoop loop; + QTimer::singleShot(msecs, &loop, &QEventLoop::quit); + loop.exec(); +} +} + +CMakeGUITest::CMakeGUITest(CMakeSetupDialog* window, QObject* parent) + : QObject(parent) + , m_window(window) +{ +} + +void CMakeGUITest::tryConfigure(int expectedResult, int timeout) +{ + auto* cmake = this->m_window->findChild<QCMakeThread*>()->cmakeInstance(); + + bool done = false; + CatchShow catchConfigure; + catchConfigure.setCallback<FirstConfigure>([&done](FirstConfigure* dialog) { + if (done) { + return; + } + done = true; + + dialog->findChild<StartCompilerSetup*>()->setCurrentGenerator( + CMAKE_GENERATOR); + dialog->accept(); + }); + + CatchShow catchMessages; + catchMessages.setCallback<QMessageBox>([](QMessageBox* box) { + if (box->text().contains("Build directory does not exist")) { + box->accept(); + } + + if (box->text().contains("Error in configuration process")) { + box->accept(); + } + }); + + QSignalSpy configureDoneSpy(cmake, &QCMake::configureDone); + QVERIFY(configureDoneSpy.isValid()); + QMetaObject::invokeMethod( + this->m_window, [this]() { this->m_window->ConfigureButton->click(); }, + Qt::QueuedConnection); + QVERIFY(configureDoneSpy.wait(timeout)); + + QCOMPARE(configureDoneSpy, { { expectedResult } }); +} + +void CMakeGUITest::sourceBinaryArgs() +{ + QFETCH(QString, sourceDir); + QFETCH(QString, binaryDir); + + // Wait a bit for everything to update + loopSleep(); + + QCOMPARE(this->m_window->SourceDirectory->text(), sourceDir); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), binaryDir); +} + +void CMakeGUITest::sourceBinaryArgs_data() +{ + QTest::addColumn<QString>("sourceDir"); + QTest::addColumn<QString>("binaryDir"); + + QTest::newRow("sourceAndBinaryDir") + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-sourceAndBinaryDir/src" + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-sourceAndBinaryDir/build"; + QTest::newRow("sourceAndBinaryDirRelative") << CMakeGUITest_BINARY_DIR + "/sourceBinaryArgs-sourceAndBinaryDirRelative/src" + << CMakeGUITest_BINARY_DIR + "/sourceBinaryArgs-sourceAndBinaryDirRelative/build"; + QTest::newRow("sourceDir") + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-sourceDir/src" + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-sourceDir"; + QTest::newRow("binaryDir") + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-binaryDir/src" + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-binaryDir/build"; + QTest::newRow("noExist") << "" + << ""; + QTest::newRow("noExistConfig") + << "" + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-noExistConfig/oldbuild"; + QTest::newRow("noExistConfigExists") + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-noExistConfigExists/src" + << CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-noExistConfigExists/build"; +} + +void CMakeGUITest::simpleConfigure() +{ + QFETCH(QString, sourceDir); + QFETCH(QString, binaryDir); + QFETCH(int, expectedResult); + + this->m_window->SourceDirectory->setText(sourceDir); + this->m_window->BinaryDirectory->setCurrentText(binaryDir); + + // Wait a bit for everything to update + loopSleep(); + + this->tryConfigure(expectedResult, 1000); +} + +void CMakeGUITest::simpleConfigure_data() +{ + QTest::addColumn<QString>("sourceDir"); + QTest::addColumn<QString>("binaryDir"); + QTest::addColumn<int>("expectedResult"); + + QTest::newRow("success") << CMakeGUITest_BINARY_DIR + "/simpleConfigure-success/src" + << CMakeGUITest_BINARY_DIR + "/simpleConfigure-success/build" + << 0; + QTest::newRow("fail") << CMakeGUITest_BINARY_DIR "/simpleConfigure-fail/src" + << CMakeGUITest_BINARY_DIR + "/simpleConfigure-fail/build" + << -1; +} + +void CMakeGUITest::environment() +{ + auto* cmake = this->m_window->findChild<QCMakeThread*>()->cmakeInstance(); + + this->m_window->SourceDirectory->setText(CMakeGUITest_BINARY_DIR + "/environment/src"); + this->m_window->BinaryDirectory->setCurrentText(CMakeGUITest_BINARY_DIR + "/environment/build"); + + // We are already testing EnvironmentDialog, so just trust that it's + // connected correctly and modify the environment directly. + auto env = cmake->environment(); + env.insert("ADDED_VARIABLE", "Added variable"); + env.insert("CHANGED_VARIABLE", "Changed variable"); + env.remove("REMOVED_VARIABLE"); + cmake->setEnvironment(env); + + // Wait a bit for everything to update + loopSleep(); + + this->tryConfigure(); + + auto penv = QProcessEnvironment::systemEnvironment(); + QVERIFY(!penv.contains("ADDED_VARIABLE")); + QCOMPARE(penv.value("KEPT_VARIABLE"), "Kept variable"); + QCOMPARE(penv.value("CHANGED_VARIABLE"), "This variable will be changed"); + QCOMPARE(penv.value("REMOVED_VARIABLE"), "Removed variable"); +} + +void CMakeGUITest::presetArg() +{ + QFETCH(WindowSetupHelper, setupFunction); + QFETCH(QString, presetName); + QFETCH(QString, sourceDir); + QFETCH(QString, binaryDir); + QFETCH(QCMakePropertyList, properties); + + if (setupFunction) { + setupFunction(this->m_window); + } + + // Wait a bit for everything to update + loopSleep(); + + QCOMPARE(this->m_window->Preset->presetName(), presetName); + QCOMPARE(this->m_window->SourceDirectory->text(), sourceDir); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), binaryDir); + + auto actualProperties = + this->m_window->CacheValues->cacheModel()->properties(); + QCOMPARE(actualProperties.size(), properties.size()); + for (int i = 0; i < actualProperties.size(); ++i) { + // operator==() only compares Key, we need to compare Value and Type too + QCOMPARE(actualProperties[i].Key, properties[i].Key); + QCOMPARE(actualProperties[i].Value, properties[i].Value); + QCOMPARE(actualProperties[i].Type, properties[i].Type); + } +} + +namespace { +QCMakePropertyList makePresetProperties(const QString& name) +{ + return QCMakePropertyList{ + QCMakeProperty{ + /*Key=*/"FALSE_VARIABLE", + /*Value=*/false, + /*Strings=*/{}, + /*Help=*/"", + /*Type=*/QCMakeProperty::BOOL, + /*Advanced=*/false, + }, + QCMakeProperty{ + /*Key=*/"FILEPATH_VARIABLE", + /*Value=*/ + QString::fromLocal8Bit(CMakeGUITest_BINARY_DIR "/%1/src/CMakeLists.txt") + .arg(name), + /*Strings=*/{}, + /*Help=*/"", + /*Type=*/QCMakeProperty::FILEPATH, + /*Advanced=*/false, + }, + QCMakeProperty{ + /*Key=*/"ON_VARIABLE", + /*Value=*/true, + /*Strings=*/{}, + /*Help=*/"", + /*Type=*/QCMakeProperty::BOOL, + /*Advanced=*/false, + }, + QCMakeProperty{ + /*Key=*/"PATH_VARIABLE", + /*Value=*/ + QString::fromLocal8Bit(CMakeGUITest_BINARY_DIR "/%1/src").arg(name), + /*Strings=*/{}, + /*Help=*/"", + /*Type=*/QCMakeProperty::PATH, + /*Advanced=*/false, + }, + QCMakeProperty{ + /*Key=*/"STRING_VARIABLE", + /*Value=*/"String value", + /*Strings=*/{}, + /*Help=*/"", + /*Type=*/QCMakeProperty::STRING, + /*Advanced=*/false, + }, + QCMakeProperty{ + /*Key=*/"UNINITIALIZED_VARIABLE", + /*Value=*/"Uninitialized value", + /*Strings=*/{}, + /*Help=*/"", + /*Type=*/QCMakeProperty::STRING, + /*Advanced=*/false, + }, + }; +} +} + +void CMakeGUITest::presetArg_data() +{ + QTest::addColumn<WindowSetupHelper>("setupFunction"); + QTest::addColumn<QString>("presetName"); + QTest::addColumn<QString>("sourceDir"); + QTest::addColumn<QString>("binaryDir"); + QTest::addColumn<QCMakePropertyList>("properties"); + + QTest::newRow("preset") << WindowSetupHelper{} << "ninja" + << CMakeGUITest_BINARY_DIR "/presetArg-preset/src" + << CMakeGUITest_BINARY_DIR + "/presetArg-preset/src/build" + << makePresetProperties("presetArg-preset"); + QTest::newRow("presetBinary") + << WindowSetupHelper{} << "ninja" + << CMakeGUITest_BINARY_DIR "/presetArg-presetBinary/src" + << CMakeGUITest_BINARY_DIR "/presetArg-presetBinary/build" + << makePresetProperties("presetArg-presetBinary"); + QTest::newRow("presetBinaryChange") + << WindowSetupHelper{ [](CMakeSetupDialog* window) { + loopSleep(); + window->Preset->setPresetName("ninja2"); + } } + << "ninja2" << CMakeGUITest_BINARY_DIR "/presetArg-presetBinaryChange/src" + << CMakeGUITest_BINARY_DIR "/presetArg-presetBinaryChange/src/build" + << makePresetProperties("presetArg-presetBinaryChange"); + QTest::newRow("noPresetBinaryChange") + << WindowSetupHelper{ [](CMakeSetupDialog* window) { + loopSleep(); + window->Preset->setPresetName("ninja"); + } } + << "ninja" << CMakeGUITest_BINARY_DIR "/presetArg-noPresetBinaryChange/src" + << CMakeGUITest_BINARY_DIR "/presetArg-noPresetBinaryChange/src/build" + << makePresetProperties("presetArg-noPresetBinaryChange"); + QTest::newRow("presetConfigExists") + << WindowSetupHelper{} << "ninja" + << CMakeGUITest_BINARY_DIR "/presetArg-presetConfigExists/src" + << CMakeGUITest_BINARY_DIR "/presetArg-presetConfigExists/src/build" + << makePresetProperties("presetArg-presetConfigExists"); + QTest::newRow("noExist") << WindowSetupHelper{} << QString{} + << CMakeGUITest_BINARY_DIR "/presetArg-noExist/src" + << "" << QCMakePropertyList{}; +} + +namespace { +void writePresets(const QString& buildDir, const QStringList& names) +{ + QJsonArray presets{ + QJsonObject{ + { "name", "base" }, + { "generator", "Ninja" }, + { "binaryDir", + QString::fromLocal8Bit("${sourceDir}/%1/${presetName}") + .arg(buildDir) }, + { "hidden", true }, + }, + }; + + for (auto const& name : names) { + presets.append(QJsonObject{ + { "name", name }, + { "inherits", QJsonArray{ "base" } }, + }); + } + + QJsonDocument doc{ QJsonObject{ + { "version", 1 }, + { "configurePresets", presets }, + } }; + + QFile presetsFile(CMakeGUITest_BINARY_DIR + "/changingPresets/src/CMakePresets.json"); + bool open = presetsFile.open(QIODevice::WriteOnly); + Q_ASSERT(open); + presetsFile.write(doc.toJson()); +} +} + +void CMakeGUITest::changingPresets() +{ + QDir::root().mkpath(CMakeGUITest_BINARY_DIR "/changingPresets/src"); + + this->m_window->SourceDirectory->setText(CMakeGUITest_BINARY_DIR + "/changingPresets/src"); + loopSleep(); + QCOMPARE(this->m_window->Preset->presetName(), QString{}); + QCOMPARE(this->m_window->Preset->presets().size(), 0); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), ""); + QCOMPARE(this->m_window->Preset->isEnabled(), false); + + writePresets("build1", { "preset" }); + loopSleep(1500); + QCOMPARE(this->m_window->Preset->presetName(), QString{}); + QCOMPARE(this->m_window->Preset->presets().size(), 1); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), ""); + QCOMPARE(this->m_window->Preset->isEnabled(), true); + + this->m_window->Preset->setPresetName("preset"); + loopSleep(); + QCOMPARE(this->m_window->Preset->presetName(), "preset"); + QCOMPARE(this->m_window->Preset->presets().size(), 1); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), + CMakeGUITest_BINARY_DIR "/changingPresets/src/build1/preset"); + QCOMPARE(this->m_window->Preset->isEnabled(), true); + + writePresets("build2", { "preset2", "preset" }); + loopSleep(1500); + QCOMPARE(this->m_window->Preset->presetName(), "preset"); + QCOMPARE(this->m_window->Preset->presets().size(), 2); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), + CMakeGUITest_BINARY_DIR "/changingPresets/src/build1/preset"); + QCOMPARE(this->m_window->Preset->isEnabled(), true); + + writePresets("build3", { "preset2" }); + loopSleep(1500); + QCOMPARE(this->m_window->Preset->presetName(), QString{}); + QCOMPARE(this->m_window->Preset->presets().size(), 1); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), + CMakeGUITest_BINARY_DIR "/changingPresets/src/build1/preset"); + QCOMPARE(this->m_window->Preset->isEnabled(), true); + + this->m_window->Preset->setPresetName("preset2"); + loopSleep(); + QCOMPARE(this->m_window->Preset->presetName(), "preset2"); + QCOMPARE(this->m_window->Preset->presets().size(), 1); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), + CMakeGUITest_BINARY_DIR "/changingPresets/src/build3/preset2"); + QCOMPARE(this->m_window->Preset->isEnabled(), true); + + QDir::root().mkpath(CMakeGUITest_BINARY_DIR "/changingPresets/src2"); + QFile::copy(CMakeGUITest_BINARY_DIR "/changingPresets/src/CMakePresets.json", + CMakeGUITest_BINARY_DIR + "/changingPresets/src2/CMakePresets.json"); + this->m_window->SourceDirectory->setText(CMakeGUITest_BINARY_DIR + "/changingPresets/src2"); + loopSleep(); + QCOMPARE(this->m_window->Preset->presetName(), QString{}); + QCOMPARE(this->m_window->Preset->presets().size(), 1); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), + CMakeGUITest_BINARY_DIR "/changingPresets/src/build3/preset2"); + QCOMPARE(this->m_window->Preset->isEnabled(), true); + + this->m_window->Preset->setPresetName("preset2"); + loopSleep(); + QCOMPARE(this->m_window->Preset->presetName(), "preset2"); + QCOMPARE(this->m_window->Preset->presets().size(), 1); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), + CMakeGUITest_BINARY_DIR "/changingPresets/src2/build3/preset2"); + QCOMPARE(this->m_window->Preset->isEnabled(), true); + + QFile(CMakeGUITest_BINARY_DIR "/changingPresets/src2/CMakePresets.json") + .remove(); + loopSleep(1500); + QCOMPARE(this->m_window->Preset->presetName(), QString{}); + QCOMPARE(this->m_window->Preset->presets().size(), 0); + QCOMPARE(this->m_window->BinaryDirectory->currentText(), + CMakeGUITest_BINARY_DIR "/changingPresets/src2/build3/preset2"); + QCOMPARE(this->m_window->Preset->isEnabled(), false); +} + +void SetupDefaultQSettings() +{ + QSettings::setDefaultFormat(QSettings::IniFormat); + QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, + QString::fromLocal8Bit(qgetenv("CMake_GUI_CONFIG_DIR"))); +} + +int CMakeGUIExec(CMakeSetupDialog* window) +{ + auto nameArray = qgetenv("CMake_GUI_TEST_NAME"); + auto name = QString::fromLocal8Bit(nameArray); + if (name.isEmpty()) { + return QApplication::exec(); + } + + QStringList args{ "CMakeGUITest", name }; + CMakeGUITest obj(window); + return QTest::qExec(&obj, args); +} diff --git a/Tests/CMakeGUI/CMakeGUITest.h b/Tests/CMakeGUI/CMakeGUITest.h new file mode 100644 index 000000000..e6293a4d8 --- /dev/null +++ b/Tests/CMakeGUI/CMakeGUITest.h @@ -0,0 +1,29 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include <QObject> + +class CMakeSetupDialog; + +class CMakeGUITest : public QObject +{ + Q_OBJECT +public: + CMakeGUITest(CMakeSetupDialog* window, QObject* parent = nullptr); + +private: + CMakeSetupDialog* m_window = nullptr; + + void tryConfigure(int expectedResult = 0, int timeout = 60000); + +private slots: + void sourceBinaryArgs(); + void sourceBinaryArgs_data(); + void simpleConfigure(); + void simpleConfigure_data(); + void environment(); + void presetArg(); + void presetArg_data(); + void changingPresets(); +}; diff --git a/Tests/CMakeGUI/CMakeLists.txt b/Tests/CMakeGUI/CMakeLists.txt new file mode 100644 index 000000000..4e8609b85 --- /dev/null +++ b/Tests/CMakeGUI/CMakeLists.txt @@ -0,0 +1,95 @@ +include(CMakeParseArguments) + +find_package(Qt5Test REQUIRED) + +include_directories( + ${CMake_SOURCE_DIR}/Source + ${CMake_SOURCE_DIR}/Source/QtDialog + ${CMake_BINARY_DIR}/Source/QtDialog + ) + +set(MOC_SRCS) +qt5_wrap_cpp(MOC_SRCS + CatchShow.h + ) +add_library(CMakeGUITestLib STATIC ${MOC_SRCS} + CatchShow.cxx + CatchShow.h + ) +target_link_libraries(CMakeGUITestLib Qt5::Core Qt5::Gui Qt5::Widgets) + +set(MOC_SRCS) +qt5_wrap_cpp(MOC_SRCS + CMakeGUITest.h + ) +add_executable(CMakeGUITest CMakeGUITest.cxx ${MOC_SRCS}) +target_link_libraries(CMakeGUITest CMakeGUIMainLib CMakeGUITestLib Qt5::Core Qt5::Test Qt5::Widgets) +target_compile_definitions(CMakeGUITest PRIVATE + "CMakeGUITest_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" + "CMakeGUITest_BINARY_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" + "CMAKE_GENERATOR=\"${CMAKE_GENERATOR}\"" + ) + +add_test(NAME CMakeGUI COMMAND ${CMAKE_CMAKE_COMMAND} + "-DCMakeGUITest_COMMAND=$<TARGET_FILE:CMakeGUITest>" + "-DCMakeGUITest_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" + "-DCMakeGUITest_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" + "-DCMakeGUITest_GENERATOR=${CMAKE_GENERATOR}" + -P "${CMAKE_CURRENT_LIST_DIR}/CMakeGUITest.cmake" + ) + +function(add_cmake_gui_lib_test name) + cmake_parse_arguments(_t "" "" "SOURCES;MOC_SOURCES" ${ARGN}) + + set(MOC_SRCS) + qt5_wrap_cpp(MOC_SRCS + ${_t_MOC_SOURCES} + ) + add_executable(${name} ${_t_SOURCES} ${MOC_SRCS}) + target_link_libraries(${name} CMakeGUILib CMakeGUITestLib Qt5::Core Qt5::Test Qt5::Widgets) + + add_test(NAME "CMakeGUILib.${name}" COMMAND ${name}) +endfunction() + +add_cmake_gui_lib_test(CatchShow + SOURCES + CatchShowTest.cxx + CatchShowTest.h + MOC_SOURCES + CatchShowTest.h + ) +add_cmake_gui_lib_test(EnvironmentDialog + SOURCES + EnvironmentDialogTest.cxx + EnvironmentDialogTest.h + MOC_SOURCES + EnvironmentDialogTest.h + ) +add_cmake_gui_lib_test(QCMakeCacheModel + SOURCES + QCMakeCacheModelTest.cxx + QCMakeCacheModelTest.h + MOC_SOURCES + QCMakeCacheModelTest.h + ) +add_cmake_gui_lib_test(QCMakePreset + SOURCES + QCMakePresetTest.cxx + QCMakePresetTest.h + MOC_SOURCES + QCMakePresetTest.h + ) +add_cmake_gui_lib_test(QCMakePresetItemModel + SOURCES + QCMakePresetItemModelTest.cxx + QCMakePresetItemModelTest.h + MOC_SOURCES + QCMakePresetItemModelTest.h + ) +add_cmake_gui_lib_test(QCMakePresetComboBox + SOURCES + QCMakePresetComboBoxTest.cxx + QCMakePresetComboBoxTest.h + MOC_SOURCES + QCMakePresetComboBoxTest.h + ) diff --git a/Tests/CMakeGUI/CatchShow.cxx b/Tests/CMakeGUI/CatchShow.cxx new file mode 100644 index 000000000..aee2d9da6 --- /dev/null +++ b/Tests/CMakeGUI/CatchShow.cxx @@ -0,0 +1,25 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "CatchShow.h" + +#include <QCoreApplication> + +CatchShow::CatchShow(QObject* parent) + : QObject(parent) +{ + QCoreApplication::instance()->installEventFilter(this); +} + +bool CatchShow::eventFilter(QObject* obj, QEvent* event) +{ + if (this->m_callback && event->type() == QEvent::Show) { + this->m_callback(obj); + } + + return this->QObject::eventFilter(obj, event); +} + +int CatchShow::count() const +{ + return this->m_count; +} diff --git a/Tests/CMakeGUI/CatchShow.h b/Tests/CMakeGUI/CatchShow.h new file mode 100644 index 000000000..0254c153c --- /dev/null +++ b/Tests/CMakeGUI/CatchShow.h @@ -0,0 +1,41 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include <functional> +#include <memory> + +#include <QObject> +#include <QWidget> + +class CatchShow : public QObject +{ + Q_OBJECT +public: + CatchShow(QObject* parent = nullptr); + + template <typename T, typename F> + void setCallback(F&& func); + bool eventFilter(QObject* obj, QEvent* event) override; + int count() const; + +private: + std::function<void(QObject* obj)> m_callback; + int m_count = 0; +}; + +template <typename T, typename F> +void CatchShow::setCallback(F&& func) +{ + this->m_callback = [this, func](QObject* obj) { + auto* d = qobject_cast<T*>(obj); + if (d) { + QMetaObject::invokeMethod(obj, + [this, func, d]() { + ++this->m_count; + func(d); + }, + Qt::QueuedConnection); + } + }; +} diff --git a/Tests/CMakeGUI/CatchShowTest.cxx b/Tests/CMakeGUI/CatchShowTest.cxx new file mode 100644 index 000000000..acea8ea0a --- /dev/null +++ b/Tests/CMakeGUI/CatchShowTest.cxx @@ -0,0 +1,49 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "CatchShowTest.h" + +#include <QMessageBox> +#include <QtTest> + +#include "CatchShow.h" + +CatchShowTest::CatchShowTest(QObject* parent) + : QObject(parent) +{ +} + +void CatchShowTest::catchShow() +{ + bool have = false; + CatchShow catcher; + catcher.setCallback<QMessageBox>([&have](QMessageBox* box) { + have = true; + box->accept(); + }); + + QCOMPARE(catcher.count(), 0); + QCOMPARE(have, false); + + { + QDialog dialog; + dialog.show(); + QCOMPARE(catcher.count(), 0); + QCOMPARE(have, false); + } + + { + have = false; + QMessageBox::critical(nullptr, "Error", "This is an error"); + QCOMPARE(catcher.count(), 1); + QCOMPARE(have, true); + } + + { + have = false; + QMessageBox::information(nullptr, "Info", "This is information"); + QCOMPARE(catcher.count(), 2); + QCOMPARE(have, true); + } +} + +QTEST_MAIN(CatchShowTest) diff --git a/Tests/CMakeGUI/CatchShowTest.h b/Tests/CMakeGUI/CatchShowTest.h new file mode 100644 index 000000000..6da216342 --- /dev/null +++ b/Tests/CMakeGUI/CatchShowTest.h @@ -0,0 +1,15 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include <QObject> + +class CatchShowTest : public QObject +{ + Q_OBJECT +public: + CatchShowTest(QObject* parent = nullptr); + +private slots: + void catchShow(); +}; diff --git a/Tests/CMakeGUI/EnvironmentDialogTest.cxx b/Tests/CMakeGUI/EnvironmentDialogTest.cxx new file mode 100644 index 000000000..9ec4996e3 --- /dev/null +++ b/Tests/CMakeGUI/EnvironmentDialogTest.cxx @@ -0,0 +1,142 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "EnvironmentDialogTest.h" + +#include <QDialogButtonBox> +#include <QMessageBox> +#include <QObject> +#include <QPushButton> +#include <QString> +#include <QtTest> + +#include "CatchShow.h" +#include "EnvironmentDialog.h" + +EnvironmentDialogTest::EnvironmentDialogTest(QObject* parent) + : QObject(parent) +{ +} + +void EnvironmentDialogTest::environmentDialog() +{ + CatchShow catcher; + catcher.setCallback<QMessageBox>([](QMessageBox* box) { box->accept(); }); + + QProcessEnvironment env; + env.insert("DELETED_VARIABLE_1", "Deleted variable 1"); + env.insert("DELETED_VARIABLE_2", "Deleted variable 2"); + env.insert("KEPT_VARIABLE", "Kept variable"); + env.insert("CHANGED_VARIABLE", "This will be changed"); + + EnvironmentDialog dialog(env); + + { + QStringList expected{ + "CHANGED_VARIABLE=This will be changed", + "DELETED_VARIABLE_1=Deleted variable 1", + "DELETED_VARIABLE_2=Deleted variable 2", + "KEPT_VARIABLE=Kept variable", + }; + QCOMPARE(dialog.environment().toStringList(), expected); + QCOMPARE(catcher.count(), 0); + } + + { + CatchShow catcher2; + bool done = false; + catcher2.setCallback<QDialog>([&catcher, &done](QDialog* box) { + if (done) { + return; + } + done = true; + + auto name = box->findChild<QLineEdit*>("name"); + auto value = box->findChild<QLineEdit*>("value"); + auto acceptReject = box->findChild<QDialogButtonBox*>(); + + name->setText(""); + value->setText(""); + acceptReject->button(QDialogButtonBox::Ok)->click(); + QCOMPARE(catcher.count(), 1); + + name->setText("KEPT_VARIABLE"); + value->setText(""); + acceptReject->button(QDialogButtonBox::Ok)->click(); + QCOMPARE(catcher.count(), 2); + + name->setText("ADDED_VARIABLE"); + value->setText("Added variable"); + acceptReject->button(QDialogButtonBox::Ok)->click(); + QCOMPARE(catcher.count(), 2); + }); + dialog.AddEntry->click(); + + QStringList expected{ + "ADDED_VARIABLE=Added variable", + "CHANGED_VARIABLE=This will be changed", + "DELETED_VARIABLE_1=Deleted variable 1", + "DELETED_VARIABLE_2=Deleted variable 2", + "KEPT_VARIABLE=Kept variable", + }; + QCOMPARE(dialog.environment().toStringList(), expected); + QCOMPARE(catcher.count(), 2); + QVERIFY(done); + } + + { + CatchShow catcher2; + bool done = false; + catcher2.setCallback<QDialog>([&done](QDialog* box) { + if (done) { + return; + } + done = true; + + auto name = box->findChild<QLineEdit*>("name"); + auto value = box->findChild<QLineEdit*>("value"); + auto acceptReject = box->findChild<QDialogButtonBox*>(); + + name->setText("DISCARDED_VARIABLE"); + value->setText("Discarded variable"); + acceptReject->button(QDialogButtonBox::Cancel)->click(); + }); + dialog.AddEntry->click(); + + QStringList expected{ + "ADDED_VARIABLE=Added variable", + "CHANGED_VARIABLE=This will be changed", + "DELETED_VARIABLE_1=Deleted variable 1", + "DELETED_VARIABLE_2=Deleted variable 2", + "KEPT_VARIABLE=Kept variable", + }; + QCOMPARE(dialog.environment().toStringList(), expected); + QCOMPARE(catcher.count(), 2); + QVERIFY(done); + } + + { + auto* model = dialog.Environment->model(); + auto* selectionModel = dialog.Environment->selectionModel(); + for (int i = 0; i < model->rowCount(); ++i) { + auto index1 = model->index(i, 0); + auto index2 = model->buddy(index1); + auto name = model->data(index1, Qt::DisplayRole).toString(); + if (name == "DELETED_VARIABLE_1" || name == "DELETED_VARIABLE_2") { + selectionModel->select(index1, QItemSelectionModel::Select); + selectionModel->select(index2, QItemSelectionModel::Select); + } else if (name == "CHANGED_VARIABLE") { + model->setData(index2, "Changed variable", Qt::DisplayRole); + } + } + dialog.RemoveEntry->click(); + + QStringList expected{ + "ADDED_VARIABLE=Added variable", + "CHANGED_VARIABLE=Changed variable", + "KEPT_VARIABLE=Kept variable", + }; + QCOMPARE(dialog.environment().toStringList(), expected); + } +} + +QTEST_MAIN(EnvironmentDialogTest) diff --git a/Tests/CMakeGUI/EnvironmentDialogTest.h b/Tests/CMakeGUI/EnvironmentDialogTest.h new file mode 100644 index 000000000..bcba2c5a8 --- /dev/null +++ b/Tests/CMakeGUI/EnvironmentDialogTest.h @@ -0,0 +1,15 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include <QObject> + +class EnvironmentDialogTest : public QObject +{ + Q_OBJECT +public: + EnvironmentDialogTest(QObject* parent = nullptr); + +private slots: + void environmentDialog(); +}; diff --git a/Tests/CMakeGUI/QCMakeCacheModelTest.cxx b/Tests/CMakeGUI/QCMakeCacheModelTest.cxx new file mode 100644 index 000000000..f9bc6aeb4 --- /dev/null +++ b/Tests/CMakeGUI/QCMakeCacheModelTest.cxx @@ -0,0 +1,108 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "QCMakeCacheModelTest.h" + +#include <algorithm> +#include <iostream> + +#include "QCMakeCacheView.h" +#include <QtTest> + +namespace { +QCMakeProperty makeProperty( + const QString& name, const QString& value, + QCMakeProperty::PropertyType type = QCMakeProperty::STRING, + bool advanced = false) +{ + return QCMakeProperty{ + /*Key=*/name, + /*Value=*/value, + /*Strings=*/{}, + /*Help=*/"", + /*Type=*/type, + /*Advanced=*/advanced, + }; +} +} + +void QCMakeCacheModelTest::setNewProperties() +{ + QFETCH(QCMakePropertyList, oldList); + QFETCH(QCMakePropertyList, newList); + QFETCH(QVector<QString>, names); + QFETCH(QVector<QString>, values); + QFETCH(QVector<QVariant>, background); + + QCMakeCacheModel model; + model.setViewType(QCMakeCacheModel::FlatView); + model.setProperties(oldList); + model.setProperties(newList); + + auto rows = model.rowCount(); + QVector<QString> actualNames(rows); + QVector<QString> actualValues(rows); + QVector<QVariant> actualBackground1(rows); + QVector<QVariant> actualBackground2(rows); + for (int i = 0; i < rows; ++i) { + auto idx1 = model.index(i, 0); + auto idx2 = model.index(i, 1); + + auto name = model.data(idx1, Qt::DisplayRole); + QVERIFY(name.canConvert<QString>()); + actualNames[i] = name.value<QString>(); + + auto value = model.data(idx2, Qt::DisplayRole); + QVERIFY(name.canConvert<QString>()); + actualValues[i] = value.value<QString>(); + + actualBackground1[i] = model.data(idx1, Qt::BackgroundRole); + actualBackground2[i] = model.data(idx2, Qt::BackgroundRole); + } + + QCOMPARE(actualNames, names); + QCOMPARE(actualValues, values); + QCOMPARE(actualBackground1, background); + QCOMPARE(actualBackground2, background); +} + +void QCMakeCacheModelTest::setNewProperties_data() +{ + QTest::addColumn<QCMakePropertyList>("oldList"); + QTest::addColumn<QCMakePropertyList>("newList"); + QTest::addColumn<QVector<QString>>("names"); + QTest::addColumn<QVector<QString>>("values"); + QTest::addColumn<QVector<QVariant>>("background"); + + QTest::newRow("empty") << QCMakePropertyList{} << QCMakePropertyList{} + << QVector<QString>{} << QVector<QString>{} + << QVector<QVariant>{}; + QTest::newRow("noNew") << QCMakePropertyList{ makeProperty("VARIABLE_1", + "Value 1") } + << QCMakePropertyList{} << QVector<QString>{} + << QVector<QString>{} << QVector<QVariant>{}; + QTest::newRow("allNew") + << QCMakePropertyList{} + << QCMakePropertyList{ makeProperty("VARIABLE_1", "Value 1") } + << QVector<QString>{ "VARIABLE_1" } << QVector<QString>{ "Value 1" } + << QVector<QVariant>{ QBrush{ QColor{ 255, 100, 100 } } }; + QTest::newRow("mixed") + << QCMakePropertyList{ makeProperty("VARIABLE_1", "Value 1") } + << QCMakePropertyList{ makeProperty("VARIABLE_2", "Value 2") } + << QVector<QString>{ "VARIABLE_2" } << QVector<QString>{ "Value 2" } + << QVector<QVariant>{ QBrush{ QColor{ 255, 100, 100 } } }; + QTest::newRow("overridden") + << QCMakePropertyList{ makeProperty("VARIABLE_1", "Value 1") } + << QCMakePropertyList{ makeProperty("VARIABLE_1", "Overridden value") } + << QVector<QString>{ "VARIABLE_1" } + << QVector<QString>{ "Overridden value" } + << QVector<QVariant>{ QVariant{} }; + QTest::newRow("overriddenMixed") + << QCMakePropertyList{ makeProperty("VARIABLE_1", "Value 1") } + << QCMakePropertyList{ makeProperty("VARIABLE_1", "Overridden value"), + makeProperty("VARIABLE_2", "Value 2") } + << QVector<QString>{ "VARIABLE_2", "VARIABLE_1" } + << QVector<QString>{ "Value 2", "Overridden value" } + << QVector<QVariant>{ QBrush{ QColor{ 255, 100, 100 } }, QVariant{} }; +} + +QTEST_MAIN(QCMakeCacheModelTest) diff --git a/Tests/CMakeGUI/QCMakeCacheModelTest.h b/Tests/CMakeGUI/QCMakeCacheModelTest.h new file mode 100644 index 000000000..e88db94ae --- /dev/null +++ b/Tests/CMakeGUI/QCMakeCacheModelTest.h @@ -0,0 +1,14 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include "QCMakeCacheView.h" +#include <QObject> + +class QCMakeCacheModelTest : public QObject +{ + Q_OBJECT +private slots: + void setNewProperties(); + void setNewProperties_data(); +}; diff --git a/Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx b/Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx new file mode 100644 index 000000000..a95d008bb --- /dev/null +++ b/Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx @@ -0,0 +1,82 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "QCMakePresetComboBoxTest.h" + +#include <QtTest> + +void QCMakePresetComboBoxTest::changePresets() +{ + QCMakePresetComboBox box; + QSignalSpy presetChanged(&box, &QCMakePresetComboBox::presetChanged); + + QCOMPARE(presetChanged.size(), 0); + + box.setPresets({}); + QCOMPARE(presetChanged.size(), 0); + + box.setPresetName(QString{}); + QCOMPARE(presetChanged.size(), 0); + + box.setPresets({ + { + /*name=*/"preset", + /*description=*/"", + /*description=*/"", + /*generator=*/"Ninja", + /*architecture=*/"", + /*setArchitecture=*/true, + /*toolset=*/"", + /*setToolset=*/true, + /*enabled=*/true, + }, + }); + QCOMPARE(presetChanged.size(), 0); + + box.setPresetName(QString{}); + QCOMPARE(presetChanged.size(), 0); + + box.setPresetName("noexist"); + QCOMPARE(presetChanged.size(), 0); + + box.setPresetName("preset"); + QCOMPARE(presetChanged.size(), 1); + QCOMPARE(presetChanged.last(), QList<QVariant>{ "preset" }); + + box.setPresets({ + { + /*name=*/"preset", + /*description=*/"", + /*description=*/"", + /*generator=*/"Ninja Multi-Config", + /*architecture=*/"", + /*setArchitecture=*/true, + /*toolset=*/"", + /*setToolset=*/true, + /*enabled=*/true, + }, + }); + QCOMPARE(presetChanged.size(), 1); + + box.setPresetName("noexist"); + QCOMPARE(presetChanged.size(), 2); + QCOMPARE(presetChanged.last(), QList<QVariant>{ QString{} }); + + box.setPresetName("preset"); + QCOMPARE(presetChanged.size(), 3); + QCOMPARE(presetChanged.last(), QList<QVariant>{ "preset" }); + + box.blockSignals(true); + box.setPresetName(QString{}); + box.blockSignals(false); + QCOMPARE(presetChanged.size(), 3); + + box.setPresetName("preset"); + QCOMPARE(presetChanged.size(), 4); + QCOMPARE(presetChanged.last(), QList<QVariant>{ "preset" }); + + box.setPresets({}); + QCOMPARE(presetChanged.size(), 5); + QCOMPARE(presetChanged.last(), QList<QVariant>{ QString{} }); +} + +QTEST_MAIN(QCMakePresetComboBoxTest) diff --git a/Tests/CMakeGUI/QCMakePresetComboBoxTest.h b/Tests/CMakeGUI/QCMakePresetComboBoxTest.h new file mode 100644 index 000000000..433adbb42 --- /dev/null +++ b/Tests/CMakeGUI/QCMakePresetComboBoxTest.h @@ -0,0 +1,13 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include "QCMakePresetComboBox.h" +#include <QObject> + +class QCMakePresetComboBoxTest : public QObject +{ + Q_OBJECT +private slots: + void changePresets(); +}; diff --git a/Tests/CMakeGUI/QCMakePresetItemModelTest.cxx b/Tests/CMakeGUI/QCMakePresetItemModelTest.cxx new file mode 100644 index 000000000..97dbb30fd --- /dev/null +++ b/Tests/CMakeGUI/QCMakePresetItemModelTest.cxx @@ -0,0 +1,166 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "QCMakePresetItemModelTest.h" + +#include <utility> + +#include "QCMakePreset.h" +#include "QCMakePresetItemModel.h" +#include <QHash> +#include <QMetaType> +#include <QSignalSpy> +#include <QVariant> +#include <QVector> +#include <QtTest> + +using QItemDataHash = QHash<Qt::ItemDataRole, QVariant>; + +void QCMakePresetItemModelTest::initTestCase() +{ + QMetaType::registerComparators<QCMakePreset>(); +} + +void QCMakePresetItemModelTest::initTestCase_data() +{ + QTest::addColumn<QVector<QCMakePreset>>("presets"); + QTest::addColumn<QVector<QItemDataHash>>("data"); + + QVector<QCMakePreset> presets{ + QCMakePreset{ + /*name=*/"no-description", + /*description=*/"", + /*description=*/"", + /*generator=*/"", + /*architecture=*/"", + /*setArchitecture=*/true, + /*toolset=*/"", + /*setToolset=*/true, + /*enabled=*/true, + }, + QCMakePreset{ + /*name=*/"short-description", + /*description=*/"Short Description", + /*description=*/"", + /*generator=*/"", + /*architecture=*/"", + /*setArchitecture=*/true, + /*toolset=*/"", + /*setToolset=*/true, + /*enabled=*/true, + }, + QCMakePreset{ + /*name=*/"long-description", + /*description=*/"", + /*description=*/"Long Description", + /*generator=*/"", + /*architecture=*/"", + /*setArchitecture=*/true, + /*toolset=*/"", + /*setToolset=*/true, + /*enabled=*/true, + }, + QCMakePreset{ + /*name=*/"disabled", + /*description=*/"", + /*description=*/"", + /*generator=*/"", + /*architecture=*/"", + /*setArchitecture=*/true, + /*toolset=*/"", + /*setToolset=*/true, + /*enabled=*/false, + }, + }; + QVector<QItemDataHash> data{ + QItemDataHash{ + { Qt::AccessibleDescriptionRole, "" }, + { Qt::DisplayRole, "no-description" }, + { Qt::ToolTipRole, "" }, + { Qt::UserRole, QVariant::fromValue(presets[0]) }, + { Qt::FontRole, QFont{} }, + }, + QItemDataHash{ + { Qt::AccessibleDescriptionRole, "" }, + { Qt::DisplayRole, "Short Description" }, + { Qt::ToolTipRole, "" }, + { Qt::UserRole, QVariant::fromValue(presets[1]) }, + { Qt::FontRole, QFont{} }, + }, + QItemDataHash{ + { Qt::AccessibleDescriptionRole, "" }, + { Qt::DisplayRole, "long-description" }, + { Qt::ToolTipRole, "Long Description" }, + { Qt::UserRole, QVariant::fromValue(presets[2]) }, + { Qt::FontRole, QFont{} }, + }, + QItemDataHash{ + { Qt::AccessibleDescriptionRole, "" }, + { Qt::DisplayRole, "disabled" }, + { Qt::ToolTipRole, "" }, + { Qt::UserRole, QVariant::fromValue(presets[3]) }, + { Qt::FontRole, QFont{} }, + }, + QItemDataHash{ + { Qt::AccessibleDescriptionRole, "separator" }, + { Qt::DisplayRole, QVariant{} }, + { Qt::ToolTipRole, QVariant{} }, + { Qt::UserRole, QVariant{} }, + { Qt::FontRole, QFont{} }, + }, + QItemDataHash{ + { Qt::AccessibleDescriptionRole, "" }, + { Qt::DisplayRole, "<custom>" }, + { Qt::ToolTipRole, "Specify all settings manually" }, + { Qt::UserRole, QVariant{} }, + { Qt::FontRole, + []() { + QFont f; + f.setItalic(true); + return f; + }() }, + }, + }; + QTest::newRow("many") << presets << data; + QTest::newRow("none") << QVector<QCMakePreset>{} + << QVector<QItemDataHash>{ data.last() }; +} + +void QCMakePresetItemModelTest::data() +{ + QFETCH_GLOBAL(QVector<QCMakePreset>, presets); + QFETCH_GLOBAL(QVector<QItemDataHash>, data); + QFETCH(Qt::ItemDataRole, role); + + QCMakePresetItemModel model; + QSignalSpy spy1(&model, &QCMakePresetItemModel::modelAboutToBeReset); + QSignalSpy spy2(&model, &QCMakePresetItemModel::modelReset); + model.setPresets(presets); + QCOMPARE(spy1.size(), 1); + QCOMPARE(spy2.size(), 1); + + QVector<QVariant> expectedData(data.size()); + for (int i = 0; i < data.size(); ++i) { + expectedData[i] = data[i][role]; + } + + auto rows = model.rowCount(); + QVector<QVariant> actualData(rows); + for (int i = 0; i < rows; ++i) { + actualData[i] = model.data(model.index(i, 0), role); + } + + QCOMPARE(actualData, expectedData); +} + +void QCMakePresetItemModelTest::data_data() +{ + QTest::addColumn<Qt::ItemDataRole>("role"); + + QTest::newRow("accessible") << Qt::AccessibleDescriptionRole; + QTest::newRow("display") << Qt::DisplayRole; + QTest::newRow("tooltip") << Qt::ToolTipRole; + QTest::newRow("user") << Qt::UserRole; + QTest::newRow("font") << Qt::FontRole; +} + +QTEST_MAIN(QCMakePresetItemModelTest) diff --git a/Tests/CMakeGUI/QCMakePresetItemModelTest.h b/Tests/CMakeGUI/QCMakePresetItemModelTest.h new file mode 100644 index 000000000..ff6efae27 --- /dev/null +++ b/Tests/CMakeGUI/QCMakePresetItemModelTest.h @@ -0,0 +1,17 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include "QCMakePresetItemModel.h" +#include <QObject> + +class QCMakePresetItemModelTest : public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + void initTestCase_data(); + + void data(); + void data_data(); +}; diff --git a/Tests/CMakeGUI/QCMakePresetTest.cxx b/Tests/CMakeGUI/QCMakePresetTest.cxx new file mode 100644 index 000000000..20810558e --- /dev/null +++ b/Tests/CMakeGUI/QCMakePresetTest.cxx @@ -0,0 +1,85 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "QCMakePresetTest.h" + +#include <utility> + +#include "QCMakePreset.h" +#include <QtTest> + +namespace { +QCMakePreset makePreset() +{ + return QCMakePreset{ + /*name=*/"name", + /*displayName=*/"displayName", + /*description=*/"description", + /*generator=*/"generator", + /*architecture=*/"architecture", + /*setArchitecture=*/true, + /*toolset=*/"toolset", + /*setToolset=*/true, + /*enabled=*/true, + }; +} + +template <typename T, typename U> +QCMakePreset makePreset(T QCMakePreset::*field, U&& value) +{ + auto preset = makePreset(); + preset.*field = std::forward<U>(value); + return preset; +} +} + +void QCMakePresetTest::equality() +{ + QFETCH(QCMakePreset, rhs); + QFETCH(bool, equal); + QFETCH(bool, lt); + QFETCH(bool, gt); + + auto lhs = makePreset(); + QVERIFY((lhs == rhs) == equal); + QVERIFY((lhs != rhs) == !equal); + QVERIFY((lhs < rhs) == lt); + QVERIFY((lhs >= rhs) == !lt); + QVERIFY((lhs > rhs) == gt); + QVERIFY((lhs <= rhs) == !gt); +} + +void QCMakePresetTest::equality_data() +{ + QTest::addColumn<QCMakePreset>("rhs"); + QTest::addColumn<bool>("equal"); + QTest::addColumn<bool>("lt"); + QTest::addColumn<bool>("gt"); + + QTest::newRow("equal") << makePreset() << true << false << false; + QTest::newRow("name") << makePreset(&QCMakePreset::name, "other-name") + << false << true << false; + QTest::newRow("displayName") + << makePreset(&QCMakePreset::displayName, "other-displayName") << false + << true << false; + QTest::newRow("description") + << makePreset(&QCMakePreset::description, "other-description") << false + << true << false; + QTest::newRow("generator") + << makePreset(&QCMakePreset::generator, "other-generator") << false << true + << false; + QTest::newRow("architecture") + << makePreset(&QCMakePreset::architecture, "other-architecture") << false + << true << false; + QTest::newRow("setArchitecture") + << makePreset(&QCMakePreset::setArchitecture, false) << false << false + << true; + QTest::newRow("toolset") << makePreset(&QCMakePreset::toolset, + "other-toolset") + << false << false << true; + QTest::newRow("setToolset") + << makePreset(&QCMakePreset::setToolset, false) << false << false << true; + QTest::newRow("enabled") << makePreset(&QCMakePreset::enabled, false) + << false << false << true; +} + +QTEST_MAIN(QCMakePresetTest) diff --git a/Tests/CMakeGUI/QCMakePresetTest.h b/Tests/CMakeGUI/QCMakePresetTest.h new file mode 100644 index 000000000..5eac88d8c --- /dev/null +++ b/Tests/CMakeGUI/QCMakePresetTest.h @@ -0,0 +1,14 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include "QCMakePreset.h" +#include <QObject> + +class QCMakePresetTest : public QObject +{ + Q_OBJECT +private slots: + void equality(); + void equality_data(); +}; diff --git a/Tests/CMakeGUI/environment/CMakeLists.txt.in b/Tests/CMakeGUI/environment/CMakeLists.txt.in new file mode 100644 index 000000000..1eeeb854d --- /dev/null +++ b/Tests/CMakeGUI/environment/CMakeLists.txt.in @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.18) +project(environment NONE) + +if(NOT "$ENV{KEPT_VARIABLE}" STREQUAL "Kept variable") + message(SEND_ERROR "KEPT_VARIABLE is \"$ENV{KEPT_VARIABLE}\", should be \"Kept variable\"") +endif() + +if(NOT "$ENV{ADDED_VARIABLE}" STREQUAL "Added variable") + message(SEND_ERROR "ADDED_VARIABLE is \"$ENV{ADDED_VARIABLE}\", should be \"Added variable\"") +endif() + +if(NOT "$ENV{CHANGED_VARIABLE}" STREQUAL "Changed variable") + message(SEND_ERROR "CHANGED_VARIABLE is \"$ENV{CHANGED_VARIABLE}\", should be \"Changed variable\"") +endif() + +if(DEFINED ENV{REMOVED_VARIABLE}) + message(SEND_ERROR "REMOVED_VARIABLE should not be defined") +endif() diff --git a/Tests/CMakeGUI/presetArg-noPresetBinaryChange/CMakePresets.json.in b/Tests/CMakeGUI/presetArg-noPresetBinaryChange/CMakePresets.json.in new file mode 100644 index 000000000..d78d69dc0 --- /dev/null +++ b/Tests/CMakeGUI/presetArg-noPresetBinaryChange/CMakePresets.json.in @@ -0,0 +1,33 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ninja", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "STRING_VARIABLE": { + "type": "STRING", + "value": "String value" + }, + "PATH_VARIABLE": { + "type": "PATH", + "value": "${sourceDir}" + }, + "FILEPATH_VARIABLE": { + "type": "FILEPATH", + "value": "${sourceDir}/CMakeLists.txt" + }, + "ON_VARIABLE": { + "type": "BOOL", + "value": "ON" + }, + "FALSE_VARIABLE": { + "type": "BOOL", + "value": "FALSE" + }, + "UNINITIALIZED_VARIABLE": "Uninitialized value" + } + } + ] +} diff --git a/Tests/CMakeGUI/presetArg-preset/CMakePresets.json.in b/Tests/CMakeGUI/presetArg-preset/CMakePresets.json.in new file mode 100644 index 000000000..d78d69dc0 --- /dev/null +++ b/Tests/CMakeGUI/presetArg-preset/CMakePresets.json.in @@ -0,0 +1,33 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ninja", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "STRING_VARIABLE": { + "type": "STRING", + "value": "String value" + }, + "PATH_VARIABLE": { + "type": "PATH", + "value": "${sourceDir}" + }, + "FILEPATH_VARIABLE": { + "type": "FILEPATH", + "value": "${sourceDir}/CMakeLists.txt" + }, + "ON_VARIABLE": { + "type": "BOOL", + "value": "ON" + }, + "FALSE_VARIABLE": { + "type": "BOOL", + "value": "FALSE" + }, + "UNINITIALIZED_VARIABLE": "Uninitialized value" + } + } + ] +} diff --git a/Tests/CMakeGUI/presetArg-presetBinary/CMakePresets.json.in b/Tests/CMakeGUI/presetArg-presetBinary/CMakePresets.json.in new file mode 100644 index 000000000..d78d69dc0 --- /dev/null +++ b/Tests/CMakeGUI/presetArg-presetBinary/CMakePresets.json.in @@ -0,0 +1,33 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ninja", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "STRING_VARIABLE": { + "type": "STRING", + "value": "String value" + }, + "PATH_VARIABLE": { + "type": "PATH", + "value": "${sourceDir}" + }, + "FILEPATH_VARIABLE": { + "type": "FILEPATH", + "value": "${sourceDir}/CMakeLists.txt" + }, + "ON_VARIABLE": { + "type": "BOOL", + "value": "ON" + }, + "FALSE_VARIABLE": { + "type": "BOOL", + "value": "FALSE" + }, + "UNINITIALIZED_VARIABLE": "Uninitialized value" + } + } + ] +} diff --git a/Tests/CMakeGUI/presetArg-presetBinaryChange/CMakePresets.json.in b/Tests/CMakeGUI/presetArg-presetBinaryChange/CMakePresets.json.in new file mode 100644 index 000000000..6fe20d68b --- /dev/null +++ b/Tests/CMakeGUI/presetArg-presetBinaryChange/CMakePresets.json.in @@ -0,0 +1,39 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ninja", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "STRING_VARIABLE": { + "type": "STRING", + "value": "String value" + }, + "PATH_VARIABLE": { + "type": "PATH", + "value": "${sourceDir}" + }, + "FILEPATH_VARIABLE": { + "type": "FILEPATH", + "value": "${sourceDir}/CMakeLists.txt" + }, + "ON_VARIABLE": { + "type": "BOOL", + "value": "ON" + }, + "FALSE_VARIABLE": { + "type": "BOOL", + "value": "FALSE" + }, + "UNINITIALIZED_VARIABLE": "Uninitialized value" + } + }, + { + "name": "ninja2", + "inherits": [ + "ninja" + ] + } + ] +} diff --git a/Tests/CMakeGUI/presetArg-presetConfigExists/CMakeLists.txt.in b/Tests/CMakeGUI/presetArg-presetConfigExists/CMakeLists.txt.in new file mode 100644 index 000000000..2ae4a5714 --- /dev/null +++ b/Tests/CMakeGUI/presetArg-presetConfigExists/CMakeLists.txt.in @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.18) +project(sourceBinaryArgs-sourceDir NONE) diff --git a/Tests/CMakeGUI/presetArg-presetConfigExists/CMakePresets.json.in b/Tests/CMakeGUI/presetArg-presetConfigExists/CMakePresets.json.in new file mode 100644 index 000000000..d78d69dc0 --- /dev/null +++ b/Tests/CMakeGUI/presetArg-presetConfigExists/CMakePresets.json.in @@ -0,0 +1,33 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "ninja", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "STRING_VARIABLE": { + "type": "STRING", + "value": "String value" + }, + "PATH_VARIABLE": { + "type": "PATH", + "value": "${sourceDir}" + }, + "FILEPATH_VARIABLE": { + "type": "FILEPATH", + "value": "${sourceDir}/CMakeLists.txt" + }, + "ON_VARIABLE": { + "type": "BOOL", + "value": "ON" + }, + "FALSE_VARIABLE": { + "type": "BOOL", + "value": "FALSE" + }, + "UNINITIALIZED_VARIABLE": "Uninitialized value" + } + } + ] +} diff --git a/Tests/CMakeGUI/presetArg-presetConfigExists/CMakeSetup.ini.in b/Tests/CMakeGUI/presetArg-presetConfigExists/CMakeSetup.ini.in new file mode 100644 index 000000000..a5d0c7185 --- /dev/null +++ b/Tests/CMakeGUI/presetArg-presetConfigExists/CMakeSetup.ini.in @@ -0,0 +1,2 @@ +[Settings] +StartPath\WhereBuild0=@CMake_BINARY_DIR@ diff --git a/Tests/CMakeGUI/simpleConfigure-fail/CMakeLists.txt.in b/Tests/CMakeGUI/simpleConfigure-fail/CMakeLists.txt.in new file mode 100644 index 000000000..dc5506415 --- /dev/null +++ b/Tests/CMakeGUI/simpleConfigure-fail/CMakeLists.txt.in @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.18) +project(simpleConfigure-fail NONE) + +message(STATUS "This is a failed configure") +message(FATAL_ERROR "Error") diff --git a/Tests/CMakeGUI/simpleConfigure-success/CMakeLists.txt.in b/Tests/CMakeGUI/simpleConfigure-success/CMakeLists.txt.in new file mode 100644 index 000000000..fc42c0012 --- /dev/null +++ b/Tests/CMakeGUI/simpleConfigure-success/CMakeLists.txt.in @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.18) +project(simpleConfigure-success NONE) + +message(STATUS "This is a successful configure") diff --git a/Tests/CMakeGUI/sourceBinaryArgs-binaryDir/CMakeLists.txt.in b/Tests/CMakeGUI/sourceBinaryArgs-binaryDir/CMakeLists.txt.in new file mode 100644 index 000000000..2ae4a5714 --- /dev/null +++ b/Tests/CMakeGUI/sourceBinaryArgs-binaryDir/CMakeLists.txt.in @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.18) +project(sourceBinaryArgs-sourceDir NONE) diff --git a/Tests/CMakeGUI/sourceBinaryArgs-noExistConfig/CMakeSetup.ini.in b/Tests/CMakeGUI/sourceBinaryArgs-noExistConfig/CMakeSetup.ini.in new file mode 100644 index 000000000..db49eeade --- /dev/null +++ b/Tests/CMakeGUI/sourceBinaryArgs-noExistConfig/CMakeSetup.ini.in @@ -0,0 +1,2 @@ +[Settings] +StartPath\WhereBuild0=@CMakeGUITest_BINARY_DIR@/sourceBinaryArgs-noExistConfig/oldbuild diff --git a/Tests/CMakeGUI/sourceBinaryArgs-noExistConfigExists/CMakeLists.txt.in b/Tests/CMakeGUI/sourceBinaryArgs-noExistConfigExists/CMakeLists.txt.in new file mode 100644 index 000000000..2ae4a5714 --- /dev/null +++ b/Tests/CMakeGUI/sourceBinaryArgs-noExistConfigExists/CMakeLists.txt.in @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.18) +project(sourceBinaryArgs-sourceDir NONE) diff --git a/Tests/CMakeGUI/sourceBinaryArgs-noExistConfigExists/CMakeSetup.ini.in b/Tests/CMakeGUI/sourceBinaryArgs-noExistConfigExists/CMakeSetup.ini.in new file mode 100644 index 000000000..4ffd917eb --- /dev/null +++ b/Tests/CMakeGUI/sourceBinaryArgs-noExistConfigExists/CMakeSetup.ini.in @@ -0,0 +1,2 @@ +[Settings] +StartPath\WhereBuild0=@CMakeGUITest_BINARY_DIR@/sourceBinaryArgs-noExistConfigExists/build diff --git a/Tests/CMakeGUI/sourceBinaryArgs-sourceDir/CMakeLists.txt.in b/Tests/CMakeGUI/sourceBinaryArgs-sourceDir/CMakeLists.txt.in new file mode 100644 index 000000000..2ae4a5714 --- /dev/null +++ b/Tests/CMakeGUI/sourceBinaryArgs-sourceDir/CMakeLists.txt.in @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.18) +project(sourceBinaryArgs-sourceDir NONE) diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index bb50d76f0..87925bdaf 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -13,6 +13,7 @@ set(CMakeLib_TESTS testCTestResourceGroups.cxx testGccDepfileReader.cxx testGeneratedFileStream.cxx + testJSONHelpers.cxx testRST.cxx testRange.cxx testOptional.cxx @@ -29,6 +30,9 @@ set(CMakeLib_TESTS testCMExtMemory.cxx testCMExtAlgorithm.cxx ) +if (CMake_TEST_FILESYSTEM_PATH OR NOT CMake_HAVE_CXX_FILESYSTEM) + list(APPEND CMakeLib_TESTS testCMFilesystemPath.cxx) +endif() add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx) diff --git a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt index 7c84ee166..4bef6c5e0 100644 --- a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt +++ b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt @@ -15,6 +15,9 @@ target_link_libraries(pseudo_purify CMakeLib) add_executable(pseudo_BC "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx") set_target_properties(pseudo_BC PROPERTIES OUTPUT_NAME BC) target_link_libraries(pseudo_BC CMakeLib) +add_executable(pseudo_cuda-memcheck "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx") +set_target_properties(pseudo_cuda-memcheck PROPERTIES OUTPUT_NAME cuda-memcheck) +target_link_libraries(pseudo_cuda-memcheck CMakeLib) # binary to be used as pre- and post-memcheck command that fails add_executable(memcheck_fail "${CMAKE_CURRENT_BINARY_DIR}/ret1.cxx") diff --git a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in index 3183bc0b6..f37ad5964 100644 --- a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in +++ b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in @@ -1,8 +1,14 @@ -#include <cmSystemTools.h> -#include "cmsys/Encoding.hxx" #include <string> +#include <vector> + +#include "cmsys/Encoding.hxx" + +#include <cmSystemTools.h> +// clang-format off #define RETVAL @_retval@ +#define CMAKE_COMMAND "@CMAKE_COMMAND@" +// clang-format on int main(int ac, char** av) { @@ -14,6 +20,9 @@ int main(int ac, char** av) std::string exename = argv[0]; std::string logarg; bool nextarg = false; + // execute the part after the last argument? + // the logfile path gets passed as environment variable PSEUDO_LOGFILE + bool exec = false; if (exename.find("valgrind") != std::string::npos) { logarg = "--log-file="; @@ -26,6 +35,10 @@ int main(int ac, char** av) } else if (exename.find("BC") != std::string::npos) { nextarg = true; logarg = "/X"; + } else if (exename.find("cuda-memcheck") != std::string::npos) { + nextarg = true; + exec = true; + logarg = "--log-file"; } if (!logarg.empty()) { @@ -45,8 +58,25 @@ int main(int ac, char** av) } } + // find the last argument position + int lastarg_pos = 1; + for (int i = 1; i < argc; ++i) { + std::string arg = argv[i]; + if (arg.find("--") == 0) { + lastarg_pos = i; + } + } + if (!logfile.empty()) { cmSystemTools::Touch(logfile, true); + // execute everything after the last argument with additional environment + int callarg_pos = lastarg_pos + (nextarg ? 2 : 1); + if (exec && callarg_pos < argc) { + std::vector<std::string> callargs{ CMAKE_COMMAND, "-E", "env", + "PSEUDO_LOGFILE=" + logfile }; + callargs.insert(callargs.end(), &argv[callarg_pos], &argv[argc]); + cmSystemTools::RunSingleCommand(callargs); + } } } diff --git a/Tests/CMakeLib/testCMExtMemory.cxx b/Tests/CMakeLib/testCMExtMemory.cxx index 6663c17d8..2aeaf7f84 100644 --- a/Tests/CMakeLib/testCMExtMemory.cxx +++ b/Tests/CMakeLib/testCMExtMemory.cxx @@ -13,7 +13,7 @@ public: class Derived : public Base { public: - ~Derived() = default; + ~Derived() override = default; void method() {} }; diff --git a/Tests/CMakeLib/testCMFilesystemPath.cxx b/Tests/CMakeLib/testCMFilesystemPath.cxx new file mode 100644 index 000000000..579ba994e --- /dev/null +++ b/Tests/CMakeLib/testCMFilesystemPath.cxx @@ -0,0 +1,1008 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include <algorithm> +#include <iostream> +#include <sstream> +#include <string> +#include <vector> + +#include <cm/filesystem> + +namespace { + +namespace fs = cm::filesystem; + +void checkResult(bool success) +{ + if (!success) { + std::cout << " => failed"; + } + std::cout << std::endl; +} + +bool testConstructors() +{ + std::cout << "testConstructors()"; + + bool result = true; + + { + fs::path p; + if (p != fs::path()) { + result = false; + } + } + { + fs::path p1("/a/b/c"); + fs::path p2("/a/b/c"); + if (p1 != p2) { + result = false; + } + if (p1.string() != p2.string()) { + result = false; + } + if (p1.string() != "/a/b/c") { + result = false; + } + } + { + std::string s("/a/b/c"); + fs::path p1(s); + fs::path p2(s.begin(), s.end()); + if (p1 != p2) { + result = false; + } + if (p1.string() != s || p2.string() != s) { + result = false; + } +#if CM_FILESYSTEM_SOURCE_TRAITS_ITERATOR + std::string s2(s); + s2 += '\0'; + fs::path p3(s2.begin()); + if (p1 != p3 || p3.string() != s) { + result = false; + } +#endif + } + { + std::wstring s(L"/a/b/c"); + fs::path p1(s); + fs::path p2(s.begin(), s.end()); + if (p1 != p2) { + result = false; + } + if (p1.wstring() != s || p2.wstring() != s) { + result = false; + } +#if CM_FILESYSTEM_SOURCE_TRAITS_ITERATOR + std::wstring s2(s); + s2 += L'\0'; + fs::path p3(s2.begin()); + if (p1 != p3 || p3.wstring() != s) { + result = false; + } +#endif + } + { + std::string s("/a/b/c"); + fs::path::string_type ws; + for (auto c : s) { + ws += fs::path::value_type(c); + } + fs::path p1(ws); + fs::path p2(ws.begin(), ws.end()); + if (p1 != p2) { + result = false; + } + if (p1.native() != ws || p2.native() != ws) { + result = false; + } +#if CM_FILESYSTEM_SOURCE_TRAITS_ITERATOR + fs::path::string_type ws2(ws); + ws2 += fs::path::value_type('\0'); + fs::path p3(ws2.begin()); + if (p1 != p3 || p3.native() != ws) { + result = false; + } +#endif + } + + checkResult(result); + + return result; +} + +bool testConcatenation() +{ + std::cout << "testConcatenation()"; + + bool result = true; + + { + fs::path p("/a/b"); + p /= "c"; + if (!(p.string() == "/a/b/c" || p.string() == "/a/b\\c")) { + result = false; + } + p += "d"; + if (!(p.string() == "/a/b/cd" || p.string() == "/a/b\\cd")) { + result = false; + } + fs::path p2("x/y"); + p /= p2; + if (!(p.string() == "/a/b/cd/x/y" || p.string() == "/a/b\\cd\\x/y")) { + result = false; + } + p = p / p2; + if (!(p.string() == "/a/b/cd/x/y/x/y" || + p.string() == "/a/b\\cd\\x/y\\x/y")) { + result = false; + } + } + { + fs::path p("a"); + p /= ""; + if (!(p.string() == "a/" || p.string() == "a\\")) { + result = false; + } + p /= "/b"; + if (p.string() != "/b") { + result = false; + } + } +#if defined(_WIN32) + { + fs::path p("a"); + p /= "c:/b"; + if (p.string() != "c:/b") { + result = false; + } + p = fs::path("a") / "c:"; + if (p.string() != "c:") { + result = false; + } + p = fs::path("c:") / ""; + if (p.string() != "c:") { + result = false; + } + p = fs::path("c:a") / "/b"; + if (p.string() != "c:/b") { + result = false; + } + p = fs::path("c:a") / "c:b"; + if (p.string() != "c:a\\b") { + result = false; + } + p = fs::path("//host") / "b"; + if (p.string() != "//host\\b") { + result = false; + } + p = fs::path("//host/") / "b"; + if (p.string() != "//host/b") { + result = false; + } + } +#endif + + checkResult(result); + + return result; +} + +bool testModifiers() +{ + std::cout << "testModifiers()"; + + bool result = true; + + { + std::string s("a///b/"); + fs::path p(s); + std::replace( + s.begin(), s.end(), '/', + static_cast<std::string::value_type>(fs::path::preferred_separator)); + p.make_preferred(); + if (p.string() != s) { + result = false; + } + } + { + fs::path p("a/b/c.e.f"); + p.remove_filename(); + if (p.string() != "a/b/") { + result = false; + } + p.remove_filename(); + if (p.string() != "a/b/") { + result = false; + } + } + { + fs::path p("a/b/c.e.f"); + p.replace_filename("x.y"); + if (p.string() != "a/b/x.y") { + result = false; + } + } + { + fs::path p("a/b/c.e.f"); + p.replace_extension(".x"); + if (p.string() != "a/b/c.e.x") { + result = false; + } + p.replace_extension(".y"); + if (p.string() != "a/b/c.e.y") { + result = false; + } + p.replace_extension(); + if (p.string() != "a/b/c.e") { + result = false; + } + p = "/a/b"; + p.replace_extension(".x"); + if (p.string() != "/a/b.x") { + result = false; + } + p = "/a/b/"; + p.replace_extension(".x"); + if (p.string() != "/a/b/.x") { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testObservers() +{ + std::cout << "testObservers()"; + + bool result = true; + + { + std::string s("a/b/c"); + fs::path p(s); + fs::path::string_type st; + for (auto c : s) { + st += static_cast<fs::path::value_type>(c); + } + if (p.native() != st || static_cast<fs::path::string_type>(p) != st || + p.c_str() != st) { + result = false; + } + } + { + std::string s("a//b//c"); + std::wstring ws(L"a//b//c"); + fs::path p(s); + if (p.string() != s || p.wstring() != ws) { + result = false; + } + } + { + std::string s("a/b/c"); + std::wstring ws; + for (auto c : s) { + ws += static_cast<std::wstring::value_type>(c); + } + std::string ns(s); + std::replace( + ns.begin(), ns.end(), '/', + static_cast<std::string::value_type>(fs::path::preferred_separator)); + fs::path p(ns); + if (p.generic_string() != s || p.generic_wstring() != ws) { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testCompare() +{ + std::cout << "testCompare()"; + + bool result = true; + + { + std::string s("a/b/c"); + fs::path p1(s); + fs::path p2(s); + if (p1.compare(p2) != 0) { + result = false; + } + p2 = "a/b"; + if (p1.compare(p2) <= 0) { + result = false; + } + p2 = "a/d"; + if (p1.compare(p2) >= 0) { + result = false; + } + p2 = "a/b/d"; + if (p1.compare(p2) >= 0) { + result = false; + } + p2 = "a/b/a"; + if (p1.compare(p2) <= 0) { + result = false; + } + p2 = "a/b/c/d"; + if (p1.compare(p2) >= 0) { + result = false; + } + p1 = "a"; + p2 = "b"; + if (p1.compare(p2) == 0) { + result = false; + } + } + { + // LWG 3096 (https://cplusplus.github.io/LWG/issue3096) + // fs::path p1("/a/"); + // fs::path p2("/a/."); + // if (p1.compare(p2) != 0) { + // result = false; + // } + } + + checkResult(result); + + return result; +} + +bool testGeneration() +{ + std::cout << "testGeneration()"; + + bool result = true; + + { + fs::path p("a/./b/.."); + if (p.lexically_normal().generic_string() != "a/") { + result = false; + } + p = "a/.///b/../"; + if (p.lexically_normal().generic_string() != "a/") { + result = false; + } + } +#if defined(_WIN32) + { + fs::path p("//host/./b/.."); + if (p.lexically_normal().string() != "\\\\host\\") { + result = false; + } + p = "//host/.///b/../"; + if (p.lexically_normal().string() != "\\\\host\\") { + result = false; + } + p = "c://a/.///b/../"; + if (p.lexically_normal().string() != "c:\\a\\") { + result = false; + } + } +#endif + + { + if (fs::path("/a//d").lexically_relative("/a/b/c") != "../../d") { + result = false; + } + if (fs::path("/a//b///c").lexically_relative("/a/d") != "../b/c") { + result = false; + } + if (fs::path("a/b/c").lexically_relative("a") != "b/c") { + result = false; + } + if (fs::path("a/b/c").lexically_relative("a/b/c/x/y") != "../..") { + result = false; + } + if (fs::path("a/b/c").lexically_relative("a/b/c") != ".") { + result = false; + } + if (fs::path("a/b").lexically_relative("c/d") != "../../a/b") { + result = false; + } + } + { +#if defined(_WIN32) + if (fs::path("/a/d").lexically_relative("e/d/c") != "/a/d") { + result = false; + } + if (!fs::path("c:/a/d").lexically_relative("e/d/c").empty()) { + result = false; + } +#else + if (!fs::path("/a/d").lexically_relative("e/d/c").empty()) { + result = false; + } +#endif + } + { +#if defined(_WIN32) + if (fs::path("c:/a/d").lexically_proximate("e/d/c") != "c:/a/d") { + result = false; + } +#else + if (fs::path("/a/d").lexically_proximate("e/d/c") != "/a/d") { + result = false; + } +#endif + if (fs::path("/a/d").lexically_proximate("/a/b/c") != "../../d") { + result = false; + } + } + // LWG 3070 + { +#if defined(_WIN32) + if (!fs::path("/a:/b:").lexically_relative("/a:/c:").empty()) { + result = false; + } + if (fs::path("c:/a/b").lexically_relative("c:/a/d") != "../b") { + result = false; + } + if (!fs::path("c:/a/b:").lexically_relative("c:/a/d").empty()) { + result = false; + } + if (!fs::path("c:/a/b").lexically_relative("c:/a/d:").empty()) { + result = false; + } +#else + if (fs::path("/a:/b:").lexically_relative("/a:/c:") != "../b:") { + result = false; + } +#endif + } + // LWG 3096 + { + if (fs::path("/a").lexically_relative("/a/.") != ".") { + result = false; + } + if (fs::path("/a").lexically_relative("/a/") != ".") { + result = false; + } + if (fs::path("a/b/c").lexically_relative("a/b/c") != ".") { + result = false; + } + if (fs::path("a/b/c").lexically_relative("a/b/c/") != ".") { + result = false; + } + if (fs::path("a/b/c").lexically_relative("a/b/c/.") != ".") { + result = false; + } + if (fs::path("a/b/c/").lexically_relative("a/b/c") != ".") { + result = false; + } + if (fs::path("a/b/c/.").lexically_relative("a/b/c") != ".") { + result = false; + } + if (fs::path("a/b/c/.").lexically_relative("a/b/c/") != ".") { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testDecomposition() +{ + std::cout << "testDecomposition()"; + + bool result = true; + + { + if (!fs::path("/a/b").root_name().empty()) { + result = false; + } +#if defined(_WIN32) + if (fs::path("c:/a/b").root_name() != "c:") { + result = false; + } + if (fs::path("c:a/b").root_name() != "c:") { + result = false; + } + if (fs::path("c:").root_name() != "c:") { + result = false; + } + if (fs::path("//host/b").root_name() != "//host") { + result = false; + } + if (fs::path("//host").root_name() != "//host") { + result = false; + } +#endif + } + { + if (!fs::path("a/b").root_directory().empty()) { + result = false; + } + if (fs::path("/a/b").root_directory() != "/") { + result = false; + } +#if defined(_WIN32) + if (!fs::path("c:a/b").root_directory().empty()) { + result = false; + } + if (fs::path("/a/b").root_directory() != "/") { + result = false; + } + if (fs::path("c:/a/b").root_directory() != "/") { + result = false; + } + if (fs::path("//host/b").root_directory() != "/") { + result = false; + } +#endif + } + { + if (!fs::path("a/b").root_path().empty()) { + result = false; + } + if (fs::path("/a/b").root_path() != "/") { + result = false; + } +#if defined(_WIN32) + if (fs::path("c:a/b").root_path() != "c:") { + result = false; + } + if (fs::path("/a/b").root_path() != "/") { + result = false; + } + if (fs::path("c:/a/b").root_path() != "c:/") { + result = false; + } + if (fs::path("//host/b").root_path() != "//host/") { + result = false; + } +#endif + } + { + if (!fs::path("/").relative_path().empty()) { + result = false; + } + if (fs::path("a/b").relative_path() != "a/b") { + result = false; + } + if (fs::path("/a/b").relative_path() != "a/b") { + result = false; + } +#if defined(_WIN32) + if (fs::path("c:a/b").relative_path() != "a/b") { + result = false; + } + if (fs::path("/a/b").relative_path() != "a/b") { + result = false; + } + if (fs::path("c:/a/b").relative_path() != "a/b") { + result = false; + } + if (fs::path("//host/b").relative_path() != "b") { + result = false; + } +#endif + } + { + if (fs::path("/a/b").parent_path() != "/a") { + result = false; + } + if (fs::path("/a/b/").parent_path() != "/a/b") { + result = false; + } + if (fs::path("/a/b/.").parent_path() != "/a/b") { + result = false; + } + if (fs::path("/").parent_path() != "/") { + result = false; + } +#if defined(_WIN32) + if (fs::path("c:/a/b").parent_path() != "c:/a") { + result = false; + } + if (fs::path("c:a").parent_path() != "c:") { + result = false; + } + if (fs::path("c:/").parent_path() != "c:/") { + result = false; + } + if (fs::path("c:").parent_path() != "c:") { + result = false; + } + if (fs::path("//host/").parent_path() != "//host/") { + result = false; + } + if (fs::path("//host").parent_path() != "//host") { + result = false; + } +#endif + } + { + if (fs::path("/a/b.txt").filename() != "b.txt") { + result = false; + } + if (fs::path("/a/.b").filename() != ".b") { + result = false; + } + if (fs::path("/foo/bar/").filename() != "") { + result = false; + } + if (fs::path("/foo/.").filename() != ".") { + result = false; + } + if (fs::path("/foo/..").filename() != "..") { + result = false; + } + if (fs::path(".").filename() != ".") { + result = false; + } + if (fs::path("..").filename() != "..") { + result = false; + } + if (!fs::path("/").filename().empty()) { + result = false; + } +#if defined(_WIN32) + if (fs::path("c:a").filename() != "a") { + result = false; + } + if (fs::path("c:/a").filename() != "a") { + result = false; + } + if (!fs::path("c:").filename().empty()) { + result = false; + } + if (!fs::path("c:/").filename().empty()) { + result = false; + } + if (!fs::path("//host").filename().empty()) { + result = false; + } +#endif + } + { + if (fs::path("/a/b.txt").stem() != "b") { + result = false; + } + if (fs::path("/a/b.c.txt").stem() != "b.c") { + result = false; + } + if (fs::path("/a/.b").stem() != ".b") { + result = false; + } + if (fs::path("/a/b").stem() != "b") { + result = false; + } + if (fs::path("/a/b/.").stem() != ".") { + result = false; + } + if (fs::path("/a/b/..").stem() != "..") { + result = false; + } + if (!fs::path("/a/b/").stem().empty()) { + result = false; + } +#if defined(_WIN32) + if (!fs::path("c:/a/b/").stem().empty()) { + result = false; + } + if (!fs::path("c:/").stem().empty()) { + result = false; + } + if (!fs::path("c:").stem().empty()) { + result = false; + } + if (!fs::path("//host/").stem().empty()) { + result = false; + } + if (!fs::path("//host").stem().empty()) { + result = false; + } +#endif + } + { + if (fs::path("/a/b.txt").extension() != ".txt") { + result = false; + } + if (fs::path("/a/b.").extension() != ".") { + result = false; + } + if (!fs::path("/a/b").extension().empty()) { + result = false; + } + if (fs::path("/a/b.txt/b.cc").extension() != ".cc") { + result = false; + } + if (fs::path("/a/b.txt/b.").extension() != ".") { + result = false; + } + if (!fs::path("/a/b.txt/b").extension().empty()) { + result = false; + } + if (!fs::path("/a/.").extension().empty()) { + result = false; + } + if (!fs::path("/a/..").extension().empty()) { + result = false; + } + if (!fs::path("/a/.hidden").extension().empty()) { + result = false; + } + if (fs::path("/a/..b").extension() != ".b") { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testQueries() +{ + std::cout << "testQueries()"; + + bool result = true; + + { + if (fs::path("/a/b").has_root_name()) { + result = false; + } + fs::path p("/a/b"); + if (!p.has_root_directory() || !p.has_root_path()) { + result = false; + } + if (!fs::path("/a/b").has_root_path() || fs::path("a/b").has_root_path()) { + result = false; + } + if (!fs::path("/a/b").has_relative_path() || + fs::path("/").has_relative_path()) { + result = false; + } + if (!fs::path("/a/b").has_parent_path() || + !fs::path("/").has_parent_path() || fs::path("a").has_parent_path()) { + result = false; + } + if (!fs::path("/a/b").has_filename() || !fs::path("a.b").has_filename() || + fs::path("/a/").has_filename() || fs::path("/").has_filename()) { + result = false; + } + if (!fs::path("/a/b").has_stem() || !fs::path("a.b").has_stem() || + !fs::path("/.a").has_stem() || fs::path("/a/").has_stem() || + fs::path("/").has_stem()) { + result = false; + } + if (!fs::path("/a/b.c").has_extension() || + !fs::path("a.b").has_extension() || fs::path("/.a").has_extension() || + fs::path("/a/").has_extension() || fs::path("/").has_extension()) { + result = false; + } +#if defined(_WIN32) + p = "c:/a/b"; + if (!fs::path("c:/a/b").has_root_name() || !p.has_root_directory() || + !p.has_root_path()) { + result = false; + } + p = "c:a/b"; + if (!p.has_root_name() || p.has_root_directory() || !p.has_root_path()) { + result = false; + } + p = "//host/b"; + if (!p.has_root_name() || !p.has_root_directory() || !p.has_root_path()) { + result = false; + } + p = "//host"; + if (!p.has_root_name() || p.has_root_directory() || !p.has_root_path()) { + result = false; + } + if (!fs::path("c:/a/b").has_relative_path() || + !fs::path("c:a/b").has_relative_path() || + !fs::path("//host/b").has_relative_path()) { + result = false; + } + if (!fs::path("c:/a/b").has_parent_path() || + !fs::path("c:/").has_parent_path() || + !fs::path("c:").has_parent_path() || + !fs::path("//host/").has_parent_path() || + !fs::path("//host").has_parent_path()) { + result = false; + } +#endif + } + { +#if defined(_WIN32) + fs::path p("c:/a"); +#else + fs::path p("/a"); +#endif + if (!p.is_absolute() || p.is_relative()) { + result = false; + } + p = "a/b"; + if (p.is_absolute() || !p.is_relative()) { + result = false; + } +#if defined(_WIN32) + p = "c:/a/b"; + if (!p.is_absolute() || p.is_relative()) { + result = false; + } + p = "//host/b"; + if (!p.is_absolute() || p.is_relative()) { + result = false; + } + p = "/a"; + if (p.is_absolute() || !p.is_relative()) { + result = false; + } + p = "c:a"; + if (p.is_absolute() || !p.is_relative()) { + result = false; + } +#endif + } + + checkResult(result); + + return result; +} + +bool testIterators() +{ + std::cout << "testIterators()"; + + bool result = true; + + { + fs::path p("/a/b/"); +#if defined(_WIN32) + std::vector<fs::path::string_type> ref{ L"/", L"a", L"b", L"" }; +#else + std::vector<fs::path::string_type> ref{ "/", "a", "b", "" }; +#endif + std::vector<fs::path::string_type> res; + for (auto i = p.begin(), e = p.end(); i != e; ++i) { + res.push_back(*i); + } + if (res != ref) { + result = false; + } + res.clear(); + for (const auto& e : p) { + res.push_back(e); + } + if (res != ref) { + result = false; + } + } + { + fs::path p("/a/b/"); +#if defined(_WIN32) + std::vector<fs::path::string_type> ref{ L"", L"b", L"a", L"/" }; +#else + std::vector<fs::path::string_type> ref{ "", "b", "a", "/" }; +#endif + std::vector<fs::path::string_type> res; + auto i = p.end(), b = p.begin(); + do { + res.push_back(*--i); + } while (i != b); + if (res != ref) { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testNonMemberFunctions() +{ + std::cout << "testNonMemberFunctions()"; + + bool result = true; + + { + fs::path p1("/a/b/"); + fs::path p2("/c/d"); + fs::swap(p1, p2); + if (p1.string() != "/c/d" || p2.string() != "/a/b/") + result = false; + } + { + auto h1 = fs::hash_value(fs::path("/a//b//")); + auto h2 = fs::hash_value(fs::path("/a/b/")); + if (h1 != h2) + result = false; + } + { + fs::path p1("/a/b/"); + fs::path p2("/c/d"); + if (p1 == p2) + result = false; + p1 = "/a//b//"; + p2 = "/a/b/"; + if (p1 != p2) + result = false; + } + { + fs::path p = "/a"; + p = p / "b" / "c"; + if (p.generic_string() != "/a/b/c") { + result = false; + } + fs::path::string_type ref; + ref += fs::path::value_type('/'); + ref += fs::path::value_type('a'); + ref += fs::path::preferred_separator; + ref += fs::path::value_type('b'); + ref += fs::path::preferred_separator; + ref += fs::path::value_type('c'); + if (p.native() != ref) { + result = false; + } + } + { + fs::path p("/a b\\c/"); + std::ostringstream oss; + oss << p; + if (oss.str() != "\"/a b\\\\c/\"") { + result = false; + } + std::istringstream iss(oss.str()); + fs::path p2; + iss >> p2; + if (p2 != p) { + result = false; + } + } + + checkResult(result); + + return result; +} +} + +int testCMFilesystemPath(int /*unused*/, char* /*unused*/ []) +{ + int result = 0; + + if (!testConstructors()) { + result = 1; + } + if (!testConcatenation()) { + result = 1; + } + if (!testModifiers()) { + result = 1; + } + if (!testObservers()) { + result = 1; + } + if (!testCompare()) { + result = 1; + } + if (!testGeneration()) { + result = 1; + } + if (!testDecomposition()) { + result = 1; + } + if (!testQueries()) { + result = 1; + } + if (!testIterators()) { + result = 1; + } + if (!testNonMemberFunctions()) { + result = 1; + } + + return result; +} diff --git a/Tests/CMakeLib/testJSONHelpers.cxx b/Tests/CMakeLib/testJSONHelpers.cxx new file mode 100644 index 000000000..a45d3205c --- /dev/null +++ b/Tests/CMakeLib/testJSONHelpers.cxx @@ -0,0 +1,504 @@ +#include <functional> +#include <iostream> +#include <map> +#include <string> +#include <vector> + +#include <cm/optional> +#include <cmext/string_view> + +#include <cm3p/json/value.h> + +#include "cmJSONHelpers.h" + +#define ASSERT_TRUE(x) \ + do { \ + if (!(x)) { \ + std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ + return false; \ + } \ + } while (false) + +namespace { +struct ObjectStruct +{ + std::string Field1; + int Field2; +}; + +struct InheritedStruct : public ObjectStruct +{ + std::string Field3; +}; + +enum class ErrorCode +{ + Success, + InvalidInt, + InvalidBool, + InvalidString, + InvalidSubObject, + InvalidObject, + InvalidArray, + MissingRequired, +}; + +auto const IntHelper = + cmJSONIntHelper<ErrorCode>(ErrorCode::Success, ErrorCode::InvalidInt, 1); +auto const RequiredIntHelper = + cmJSONRequiredHelper<int, ErrorCode>(ErrorCode::MissingRequired, IntHelper); +auto const UIntHelper = + cmJSONUIntHelper<ErrorCode>(ErrorCode::Success, ErrorCode::InvalidInt, 1); +auto const BoolHelper = cmJSONBoolHelper<ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidBool, false); +auto const StringHelper = cmJSONStringHelper<ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidString, "default"); +auto const RequiredStringHelper = cmJSONRequiredHelper<std::string, ErrorCode>( + ErrorCode::MissingRequired, StringHelper); +auto const StringVectorHelper = cmJSONVectorHelper<std::string, ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidArray, StringHelper); +auto const StringVectorFilterHelper = + cmJSONVectorFilterHelper<std::string, ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidArray, StringHelper, + [](const std::string& value) { return value != "ignore"; }); +auto const StringMapHelper = cmJSONMapHelper<std::string, ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidObject, StringHelper); +auto const StringMapFilterHelper = + cmJSONMapFilterHelper<std::string, ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidObject, StringHelper, + [](const std::string& key) { return key != "ignore"; }); +auto const OptionalStringHelper = + cmJSONOptionalHelper<std::string>(ErrorCode::Success, StringHelper); + +bool testInt() +{ + Json::Value v(2); + int i = 0; + ASSERT_TRUE(IntHelper(i, &v) == ErrorCode::Success); + ASSERT_TRUE(i == 2); + + i = 0; + v = Json::nullValue; + ASSERT_TRUE(IntHelper(i, &v) == ErrorCode::InvalidInt); + + i = 0; + ASSERT_TRUE(IntHelper(i, nullptr) == ErrorCode::Success); + ASSERT_TRUE(i == 1); + + return true; +} + +bool testUInt() +{ + Json::Value v(2); + unsigned int i = 0; + ASSERT_TRUE(UIntHelper(i, &v) == ErrorCode::Success); + ASSERT_TRUE(i == 2); + + i = 0; + v = Json::nullValue; + ASSERT_TRUE(UIntHelper(i, &v) == ErrorCode::InvalidInt); + + i = 0; + ASSERT_TRUE(UIntHelper(i, nullptr) == ErrorCode::Success); + ASSERT_TRUE(i == 1); + + return true; +} + +bool testBool() +{ + Json::Value v(true); + bool b = false; + ASSERT_TRUE(BoolHelper(b, &v) == ErrorCode::Success); + ASSERT_TRUE(b); + + b = false; + v = false; + ASSERT_TRUE(BoolHelper(b, &v) == ErrorCode::Success); + ASSERT_TRUE(!b); + + b = false; + v = 4; + ASSERT_TRUE(BoolHelper(b, &v) == ErrorCode::InvalidBool); + + b = true; + ASSERT_TRUE(BoolHelper(b, nullptr) == ErrorCode::Success); + ASSERT_TRUE(!b); + + return true; +} + +bool testString() +{ + Json::Value v("str"); + std::string str = ""; + ASSERT_TRUE(StringHelper(str, &v) == ErrorCode::Success); + ASSERT_TRUE(str == "str"); + + str = ""; + v = Json::nullValue; + ASSERT_TRUE(StringHelper(str, &v) == ErrorCode::InvalidString); + + str = ""; + ASSERT_TRUE(StringHelper(str, nullptr) == ErrorCode::Success); + ASSERT_TRUE(str == "default"); + + return true; +} + +bool testObject() +{ + auto const subhelper = + cmJSONObjectHelper<ObjectStruct, ErrorCode>(ErrorCode::Success, + ErrorCode::InvalidSubObject) + .Bind("subfield"_s, &ObjectStruct::Field2, IntHelper); + auto const helper = cmJSONObjectHelper<ObjectStruct, ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidObject) + .Bind("field1"_s, &ObjectStruct::Field1, StringHelper) + .Bind("field2"_s, subhelper) + .Bind<std::string>("field3"_s, nullptr, StringHelper); + + Json::Value v(Json::objectValue); + v["field1"] = "Hello"; + v["field2"] = Json::objectValue; + v["field2"]["subfield"] = 2; + v["field3"] = "world!"; + v["extra"] = "extra"; + + ObjectStruct s1; + ASSERT_TRUE(helper(s1, &v) == ErrorCode::Success); + ASSERT_TRUE(s1.Field1 == "Hello"); + ASSERT_TRUE(s1.Field2 == 2); + + v["field2"]["subfield"] = "wrong"; + ObjectStruct s2; + ASSERT_TRUE(helper(s2, &v) == ErrorCode::InvalidInt); + + v["field2"].removeMember("subfield"); + ObjectStruct s3; + ASSERT_TRUE(helper(s3, &v) == ErrorCode::InvalidSubObject); + + v.removeMember("field2"); + ObjectStruct s4; + ASSERT_TRUE(helper(s4, &v) == ErrorCode::InvalidObject); + + v["field2"] = Json::objectValue; + v["field2"]["subfield"] = 2; + v["field3"] = 3; + ObjectStruct s5; + ASSERT_TRUE(helper(s5, &v) == ErrorCode::InvalidString); + + v.removeMember("field3"); + ObjectStruct s6; + ASSERT_TRUE(helper(s6, &v) == ErrorCode::InvalidObject); + + v = "Hello"; + ObjectStruct s7; + ASSERT_TRUE(helper(s7, &v) == ErrorCode::InvalidObject); + + ObjectStruct s8; + ASSERT_TRUE(helper(s8, nullptr) == ErrorCode::InvalidObject); + + return true; +} + +bool testObjectInherited() +{ + auto const helper = + cmJSONObjectHelper<InheritedStruct, ErrorCode>(ErrorCode::Success, + ErrorCode::InvalidObject) + .Bind("field1"_s, &InheritedStruct::Field1, StringHelper) + .Bind("field2"_s, &InheritedStruct::Field2, IntHelper) + .Bind("field3"_s, &InheritedStruct::Field3, StringHelper); + + Json::Value v(Json::objectValue); + v["field1"] = "Hello"; + v["field2"] = 2; + v["field3"] = "world!"; + v["extra"] = "extra"; + + InheritedStruct s1; + ASSERT_TRUE(helper(s1, &v) == ErrorCode::Success); + ASSERT_TRUE(s1.Field1 == "Hello"); + ASSERT_TRUE(s1.Field2 == 2); + ASSERT_TRUE(s1.Field3 == "world!"); + + v["field2"] = "wrong"; + InheritedStruct s2; + ASSERT_TRUE(helper(s2, &v) == ErrorCode::InvalidInt); + + v.removeMember("field2"); + InheritedStruct s3; + ASSERT_TRUE(helper(s3, &v) == ErrorCode::InvalidObject); + + v["field2"] = 2; + v["field3"] = 3; + InheritedStruct s4; + ASSERT_TRUE(helper(s4, &v) == ErrorCode::InvalidString); + + v.removeMember("field3"); + InheritedStruct s5; + ASSERT_TRUE(helper(s5, &v) == ErrorCode::InvalidObject); + + v = "Hello"; + InheritedStruct s6; + ASSERT_TRUE(helper(s6, &v) == ErrorCode::InvalidObject); + + InheritedStruct s7; + ASSERT_TRUE(helper(s7, nullptr) == ErrorCode::InvalidObject); + + return true; +} + +bool testObjectNoExtra() +{ + auto const helper = cmJSONObjectHelper<ObjectStruct, ErrorCode>( + ErrorCode::Success, ErrorCode::InvalidObject, false) + .Bind("field1"_s, &ObjectStruct::Field1, StringHelper) + .Bind("field2"_s, &ObjectStruct::Field2, IntHelper); + + Json::Value v(Json::objectValue); + v["field1"] = "Hello"; + v["field2"] = 2; + + ObjectStruct s1; + ASSERT_TRUE(helper(s1, &v) == ErrorCode::Success); + ASSERT_TRUE(s1.Field1 == "Hello"); + ASSERT_TRUE(s1.Field2 == 2); + + v["extra"] = "world!"; + ObjectStruct s2; + ASSERT_TRUE(helper(s2, &v) == ErrorCode::InvalidObject); + + return true; +} + +bool testObjectOptional() +{ + auto const helper = + cmJSONObjectHelper<ObjectStruct, ErrorCode>(ErrorCode::Success, + ErrorCode::InvalidObject) + .Bind("field1"_s, &ObjectStruct::Field1, StringHelper, false) + .Bind("field2"_s, &ObjectStruct::Field2, IntHelper, false) + .Bind<std::string>("field3_s", nullptr, StringHelper, false); + + Json::Value v(Json::objectValue); + v["field1"] = "Hello"; + v["field2"] = 2; + v["field3"] = "world!"; + v["extra"] = "extra"; + + ObjectStruct s1; + ASSERT_TRUE(helper(s1, &v) == ErrorCode::Success); + ASSERT_TRUE(s1.Field1 == "Hello"); + ASSERT_TRUE(s1.Field2 == 2); + + v = Json::objectValue; + ObjectStruct s2; + ASSERT_TRUE(helper(s2, &v) == ErrorCode::Success); + ASSERT_TRUE(s2.Field1 == "default"); + ASSERT_TRUE(s2.Field2 == 1); + + ObjectStruct s3; + ASSERT_TRUE(helper(s3, nullptr) == ErrorCode::Success); + ASSERT_TRUE(s3.Field1 == "default"); + ASSERT_TRUE(s3.Field2 == 1); + + return true; +} + +bool testVector() +{ + Json::Value v(Json::arrayValue); + v.append("Hello"); + v.append("world!"); + v.append("ignore"); + + std::vector<std::string> l{ "default" }; + std::vector<std::string> expected{ "Hello", "world!", "ignore" }; + ASSERT_TRUE(StringVectorHelper(l, &v) == ErrorCode::Success); + ASSERT_TRUE(l == expected); + + v[1] = 2; + l = { "default" }; + ASSERT_TRUE(StringVectorHelper(l, &v) == ErrorCode::InvalidString); + + v = "Hello"; + l = { "default" }; + ASSERT_TRUE(StringVectorHelper(l, &v) == ErrorCode::InvalidArray); + + l = { "default" }; + ASSERT_TRUE(StringVectorHelper(l, nullptr) == ErrorCode::Success); + ASSERT_TRUE(l.empty()); + + return true; +} + +bool testVectorFilter() +{ + Json::Value v(Json::arrayValue); + v.append("Hello"); + v.append("world!"); + v.append("ignore"); + + std::vector<std::string> l{ "default" }; + std::vector<std::string> expected{ + "Hello", + "world!", + }; + ASSERT_TRUE(StringVectorFilterHelper(l, &v) == ErrorCode::Success); + ASSERT_TRUE(l == expected); + + v[1] = 2; + l = { "default" }; + ASSERT_TRUE(StringVectorFilterHelper(l, &v) == ErrorCode::InvalidString); + + v = "Hello"; + l = { "default" }; + ASSERT_TRUE(StringVectorFilterHelper(l, &v) == ErrorCode::InvalidArray); + + l = { "default" }; + ASSERT_TRUE(StringVectorFilterHelper(l, nullptr) == ErrorCode::Success); + ASSERT_TRUE(l.empty()); + + return true; +} + +bool testMap() +{ + Json::Value v(Json::objectValue); + v["field1"] = "Hello"; + v["field2"] = "world!"; + v["ignore"] = "ignore"; + + std::map<std::string, std::string> m{ { "key", "default" } }; + std::map<std::string, std::string> expected{ { "field1", "Hello" }, + { "field2", "world!" }, + { "ignore", "ignore" } }; + ASSERT_TRUE(StringMapHelper(m, &v) == ErrorCode::Success); + ASSERT_TRUE(m == expected); + + v = Json::arrayValue; + m = { { "key", "default" } }; + ASSERT_TRUE(StringMapHelper(m, &v) == ErrorCode::InvalidObject); + + m = { { "key", "default" } }; + ASSERT_TRUE(StringMapHelper(m, nullptr) == ErrorCode::Success); + ASSERT_TRUE(m.empty()); + + return true; +} + +bool testMapFilter() +{ + Json::Value v(Json::objectValue); + v["field1"] = "Hello"; + v["field2"] = "world!"; + v["ignore"] = "ignore"; + + std::map<std::string, std::string> m{ { "key", "default" } }; + std::map<std::string, std::string> expected{ { "field1", "Hello" }, + { "field2", "world!" } }; + ASSERT_TRUE(StringMapFilterHelper(m, &v) == ErrorCode::Success); + ASSERT_TRUE(m == expected); + + v = Json::arrayValue; + m = { { "key", "default" } }; + ASSERT_TRUE(StringMapFilterHelper(m, &v) == ErrorCode::InvalidObject); + + m = { { "key", "default" } }; + ASSERT_TRUE(StringMapFilterHelper(m, nullptr) == ErrorCode::Success); + ASSERT_TRUE(m.empty()); + + return true; +} + +bool testOptional() +{ + Json::Value v = "Hello"; + + cm::optional<std::string> str{ "default" }; + ASSERT_TRUE(OptionalStringHelper(str, &v) == ErrorCode::Success); + ASSERT_TRUE(str == "Hello"); + + str.emplace("default"); + ASSERT_TRUE(OptionalStringHelper(str, nullptr) == ErrorCode::Success); + ASSERT_TRUE(str == cm::nullopt); + + return true; +} + +bool testRequired() +{ + Json::Value v = "Hello"; + + std::string str = "default"; + int i = 1; + ASSERT_TRUE(RequiredStringHelper(str, &v) == ErrorCode::Success); + ASSERT_TRUE(str == "Hello"); + ASSERT_TRUE(RequiredIntHelper(i, &v) == ErrorCode::InvalidInt); + + v = 2; + str = "default"; + i = 1; + ASSERT_TRUE(RequiredStringHelper(str, &v) == ErrorCode::InvalidString); + ASSERT_TRUE(RequiredIntHelper(i, &v) == ErrorCode::Success); + ASSERT_TRUE(i == 2); + + str = "default"; + i = 1; + ASSERT_TRUE(RequiredStringHelper(str, nullptr) == + ErrorCode::MissingRequired); + ASSERT_TRUE(RequiredIntHelper(i, nullptr) == ErrorCode::MissingRequired); + + return true; +} +} + +int testJSONHelpers(int /*unused*/, char* /*unused*/ []) +{ + if (!testInt()) { + return 1; + } + if (!testUInt()) { + return 1; + } + if (!testBool()) { + return 1; + } + if (!testString()) { + return 1; + } + if (!testObject()) { + return 1; + } + if (!testObjectInherited()) { + return 1; + } + if (!testObjectNoExtra()) { + return 1; + } + if (!testObjectOptional()) { + return 1; + } + if (!testVector()) { + return 1; + } + if (!testVectorFilter()) { + return 1; + } + if (!testMap()) { + return 1; + } + if (!testMapFilter()) { + return 1; + } + if (!testOptional()) { + return 1; + } + if (!testRequired()) { + return 1; + } + return 0; +} diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx index c6bc9c231..de09c0fce 100644 --- a/Tests/CMakeLib/testOptional.cxx +++ b/Tests/CMakeLib/testOptional.cxx @@ -29,6 +29,13 @@ public: CONST_RVALUE_REFERENCE, SWAP, + + COMPARE_EE_EQ, + COMPARE_EE_NE, + COMPARE_EE_LT, + COMPARE_EE_LE, + COMPARE_EE_GT, + COMPARE_EE_GE, }; EventType Type; @@ -75,6 +82,14 @@ public: int Value = 0; }; +#define ASSERT_TRUE(x) \ + do { \ + if (!(x)) { \ + std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ + return false; \ + } \ + } while (false) + // Certain builds of GCC generate false -Wmaybe-uninitialized warnings when // doing a release build with the system version of std::optional. These // warnings do not manifest when using our own cm::optional implementation. @@ -153,6 +168,42 @@ EventLogger& EventLogger::operator=(int value) return *this; } +bool operator==(const EventLogger& lhs, const EventLogger& rhs) +{ + events.push_back({ Event::COMPARE_EE_EQ, &lhs, &rhs, lhs.Value }); + return lhs.Value == rhs.Value; +} + +bool operator!=(const EventLogger& lhs, const EventLogger& rhs) +{ + events.push_back({ Event::COMPARE_EE_NE, &lhs, &rhs, lhs.Value }); + return lhs.Value != rhs.Value; +} + +bool operator<(const EventLogger& lhs, const EventLogger& rhs) +{ + events.push_back({ Event::COMPARE_EE_LT, &lhs, &rhs, lhs.Value }); + return lhs.Value < rhs.Value; +} + +bool operator<=(const EventLogger& lhs, const EventLogger& rhs) +{ + events.push_back({ Event::COMPARE_EE_LE, &lhs, &rhs, lhs.Value }); + return lhs.Value <= rhs.Value; +} + +bool operator>(const EventLogger& lhs, const EventLogger& rhs) +{ + events.push_back({ Event::COMPARE_EE_GT, &lhs, &rhs, lhs.Value }); + return lhs.Value > rhs.Value; +} + +bool operator>=(const EventLogger& lhs, const EventLogger& rhs) +{ + events.push_back({ Event::COMPARE_EE_GE, &lhs, &rhs, lhs.Value }); + return lhs.Value >= rhs.Value; +} + void EventLogger::Reference() & { events.push_back({ Event::REFERENCE, this, nullptr, this->Value }); @@ -368,42 +419,23 @@ static bool testDereference(std::vector<Event>& expected) static bool testHasValue(std::vector<Event>& expected) { - bool retval = true; - const cm::optional<EventLogger> o1{ 4 }; const cm::optional<EventLogger> o2{}; - if (!o1.has_value()) { - std::cout << "o1 should have a value" << std::endl; - retval = false; - } - - if (!o1) { - std::cout << "(bool)o1 should be true" << std::endl; - retval = false; - } - - if (o2.has_value()) { - std::cout << "o2 should not have a value" << std::endl; - retval = false; - } - - if (o2) { - std::cout << "(bool)o2 should be false" << std::endl; - retval = false; - } + ASSERT_TRUE(o1.has_value()); + ASSERT_TRUE(o1); + ASSERT_TRUE(!o2.has_value()); + ASSERT_TRUE(!o2); expected = { { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 }, { Event::DESTRUCT, &*o1, nullptr, 4 }, }; - return retval; + return true; } static bool testValue(std::vector<Event>& expected) { - bool retval = true; - cm::optional<EventLogger> o1{ 4 }; const cm::optional<EventLogger> o2{ 5 }; cm::optional<EventLogger> o3{}; @@ -418,10 +450,7 @@ static bool testValue(std::vector<Event>& expected) } catch (cm::bad_optional_access&) { thrown = true; } - if (!thrown) { - std::cout << "o3.value() did not throw" << std::endl; - retval = false; - } + ASSERT_TRUE(thrown); thrown = false; try { @@ -429,10 +458,7 @@ static bool testValue(std::vector<Event>& expected) } catch (cm::bad_optional_access&) { thrown = true; } - if (!thrown) { - std::cout << "o4.value() did not throw" << std::endl; - retval = false; - } + ASSERT_TRUE(thrown); expected = { { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 }, @@ -442,13 +468,11 @@ static bool testValue(std::vector<Event>& expected) { Event::DESTRUCT, &*o2, nullptr, 5 }, { Event::DESTRUCT, &*o1, nullptr, 4 }, }; - return retval; + return true; } static bool testValueOr() { - bool retval = true; - const cm::optional<EventLogger> o1{ 4 }; cm::optional<EventLogger> o2{ 5 }; const cm::optional<EventLogger> o3{}; @@ -460,33 +484,133 @@ static bool testValueOr() EventLogger e4{ 9 }; EventLogger r1 = o1.value_or(e1); - if (r1.Value != 4) { - std::cout << "r1.Value should be 4" << std::endl; - retval = false; - } + ASSERT_TRUE(r1.Value == 4); EventLogger r2 = std::move(o2).value_or(e2); - if (r2.Value != 5) { - std::cout << "r2.Value should be 5" << std::endl; - retval = false; - } + ASSERT_TRUE(r2.Value == 5); EventLogger r3 = o3.value_or(e3); - if (r3.Value != 8) { - std::cout << "r3.Value should be 8" << std::endl; - retval = false; - } + ASSERT_TRUE(r3.Value == 8); EventLogger r4 = std::move(o4).value_or(e4); - if (r4.Value != 9) { - std::cout << "r4.Value should be 9" << std::endl; - retval = false; - } + ASSERT_TRUE(r4.Value == 9); - return retval; + return true; } -static bool testSwap(std::vector<Event>& expected) +static bool testComparison(std::vector<Event>& expected) { - bool retval = true; + const cm::optional<EventLogger> o1{ 1 }; + const cm::optional<EventLogger> o2{ 2 }; + const cm::optional<EventLogger> o3{ 2 }; + const cm::optional<EventLogger> o4{}; + const cm::optional<EventLogger> o5{}; + const EventLogger e1{ 2 }; + + ASSERT_TRUE(!(o1 == o2) && o1 != o2); + ASSERT_TRUE(o1 < o2 && !(o1 >= o2)); + ASSERT_TRUE(!(o1 > o2) && o1 <= o2); + + ASSERT_TRUE(o2 == o3 && !(o2 != o3)); + ASSERT_TRUE(!(o2 < o3) && o2 >= o3); + ASSERT_TRUE(!(o2 > o3) && o2 <= o3); + + ASSERT_TRUE(!(o3 == o4) && o3 != o4); + ASSERT_TRUE(!(o3 < o4) && o3 >= o4); + ASSERT_TRUE(o3 > o4 && !(o3 <= o4)); + + ASSERT_TRUE(o4 == o5 && !(o4 != o5)); + ASSERT_TRUE(!(o4 < o5) && o4 >= o5); + ASSERT_TRUE(!(o4 > o5) && o4 <= o5); + + ASSERT_TRUE(!(o1 == cm::nullopt) && o1 != cm::nullopt); + ASSERT_TRUE(!(o1 < cm::nullopt) && o1 >= cm::nullopt); + ASSERT_TRUE(o1 > cm::nullopt && !(o1 <= cm::nullopt)); + + ASSERT_TRUE(!(cm::nullopt == o1) && cm::nullopt != o1); + ASSERT_TRUE(cm::nullopt < o1 && !(cm::nullopt >= o1)); + ASSERT_TRUE(!(cm::nullopt > o1) && cm::nullopt <= o1); + + ASSERT_TRUE(o4 == cm::nullopt && !(o4 != cm::nullopt)); + ASSERT_TRUE(!(o4 < cm::nullopt) && o4 >= cm::nullopt); + ASSERT_TRUE(!(o4 > cm::nullopt) && o4 <= cm::nullopt); + + ASSERT_TRUE(cm::nullopt == o4 && !(cm::nullopt != o4)); + ASSERT_TRUE(!(cm::nullopt < o4) && cm::nullopt >= o4); + ASSERT_TRUE(!(cm::nullopt > o4) && cm::nullopt <= o4); + + ASSERT_TRUE(!(o1 == e1) && o1 != e1); + ASSERT_TRUE(o1 < e1 && !(o1 >= e1)); + ASSERT_TRUE(!(o1 > e1) && o1 <= e1); + + ASSERT_TRUE(o2 == e1 && !(o2 != e1)); + ASSERT_TRUE(!(o2 < e1) && o2 >= e1); + ASSERT_TRUE(!(o2 > e1) && o2 <= e1); + ASSERT_TRUE(!(o4 == e1) && o4 != e1); + ASSERT_TRUE(o4 < e1 && !(o4 >= e1)); + ASSERT_TRUE(!(o4 > e1) && o4 <= e1); + + ASSERT_TRUE(!(e1 == o1) && e1 != o1); + ASSERT_TRUE(!(e1 < o1) && e1 >= o1); + ASSERT_TRUE(e1 > o1 && !(e1 <= o1)); + + ASSERT_TRUE(e1 == o2 && !(e1 != o2)); + ASSERT_TRUE(!(e1 < o2) && e1 >= o2); + ASSERT_TRUE(!(e1 > o2) && e1 <= o2); + + ASSERT_TRUE(!(e1 == o4) && e1 != o4); + ASSERT_TRUE(!(e1 < o4) && e1 >= o4); + ASSERT_TRUE(e1 > o4 && !(e1 <= o4)); + + expected = { + { Event::VALUE_CONSTRUCT, &*o1, nullptr, 1 }, + { Event::VALUE_CONSTRUCT, &*o2, nullptr, 2 }, + { Event::VALUE_CONSTRUCT, &*o3, nullptr, 2 }, + { Event::VALUE_CONSTRUCT, &e1, nullptr, 2 }, + { Event::COMPARE_EE_EQ, &*o1, &*o2, 1 }, + { Event::COMPARE_EE_NE, &*o1, &*o2, 1 }, + { Event::COMPARE_EE_LT, &*o1, &*o2, 1 }, + { Event::COMPARE_EE_GE, &*o1, &*o2, 1 }, + { Event::COMPARE_EE_GT, &*o1, &*o2, 1 }, + { Event::COMPARE_EE_LE, &*o1, &*o2, 1 }, + { Event::COMPARE_EE_EQ, &*o2, &*o3, 2 }, + { Event::COMPARE_EE_NE, &*o2, &*o3, 2 }, + { Event::COMPARE_EE_LT, &*o2, &*o3, 2 }, + { Event::COMPARE_EE_GE, &*o2, &*o3, 2 }, + { Event::COMPARE_EE_GT, &*o2, &*o3, 2 }, + { Event::COMPARE_EE_LE, &*o2, &*o3, 2 }, + { Event::COMPARE_EE_EQ, &*o1, &e1, 1 }, + { Event::COMPARE_EE_NE, &*o1, &e1, 1 }, + { Event::COMPARE_EE_LT, &*o1, &e1, 1 }, + { Event::COMPARE_EE_GE, &*o1, &e1, 1 }, + { Event::COMPARE_EE_GT, &*o1, &e1, 1 }, + { Event::COMPARE_EE_LE, &*o1, &e1, 1 }, + { Event::COMPARE_EE_EQ, &*o2, &e1, 2 }, + { Event::COMPARE_EE_NE, &*o2, &e1, 2 }, + { Event::COMPARE_EE_LT, &*o2, &e1, 2 }, + { Event::COMPARE_EE_GE, &*o2, &e1, 2 }, + { Event::COMPARE_EE_GT, &*o2, &e1, 2 }, + { Event::COMPARE_EE_LE, &*o2, &e1, 2 }, + { Event::COMPARE_EE_EQ, &e1, &*o1, 2 }, + { Event::COMPARE_EE_NE, &e1, &*o1, 2 }, + { Event::COMPARE_EE_LT, &e1, &*o1, 2 }, + { Event::COMPARE_EE_GE, &e1, &*o1, 2 }, + { Event::COMPARE_EE_GT, &e1, &*o1, 2 }, + { Event::COMPARE_EE_LE, &e1, &*o1, 2 }, + { Event::COMPARE_EE_EQ, &e1, &*o2, 2 }, + { Event::COMPARE_EE_NE, &e1, &*o2, 2 }, + { Event::COMPARE_EE_LT, &e1, &*o2, 2 }, + { Event::COMPARE_EE_GE, &e1, &*o2, 2 }, + { Event::COMPARE_EE_GT, &e1, &*o2, 2 }, + { Event::COMPARE_EE_LE, &e1, &*o2, 2 }, + { Event::DESTRUCT, &e1, nullptr, 2 }, + { Event::DESTRUCT, &*o3, nullptr, 2 }, + { Event::DESTRUCT, &*o2, nullptr, 2 }, + { Event::DESTRUCT, &*o1, nullptr, 1 }, + }; + return true; +} + +static bool testSwap(std::vector<Event>& expected) +{ cm::optional<EventLogger> o1{ 4 }; auto const* v1 = &*o1; cm::optional<EventLogger> o2{}; @@ -494,66 +618,30 @@ static bool testSwap(std::vector<Event>& expected) o1.swap(o2); auto const* v2 = &*o2; - if (o1.has_value()) { - std::cout << "o1 should not have value" << std::endl; - retval = false; - } - if (!o2.has_value()) { - std::cout << "o2 should have value" << std::endl; - retval = false; - } - if (o2.value().Value != 4) { - std::cout << "value of o2 should be 4" << std::endl; - retval = false; - } + ASSERT_TRUE(!o1.has_value()); + ASSERT_TRUE(o2.has_value()); + ASSERT_TRUE(o2.value().Value == 4); o1.swap(o2); - if (!o1.has_value()) { - std::cout << "o1 should have value" << std::endl; - retval = false; - } - if (o1.value().Value != 4) { - std::cout << "value of o1 should be 4" << std::endl; - retval = false; - } - if (o2.has_value()) { - std::cout << "o2 should not have value" << std::endl; - retval = false; - } + ASSERT_TRUE(o1.has_value()); + ASSERT_TRUE(o1.value().Value == 4); + ASSERT_TRUE(!o2.has_value()); o2.emplace(5); o1.swap(o2); - if (!o1.has_value()) { - std::cout << "o1 should have value" << std::endl; - retval = false; - } - if (o1.value().Value != 5) { - std::cout << "value of o1 should be 5" << std::endl; - retval = false; - } - if (!o2.has_value()) { - std::cout << "o2 should not have value" << std::endl; - retval = false; - } - if (o2.value().Value != 4) { - std::cout << "value of o2 should be 4" << std::endl; - retval = false; - } + ASSERT_TRUE(o1.has_value()); + ASSERT_TRUE(o1.value().Value == 5); + ASSERT_TRUE(o2.has_value()); + ASSERT_TRUE(o2.value().Value == 4); o1.reset(); o2.reset(); o1.swap(o2); - if (o1.has_value()) { - std::cout << "o1 should not have value" << std::endl; - retval = false; - } - if (o2.has_value()) { - std::cout << "o2 should not have value" << std::endl; - retval = false; - } + ASSERT_TRUE(!o1.has_value()); + ASSERT_TRUE(!o2.has_value()); expected = { { Event::VALUE_CONSTRUCT, v1, nullptr, 4 }, @@ -566,22 +654,17 @@ static bool testSwap(std::vector<Event>& expected) { Event::DESTRUCT, v1, nullptr, 5 }, { Event::DESTRUCT, v2, nullptr, 4 }, }; - return retval; + return true; } static bool testReset(std::vector<Event>& expected) { - bool retval = true; - cm::optional<EventLogger> o{ 4 }; auto const* v = &*o; o.reset(); - if (o.has_value()) { - std::cout << "o should not have value" << std::endl; - retval = false; - } + ASSERT_TRUE(!o.has_value()); o.reset(); @@ -589,7 +672,7 @@ static bool testReset(std::vector<Event>& expected) { Event::VALUE_CONSTRUCT, v, nullptr, 4 }, { Event::DESTRUCT, v, nullptr, 4 }, }; - return retval; + return true; } static bool testEmplace(std::vector<Event>& expected) @@ -630,8 +713,6 @@ static bool testMakeOptional(std::vector<Event>& expected) static bool testMemoryRange(std::vector<Event>& expected) { - bool retval = true; - cm::optional<EventLogger> o{ 4 }; auto* ostart = &o; @@ -639,17 +720,14 @@ static bool testMemoryRange(std::vector<Event>& expected) auto* estart = &o.value(); auto* eend = estart + 1; - if (static_cast<void*>(estart) < static_cast<void*>(ostart) || - static_cast<void*>(eend) > static_cast<void*>(oend)) { - std::cout << "value is not within memory range of optional" << std::endl; - retval = false; - } + ASSERT_TRUE(static_cast<void*>(estart) >= static_cast<void*>(ostart) && + static_cast<void*>(eend) <= static_cast<void*>(oend)); expected = { { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 }, { Event::DESTRUCT, &*o, nullptr, 4 }, }; - return retval; + return true; } int testOptional(int /*unused*/, char* /*unused*/ []) @@ -691,6 +769,7 @@ int testOptional(int /*unused*/, char* /*unused*/ []) DO_EVENT_TEST(testHasValue); DO_EVENT_TEST(testValue); DO_TEST(testValueOr); + DO_EVENT_TEST(testComparison); DO_EVENT_TEST(testSwap); DO_EVENT_TEST(testReset); DO_EVENT_TEST(testEmplace); diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect index c19ee9400..970adaa4e 100644 --- a/Tests/CMakeLib/testRST.expect +++ b/Tests/CMakeLib/testRST.expect @@ -5,7 +5,7 @@ Command ``some_cmd()`` explicit cmake domain. Command ``some_cmd()`` without target. Command ``some_cmd`` with target. Command ``some_cmd_<cmd>()`` placeholder without target. -Command ``some_cmd_<cmd>`` placholder with target. +Command ``some_cmd_<cmd>`` placeholder with target. Command ``some_cmd()`` with parens. Command ``some_cmd(SUB)`` with subcommand. Command ``some_cmd(SUB)`` with subcommand and target. diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst index d2d1140f3..6462f1b7f 100644 --- a/Tests/CMakeLib/testRST.rst +++ b/Tests/CMakeLib/testRST.rst @@ -12,7 +12,7 @@ Command :cmake:command:`some_cmd` explicit cmake domain. Command :command:`some_cmd` without target. Command :command:`some_cmd <some_cmd>` with target. Command :command:`some_cmd_<cmd>` placeholder without target. -Command :command:`some_cmd_<cmd> <some_cmd>` placholder with target. +Command :command:`some_cmd_<cmd> <some_cmd>` placeholder with target. Command :command:`some_cmd()` with parens. Command :command:`some_cmd(SUB)` with subcommand. Command :command:`some_cmd(SUB) <some_cmd>` with subcommand and target. diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index 63826cf28..c2706c1f9 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -226,5 +226,15 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) "cmStrToULong rejects trailing content."); } + // ---------------------------------------------------------------------- + // Test cmStrLen + { + constexpr auto len = cmStrLen("Hello world!"); + assert_ok(len == 12, + "cmStrLen returns length of non-empty literal string"); + assert_ok(cmStrLen("") == 0, + "cmStrLen returns length of empty literal string"); + } + return failed; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index db6dbf379..9aa401d93 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -206,6 +206,26 @@ if(BUILD_TESTING) set(${reg} 0) endif() endforeach() + if(COMMAND cmake_host_system_information) + set(info_vs15 "VS_15_DIR") + set(info_vs16 "VS_16_DIR") + set(vs_versions) + if(WIN32) + if(NOT CMAKE_VERSION VERSION_LESS 3.14) + set(vs_versions vs15 vs16) + elseif(NOT CMAKE_VERSION VERSION_LESS 3.8) + set(vs_versions vs15) + endif() + endif() + foreach(info ${vs_versions}) + cmake_host_system_information(RESULT found QUERY "${info_${info}}") + if(found) + set(${info} 1) + else() + set(${info} 0) + endif() + endforeach() + endif() endif() #--------------------------------------------------------------------------- @@ -420,6 +440,10 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CSharpOnly CSharpOnly) ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx) + ADD_TEST_MACRO(CSharpWin32GenEx CSharpWin32GenEx) + set_tests_properties(CSharpWin32GenEx PROPERTIES + PASS_REGULAR_EXPRESSION "Target \"CSharpWin32GenEx\" has a generator expression in its\n WIN32_EXECUTABLE property\\. This is not supported on managed executables\\." + ) endif() ADD_TEST_MACRO(COnly COnly) @@ -697,38 +721,28 @@ if(BUILD_TESTING) # build the "Simple" test with the ExtraGenerators, if available # This doesn't test whether the generated project files work (unfortunately), # mainly it tests that cmake doesn't crash when generating these project files. - if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "Ninja") - - # check which generators we have - execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help - OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput) - - set(extraGenerators - "CodeBlocks" - "CodeLite" - "Eclipse CDT4" - "Kate" - "Sublime Text 2") - - foreach(extraGenerator ${extraGenerators}) - if ("${cmakeOutput}" MATCHES "${extraGenerator} - ${CMAKE_GENERATOR}") - set(extraGeneratorTestName "Simple_${extraGenerator}Generator") - string(REPLACE " " "" extraGeneratorTestName ${extraGeneratorTestName}) - - add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Simple" - "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}" - --build-two-config - --build-generator "${extraGenerator} - ${CMAKE_GENERATOR}" - --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}" - --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-project Simple - --test-command Simple) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}") - endif () - endforeach(extraGenerator) - + if(CMAKE_GENERATOR MATCHES "^(Unix Makefiles|Ninja)$" + AND NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + foreach(extraGenerator + "CodeBlocks" + "CodeLite" + "Eclipse CDT4" + "Kate" + "Sublime Text 2" + ) + string(REPLACE " " "" extraGeneratorTestName "Simple_${extraGenerator}Generator") + add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Simple" + "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}" + --build-two-config + --build-generator "${extraGenerator} - ${CMAKE_GENERATOR}" + --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" + --build-project Simple + --test-command Simple) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}") + endforeach() endif() # test for correct sub-project generation @@ -774,27 +788,6 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject") endif() - # macro to add a test that will build a nightly release - # of CMake for given platform using the release scripts - macro(ADD_NIGHTLY_BUILD_TEST name script) - set(_TEST_DIR "${CMake_BINARY_DIR}/Tests/${name}") - file(MAKE_DIRECTORY "${_TEST_DIR}") - file(WRITE "${_TEST_DIR}/nightly-cmake.sh" - "set -e -cd ${_TEST_DIR} -${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script} -${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGHTLY_RELEASES}' - ") - add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh) - if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) - set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - endif() - endmacro() - if(CMake_BUILD_NIGHTLY_RELEASES) - ADD_NIGHTLY_BUILD_TEST(CMakeNightlyOSX - osx_release.cmake) - endif() - # add tests with more complex invocations add_test(Framework ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1451,6 +1444,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH Patch PostgreSQL Protobuf + SDL SQLite3 TIFF Vulkan @@ -1468,6 +1462,10 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_subdirectory(CudaOnly) endif() + if(CMake_TEST_ISPC) + add_subdirectory(ISPC) + endif() + if(CMake_TEST_FindGTest) add_subdirectory(FindGTest) add_subdirectory(GoogleTest) @@ -1635,7 +1633,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH set_tests_properties(${tutorial_test_name} PROPERTIES PASS_REGULAR_EXPRESSION ${pass_regex}) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/${tutorial_build_dir}_Build") + list(APPEND TEST_BUILD_DIRS "${tutorial_build_dir}_Build") endfunction() if(NOT CMake_TEST_EXTERNAL_CMAKE) @@ -1655,6 +1653,44 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_tutorial_test(Complete FALSE 25 ${pass_regex}) endif() + function(add_importexport_test export_name import_name) + set(install_dir + "${CMake_BINARY_DIR}/Tests/ImportExport/Install${export_name}") + set(export_build_dir "${CMake_BINARY_DIR}/Tests/ImportExport/${export_name}Build") + set(export_test_name "Guide.ImportExport.${export_name}") + add_test(${export_test_name} ${CMAKE_CTEST_COMMAND} + -C "Release" + --build-and-test + "${CMake_SOURCE_DIR}/Help/guide/importing-exporting/${export_name}" + "${export_build_dir}" + ${build_generator_args} + --build-project ${export_name} + --build-target install + --build-options + "-DCMAKE_INSTALL_PREFIX:PATH=${install_dir}") + list(APPEND TEST_BUILD_DIRS "${export_build_dir}") + + set(import_build_dir "${CMake_BINARY_DIR}/Tests/ImportExport/${import_name}Build") + set(import_test_name "Guide.ImportExport.${import_name}") + add_test(${import_test_name} ${CMAKE_CTEST_COMMAND} + -C "Release" + --build-and-test + "${CMake_SOURCE_DIR}/Help/guide/importing-exporting/${import_name}" + "${import_build_dir}" + ${build_generator_args} + --build-project ${import_name} + --build-options + "-DCMAKE_PREFIX_PATH:PATH=${install_dir}/lib/cmake") + set_tests_properties(${import_test_name} PROPERTIES DEPENDS ${export_test_name}) + list(APPEND TEST_BUILD_DIRS "${import_build_dir}") + endfunction() + + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_importexport_test("MyExe" "Importing") + add_importexport_test("MathFunctions" "Downstream") + add_importexport_test("MathFunctionsComponents" "DownstreamComponents") + endif() + add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test "${CMake_SOURCE_DIR}/Tests/Testing" @@ -2315,32 +2351,41 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH endforeach() endif() + macro(add_test_VSAndroid name generator platform) + add_test(NAME "VSAndroid.${name}.${platform}" COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSAndroid" + "${CMake_BINARY_DIR}/Tests/VSAndroid/${name}/${platform}" + --build-generator "${generator}" + --build-project VSAndroid + --build-config $<CONFIGURATION> + --build-options -DCMAKE_SYSTEM_NAME=Android "-A${platform}" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSAndroid/${name}") + endmacro() if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ") - macro(add_test_VSNsightTegra name generator) - add_test(NAME VSNsightTegra.${name} COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/VSNsightTegra" - "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}" - --build-generator "${generator}" - --build-project VSNsightTegra - --build-config $<CONFIGURATION> - --build-options -DCMAKE_SYSTEM_NAME=Android - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}") - endmacro() if(vs10) - add_test_VSNsightTegra(vs10 "Visual Studio 10 2010") + add_test_VSAndroid(vs10 "Visual Studio 10 2010" "Tegra-Android") endif() if(vs11) - add_test_VSNsightTegra(vs11 "Visual Studio 11 2012") + add_test_VSAndroid(vs11 "Visual Studio 11 2012" "Tegra-Android") endif() if(vs12) - add_test_VSNsightTegra(vs12 "Visual Studio 12 2013") + add_test_VSAndroid(vs12 "Visual Studio 12 2013" "Tegra-Android") endif() if(vs14) - add_test_VSNsightTegra(vs14 "Visual Studio 14 2015") + add_test_VSAndroid(vs14 "Visual Studio 14 2015" "Tegra-Android") endif() endif() + if(vs14 AND CMake_TEST_ANDROID_VS14) + add_test_VSAndroid(vs14 "Visual Studio 14 2015" "ARM") + endif() + if(vs15 AND CMake_TEST_ANDROID_VS15) + add_test_VSAndroid(vs15 "Visual Studio 15 2017" "ARM") + endif() + if(vs16 AND CMake_TEST_ANDROID_VS16) + add_test_VSAndroid(vs16 "Visual Studio 16 2019" "ARM") + endif() if (APPLE) if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") @@ -2397,36 +2442,6 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest") endif() - add_test(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet" - "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet" - ${build_generator_args} - --build-noclean - --build-project WarnUnusedUnusedViaSet - --build-options - "--warn-unused-vars") - set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES - PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'") - set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES - FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'") - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet") - - add_test(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset" - "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset" - ${build_generator_args} - --build-noclean - --build-project WarnUnusedUnusedViaUnset - --build-options - "--warn-unused-vars") - set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Warning \\(dev\\) at CMakeLists.txt:7 \\(set\\):") - set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES - FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):") - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused" @@ -2916,7 +2931,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH PASS_REGULAR_EXPRESSION "Failed") else() set_tests_properties(CTestTestCrash PROPERTIES - PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Child aborted)") + PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Subprocess aborted)") endif() configure_file( @@ -3250,6 +3265,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH COMMAND ${CMAKE_CMAKE_COMMAND} -D "bootstrap=${bootstrap}" -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest" + -D "generator=${CMAKE_GENERATOR}" -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest") @@ -3516,6 +3532,10 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_subdirectory(CMakeTests) endif() + if(BUILD_QtDialog AND CMake_TEST_GUI AND NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CMakeGUI) + endif() + # If this is not an in-source build, provide a target to wipe out # all the test build directories. This must come at the end after # all the above logic has finished adding to TEST_BUILD_DIRS diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 361cf5f2c..a41b44ed9 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -38,6 +38,11 @@ if (APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") add_CMakeOnly_test(CheckOBJCXXCompilerFlag) endif() +if(CMake_TEST_CUDA) + add_CMakeOnly_test(CompilerIdCUDA) +endif() + + if(CMAKE_Fortran_COMPILER) add_CMakeOnly_test(CompilerIdFortran) endif() diff --git a/Tests/CMakeOnly/CompilerIdCUDA/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdCUDA/CMakeLists.txt new file mode 100644 index 000000000..da1400024 --- /dev/null +++ b/Tests/CMakeOnly/CompilerIdCUDA/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.18) +project(CompilerIdCUDA CUDA) + +foreach(v + CMAKE_CUDA_COMPILER + CMAKE_CUDA_COMPILER_ID + CMAKE_CUDA_COMPILER_VERSION + ) + if(${v}) + message(STATUS "${v}=[${${v}}]") + else() + message(SEND_ERROR "${v} not set!") + endif() +endforeach() diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index e32d693a7..348e6d05d 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -35,7 +35,7 @@ AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") set_tests_properties(CMake.FileDownload PROPERTIES PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" - FAIL_REGULAR_EXPRESSION "Unexpected status" + FAIL_REGULAR_EXPRESSION "Unexpected status|incorrectly interpreted" ) AddCMakeTest(FileDownloadBadHash "") set_property(TEST CMake.FileDownloadBadHash PROPERTY diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 76c0000c2..69d9a14c4 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -163,3 +163,16 @@ __reportIfWrongStatus("${status}" 0) if(NOT EXISTS file12.png) message(SEND_ERROR "file12.png not downloaded: ${status}") endif() + +message(STATUS "FileDownload:13") +file(DOWNLOAD + ${url} + TIMEOUT ${timeout} + STATUS status + ) +__reportIfWrongStatus("${status}" 0) +if(EXISTS TIMEOUT) + file(REMOVE TIMEOUT) + message(SEND_ERROR "TIMEOUT argument was incorrectly interpreted as a filename") +endif() +message(STATUS "${status}") diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake index 145f28a3f..fc3c28adf 100644 --- a/Tests/CMakeTests/FileTestScript.cmake +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -10,7 +10,7 @@ elseif(testname STREQUAL different_not_enough_args) # fail file(DIFFERENT ffff) elseif(testname STREQUAL download_not_enough_args) # fail - file(DOWNLOAD ffff) + file(DOWNLOAD) elseif(testname STREQUAL read_not_enough_args) # fail file(READ ffff) @@ -181,7 +181,7 @@ elseif(testname STREQUAL to_native_path) # pass message("v='${v}'") elseif(testname STREQUAL download_wrong_number_of_args) # fail - file(DOWNLOAD zzzz://bogus/ffff) + file(DOWNLOAD) elseif(testname STREQUAL download_file_with_no_path) # pass file(DOWNLOAD zzzz://bogus/ffff ffff) diff --git a/Tests/COnly/CMakeLists.txt b/Tests/COnly/CMakeLists.txt index 20615fea1..1c24017b6 100644 --- a/Tests/COnly/CMakeLists.txt +++ b/Tests/COnly/CMakeLists.txt @@ -1,5 +1,5 @@ # a simple C only test case -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project (COnly C) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index 253d128f1..f3d3ad03f 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -88,12 +88,14 @@ if(CPackGen MATCHES "DragNDrop") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg") if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) + set(expect_dmg_sla 1) elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) + set(expect_dmg_sla 1) endif() endif() @@ -138,6 +140,36 @@ if(expected_file_mask) if(NOT actual_count EQUAL expected_count) message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error})") endif() + + if(expect_dmg_sla) + execute_process(COMMAND hdiutil udifderez -xml "${expected_file}" OUTPUT_VARIABLE out ERROR_VARIABLE err RESULT_VARIABLE res) + if(NOT res EQUAL 0) + string(REPLACE "\n" "\n " err " ${err}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${expected_file}\nfailed with:\n${err}") + endif() + foreach(key "LPic" "STR#" "TEXT") + if(NOT out MATCHES "<key>${key}</key>") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${expected_file}\ndid not show '${key}' key:\n${out}") + endif() + endforeach() + foreach(line + # LPic first and last base64 lines + "\tAAIAEQADAAEAAAAAAAIAAAAIAAMAAAABAAQAAAAEAAUAAAAOAAYA\n" + "\tAA0AAABbAAQAAAAzAA8AAQAMABAAAAALAA4AAA==\n" + # STR# first and last base64 lines + "\tAAkHRW5nbGlzaAVBZ3JlZQhEaXNhZ3JlZQVQcmludAdTYXZlLi4u\n" + "\tdGVkIGEgcHJpbnRlci4=\n" + # TEXT first and last base64 lines + "\tTElDRU5TRQ0tLS0tLS0tDVRoaXMgaXMgYW4gaW5zdGFsbGVyIGNy\n" + "\tTm8gbGljZW5zZSBwcm92aWRlZC4NDQ==\n" + ) + if(NOT out MATCHES "${line}") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${expected_file}\ndid not show '${line}':\n${out}") + endif() + endforeach() + endif() endif() # Validate content diff --git a/Tests/CSharpOnly/CMakeLists.txt b/Tests/CSharpOnly/CMakeLists.txt index 42cbe2e60..195af05cb 100644 --- a/Tests/CSharpOnly/CMakeLists.txt +++ b/Tests/CSharpOnly/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.3) # a simple CSharp only test case project (CSharpOnly CSharp) diff --git a/Tests/CSharpWin32GenEx/CMakeLists.txt b/Tests/CSharpWin32GenEx/CMakeLists.txt new file mode 100644 index 000000000..f4a8d00f6 --- /dev/null +++ b/Tests/CSharpWin32GenEx/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.18) +project(CSharpWin32GenEx CSharp) + +add_executable(CSharpWin32GenEx csharpwin32genex.cs) +set_property(TARGET CSharpWin32GenEx PROPERTY WIN32_EXECUTABLE $<1:1>) diff --git a/Tests/CSharpWin32GenEx/csharpwin32genex.cs b/Tests/CSharpWin32GenEx/csharpwin32genex.cs new file mode 100644 index 000000000..9892ee029 --- /dev/null +++ b/Tests/CSharpWin32GenEx/csharpwin32genex.cs @@ -0,0 +1,9 @@ +namespace CSharpWin32GenEx +{ + class CSharpWin32GenEx + { + public static void Main(string[] args) + { + } + } +} diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index 6e69e8b4e..1db00cc8a 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -8,7 +8,12 @@ project(ConfigSources CXX) # Source file(s) named with the configuration(s). file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/config_$<CONFIG>.cpp" - CONTENT "void config_$<CONFIG>() {}\n" + CONTENT [[ +#if defined(_WIN32) && defined(OBJ_SHARED) +__declspec(dllexport) +#endif +void config_$<CONFIG>() {} +]] ) # Per-config sources via INTERFACE_SOURCES. @@ -76,3 +81,26 @@ else() endif() add_library(OneConfigOnly OBJECT "$<$<CONFIG:${one_config}>:${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp>") set_property(TARGET OneConfigOnly PROPERTY LINKER_LANGUAGE CXX) + + +# --------------------------------------------------------------------------- +# Makes sure that each configuration uses the correct generated file. +add_library(ObjLibFromGeneratedSources OBJECT) +set_property(TARGET ObjLibFromGeneratedSources PROPERTY POSITION_INDEPENDENT_CODE 1) +target_compile_definitions(ObjLibFromGeneratedSources PRIVATE OBJ_SHARED) +target_sources(ObjLibFromGeneratedSources PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config_$<CONFIG>.cpp) +add_library(SharedLibFromObjLibFromGeneratedSources SHARED shared.cpp) +target_link_libraries(SharedLibFromObjLibFromGeneratedSources PRIVATE ObjLibFromGeneratedSources) + + +# --------------------------------------------------------------------------- +# Make sure that additional build-events do not confuse CMake when using generated files. +add_library(SharedLibFromGeneratedSources SHARED) +set_property(TARGET SharedLibFromGeneratedSources PROPERTY POSITION_INDEPENDENT_CODE 1) +target_sources(SharedLibFromGeneratedSources PRIVATE + shared.cpp + ${CMAKE_CURRENT_BINARY_DIR}/config_$<CONFIG>.cpp + ) +add_custom_command(TARGET SharedLibFromGeneratedSources POST_BUILD + COMMAND "${CMAKE_COMMAND}" "-E" "echo" "$<TARGET_FILE:SharedLibFromGeneratedSources>" + ) diff --git a/Tests/ConfigSources/shared.cpp b/Tests/ConfigSources/shared.cpp new file mode 100644 index 000000000..1726c46b0 --- /dev/null +++ b/Tests/ConfigSources/shared.cpp @@ -0,0 +1,8 @@ +#if defined(_WIN32) +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif +EXPORT void shared() +{ +} diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 35ceb333c..be5ccac50 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -17,13 +17,12 @@ add_cuda_test_macro(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly) add_cuda_test_macro(Cuda.Toolkit Toolkit) add_cuda_test_macro(Cuda.IncludePathNoToolkit IncludePathNoToolkit) add_cuda_test_macro(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) +add_cuda_test_macro(Cuda.Complex CudaComplex) +add_cuda_test_macro(Cuda.ProperLinkFlags ProperLinkFlags) -# Separable compilation is currently only supported on NVCC. Disable tests -# using it for other compilers. if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") - add_cuda_test_macro(Cuda.Complex CudaComplex) + # Clang lacks __CUDACC_VER*__ defines. add_cuda_test_macro(Cuda.ProperDeviceLibraries ProperDeviceLibraries) - add_cuda_test_macro(Cuda.ProperLinkFlags ProperLinkFlags) endif() # The CUDA only ships the shared version of the toolkit libraries diff --git a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt index f4ad83a30..50338cfcd 100644 --- a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt +++ b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(CXXStandardSetTwice CXX CUDA) set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(CXXStandardSetTwice main.cu) target_compile_features(CXXStandardSetTwice PUBLIC cxx_std_11) diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt index 265bd85c1..63defdf72 100644 --- a/Tests/Cuda/Complex/CMakeLists.txt +++ b/Tests/Cuda/Complex/CMakeLists.txt @@ -1,6 +1,5 @@ - -cmake_minimum_required(VERSION 3.7) -project (Complex CXX CUDA) +cmake_minimum_required(VERSION 3.18) +project(Complex CXX CUDA) #Goal for this example: #build a cpp dynamic library base @@ -14,8 +13,6 @@ project (Complex CXX CUDA) #this tests that we can properly handle linking cuda and cpp together #and also building cpp targets that need cuda implicit libraries -#verify that we can pass explicit cuda arch flags -set(CMAKE_CUDA_ARCHITECTURES 30) set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD_REQUIRED TRUE) diff --git a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt index 7098a7df5..b01b9d7f0 100644 --- a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt +++ b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt @@ -1,6 +1,5 @@ - -cmake_minimum_required(VERSION 3.7) -project (ConsumeCompileFeatures CXX CUDA) +cmake_minimum_required(VERSION 3.18) +project(ConsumeCompileFeatures CXX CUDA) #Goal for this example: #build a c++11 library that express a c++11 public compile feature diff --git a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt index e40ffa6da..ac2b2f512 100644 --- a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(MixedStandardLevels1 CXX CUDA) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CUDA_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels1 main.cu lib.cpp) diff --git a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt index 7af8081fa..9ef734b5c 100644 --- a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(MixedStandardLevels2 CXX CUDA) set(CMAKE_CXX_STANDARD 17) #this can decay -set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels2 main.cu lib.cpp) target_compile_features(MixedStandardLevels2 PUBLIC cuda_std_11) diff --git a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt index 2c420030a..629d99cf8 100644 --- a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt @@ -1,8 +1,6 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(MixedStandardLevels3 CXX CUDA) -set(CMAKE_CUDA_ARCHITECTURES 30) - add_executable(MixedStandardLevels3 main.cu lib.cpp) target_compile_features(MixedStandardLevels3 PUBLIC cuda_std_03 cxx_std_14) diff --git a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt index 230230d0d..8ce57ca21 100644 --- a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(MixedStandardLevels4 CXX CUDA) set(CMAKE_CUDA_STANDARD 03) -set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels4 main.cu lib.cpp) target_compile_features(MixedStandardLevels4 PUBLIC cxx_std_14) diff --git a/Tests/Cuda/MixedStandardLevels4/lib.cpp b/Tests/Cuda/MixedStandardLevels4/lib.cpp index ef6fc2005..2a65c77c9 100644 --- a/Tests/Cuda/MixedStandardLevels4/lib.cpp +++ b/Tests/Cuda/MixedStandardLevels4/lib.cpp @@ -3,7 +3,7 @@ constexpr int func(int A, int B) { #if defined(_MSC_VER) && _MSC_VER < 1913 - // no suppport for extended constexpr + // no support for extended constexpr return B * A; #else // Verify that we have at least c++14 diff --git a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt index 5f5ee0637..a3c355761 100644 --- a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(MixedStandardLevels5 CXX CUDA) set(CMAKE_CXX_STANDARD 98) -set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels5 main.cu lib.cpp) diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt index 395bd3881..d308514cb 100644 --- a/Tests/Cuda/ObjectLibrary/CMakeLists.txt +++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project (ObjectLibrary CUDA CXX) #Goal for this example: # diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt index fe28c3edc..1ef77f407 100644 --- a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt +++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt @@ -1,12 +1,16 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.18) project(ProperDeviceLibraries CXX CUDA) set(CMAKE_CUDA_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 35) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads) +if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0) + # cublas_device requires at least sm_35. + set(CMAKE_CUDA_ARCHITECTURES 35) +endif() + add_executable(ProperDeviceLibraries main.cu) set_target_properties(ProperDeviceLibraries PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/Tests/Cuda/ProperLinkFlags/CMakeLists.txt b/Tests/Cuda/ProperLinkFlags/CMakeLists.txt index d38da6d14..862b03bf2 100644 --- a/Tests/Cuda/ProperLinkFlags/CMakeLists.txt +++ b/Tests/Cuda/ProperLinkFlags/CMakeLists.txt @@ -1,6 +1,5 @@ - -cmake_minimum_required(VERSION 3.7) -project (ProperLinkFlags CUDA CXX) +cmake_minimum_required(VERSION 3.18) +project(ProperLinkFlags CUDA CXX) #Goal for this example: #Verify that when we have CXX and CUDA enabled and we link an executable that @@ -19,7 +18,6 @@ set(CMAKE_CXX_FLAGS "-Wall") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 35) add_executable(ProperLinkFlags file1.cu main.cxx) set_target_properties( ProperLinkFlags diff --git a/Tests/Cuda/ProperLinkFlags/file1.cu b/Tests/Cuda/ProperLinkFlags/file1.cu index 9a105f04f..1ce63bf98 100644 --- a/Tests/Cuda/ProperLinkFlags/file1.cu +++ b/Tests/Cuda/ProperLinkFlags/file1.cu @@ -3,7 +3,6 @@ result_type __device__ file1_func(int x) { - __ldg(&x); result_type r; r.input = x; r.sum = x * x; diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt index 48df55856..61a3190be 100644 --- a/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt +++ b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.18) project(SharedRuntimePlusToolkit CXX) #Goal for this example: diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt index 049cbce1f..cc5fa0c2d 100644 --- a/Tests/Cuda/WithC/CMakeLists.txt +++ b/Tests/Cuda/WithC/CMakeLists.txt @@ -1,8 +1,6 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(WithC CUDA C) -set(CMAKE_CUDA_ARCHITECTURES 30) - add_executable(CudaWithC main.c cuda.cu) if(APPLE) diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 7376a73d7..033f1976f 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -12,33 +12,31 @@ add_cuda_test_macro(CudaOnly.SharedRuntimePlusToolkit CudaOnlySharedRuntimePlusT add_cuda_test_macro(CudaOnly.Standard98 CudaOnlyStandard98) add_cuda_test_macro(CudaOnly.Toolkit CudaOnlyToolkit) add_cuda_test_macro(CudaOnly.WithDefs CudaOnlyWithDefs) +add_cuda_test_macro(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) +add_cuda_test_macro(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) +add_cuda_test_macro(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") + # Clang doesn't have flags for selecting the runtime. add_cuda_test_macro(CudaOnly.SharedRuntimeViaCUDAFlags CudaOnlySharedRuntimeViaCUDAFlags) - # Separable compilation is currently only supported on NVCC. Disable tests - # using it for other compilers. - add_cuda_test_macro(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) - add_cuda_test_macro(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) - add_cuda_test_macro(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) - - add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/DontResolveDeviceSymbols/" - "${CMAKE_CURRENT_BINARY_DIR}/DontResolveDeviceSymbols/" - ${build_generator_args} - --build-project DontResolveDeviceSymbols - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) - set_property(TEST "CudaOnly.DontResolveDeviceSymbols" APPEND - PROPERTY LABELS "CUDA") - # Only NVCC defines __CUDACC_DEBUG__ when compiling in debug mode. add_cuda_test_macro(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) endif() +add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}/DontResolveDeviceSymbols/" + "${CMAKE_CURRENT_BINARY_DIR}/DontResolveDeviceSymbols/" + ${build_generator_args} + --build-project DontResolveDeviceSymbols + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> +) +set_property(TEST "CudaOnly.DontResolveDeviceSymbols" APPEND + PROPERTY LABELS "CUDA") + # The CUDA only ships the shared version of the toolkit libraries # on windows if(NOT WIN32) diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt index e10a34873..caf9391d1 100644 --- a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt +++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.7) -project (CircularLinkLine CUDA) +cmake_minimum_required(VERSION 3.18) +project(CircularLinkLine CUDA) #Goal for this example: # Verify that we de-duplicate the device link line @@ -7,7 +7,6 @@ project (CircularLinkLine CUDA) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 30) add_library(CUDACircularDeviceLinking1 STATIC file1.cu) add_library(CUDACircularDeviceLinking2 STATIC file2.cu) diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt index 126566035..c8e8ebc94 100644 --- a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.13) -project (DontResolveDeviceSymbols CUDA) +cmake_minimum_required(VERSION 3.18) +project(DontResolveDeviceSymbols CUDA) # Find nm and dumpbin if(CMAKE_NM) @@ -26,7 +26,6 @@ endif() # Verify that we can't use those device symbols from anything set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 30 50) set(CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS OFF) add_library(CUDANoDeviceResolve SHARED file1.cu) diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu b/Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu index 3924f67c6..90c70e280 100644 --- a/Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu +++ b/Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu @@ -61,7 +61,7 @@ int file1_launch_kernel() err = cudaGetLastError(); std::cout << err << " " << cudaGetErrorString(err) << std::endl; if (err == cudaSuccess) { - // This kernel launch should failed as the device linking never occured + // This kernel launch should failed as the device linking never occurred std::cerr << "file1_kernel: kernel launch should have failed" << std::endl; return 1; } diff --git a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt index 6675655cf..e9c0c1b9c 100644 --- a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt +++ b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt @@ -1,9 +1,7 @@ - -cmake_minimum_required(VERSION 3.7) -project (GPUDebugFlag CUDA) +cmake_minimum_required(VERSION 3.18) +project(GPUDebugFlag CUDA) set(CMAKE_CUDA_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 30) # Goal for this example: # Verify that enabling device debug works. diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index bd94ec813..a44b2f2a7 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project (ResolveDeviceSymbols CUDA) # Find nm and dumpbin @@ -21,8 +21,6 @@ endif() # confirming that the first static library is on the device link line # 3. Verify that we can't use those device symbols from anything that links # to the static library -set(CMAKE_CUDA_ARCHITECTURES 30 50) - add_library(CUDAResolveDeviceDepsA STATIC file1.cu) add_library(CUDAResolveDeviceDepsB STATIC file2.cu) target_compile_features(CUDAResolveDeviceDepsA PUBLIC cuda_std_11) diff --git a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt index 0da57390b..b3b2210dc 100644 --- a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt +++ b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project (RuntimeControls CUDA) # Find nm and dumpbin @@ -16,7 +16,6 @@ else() endif() set(CMAKE_CUDA_STANDARD 11) -set(CMAKE_CUDA_ARCHITECTURES 30) set(CMAKE_CUDA_RUNTIME_LIBRARY static) if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index 586be81ff..864ecbfb5 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -1,6 +1,5 @@ - -cmake_minimum_required(VERSION 3.7) -project (SeparateCompilation CUDA) +cmake_minimum_required(VERSION 3.18) +project(SeparateCompilation CUDA) #Goal for this example: #Build a static library that defines multiple methods and kernels that @@ -9,7 +8,6 @@ project (SeparateCompilation CUDA) #and executables. #We complicate the matter by also testing that multiple static libraries #all containing cuda separable compilation code links properly -set(CMAKE_CUDA_ARCHITECTURES 30 35 50 52) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu) target_compile_features(CUDASeparateLibA PRIVATE cuda_std_11) diff --git a/Tests/CudaOnly/Standard98/CMakeLists.txt b/Tests/CudaOnly/Standard98/CMakeLists.txt index 3ba036095..682335295 100644 --- a/Tests/CudaOnly/Standard98/CMakeLists.txt +++ b/Tests/CudaOnly/Standard98/CMakeLists.txt @@ -1,8 +1,6 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.18) project(CudaOnlyStandard98 CUDA) -set(CMAKE_CUDA_ARCHITECTURES 30) - # Support setting CUDA Standard to 98 which internally gets transformed to # CUDA03 set(CMAKE_CUDA_STANDARD 98) diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt b/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt index 708a352c6..534bab2c0 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.18) project(StaticRuntimePlusToolkit CUDA) #Goal for this example: diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index 0ed81d89d..02f043f36 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -1,9 +1,6 @@ +cmake_minimum_required(VERSION 3.18) +project(WithDefs CUDA) -cmake_minimum_required(VERSION 3.7) -project (WithDefs CUDA) - -#verify that we can pass explicit cuda arch flags -set(CMAKE_CUDA_ARCHITECTURES 30) set(release_compile_defs DEFREL) #Goal for this example: diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 53d56bf94..c1a7a5768 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -514,6 +514,14 @@ add_custom_target(UseConsoleTarget ALL USES_TERMINAL ) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + # Xcode's "new build system" does not support multiple targets + # producing the same custom command output. + add_custom_target(GenPath DEPENDS "${gen_path}") + add_dependencies(NormDepends GenPath) + add_dependencies(UseConsole GenPath) +endif() + # Test COMMAND_EXPAND_LISTS set(cmp_args "1ARG=COMMAND_EXPAND_LISTS" "2ARG=test" "3ARG=outfile" "4ARG=content") diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt index 8207dd166..09689cb42 100644 --- a/Tests/CxxOnly/CMakeLists.txt +++ b/Tests/CxxOnly/CMakeLists.txt @@ -1,4 +1,5 @@ # a simple CXX only test case +cmake_minimum_required(VERSION 2.8.12) project (CxxOnly CXX) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 387fe6b44..6d9b4ab4f 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -669,3 +669,18 @@ endif() # IMPORTED_LINK_INTERFACE_LANGUAGES entries should not be targets. add_library(C INTERFACE) add_library(CXX INTERFACE) + +#------------------------------------------------------------------------------ +# test export of targets built from sources named using $<CONFIG> generator-expression +# FIXME: Enable test on Xcode generator when it supports per-config sources. +if(NOT XCODE) + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Generated_$<CONFIG>.cpp" CONTENT "// content") + add_library(testStaticFromGeneratedSource STATIC) + target_sources(testStaticFromGeneratedSource PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/Generated_$<CONFIG>.cpp") + + add_library(testLibFromGeneratedSource SHARED empty.cpp) + target_link_libraries(testLibFromGeneratedSource PRIVATE testStaticFromGeneratedSource) + + install(TARGETS testLibFromGeneratedSource EXPORT testLibFromGeneratedSource_Export) + install(EXPORT testLibFromGeneratedSource_Export DESTINATION lib) +endif() diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index 43b721778..ba2164bc3 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -1,11 +1,26 @@ - -add_library(headeronly INTERFACE) +set(headeronly_headers headeronly/headeronly.h) +add_library(headeronly INTERFACE ${headeronly_headers}) set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headeronly>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/headeronly>" ) set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE") +add_custom_command(OUTPUT headergen/headergen.h + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/headergen.h.in + ${CMAKE_CURRENT_BINARY_DIR}/headergen/headergen.h + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/headergen.h.in + VERBATIM) + +add_library(headergen INTERFACE headergen/headergen.h) +set_property(TARGET headergen PROPERTY INTERFACE_INCLUDE_DIRECTORIES + "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/headergen>" +) +set_property(TARGET headergen PROPERTY PUBLIC_HEADER + ${CMAKE_CURRENT_BINARY_DIR}/headergen/headergen.h) + add_library(pch_iface INTERFACE) target_precompile_headers(pch_iface INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/pch/pch.h>" @@ -54,6 +69,11 @@ install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_targe pch_iface cmakeonly EXPORT expInterface ) +install(TARGETS headergen + EXPORT expInterface + PUBLIC_HEADER DESTINATION include/headergen + INCLUDES DESTINATION include/headergen +) install(TARGETS sharedlib EXPORT expInterface RUNTIME DESTINATION bin @@ -63,7 +83,7 @@ install(TARGETS sharedlib BUNDLE DESTINATION Applications ) install(FILES - headeronly/headeronly.h + ${headeronly_headers} DESTINATION include/headeronly ) install(FILES diff --git a/Tests/ExportImport/Export/Interface/headergen.h.in b/Tests/ExportImport/Export/Interface/headergen.h.in new file mode 100644 index 000000000..bda2b816f --- /dev/null +++ b/Tests/ExportImport/Export/Interface/headergen.h.in @@ -0,0 +1 @@ +#define HEADERGEN_H diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 189f7a2bc..a8a98fcb6 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -23,3 +23,6 @@ add_subdirectory(try_compile) # Test package INTERFACE controls add_subdirectory(Interface) + +# Test package version range +add_subdirectory(version_range) diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index ef666b1a7..202c23e21 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -12,6 +12,9 @@ set_property(TARGET define_iface PROPERTY add_executable(headeronlytest_bld headeronlytest.cpp) target_link_libraries(headeronlytest_bld bld::headeronly) +add_executable(headergentest_bld headergentest.cpp) +target_link_libraries(headergentest_bld bld::headergen) + set_property(TARGET bld::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface) add_executable(interfacetest_bld interfacetest.cpp) @@ -93,6 +96,9 @@ target_compile_definitions(source_target_test_exp PRIVATE USE_FROM_INSTALL_DIR) add_executable(headeronlytest_exp headeronlytest.cpp) target_link_libraries(headeronlytest_exp exp::headeronly) +add_executable(headergentest_exp headergentest.cpp) +target_link_libraries(headergentest_exp exp::headergen) + set_property(TARGET exp::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface) add_executable(interfacetest_exp interfacetest.cpp) diff --git a/Tests/ExportImport/Import/Interface/headergentest.cpp b/Tests/ExportImport/Import/Interface/headergentest.cpp new file mode 100644 index 000000000..88ff7f1b7 --- /dev/null +++ b/Tests/ExportImport/Import/Interface/headergentest.cpp @@ -0,0 +1,11 @@ + +#include "headergen.h" + +#ifndef HEADERGEN_H +# error Expected HEADERGEN_H +#endif + +int main() +{ + return 0; +} diff --git a/Tests/ExportImport/Import/version_range/CMakeLists.txt b/Tests/ExportImport/Import/version_range/CMakeLists.txt new file mode 100644 index 000000000..73b1d1ecc --- /dev/null +++ b/Tests/ExportImport/Import/version_range/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.18) + +find_package(testLibRequired 2.0...3.0) + +if (NOT testLibRequired_FOUND) + message(SEND_ERROR "version_range: fail to find package testLibRequired(2.5) with range 2.0...3.0") +endif() + + +find_package(testLibRequired 2.0...<2.5) + +if (testLibRequired_FOUND) + message(SEND_ERROR "version_range: package testLibRequired(2.5) unexpectedly found with range 2.0...<2.5") +endif() diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index c8850eaf2..29cdcc99e 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(ExternalProjectTest NONE) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + cmake_policy(SET CMP0114 NEW) +endif() include(ExternalProject) diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index 1075a9d07..789e4fb29 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/Tests/ExternalProjectLocal/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(ExternalProjectLocalTest NONE) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + cmake_policy(SET CMP0114 NEW) +endif() include(ExternalProject) diff --git a/Tests/ExternalProjectUpdate/CMakeLists.txt b/Tests/ExternalProjectUpdate/CMakeLists.txt index 9dddae207..563a6cf9f 100644 --- a/Tests/ExternalProjectUpdate/CMakeLists.txt +++ b/Tests/ExternalProjectUpdate/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 2.8) project(ExternalProjectUpdateTest NONE) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + cmake_policy(SET CMP0114 NEW) +endif() +cmake_policy(GET CMP0114 cmp0114) include(ExternalProject) @@ -18,8 +22,16 @@ set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER set(base "${CMAKE_BINARY_DIR}/CMakeExternals") set(binary_base "${base}/Build") set_property(DIRECTORY PROPERTY EP_BASE ${base}) -set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) -set_property(DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS update) +if(cmp0114 STREQUAL "NEW") + set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test update) + set(TestUpdateCommand_STEP_TARGETS STEP_TARGETS update) + set(TestUpdateCommand_INDEPENDENT_STEP_TARGETS) +else() + set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) + set_property(DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS update) + set(TestUpdateCommand_STEP_TARGETS) + set(TestUpdateCommand_INDEPENDENT_STEP_TARGETS INDEPENDENT_STEP_TARGETS update) +endif() ExternalProject_Add(TestUpdateCommand SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} @@ -28,7 +40,8 @@ ExternalProject_Add(TestUpdateCommand CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" - INDEPENDENT_STEP_TARGETS update + ${TestUpdateCommand_STEP_TARGETS} + ${TestUpdateCommand_INDEPENDENT_STEP_TARGETS} ) add_custom_target(TestUpdateCommandDriver ALL) add_dependencies(TestUpdateCommandDriver TestUpdateCommand-update) diff --git a/Tests/FindBLAS/Test/main.c b/Tests/FindBLAS/Test/main.c index 7360deec6..e61b02cbe 100644 --- a/Tests/FindBLAS/Test/main.c +++ b/Tests/FindBLAS/Test/main.c @@ -2,13 +2,15 @@ #include <string.h> // declare what parts of the blas C-API we need -void cblas_dswap(const int N, double* X, const int incX, double* Y, - const int incY); +void dswap_(int* N, double* X, int* incX, double* Y, int* incY); int main() { double x[4] = { 1, 2, 3, 4 }; double y[4] = { 8, 7, 7, 6 }; - cblas_dswap(4, x, 1, y, 1); + int N = 4; + int incX = 1; + int incY = 1; + dswap_(&N, x, &incX, y, &incY); return 0; } diff --git a/Tests/FindBoost/TestPython/CMakeLists.txt b/Tests/FindBoost/TestPython/CMakeLists.txt index 4d137ca0d..6d292cd39 100644 --- a/Tests/FindBoost/TestPython/CMakeLists.txt +++ b/Tests/FindBoost/TestPython/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.14) project(TestFindBoostPython CXX) include(CTest) -find_package(Boost OPTIONAL_COMPONENTS python27 python34 python35 python36 python37) +find_package(Boost OPTIONAL_COMPONENTS python27 python34 python35 python36 python37 python38 python39) set(FAILTEST TRUE) -foreach (v IN ITEMS 27 34 35 36 37) +foreach (v IN ITEMS 27 34 35 36 37 38 39) if (Boost_PYTHON${v}_FOUND) set(FAILTEST FALSE) break() diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 5ef67d031..af9fa9609 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -24,7 +24,7 @@ main.o: clean main.cpp pngtest: main.o @$(CMAKE_FOO) -DMODE=LINK >$(tmp) @foo="`cat $(tmp)`"; \ - printf '"%s" %s %s -o pngtest main.o %s\n' $(CMAKE_CXX_COMPILER) "$(CMAKE_CXX_FLAGS)" "$(LDFLAGS)" "$$foo" >$(tmp) + printf '"%s" %s %s %s -o pngtest main.o %s\n' $(CMAKE_CXX_COMPILER) "$(CMAKE_CXX_FLAGS)" "$(__EXTRA_OSX_SYSROOT_FLAGS)" "$(LDFLAGS)" "$$foo" >$(tmp) @cat $(tmp) @sh $(tmp) @rm -f $(tmp) diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index fdfa36ebd..44484c35e 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -243,6 +243,87 @@ if(CMake_TEST_FindPython) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + add_test(NAME FindPython.Python3.VersionRange.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VersionRange.LOCATION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 + -DPython3_FIND_STRATEGY=LOCATION + ) + add_test(NAME FindPython.Python3.VersionRange.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VersionRange.VERSION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 + -DPython3_FIND_STRATEGY=VERSION + ) + add_test(NAME FindPython.Python2.VersionRange.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VersionRange.LOCATION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_STRATEGY=LOCATION + ) + add_test(NAME FindPython.Python2.VersionRange.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VersionRange.VERSION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_STRATEGY=VERSION + ) + add_test(NAME FindPython.Python.V2.VersionRange.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VersionRange.LOCATION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=2 + -DPython_FIND_STRATEGY=LOCATION + ) + add_test(NAME FindPython.Python.V2.VersionRange.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VersionRange.VERSION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=2 + -DPython_FIND_STRATEGY=VERSION + ) + add_test(NAME FindPython.Python.V3.VersionRange.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.VersionRange.LOCATION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=3 + -DPython_FIND_STRATEGY=LOCATION + ) + add_test(NAME FindPython.Python.V3.VersionRange.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.VersionRange.VERSION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=3 + -DPython_FIND_STRATEGY=VERSION + ) + add_test(NAME FindPython.MultiplePackages COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -492,6 +573,29 @@ if(CMake_TEST_FindPython_IronPython) --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + add_test(NAME FindPython.IronPython2.VersionRange.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VersionRange.LOCATION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_IMPLEMENTATIONS=IronPython + -DPython2_FIND_STRATEGY=LOCATION + ) + add_test(NAME FindPython.IronPython2.VersionRange.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VersionRange.VERSION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_IMPLEMENTATIONS=IronPython + -DPython2_FIND_STRATEGY=VERSION + ) endif() if(CMake_TEST_FindPython_PyPy) diff --git a/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt index fed963e47..2164ac1ab 100644 --- a/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt +++ b/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(TestCustomFailureMessage.Check LANGUAGES C) +project(TestCustomFailureMessage.Check LANGUAGES NONE) find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS}) diff --git a/Tests/FindPython/ExactVersion/CMakeLists.txt b/Tests/FindPython/ExactVersion/CMakeLists.txt index e09f73a9d..60abb2620 100644 --- a/Tests/FindPython/ExactVersion/CMakeLists.txt +++ b/Tests/FindPython/ExactVersion/CMakeLists.txt @@ -1,16 +1,16 @@ cmake_minimum_required(VERSION 3.1) -project(TestExactVersion C) +project(TestExactVersion LANGUAGES C) find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development) -if (NOT Python${Python_MAJOR_VERSION}_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") +if(NOT Python${Python_MAJOR_VERSION}_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") endif() -if (NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Interpreter") +if(NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter") endif() -if (NOT Python${Python_MAJOR_VERSION}_Development_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Development") +if(NOT Python${Python_MAJOR_VERSION}_Development_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development") endif() if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter) @@ -26,22 +26,22 @@ endif() # reset artifacts and second search with exact version already founded -unset (Python${Python_MAJOR_VERSION}_EXECUTABLE) -unset (_Python${Python_MAJOR_VERSION}_EXECUTABLE CACHE) +unset(Python${Python_MAJOR_VERSION}_EXECUTABLE) +unset(_Python${Python_MAJOR_VERSION}_EXECUTABLE CACHE) -unset (_Python${Python_MAJOR_VERSION}_LIBRARY_RELEASE CACHE) -unset (_Python${Python_MAJOR_VERSION}_INCLUDE_DIR CACHE) +unset(_Python${Python_MAJOR_VERSION}_LIBRARY_RELEASE CACHE) +unset(_Python${Python_MAJOR_VERSION}_INCLUDE_DIR CACHE) -set (Python_REQUESTED_VERSION ${Python${Python_MAJOR_VERSION}_VERSION}) +set(Python_REQUESTED_VERSION ${Python${Python_MAJOR_VERSION}_VERSION}) find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter Development) -if (NOT Python${Python_MAJOR_VERSION}_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") +if(NOT Python${Python_MAJOR_VERSION}_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") endif() -if (NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Interpreter") +if(NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter") endif() -if (NOT Python${Python_MAJOR_VERSION}_Development_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Development") +if(NOT Python${Python_MAJOR_VERSION}_Development_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development") endif() if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter) diff --git a/Tests/FindPython/Implementation/CMakeLists.txt b/Tests/FindPython/Implementation/CMakeLists.txt index d64fa1edd..592329b8c 100644 --- a/Tests/FindPython/Implementation/CMakeLists.txt +++ b/Tests/FindPython/Implementation/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.1) -project(TestImplementation${Python_REQUESTED_IMPLEMENTATION} C) +project(TestImplementation${Python_REQUESTED_IMPLEMENTATION} LANGUAGES NONE) set (Python${Python_REQUESTED_VERSION}_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION}) find_package(Python${Python_REQUESTED_VERSION} COMPONENTS Interpreter) if (NOT Python${Python_REQUESTED_VERSION}_FOUND OR NOT Python${Python_REQUESTED_VERSION}_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python${Python_REQUESTED_VERSION}") + message (FATAL_ERROR "Failed to find Python${Python_REQUESTED_VERSION}") endif() if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython" @@ -24,7 +24,7 @@ set (Python_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION}) find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter) if (NOT Python_FOUND OR NOT Python_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") endif() if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython" diff --git a/Tests/FindPython/IronPython/CMakeLists.txt b/Tests/FindPython/IronPython/CMakeLists.txt index 3493c29bb..47ca022a9 100644 --- a/Tests/FindPython/IronPython/CMakeLists.txt +++ b/Tests/FindPython/IronPython/CMakeLists.txt @@ -1,23 +1,23 @@ cmake_minimum_required(VERSION 3.1) -project(TestIronPython C) +project(TestIronPython LANGUAGES NONE) set (Python_FIND_IMPLEMENTATIONS IronPython) find_package(Python ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Compiler) if (NOT Python_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") endif() if (NOT Python_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python Interpreter") + message (FATAL_ERROR "Failed to find Python Interpreter") endif() if (NOT Python_INTERPRETER_ID STREQUAL "IronPython") message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") endif() if (NOT Python_Compiler_FOUND) - message (FATAL_ERROR "Fail to found Python Compiler") + message (FATAL_ERROR "Failed to find Python Compiler") endif() if (NOT Python_COMPILER_ID STREQUAL "IronPython") message (FATAL_ERROR "Erroneous compiler ID (${Python_COMPILER_ID})") diff --git a/Tests/FindPython/IronPython2/CMakeLists.txt b/Tests/FindPython/IronPython2/CMakeLists.txt index 1db798cc2..fd9d94797 100644 --- a/Tests/FindPython/IronPython2/CMakeLists.txt +++ b/Tests/FindPython/IronPython2/CMakeLists.txt @@ -1,23 +1,23 @@ cmake_minimum_required(VERSION 3.1) -project(TestIronPython2 C) +project(TestIronPython2 LANGUAGES NONE) set (Python2_FIND_IMPLEMENTATIONS "IronPython") find_package(Python2 COMPONENTS Interpreter Compiler) if (NOT Python2_FOUND) - message (FATAL_ERROR "Fail to found Python 2") + message (FATAL_ERROR "Failed to find Python 2") endif() if (NOT Python2_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python 2 Interpreter") + message (FATAL_ERROR "Failed to find Python 2 Interpreter") endif() if (NOT Python2_INTERPRETER_ID STREQUAL "IronPython") message (FATAL_ERROR "Erroneous interpreter ID (${Python2_INTERPRETER_ID})") endif() if (NOT Python2_Compiler_FOUND) - message (FATAL_ERROR "Fail to found Python 2 Compiler") + message (FATAL_ERROR "Failed to find Python 2 Compiler") endif() if (NOT Python2_COMPILER_ID STREQUAL "IronPython") message (FATAL_ERROR "Erroneous compiler ID (${Python2_COMPILER_ID})") diff --git a/Tests/FindPython/NumPy/CMakeLists.txt b/Tests/FindPython/NumPy/CMakeLists.txt index f55702666..3e17f6895 100644 --- a/Tests/FindPython/NumPy/CMakeLists.txt +++ b/Tests/FindPython/NumPy/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1) -project(TestNumPy C) +project(TestNumPy LANGUAGES C) find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy) find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy) diff --git a/Tests/FindPython/NumPyOnly/CMakeLists.txt b/Tests/FindPython/NumPyOnly/CMakeLists.txt index a5db6037c..bedc627e0 100644 --- a/Tests/FindPython/NumPyOnly/CMakeLists.txt +++ b/Tests/FindPython/NumPyOnly/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1) -project(TestNumPyOnly C) +project(TestNumPyOnly LANGUAGES C) find_package(Python2 REQUIRED COMPONENTS NumPy) find_package(Python3 REQUIRED COMPONENTS NumPy) diff --git a/Tests/FindPython/PyPy/CMakeLists.txt b/Tests/FindPython/PyPy/CMakeLists.txt index b4ade8c92..4cf7c0ab7 100644 --- a/Tests/FindPython/PyPy/CMakeLists.txt +++ b/Tests/FindPython/PyPy/CMakeLists.txt @@ -1,29 +1,29 @@ cmake_minimum_required(VERSION 3.1) -project(TestPyPy C) +project(TestPyPy LANGUAGES C) set (Python_FIND_IMPLEMENTATIONS PyPy) find_package(Python ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development) if (NOT Python_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION}") + message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION}") endif() if (NOT Python_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy Interpreter") + message (FATAL_ERROR "Failed to find Python PyPy Interpreter") endif() if (NOT Python_INTERPRETER_ID STREQUAL "PyPy") message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") endif() if (NOT Python_Development.Module_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION} Development.Module") + message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development.Module") endif() if (NOT Python_Development.Embed_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION} Development.Embed") + message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development.Embed") endif() if (NOT Python_Development_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy ${Python_REQUESTED_VERSION} Development") + message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development") endif() if(NOT TARGET Python::Interpreter) diff --git a/Tests/FindPython/PyPy2/CMakeLists.txt b/Tests/FindPython/PyPy2/CMakeLists.txt index 2f0ddc9fe..ebfc9abd0 100644 --- a/Tests/FindPython/PyPy2/CMakeLists.txt +++ b/Tests/FindPython/PyPy2/CMakeLists.txt @@ -1,29 +1,29 @@ cmake_minimum_required(VERSION 3.1) -project(TestPyPy2 C) +project(TestPyPy2 LANGUAGES C) set (Python2_FIND_IMPLEMENTATIONS "PyPy") find_package(Python2 COMPONENTS Interpreter Development) if (NOT Python2_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 2") + message (FATAL_ERROR "Failed to find Python PyPy 2") endif() if (NOT Python2_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 2 Interpreter") + message (FATAL_ERROR "Failed to find Python PyPy 2 Interpreter") endif() if (NOT Python2_INTERPRETER_ID STREQUAL "PyPy") message (FATAL_ERROR "Erroneous interpreter ID (${Python2_INTERPRETER_ID})") endif() if (NOT Python2_Development.Module_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 2 Development.Module") + message (FATAL_ERROR "Failed to find Python PyPy 2 Development.Module") endif() if (NOT Python2_Development.Embed_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 2 Development.Embed") + message (FATAL_ERROR "Failed to find Python PyPy 2 Development.Embed") endif() if (NOT Python2_Development_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 2 Development") + message (FATAL_ERROR "Failed to find Python PyPy 2 Development") endif() if(NOT TARGET Python2::Interpreter) diff --git a/Tests/FindPython/PyPy3/CMakeLists.txt b/Tests/FindPython/PyPy3/CMakeLists.txt index 5562d5731..bf7cd61ae 100644 --- a/Tests/FindPython/PyPy3/CMakeLists.txt +++ b/Tests/FindPython/PyPy3/CMakeLists.txt @@ -1,29 +1,29 @@ cmake_minimum_required(VERSION 3.1) -project(TestPyPy3 C) +project(TestPyPy3 LANGUAGES C) set (Python3_FIND_IMPLEMENTATIONS "PyPy") find_package(Python3 COMPONENTS Interpreter Development) if (NOT Python3_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 3") + message (FATAL_ERROR "Failed to find Python PyPy 3") endif() if (NOT Python3_Interpreter_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 3 Interpreter") + message (FATAL_ERROR "Failed to find Python PyPy 3 Interpreter") endif() if (NOT Python3_INTERPRETER_ID STREQUAL "PyPy") message (FATAL_ERROR "Erroneous interpreter ID (${Python3_INTERPRETER_ID})") endif() if (NOT Python3_Development.Module_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 3 Development.Module") + message (FATAL_ERROR "Failed to find Python PyPy 3 Development.Module") endif() if (NOT Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 3 Development.Embed") + message (FATAL_ERROR "Failed to find Python PyPy 3 Development.Embed") endif() if (NOT Python3_Development_FOUND) - message (FATAL_ERROR "Fail to found Python PyPy 3 Development") + message (FATAL_ERROR "Failed to find Python PyPy 3 Development") endif() if(NOT TARGET Python3::Interpreter) diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt index e8828a2c1..9bec22f76 100644 --- a/Tests/FindPython/Python/CMakeLists.txt +++ b/Tests/FindPython/Python/CMakeLists.txt @@ -1,18 +1,18 @@ cmake_minimum_required(VERSION 3.1) -project(TestPython C) +project(TestPython LANGUAGES C) include(CTest) find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development) if (NOT Python_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") endif() if (NOT Python_Development.Module_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module'") + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module'") endif() if (NOT Python_Development.Embed_FOUND) - message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed'") + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed'") endif() if(NOT TARGET Python::Interpreter) diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt index 609d80f3f..39577b2a2 100644 --- a/Tests/FindPython/Python2/CMakeLists.txt +++ b/Tests/FindPython/Python2/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1) -project(TestPython2 C) +project(TestPython2 LANGUAGES C) include(CTest) @@ -11,16 +11,16 @@ endif() find_package(Python2 REQUIRED COMPONENTS Interpreter Development) if (NOT Python2_FOUND) - message (FATAL_ERROR "Fail to found Python 2") + message (FATAL_ERROR "Failed to find Python 2") endif() if (NOT Python2_Development_FOUND) - message (FATAL_ERROR "Fail to found Python 2 'Development' component") + message (FATAL_ERROR "Failed to find Python 2 'Development' component") endif() if (NOT Python2_Development.Module_FOUND) - message (FATAL_ERROR "Fail to found Python 2 'Development.Module' component") + message (FATAL_ERROR "Failed to find Python 2 'Development.Module' component") endif() if (NOT Python2_Development.Embed_FOUND) - message (FATAL_ERROR "Fail to found Python 2 'Development.Embed' component") + message (FATAL_ERROR "Failed to find Python 2 'Development.Embed' component") endif() if(NOT TARGET Python2::Interpreter) diff --git a/Tests/FindPython/Python2Embedded/CMakeLists.txt b/Tests/FindPython/Python2Embedded/CMakeLists.txt index 1cf6034d5..a1036ce74 100644 --- a/Tests/FindPython/Python2Embedded/CMakeLists.txt +++ b/Tests/FindPython/Python2Embedded/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.1) -project(TestPython2Embedded C) +project(TestPython2Embedded LANGUAGES C) include(CTest) find_package(Python2 REQUIRED COMPONENTS Development.Embed) if (NOT Python2_FOUND) - message (FATAL_ERROR "Fail to found Python 2") + message (FATAL_ERROR "Failed to find Python 2") endif() if (Python2_Development_FOUND) message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found") diff --git a/Tests/FindPython/Python2Module/CMakeLists.txt b/Tests/FindPython/Python2Module/CMakeLists.txt index 0bc3390ce..c9d46ac62 100644 --- a/Tests/FindPython/Python2Module/CMakeLists.txt +++ b/Tests/FindPython/Python2Module/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.1) -project(TestPython2Module C) +project(TestPython2Module LANGUAGES C) include(CTest) find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module) if (NOT Python2_FOUND) - message (FATAL_ERROR "Fail to found Python 2") + message (FATAL_ERROR "Failed to find Python 2") endif() if (Python2_Development_FOUND) message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found") diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt index d6e5fdb2f..e40557dfc 100644 --- a/Tests/FindPython/Python3/CMakeLists.txt +++ b/Tests/FindPython/Python3/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1) -project(TestPython3 C) +project(TestPython3 LANGUAGES C) include(CTest) @@ -11,16 +11,16 @@ endif() find_package(Python3 REQUIRED COMPONENTS Interpreter Development) if (NOT Python3_FOUND) - message (FATAL_ERROR "Fail to found Python 3") + message (FATAL_ERROR "Failed to find Python 3") endif() if (NOT Python3_Development_FOUND) - message (FATAL_ERROR "Fail to found Python 3 'Development' component") + message (FATAL_ERROR "Failed to find Python 3 'Development' component") endif() if (NOT Python3_Development.Module_FOUND) - message (FATAL_ERROR "Fail to found Python 3 'Development.Module' component") + message (FATAL_ERROR "Failed to find Python 3 'Development.Module' component") endif() if (NOT Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Fail to found Python 3 'Development.Embed' component") + message (FATAL_ERROR "Failed to find Python 3 'Development.Embed' component") endif() if(NOT TARGET Python3::Interpreter) diff --git a/Tests/FindPython/Python3Embedded/CMakeLists.txt b/Tests/FindPython/Python3Embedded/CMakeLists.txt index 184c0b453..c45bd8c83 100644 --- a/Tests/FindPython/Python3Embedded/CMakeLists.txt +++ b/Tests/FindPython/Python3Embedded/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.1) -project(TestPython3Embedded C) +project(TestPython3Embedded LANGUAGES C) include(CTest) find_package(Python3 REQUIRED COMPONENTS Development.Embed) if (NOT Python3_FOUND) - message (FATAL_ERROR "Fail to found Python 3") + message (FATAL_ERROR "Failed to find Python 3") endif() if (Python3_Development_FOUND) message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") diff --git a/Tests/FindPython/Python3Module/CMakeLists.txt b/Tests/FindPython/Python3Module/CMakeLists.txt index 676f4c89d..5945962b9 100644 --- a/Tests/FindPython/Python3Module/CMakeLists.txt +++ b/Tests/FindPython/Python3Module/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.1) -project(TestPython3Module C) +project(TestPython3Module LANGUAGES C) include(CTest) find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) if (NOT Python3_FOUND) - message (FATAL_ERROR "Fail to found Python 3") + message (FATAL_ERROR "Failed to find Python 3") endif() if (Python3_Development_FOUND) message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") diff --git a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt index 39e8ea562..ae50f32c9 100644 --- a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt +++ b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt @@ -6,11 +6,11 @@ include(CTest) find_package(Python2 REQUIRED COMPONENTS Interpreter Development) if (NOT Python2_FOUND) - message (FATAL_ERROR "Fail to found Python 2") + message (FATAL_ERROR "Failed to find Python 2") endif() find_package(Python3 REQUIRED COMPONENTS Interpreter Development) if (NOT Python3_FOUND) - message (FATAL_ERROR "Fail to found Python 3") + message (FATAL_ERROR "Failed to find Python 3") endif() diff --git a/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt index b859ac57f..287cfdbb5 100644 --- a/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt +++ b/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt @@ -29,13 +29,13 @@ endif() if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter) - message (FATAL_ERROR "Fail to use input variable Python3_EXECUTABLE") + message (FATAL_ERROR "Failed to use input variable Python3_EXECUTABLE") endif() if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library) - message (FATAL_ERROR "Fail to use input variable Python3_LIBRARY") + message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY") endif() if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include) - message (FATAL_ERROR "Fail to use input variable Python3_INCLUDE_DIR") + message (FATAL_ERROR "Failed to use input variable Python3_INCLUDE_DIR") endif() diff --git a/Tests/FindPython/SOABI/CMakeLists.txt b/Tests/FindPython/SOABI/CMakeLists.txt index 36daa9f81..84f736243 100644 --- a/Tests/FindPython/SOABI/CMakeLists.txt +++ b/Tests/FindPython/SOABI/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(TestSOABI C) +project(TestSOABI LANGUAGES C) find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) if (NOT Python3_FOUND) - message (FATAL_ERROR "Fail to found Python 3") + message (FATAL_ERROR "Failed to find Python 3") endif() if(NOT DEFINED Python3_SOABI) diff --git a/Tests/FindPython/VersionRange/CMakeLists.txt b/Tests/FindPython/VersionRange/CMakeLists.txt new file mode 100644 index 000000000..957941d47 --- /dev/null +++ b/Tests/FindPython/VersionRange/CMakeLists.txt @@ -0,0 +1,64 @@ +cmake_minimum_required (VERSION 3.18...3.19) + +project (TestVersionRange LANGUAGES C) + + +find_package (${Python} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter) +if (NOT ${Python}_FOUND) + message (FATAL_ERROR "Failed to find ${Python} ${Python_REQUESTED_VERSION}") +endif() + +if (Python_REQUESTED_VERSION VERSION_LESS 3.0) + set (IN_VERSION_RANGE 2.0...<3.0) + set (OUT_VERSION_RANGE 2.0...<${${Python}_VERSION}) +else() + set (IN_VERSION_RANGE 3.0...<4.0) + set (OUT_VERSION_RANGE 3.0...<${${Python}_VERSION}) +endif() + +function (FIND_PYTHON EXPECTED_VERSION RANGE) + macro (FIND_PYTHON_PACKAGE) + unset (_${Python}_EXECUTABLE CACHE) + unset (_${Python}_LIBRARY_RELEASE CACHE) + unset (_${Python}_INCLUDE_DIR CACHE) + unset (${Python}_FOUND) + + find_package (${Python} ${ARGV}) + endmacro() + + find_python_package(${RANGE} ${ARGN}) + + if (EXPECTED_VERSION STREQUAL "NONE") + while (${Python}_FOUND AND ${Python}_VERSION VERSION_GREATER ${Python_REQUESTED_VERSION}) + # Possible if multiple versions are installed + # Try with a different range + find_python_package(${Python_REQUESTED_VERSION}.0...<${${Python}_VERSION} ${ARGN}) + endwhile() + if (${Python}_FOUND) + message (SEND_ERROR "Unexpectedly found version: ${${Python}_VERSION} for '${Python} ${Python_REQUESTED_VERSION}.0...<${${Python}_VERSION} ${ARGN}'") + endif() + return() + endif() + + if (NOT ${Python}_FOUND) + message (SEND_ERROR "Not found: ${Python} ${RANGE} ${ARGN}") + elseif (NOT ${Python}_VERSION VERSION_EQUAL EXPECTED_VERSION) + message (SEND_ERROR "Wrong version: ${${Python}_VERSION} for '${Python} ${RANGE} ${ARGN}'") + endif() +endfunction() + +find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Interpreter) +if (${Python}_FIND_IMPLEMENTATIONS STREQUAL "IronPython") + find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Compiler) +else() + find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Development) +endif() + +find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Interpreter) +if (${Python}_FIND_IMPLEMENTATIONS STREQUAL "IronPython") + find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Compiler) +else() + find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Development) +endif() + +find_python ("NONE" 5...6 COMPONENTS Interpreter) diff --git a/Tests/FindPython/VirtualEnv/CMakeLists.txt b/Tests/FindPython/VirtualEnv/CMakeLists.txt index 045a3f243..dae328269 100644 --- a/Tests/FindPython/VirtualEnv/CMakeLists.txt +++ b/Tests/FindPython/VirtualEnv/CMakeLists.txt @@ -6,7 +6,7 @@ include(CTest) find_package(Python3 REQUIRED COMPONENTS Interpreter) if (NOT Python3_FOUND) - message (FATAL_ERROR "Fail to found Python 3") + message (FATAL_ERROR "Failed to find Python 3") endif() set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/py3venv") diff --git a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt index 565095a88..23d208d4c 100644 --- a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt +++ b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt @@ -6,7 +6,7 @@ include(CTest) find_program(CONDA_EXECUTABLE conda) if (CONDA_EXECUTABLE EQUAL NOTFOUND) - message (FATAL_ERROR "Fail to found Conda") + message (FATAL_ERROR "Failed to find Conda") endif() set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/condaenv") diff --git a/Tests/FindRuby/CMakeLists.txt b/Tests/FindRuby/CMakeLists.txt index 3f4807c53..ee589234d 100644 --- a/Tests/FindRuby/CMakeLists.txt +++ b/Tests/FindRuby/CMakeLists.txt @@ -24,7 +24,7 @@ if(CMake_TEST_FindRuby) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) set_tests_properties(FindRuby.Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Ruby.*(Required is at least version \"[0-9]+\\.[0-9]+\\.[0-9]+\")") + PASS_REGULAR_EXPRESSION "Could NOT find Ruby.*(Required[ \n]+is[ \n]+at[ \n]+least[ \n]+version[ \n]*\"[0-9]+\\.[0-9]+\\.[0-9]+\")") # Looks for 1.9.9 EXACTLY, which unlike the "FindRuby" test above will fail on every machine # since this version doesn't exist (ruby goes from 1.9.3 to 2.0.0) diff --git a/Tests/FindRuby/Rvm/CMakeLists.txt b/Tests/FindRuby/Rvm/CMakeLists.txt index 545fc9480..14bdbec83 100644 --- a/Tests/FindRuby/Rvm/CMakeLists.txt +++ b/Tests/FindRuby/Rvm/CMakeLists.txt @@ -23,7 +23,7 @@ if (result) message (FATAL_ERROR "Unable to detect RVM ruby version from `${MY_RUBY_HOME}/bin/ruby`: ${RVM_RUBY_VERSION}") endif() -execute_process(COMMAND "${CMAKE_COMMAND}" -E env --unset=MY_RUBY_HOME --unset=PATH +execute_process(COMMAND "${CMAKE_COMMAND}" -E env --unset=MY_RUBY_HOME PATH=/usr/bin:/bin "which" "ruby" RESULT_VARIABLE result OUTPUT_VARIABLE SYSTEM_RUBY diff --git a/Tests/FindSDL/CMakeLists.txt b/Tests/FindSDL/CMakeLists.txt new file mode 100644 index 000000000..e786204dd --- /dev/null +++ b/Tests/FindSDL/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindSDL.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindSDL/Test" + "${CMake_BINARY_DIR}/Tests/FindSDL/Test" + ${build_generator_args} + --build-project TestFindSDL + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindSDL/Test/CMakeLists.txt b/Tests/FindSDL/Test/CMakeLists.txt new file mode 100644 index 000000000..61d4f4b33 --- /dev/null +++ b/Tests/FindSDL/Test/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindSDL C) +include(CTest) + +find_package(SDL) + +add_definitions( + -DCMAKE_EXPECTED_SDL_VERSION_MAJOR=${SDL_VERSION_MAJOR} + -DCMAKE_EXPECTED_SDL_VERSION_MINOR=${SDL_VERSION_MINOR} + -DCMAKE_EXPECTED_SDL_VERSION_PATCH=${SDL_VERSION_PATCH}) + +add_executable(test_sdl_tgt main.c) +target_link_libraries(test_sdl_tgt SDL::SDL) +add_test(NAME test_sdl_tgt COMMAND test_sdl_tgt) + +add_executable(test_sdl_var main.c) +target_include_directories(test_sdl_var PRIVATE ${SDL_INCLUDE_DIRS}) +target_link_libraries(test_sdl_var PRIVATE ${SDL_LIBRARIES}) +add_test(NAME test_sdl_var COMMAND test_sdl_var) diff --git a/Tests/FindSDL/Test/main.c b/Tests/FindSDL/Test/main.c new file mode 100644 index 000000000..057289ceb --- /dev/null +++ b/Tests/FindSDL/Test/main.c @@ -0,0 +1,18 @@ +#include <SDL.h> + +int main() +{ + // Test 1 requires headers only. + SDL_version compiled; + SDL_VERSION(&compiled); + if (compiled.major != CMAKE_EXPECTED_SDL_VERSION_MAJOR || + compiled.minor != CMAKE_EXPECTED_SDL_VERSION_MINOR || + compiled.patch != CMAKE_EXPECTED_SDL_VERSION_PATCH) + return 1; + + // Test 2 requires to link to the library. + if (SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) + return 2; + + return 0; +} diff --git a/Tests/FindTIFF/Test/CMakeLists.txt b/Tests/FindTIFF/Test/CMakeLists.txt index 85453edbc..e235db369 100644 --- a/Tests/FindTIFF/Test/CMakeLists.txt +++ b/Tests/FindTIFF/Test/CMakeLists.txt @@ -1,14 +1,23 @@ cmake_minimum_required(VERSION 3.1) -project(TestFindTIFF C) +project(TestFindTIFF) include(CTest) -find_package(TIFF REQUIRED) +find_package(TIFF REQUIRED COMPONENTS CXX) add_executable(test_tiff_tgt main.c) target_link_libraries(test_tiff_tgt TIFF::TIFF) add_test(NAME test_tiff_tgt COMMAND test_tiff_tgt) +add_executable(test_tiffxx_tgt main.cxx) +target_link_libraries(test_tiffxx_tgt TIFF::CXX) +add_test(NAME test_tiffxx_tgt COMMAND test_tiffxx_tgt) + add_executable(test_tiff_var main.c) target_include_directories(test_tiff_var PRIVATE ${TIFF_INCLUDE_DIRS}) target_link_libraries(test_tiff_var PRIVATE ${TIFF_LIBRARIES}) add_test(NAME test_tiff_var COMMAND test_tiff_var) + +add_executable(test_tiffxx_var main.cxx) +target_include_directories(test_tiffxx_var PRIVATE ${TIFF_INCLUDE_DIRS}) +target_link_libraries(test_tiffxx_var PRIVATE ${TIFF_LIBRARIES}) +add_test(NAME test_tiffxx_var COMMAND test_tiffxx_var) diff --git a/Tests/FindTIFF/Test/main.cxx b/Tests/FindTIFF/Test/main.cxx new file mode 100644 index 000000000..f80a31f1b --- /dev/null +++ b/Tests/FindTIFF/Test/main.cxx @@ -0,0 +1,16 @@ +#include <fstream> + +#include <assert.h> +#include <tiffio.hxx> + +int main() +{ + /* Without any TIFF file to open, test that the call fails as + expected. This tests that linking worked. */ + TIFF* tiff = TIFFOpen("invalid.tiff", "r"); + assert(!tiff); + + std::ifstream s; + TIFF* tiffxx = TIFFStreamOpen("invalid.tiff", &s); + return 0; +} diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt index 0b13d5320..9d36a0da3 100644 --- a/Tests/FindVulkan/Test/CMakeLists.txt +++ b/Tests/FindVulkan/Test/CMakeLists.txt @@ -13,3 +13,12 @@ add_executable(test_var main.c) target_include_directories(test_var PRIVATE ${Vulkan_INCLUDE_DIRS}) target_link_libraries(test_var PRIVATE ${Vulkan_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +if(Vulkan_GLSLC_EXECUTABLE) + add_test(NAME test_glslc + COMMAND ${CMAKE_COMMAND} + "-DVULKAN_GLSLC_EXECUTABLE=${Vulkan_GLSLC_EXECUTABLE}" + "-DVULKAN_GLSLC_EXECUTABLE_TARGET=$<TARGET_FILE:Vulkan::glslc>" + -P "${CMAKE_CURRENT_LIST_DIR}/Run-glslc.cmake" + ) +endif() diff --git a/Tests/FindVulkan/Test/Run-glslc.cmake b/Tests/FindVulkan/Test/Run-glslc.cmake new file mode 100644 index 000000000..086eb9d0f --- /dev/null +++ b/Tests/FindVulkan/Test/Run-glslc.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.12) + +function(run_glslc exe exe_display) + execute_process(COMMAND ${exe} --help + OUTPUT_VARIABLE output + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE result + ) + + if(NOT result EQUAL 0) + message(SEND_ERROR "Result of ${exe_display} --help is ${result}, should be 0") + endif() + + if(NOT output MATCHES "^glslc - Compile shaders into SPIR-V") + message(SEND_ERROR "Output of ${exe_display} --help is \"${output}\", should begin with \"glslc - Compile shaders into SPIR-V\"") + endif() +endfunction() + +run_glslc("${VULKAN_GLSLC_EXECUTABLE}" "\${VULKAN_GLSLC_EXECUTABLE}") +run_glslc("${VULKAN_GLSLC_EXECUTABLE_TARGET}" "Vulkan::glslc") diff --git a/Tests/FindVulkan/Test/main.c b/Tests/FindVulkan/Test/main.c index b29c9ec9e..1bff6510e 100644 --- a/Tests/FindVulkan/Test/main.c +++ b/Tests/FindVulkan/Test/main.c @@ -2,10 +2,10 @@ int main() { - VkInstanceCreateInfo instanceCreateInfo = {}; + VkInstanceCreateInfo instanceCreateInfo = { 0 }; instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - VkApplicationInfo applicationInfo = {}; + VkApplicationInfo applicationInfo = { 0 }; applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; applicationInfo.apiVersion = VK_API_VERSION_1_0; applicationInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); diff --git a/Tests/FindX11/Test/CMakeLists.txt b/Tests/FindX11/Test/CMakeLists.txt index b2adfb2bc..5b304d9d5 100644 --- a/Tests/FindX11/Test/CMakeLists.txt +++ b/Tests/FindX11/Test/CMakeLists.txt @@ -29,9 +29,12 @@ test_x11_component(x11_components SM) set(X11_X11_FOUND ${X11_FOUND}) test_x11_component(x11_components X11) test_x11_component(x11_components Xau) +test_x11_component(x11_components Xaw) test_x11_component(x11_components xcb) test_x11_component(x11_components X11_xcb) test_x11_component(x11_components xcb_icccm) +test_x11_component(x11_components xcb_util) +test_x11_component(x11_components xcb_xfixes) test_x11_component(x11_components xcb_xkb) test_x11_component(x11_components Xcomposite) test_x11_component(x11_components Xdamage) @@ -67,9 +70,12 @@ target_link_libraries(test_var PRIVATE ${X11_LIBRARIES}) # Not included in X11_LIBRARIES. foreach(lib Xau + Xaw xcb X11_xcb xcb_icccm + xcb_util + xcb_xfixes Xcomposite Xdamage Xdmcp diff --git a/Tests/FindX11/Test/main.c b/Tests/FindX11/Test/main.c index c8144e09c..b44ae2834 100644 --- a/Tests/FindX11/Test/main.c +++ b/Tests/FindX11/Test/main.c @@ -308,6 +308,62 @@ static int test_Xv(void) } #endif +#ifdef HAVE_X11_Xaw +# include <X11/Intrinsic.h> +# include <X11/Xaw/Box.h> + +static void test_Xaw(void) +{ + XrmOptionDescRec opt_table[] = { { NULL } }; + + Widget toplevel; + toplevel = + XtInitialize("test", "test", opt_table, XtNumber(opt_table), NULL, NULL); + Widget box = + XtCreateManagedWidget("testbox", boxWidgetClass, toplevel, NULL, 0); + return; +} + +#endif + +#ifdef HAVE_xcb +# include <xcb/xcb.h> + +static void test_xcb(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_disconnect(connection); +} + +# ifdef HAVE_xcb_util +# include <xcb/xcb_aux.h> + +static void test_xcb_util(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_screen_t* screen = xcb_aux_get_screen(connection, screen_nbr); + xcb_disconnect(connection); +} + +# endif + +# ifdef HAVE_xcb_xfixes +# include <xcb/xcb_xfixes.h> + +static void test_xcb_xfixes(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_xfixes_query_version(connection, 1, 0); + xcb_disconnect(connection); +} + +# endif + +#endif + #include <stddef.h> int main(int argc, char* argv[]) @@ -392,6 +448,19 @@ int main(int argc, char* argv[]) #ifdef HAVE_X11_Xv test_Xv, #endif +#ifdef HAVE_X11_Xaw + test_Xaw, +#endif +#ifdef HAVE_xcb + test_xcb, +#endif +#ifdef HAVE_xcb_util + test_xcb_util, +#endif +#ifdef HAVE_xcb_xfixes + test_xcb_xfixes, +#endif + NULL, }; diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index d24df2df8..637f5816a 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(FortranOnly Fortran) message("CTEST_FULL_OUTPUT ") diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 9d5134203..ebbe28873 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -40,9 +40,9 @@ add_custom_target(check-part1 ALL -Dtest_and_0_invalidcontent=$<AND:0,invalidcontent> -Dtest_config_0=$<CONFIG:$<CONFIGURATION>x> -Dtest_config_1=$<CONFIG:$<CONFIGURATION>> - -Dtest_config_debug=$<CONFIG:Debug>$<CONFIG:DEBUG>$<CONFIG:DeBuG> - -Dtest_config_release=$<CONFIG:Release>$<CONFIG:RELEASE>$<CONFIG:ReLeAsE> - -Dtest_config_relwithdebinfo=$<CONFIG:RelWithDebInfo>$<CONFIG:RELWITHDEBINFO>$<CONFIG:relwithdebinfo> + -Dtest_config_debug=$<CONFIG:Debug,DEBUG,DeBuG> + -Dtest_config_release=$<CONFIG:Release>$<CONFIG:RELEASE,ReLeAsE> + -Dtest_config_relwithdebinfo=$<CONFIG:RelWithDebInfo,RELWITHDEBINFO>$<CONFIG:relwithdebinfo> -Dtest_config_minsizerel=$<CONFIG:MinSizeRel>$<CONFIG:MINSIZEREL>$<CONFIG:minsizerel> -Dtest_not_0=$<NOT:0> -Dtest_not_1=$<NOT:1> @@ -180,9 +180,7 @@ set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) set_property(TARGET imported3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:DEBUG>:$<TARGET_PROPERTY:imported1,INTERFACE_INCLUDE_DIRECTORIES>>) set_property(TARGET imported3 APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELEASE>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) -set_property(TARGET imported3 APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELWITHDEBINFO>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) + INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELEASE,RELWITHDEBINFO>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) set_property(TARGET imported3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:MINSIZEREL>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 4fb730887..5571c3d6a 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -9,11 +9,11 @@ check(test_version_equal_1 "0") check(test_version_equal_2 "1") if(config AND NOT config STREQUAL NoConfig) - if(NOT "${test_imported_includes}" MATCHES "^;*/imported[12]/include/with space;*$") + if(NOT "${test_imported_includes}" MATCHES "^[^;]*/imported[12]/include/with space$") message(SEND_ERROR "test_imported_includes is not correct: ${test_imported_includes}") endif() else() - if(NOT "${test_imported_includes}" MATCHES "^;;;$") + if(NOT "${test_imported_includes}" MATCHES "^$") message(SEND_ERROR "test_imported_includes is not an empty list: ${test_imported_includes}") endif() endif() diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/standard.h b/Tests/GhsMulti/GhsMultiSrcGroups/standard.h index 2773a5511..66522d5c8 100644 --- a/Tests/GhsMulti/GhsMultiSrcGroups/standard.h +++ b/Tests/GhsMulti/GhsMultiSrcGroups/standard.h @@ -1 +1 @@ -#define somthing +#define something diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test3.h b/Tests/GhsMulti/GhsMultiSrcGroups/test3.h index 2773a5511..66522d5c8 100644 --- a/Tests/GhsMulti/GhsMultiSrcGroups/test3.h +++ b/Tests/GhsMulti/GhsMultiSrcGroups/test3.h @@ -1 +1 @@ -#define somthing +#define something diff --git a/Tests/ISPC/CMakeLists.txt b/Tests/ISPC/CMakeLists.txt new file mode 100644 index 000000000..c13271a81 --- /dev/null +++ b/Tests/ISPC/CMakeLists.txt @@ -0,0 +1,16 @@ + + +macro (add_ispc_test_macro name) + add_test_macro("${name}" ${ARGN}) + set_property(TEST "${name}" APPEND + PROPERTY LABELS "ISPC") +endmacro () + +add_ispc_test_macro(ISPC.ChainedStaticLibraries ISPCChainedStaticLibraries) +add_ispc_test_macro(ISPC.Defines ISPCDefines) +add_ispc_test_macro(ISPC.DynamicLibrary ISPCDynamicLibrary) +add_ispc_test_macro(ISPC.ObjectGenex ISPCObjectGenex) +add_ispc_test_macro(ISPC.ObjectLibrary ISPCObjectLibrary) +add_ispc_test_macro(ISPC.ResponseAndDefine ISPCResponseAndDefine) +add_ispc_test_macro(ISPC.StaticLibrary ISPCStaticLibrary) +add_ispc_test_macro(ISPC.TryCompile ISPCTryCompile) diff --git a/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt b/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt new file mode 100644 index 000000000..9a255a0b8 --- /dev/null +++ b/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCChainedStaticLibraries CXX ISPC) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + + +add_library(ispc_objects1 STATIC extra.ispc extra.cxx) +add_library(ispc_objects2 STATIC simple.ispc) + +set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") + +set_target_properties(ispc_objects2 PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4") + +target_link_libraries(ispc_objects2 PRIVATE ispc_objects1) + +add_executable(ISPCChainedStaticLibraries main.cxx) +target_link_libraries(ISPCChainedStaticLibraries PUBLIC ispc_objects2) diff --git a/Tests/ISPC/ChainedStaticLibraries/extra.cxx b/Tests/ISPC/ChainedStaticLibraries/extra.cxx new file mode 100644 index 000000000..88ef3a795 --- /dev/null +++ b/Tests/ISPC/ChainedStaticLibraries/extra.cxx @@ -0,0 +1,17 @@ +#include <stdio.h> + +#include "extra.ispc.h" + +int extra() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::extra(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/ISPC/ChainedStaticLibraries/extra.ispc b/Tests/ISPC/ChainedStaticLibraries/extra.ispc new file mode 100644 index 000000000..5a4a44249 --- /dev/null +++ b/Tests/ISPC/ChainedStaticLibraries/extra.ispc @@ -0,0 +1,12 @@ + +export void extra(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ChainedStaticLibraries/main.cxx b/Tests/ISPC/ChainedStaticLibraries/main.cxx new file mode 100644 index 000000000..4f1c9be3d --- /dev/null +++ b/Tests/ISPC/ChainedStaticLibraries/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/ChainedStaticLibraries/simple.ispc b/Tests/ISPC/ChainedStaticLibraries/simple.ispc new file mode 100644 index 000000000..70cb58885 --- /dev/null +++ b/Tests/ISPC/ChainedStaticLibraries/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/Defines/CMakeLists.txt b/Tests/ISPC/Defines/CMakeLists.txt new file mode 100644 index 000000000..764580458 --- /dev/null +++ b/Tests/ISPC/Defines/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.18) +project(ISPCDefines CXX ISPC) + +set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4;avx512knl-i32x16;avx512skx-i32x8") +set(CMAKE_ISPC_FLAGS -DM_PI=3.1415926535f) +add_compile_definitions([==[STRUCT_DEFINE=struct{uniform int a]==]) + +add_executable(ISPCDefines + main.cxx + simple.ispc + ) + +set_target_properties(ISPCDefines PROPERTIES POSITION_INDEPENDENT_CODE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set_source_files_properties(simple.ispc PROPERTIES COMPILE_OPTIONS "--arch=x86") +endif() diff --git a/Tests/ISPC/Defines/main.cxx b/Tests/ISPC/Defines/main.cxx new file mode 100644 index 000000000..4f1c9be3d --- /dev/null +++ b/Tests/ISPC/Defines/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/Defines/simple.ispc b/Tests/ISPC/Defines/simple.ispc new file mode 100644 index 000000000..d8d64656a --- /dev/null +++ b/Tests/ISPC/Defines/simple.ispc @@ -0,0 +1,15 @@ + +//textual error if STRUCT_DEFINE not set +STRUCT_DEFINE;}; + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < M_PI) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/DynamicLibrary/CMakeLists.txt b/Tests/ISPC/DynamicLibrary/CMakeLists.txt new file mode 100644 index 000000000..465509031 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/CMakeLists.txt @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCDynamicLibrary CXX ISPC) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + + +add_library(ispc_objects1 STATIC extra.ispc extra.cxx) +add_library(ispc_objects2 SHARED simple.ispc) +target_sources(ispc_objects2 PRIVATE simple.cxx) + +set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON) + +set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") +set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4") + +target_link_libraries(ispc_objects2 PUBLIC ispc_objects1) + +add_executable(ISPCDynamicLibrary main.cxx) +target_link_libraries(ISPCDynamicLibrary PUBLIC ispc_objects2) diff --git a/Tests/ISPC/DynamicLibrary/extra.cxx b/Tests/ISPC/DynamicLibrary/extra.cxx new file mode 100644 index 000000000..b3623d15b --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/extra.cxx @@ -0,0 +1,23 @@ +#include <stdio.h> + +#include "extra.ispc.h" + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +EXPORT int extra() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::extra(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/ISPC/DynamicLibrary/extra.ispc b/Tests/ISPC/DynamicLibrary/extra.ispc new file mode 100644 index 000000000..5a4a44249 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/extra.ispc @@ -0,0 +1,12 @@ + +export void extra(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/DynamicLibrary/main.cxx b/Tests/ISPC/DynamicLibrary/main.cxx new file mode 100644 index 000000000..f9072c74a --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/main.cxx @@ -0,0 +1,17 @@ + + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +#else +# define IMPORT +#endif + +IMPORT int simple(); +int extra(); + +int main() +{ + extra(); + simple(); + return 0; +} diff --git a/Tests/ISPC/DynamicLibrary/shim.cxx b/Tests/ISPC/DynamicLibrary/shim.cxx new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/shim.cxx diff --git a/Tests/ISPC/DynamicLibrary/simple.cxx b/Tests/ISPC/DynamicLibrary/simple.cxx new file mode 100644 index 000000000..cb5a779e3 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/simple.cxx @@ -0,0 +1,23 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +EXPORT int simple() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/ISPC/DynamicLibrary/simple.ispc b/Tests/ISPC/DynamicLibrary/simple.ispc new file mode 100644 index 000000000..70cb58885 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ObjectGenex/CMakeLists.txt b/Tests/ISPC/ObjectGenex/CMakeLists.txt new file mode 100644 index 000000000..bc0cbf6fc --- /dev/null +++ b/Tests/ISPC/ObjectGenex/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.18) +project(ISPCObjectGenex CXX ISPC) + +set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4;avx512knl-i32x16;avx512skx-i32x8") + +add_library(ispc_objects OBJECT + simple.ispc + ) +target_compile_definitions(ispc_objects PRIVATE + $<$<COMPILE_LANG_AND_ID:ISPC,Intel>:M_PI=3.1415926535f> +) +set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set_source_files_properties(simple.ispc PROPERTIES COMPILE_OPTIONS "--arch=x86") +endif() + + +#Test ObjectFiles with file(GENERATE) +file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gen_$<LOWER_CASE:$<CONFIG>/>path_to_objs.h + CONTENT [[ +#ifndef path_to_objs +#define path_to_objs + +#include <string> + +static std::string obj_paths = "$<TARGET_OBJECTS:ispc_objects>"; + +#endif + +]] +) + + +add_executable(ISPCObjectGenex main.cxx) +add_dependencies(ISPCObjectGenex ispc_objects) + +list(LENGTH CMAKE_ISPC_INSTRUCTION_SETS numberOfTargets) +math(EXPR numberOfTargets "${numberOfTargets}+1") +target_compile_definitions(ISPCObjectGenex PRIVATE + "ExpectedISPCObjects=${numberOfTargets}" + "CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>" + ) +target_include_directories(ISPCObjectGenex PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) +target_compile_features(ISPCObjectGenex PRIVATE cxx_std_11) diff --git a/Tests/ISPC/ObjectGenex/main.cxx b/Tests/ISPC/ObjectGenex/main.cxx new file mode 100644 index 000000000..143e74e13 --- /dev/null +++ b/Tests/ISPC/ObjectGenex/main.cxx @@ -0,0 +1,87 @@ +#include <stdio.h> + +/* + Define GENERATED_HEADER macro to allow c++ files to include headers + generated based on different configuration types. +*/ + +/* clang-format off */ +#define GENERATED_HEADER(x) GENERATED_HEADER0(CONFIG_TYPE/x) +/* clang-format on */ +#define GENERATED_HEADER0(x) GENERATED_HEADER1(x) +#define GENERATED_HEADER1(x) <x> + +#include GENERATED_HEADER(path_to_objs.h) + +#include <vector> +std::vector<std::string> expandList(std::string const& arg) +{ + std::vector<std::string> output; + // If argument is empty or no `;` just copy the current string + if (arg.empty() || arg.find(';') == std::string::npos) { + output.emplace_back(arg); + return output; + } + + std::string newArg; + // Break the string at non-escaped semicolons not nested in []. + int squareNesting = 0; + auto last = arg.begin(); + auto const cend = arg.end(); + for (auto c = last; c != cend; ++c) { + switch (*c) { + case '\\': { + // We only want to allow escaping of semicolons. Other + // escapes should not be processed here. + auto cnext = c + 1; + if ((cnext != cend) && *cnext == ';') { + newArg.append(last, c); + // Skip over the escape character + last = cnext; + c = cnext; + } + } break; + case '[': { + ++squareNesting; + } break; + case ']': { + --squareNesting; + } break; + case ';': { + // Break the string here if we are not nested inside square + // brackets. + if (squareNesting == 0) { + newArg.append(last, c); + // Skip over the semicolon + last = c + 1; + if (!newArg.empty()) { + // Add the last argument if the string is not empty. + output.push_back(newArg); + newArg.clear(); + } + } + } break; + default: { + // Just append this character. + } break; + } + } + newArg.append(last, cend); + if (!newArg.empty()) { + // Add the last argument if the string is not empty. + output.push_back(std::move(newArg)); + } + + return output; +} + +int main() +{ + // determine that the number of object files specified in obj_paths + // is equal to the number of arch's + + std::vector<std::string> paths = expandList(obj_paths); + const bool correctSize = (paths.size() == ExpectedISPCObjects); + + return (correctSize) ? 0 : 1; +} diff --git a/Tests/ISPC/ObjectGenex/simple.ispc b/Tests/ISPC/ObjectGenex/simple.ispc new file mode 100644 index 000000000..a76b76cfe --- /dev/null +++ b/Tests/ISPC/ObjectGenex/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < M_PI) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ObjectLibrary/CMakeLists.txt b/Tests/ISPC/ObjectLibrary/CMakeLists.txt new file mode 100644 index 000000000..4767d7e65 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,18 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCObjectLibrary CXX ISPC) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + + +add_library(ispc_objects OBJECT simple.ispc extra.ispc) + +set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(ispc_objects PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") + + +add_executable(ISPCObjectLibrary main.cxx extra.cxx) +target_link_libraries(ISPCObjectLibrary PRIVATE ispc_objects) diff --git a/Tests/ISPC/ObjectLibrary/extra.cxx b/Tests/ISPC/ObjectLibrary/extra.cxx new file mode 100644 index 000000000..88ef3a795 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/extra.cxx @@ -0,0 +1,17 @@ +#include <stdio.h> + +#include "extra.ispc.h" + +int extra() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::extra(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/ISPC/ObjectLibrary/extra.ispc b/Tests/ISPC/ObjectLibrary/extra.ispc new file mode 100644 index 000000000..5a4a44249 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/extra.ispc @@ -0,0 +1,12 @@ + +export void extra(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ObjectLibrary/main.cxx b/Tests/ISPC/ObjectLibrary/main.cxx new file mode 100644 index 000000000..4f1c9be3d --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/ObjectLibrary/simple.ispc b/Tests/ISPC/ObjectLibrary/simple.ispc new file mode 100644 index 000000000..70cb58885 --- /dev/null +++ b/Tests/ISPC/ObjectLibrary/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/ResponseAndDefine/CMakeLists.txt b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt new file mode 100644 index 000000000..753920993 --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.18) +project(ispc_spaces_in_path ISPC CXX) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) + +# Make sure we can handle an arg file with tricky defines including spaces in -I include +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/path with spaces/simple_include.h" +" + typedef float FLOAT_TYPE; +" +) + +add_executable(ISPCResponseAndDefine main.cxx simple.ispc) +set_target_properties(ISPCResponseAndDefine PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(ISPCResponseAndDefine PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +target_compile_options(ISPCResponseAndDefine PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>") +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ISPCResponseAndDefine PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--arch=x86>") +endif() + + + +target_compile_definitions(ISPCResponseAndDefine PRIVATE + "$<$<COMPILE_LANGUAGE:ISPC>:STRUCT_DEFINE=struct{uniform int a>;M_PI=3.14159f") +target_include_directories(ISPCResponseAndDefine PRIVATE + "$<$<COMPILE_LANGUAGE:ISPC>:${CMAKE_CURRENT_BINARY_DIR}/fake path with spaces>" + "$<$<COMPILE_LANGUAGE:ISPC>:${CMAKE_CURRENT_BINARY_DIR}/path with spaces>") diff --git a/Tests/ISPC/ResponseAndDefine/main.cxx b/Tests/ISPC/ResponseAndDefine/main.cxx new file mode 100644 index 000000000..4f1c9be3d --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/ResponseAndDefine/simple.ispc b/Tests/ISPC/ResponseAndDefine/simple.ispc new file mode 100644 index 000000000..81fd7ca54 --- /dev/null +++ b/Tests/ISPC/ResponseAndDefine/simple.ispc @@ -0,0 +1,16 @@ + +STRUCT_DEFINE;}; + +#include "simple_include.h" + +export void simple(uniform FLOAT_TYPE vin[], uniform FLOAT_TYPE vout[], + uniform int count) { + foreach (index = 0 ... count) { + FLOAT_TYPE v = vin[index]; + if (v < M_PI) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/StaticLibrary/CMakeLists.txt b/Tests/ISPC/StaticLibrary/CMakeLists.txt new file mode 100644 index 000000000..ebe59609b --- /dev/null +++ b/Tests/ISPC/StaticLibrary/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCStaticLibrary CXX ISPC) + +add_library(ispc_objects STATIC simple.ispc) + +target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>") +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--arch=x86>") +endif() + +set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_executable(ISPCStaticLibrary main.cxx) +target_link_libraries(ISPCStaticLibrary PRIVATE ispc_objects) diff --git a/Tests/ISPC/StaticLibrary/main.cxx b/Tests/ISPC/StaticLibrary/main.cxx new file mode 100644 index 000000000..4f1c9be3d --- /dev/null +++ b/Tests/ISPC/StaticLibrary/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/StaticLibrary/simple.ispc b/Tests/ISPC/StaticLibrary/simple.ispc new file mode 100644 index 000000000..70cb58885 --- /dev/null +++ b/Tests/ISPC/StaticLibrary/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/TryCompile/CMakeLists.txt b/Tests/ISPC/TryCompile/CMakeLists.txt new file mode 100644 index 000000000..742f5118d --- /dev/null +++ b/Tests/ISPC/TryCompile/CMakeLists.txt @@ -0,0 +1,16 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCTryCompile ISPC CXX) + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + +#Verify we can use try_compile with ISPC +try_compile(result "${CMAKE_CURRENT_BINARY_DIR}" + SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/simple.ispc" + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/result.o") + +add_executable(ISPCTryCompile main.cxx ) +target_link_libraries(ISPCTryCompile "${CMAKE_CURRENT_BINARY_DIR}/result.o") diff --git a/Tests/ISPC/TryCompile/main.cxx b/Tests/ISPC/TryCompile/main.cxx new file mode 100644 index 000000000..c8d1ed6e2 --- /dev/null +++ b/Tests/ISPC/TryCompile/main.cxx @@ -0,0 +1,19 @@ +#include <stdio.h> + +namespace ispc { +extern "C" { +void simple(float*, float*, int); +} +} + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/TryCompile/simple.ispc b/Tests/ISPC/TryCompile/simple.ispc new file mode 100644 index 000000000..70cb58885 --- /dev/null +++ b/Tests/ISPC/TryCompile/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index eb08676e0..1f5b66447 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -17,6 +17,7 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA endif() if (run_sys_includes_test) add_subdirectory(SystemIncludeDirectories) + add_subdirectory(SystemIncludeDirectoriesPerLang) endif() endif() diff --git a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt new file mode 100644 index 000000000..70dfa017b --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.17 FATAL_ERROR) + +project(SystemIncludeDirectoriesPerLang) + +add_library(c_interface INTERFACE) +set_target_properties(c_interface PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}>" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}>" +) +target_compile_options(c_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:C,GNU,Clang>:-Werror=unused-variable>") + +add_library(cxx_interface INTERFACE) +set_target_properties(cxx_interface PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_system_include>" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_system_include>" +) +target_compile_options(cxx_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Werror=unused-variable>") + +# The C header must come before the C++ header for this test to smoke out the +# failure. The order of sources is how CMake determines the include cache +# and we need it to cache on the 'bad' language first +add_executable(consume_multi_lang_includes main.c smoke_out_includes.cxx) +target_link_libraries(consume_multi_lang_includes PRIVATE c_interface cxx_interface) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/cxx_system_include/header.h b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/cxx_system_include/header.h new file mode 100644 index 000000000..8dcd22622 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/cxx_system_include/header.h @@ -0,0 +1,10 @@ + +// Generate a warning in here + +int function_that_generates_warning(int x) +{ + int y = x; + int z = 2; + y -= x; + return y; +} diff --git a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/main.c b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/main.c new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/smoke_out_includes.cxx b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/smoke_out_includes.cxx new file mode 100644 index 000000000..dbfc557b3 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/smoke_out_includes.cxx @@ -0,0 +1,7 @@ + +#include <header.h> + +int empty_func() +{ + return function_that_generates_warning(4); +} diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 311ca2a4e..ec0a60405 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -44,6 +44,7 @@ add_executable(InterfaceLibrary definetestexe.cpp) target_link_libraries(InterfaceLibrary iface_nodepends headeriface + iface_genheader subiface intermediate diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp index 9156426cd..6c538405e 100644 --- a/Tests/InterfaceLibrary/definetestexe.cpp +++ b/Tests/InterfaceLibrary/definetestexe.cpp @@ -15,6 +15,12 @@ # error Expected IFACE_HEADER_BUILDDIR #endif +#include "iface_genheader.h" + +#ifndef IFACE_GENHEADER +# error Expected IFACE_GENHEADER +#endif + extern int obj(); extern int sub(); extern int item(); diff --git a/Tests/InterfaceLibrary/headerdir/CMakeLists.txt b/Tests/InterfaceLibrary/headerdir/CMakeLists.txt index 826a9ed9c..ae030d751 100644 --- a/Tests/InterfaceLibrary/headerdir/CMakeLists.txt +++ b/Tests/InterfaceLibrary/headerdir/CMakeLists.txt @@ -11,3 +11,12 @@ add_custom_target(headeriface_gen VERBATIM ) add_dependencies(headeriface headeriface_gen) + +add_custom_command(OUTPUT iface_genheader.h + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/iface_genheader.h.in + ${CMAKE_CURRENT_BINARY_DIR}/iface_genheader.h + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/iface_genheader.h.in + VERBATIM) +add_library(iface_genheader INTERFACE iface_genheader.h) diff --git a/Tests/InterfaceLibrary/headerdir/iface_genheader.h.in b/Tests/InterfaceLibrary/headerdir/iface_genheader.h.in new file mode 100644 index 000000000..0a21b6268 --- /dev/null +++ b/Tests/InterfaceLibrary/headerdir/iface_genheader.h.in @@ -0,0 +1 @@ +#define IFACE_GENHEADER diff --git a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c index 99f0de925..af7b09259 100644 --- a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c +++ b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c @@ -91,7 +91,7 @@ static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[]) source_file = info->CAPI->CreateNewSourceFile(mf); cstr = info->CAPI->SourceFileGetSourceName(source_file); - sprintf(buffer, "Shold be empty (source file name): [%s]", cstr); + sprintf(buffer, "Should be empty (source file name): [%s]", cstr); info->CAPI->DisplaySatus(mf, buffer); cstr = info->CAPI->SourceFileGetFullPath(source_file); sprintf(buffer, "Should be empty (source file full path): [%s]", cstr); diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c index 99f0de925..af7b09259 100644 --- a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c +++ b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c @@ -91,7 +91,7 @@ static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[]) source_file = info->CAPI->CreateNewSourceFile(mf); cstr = info->CAPI->SourceFileGetSourceName(source_file); - sprintf(buffer, "Shold be empty (source file name): [%s]", cstr); + sprintf(buffer, "Should be empty (source file name): [%s]", cstr); info->CAPI->DisplaySatus(mf, buffer); cstr = info->CAPI->SourceFileGetFullPath(source_file); sprintf(buffer, "Should be empty (source file full path): [%s]", cstr); diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in index bf98e918c..3632e03e2 100644 --- a/Tests/MFC/CMakeLists.txt.in +++ b/Tests/MFC/CMakeLists.txt.in @@ -65,3 +65,6 @@ if("${CMAKE_MFC_FLAG}" STREQUAL "2") set(CMAKE_INSTALL_MFC_LIBRARIES ON) include(InstallRequiredSystemLibraries) endif() + +# Encode the value inside a generator expression to test evaluation. +set(CMAKE_MFC_FLAG "$<1:${CMAKE_MFC_FLAG}>") diff --git a/Tests/Module/CheckTypeSize/CMakeLists.txt b/Tests/Module/CheckTypeSize/CMakeLists.txt index 16989fe23..102cf0c17 100644 --- a/Tests/Module/CheckTypeSize/CMakeLists.txt +++ b/Tests/Module/CheckTypeSize/CMakeLists.txt @@ -21,6 +21,8 @@ check_type_size("((struct somestruct*)0)->somechar" SIZEOF_STRUCTMEMBER_CHAR) # Check CXX types check_type_size(bool SIZEOF_BOOL LANGUAGE CXX) +check_type_size(uint8_t SIZEOF_UINT8_T LANGUAGE CXX) +check_type_size(std::uint8_t SIZEOF_STD_UINT8_T LANGUAGE CXX) set(CMAKE_EXTRA_INCLUDE_FILES someclass.hxx) check_type_size("((ns::someclass*)0)->someint" SIZEOF_NS_CLASSMEMBER_INT LANGUAGE CXX) diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx index 15dc890c8..45cd393d0 100644 --- a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx +++ b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx @@ -11,6 +11,12 @@ #ifdef HAVE_STDDEF_H # include <stddef.h> #endif +#ifdef HAVE_CSTDINT +# include <cstdint> +#endif +#ifdef HAVE_CSTDDEF +# include <cstddef> +#endif #include <stdio.h> @@ -122,6 +128,26 @@ int main() NODEF(SIZEOF_SSIZE_T); #endif +/* uint8_t */ +#if defined(SIZEOF_UINT8_T) + CHECK(uint8_t, SIZEOF_UINT8_T); +# if !defined(HAVE_SIZEOF_UINT8_T) + NODEF(HAVE_SIZEOF_UINT8_T); +# endif +#elif defined(HAVE_SIZEOF_UINT8_T) + NODEF(SIZEOF_UINT8_T); +#endif + +/* std::uint8_t */ +#if defined(SIZEOF_STD_UINT8_T) + CHECK(std::uint8_t, SIZEOF_STD_UINT8_T); +# if !defined(HAVE_SIZEOF_STD_UINT8_T) + NODEF(HAVE_SIZEOF_STD_UINT8_T); +# endif +#elif defined(HAVE_SIZEOF_STD_UINT8_T) + NODEF(SIZEOF_STD_UINT8_T); +#endif + /* ns::someclass::someint */ #if defined(SIZEOF_NS_CLASSMEMBER_INT) CHECK(y.someint, SIZEOF_NS_CLASSMEMBER_INT); diff --git a/Tests/Module/CheckTypeSize/config.hxx.in b/Tests/Module/CheckTypeSize/config.hxx.in index 8c66ade6c..9a8068936 100644 --- a/Tests/Module/CheckTypeSize/config.hxx.in +++ b/Tests/Module/CheckTypeSize/config.hxx.in @@ -1,11 +1,21 @@ #cmakedefine HAVE_SYS_TYPES_H #cmakedefine HAVE_STDINT_H #cmakedefine HAVE_STDDEF_H +#cmakedefine HAVE_CSTDINT +#cmakedefine HAVE_CSTDDEF /* bool */ #cmakedefine HAVE_SIZEOF_BOOL @SIZEOF_BOOL_CODE@ +/* uint8_t */ +#cmakedefine HAVE_SIZEOF_UINT8_T +@SIZEOF_UINT8_T_CODE@ + +/* std::uint8_t */ +#cmakedefine HAVE_SIZEOF_STD_UINT8_T +@SIZEOF_STD_UINT8_T_CODE@ + /* struct ns::somestruct::someint */ #cmakedefine HAVE_SIZEOF_NS_STRUCTMEMBER_INT @SIZEOF_NS_STRUCTMEMBER_INT_CODE@ diff --git a/Tests/Module/ExternalData/Data5/CMakeLists.txt b/Tests/Module/ExternalData/Data5/CMakeLists.txt index ea67f05af..b13240d8a 100644 --- a/Tests/Module/ExternalData/Data5/CMakeLists.txt +++ b/Tests/Module/ExternalData/Data5/CMakeLists.txt @@ -6,6 +6,13 @@ ExternalData_Add_Test(Data5.A -P ${CMAKE_CURRENT_SOURCE_DIR}/Data5Check.cmake ) ExternalData_Add_Target(Data5.A) + +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + # Xcode's "new build system" does not support multiple targets + # producing the same custom command output. + return() +endif() + ExternalData_Add_Test(Data5.B NAME Data5Check.B COMMAND ${CMAKE_COMMAND} diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt index 162a1780b..a1158c6be 100644 --- a/Tests/Properties/CMakeLists.txt +++ b/Tests/Properties/CMakeLists.txt @@ -165,6 +165,34 @@ add_library(maindirtest SHARED) generate_file_for_set_property_test(32 maindirtest) generate_file_for_set_property_test(33 maindirtest) +# Set/get properties by binary directory path. +add_subdirectory(SubDir SubDirA) +get_property(dir_prop_top DIRECTORY PROPERTY dir_prop_top) +if(NOT dir_prop_top STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/SubDirA") + message(SEND_ERROR "dir_prop_top unexpected value after SubDirA:\n ${dir_prop_top}") +endif() +add_subdirectory(SubDir SubDirB) +get_property(dir_prop_top DIRECTORY PROPERTY dir_prop_top) +if(NOT dir_prop_top STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/SubDirB") + message(SEND_ERROR "dir_prop_top unexpected value after SubDirB:\n ${dir_prop_top}") +endif() +get_property(dir_prop_subA DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SubDirA PROPERTY dir_prop_sub) +if(NOT dir_prop_subA STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/SubDirA") + message(SEND_ERROR "SubDirA property dir_prop_sub incorrect:\n ${dir_prop_subA}") +endif() +get_property(dir_prop_subB DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SubDirB PROPERTY dir_prop_sub) +if(NOT dir_prop_subB STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/SubDirB") + message(SEND_ERROR "SubDirB property dir_prop_sub incorrect:\n ${dir_prop_subB}") +endif() +get_directory_property(dir_prop_subA DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SubDirA dir_prop_sub) +if(NOT dir_prop_subA STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/SubDirA") + message(SEND_ERROR "SubDirA property dir_prop_sub incorrect:\n ${dir_prop_subA}") +endif() +get_directory_property(dir_prop_subB DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SubDirB dir_prop_sub) +if(NOT dir_prop_subB STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/SubDirB") + message(SEND_ERROR "SubDirB property dir_prop_sub incorrect:\n ${dir_prop_subB}") +endif() + add_subdirectory(SubDir2) set(src_prefix "${CMAKE_CURRENT_BINARY_DIR}/SubDir2/") diff --git a/Tests/Properties/SubDir/CMakeLists.txt b/Tests/Properties/SubDir/CMakeLists.txt new file mode 100644 index 000000000..f34cc8c7f --- /dev/null +++ b/Tests/Properties/SubDir/CMakeLists.txt @@ -0,0 +1,2 @@ +set_property(DIRECTORY PROPERTY dir_prop_sub ${CMAKE_CURRENT_BINARY_DIR}) +set_property(DIRECTORY ${CMAKE_BINARY_DIR} PROPERTY dir_prop_top ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt index 9e6fe8b34..d9fc2b07d 100644 --- a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt +++ b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt @@ -9,8 +9,8 @@ include_directories(${CBD}) # A GENERATED file ensures there will be an _autogen target in VS add_custom_command ( - OUTPUT "${CBD}/config.hpp" - COMMAND ${CMAKE_COMMAND} -E copy "${CSD}/config.hpp.in" "${CBD}/config.hpp" + OUTPUT "${CBD}/config_a.hpp" + COMMAND ${CMAKE_COMMAND} -E copy "${CSD}/config.hpp.in" "${CBD}/config_a.hpp" ) @@ -30,13 +30,18 @@ add_dependencies ( a_mc a_qt_autogen ) # - depends on a GENERATED file # - AUTOMOC enabled # - depends on a target (a_mc) that depends on a_qt_qutogen -add_library ( a_qt a_qt.cpp "${CBD}/config.hpp" ) +add_library ( a_qt a_qt.cpp "${CBD}/config_a.hpp" ) add_dependencies ( a_qt a_mc ) target_link_libraries ( a_qt ${QT_QTCORE_TARGET}) set_target_properties ( a_qt PROPERTIES AUTOMOC TRUE) # Disable AUTOGEN_ORIGIN_DEPENDS to avoid loop dependencies set_target_properties ( a_qt PROPERTIES AUTOGEN_ORIGIN_DEPENDS OFF) +# A GENERATED file ensures there will be an _autogen target in VS +add_custom_command ( + OUTPUT "${CBD}/config_b.hpp" + COMMAND ${CMAKE_COMMAND} -E copy "${CSD}/config.hpp.in" "${CBD}/config_b.hpp" + ) # Library "b_mc" provides a header that holds a string function that returns # the content of mocs_compilation.cpp from b_qt. @@ -57,7 +62,7 @@ add_library ( b_mc ${CSD}/b_mc.hpp ${CBD}/b_mc.cpp ) # - depends on a GENERATED file # - AUTOMOC enabled # - depends on a library (b_mc) that depends on b_qt_qutogen -add_library ( b_qt b_qt.cpp "${CBD}/config.hpp" ) +add_library ( b_qt b_qt.cpp "${CBD}/config_b.hpp" ) target_link_libraries ( b_qt b_mc ) target_link_libraries ( b_qt ${QT_QTCORE_TARGET}) set_target_properties ( b_qt PROPERTIES AUTOMOC TRUE) diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp index fafc8a20e..313b58b73 100644 --- a/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp +++ b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp @@ -3,7 +3,7 @@ #include <string> -#include <config.hpp> +#include <config_a.hpp> #include <QObject> diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp index b798e71ca..2e5775e13 100644 --- a/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp +++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp @@ -3,7 +3,7 @@ #include <string> -#include <config.hpp> +#include <config_b.hpp> #include <QObject> diff --git a/Tests/QtAutogen/MocSkipSource/CMakeLists.txt b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt index 454e896e8..c88673618 100644 --- a/Tests/QtAutogen/MocSkipSource/CMakeLists.txt +++ b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt @@ -29,6 +29,13 @@ set_property(SOURCE qItemD.hpp PROPERTY SKIP_AUTOGEN ON) add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) set_property(TARGET skipMocA PROPERTY AUTOMOC ON) target_link_libraries(skipMocA ${QT_LIBRARIES}) + +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + # FIXME: Fix AUTOMOC for the Xcode "new build system" to avoid + # duplicating custom commands in multiple _autogen targets. + return() +endif() + # AUTOMOC and AUTOUIC enabled add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc}) set_property(TARGET skipMocB PROPERTY AUTOMOC ON) diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake index 45798ce59..c4b1a00dd 100644 --- a/Tests/RunCMake/Android/RunCMakeTest.cmake +++ b/Tests/RunCMake/Android/RunCMakeTest.cmake @@ -18,15 +18,33 @@ function(run_Android case) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(${case}) - run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .) + set(configs ".") + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(configs Release Debug) + endif() + foreach(config IN LISTS configs) + set(build_suffix) + set(config_arg) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(build_suffix "-${config}") + set(config_arg --config "${config}") + endif() + run_cmake_command(${case}-build${build_suffix} ${CMAKE_COMMAND} --build . ${config_arg}) + endforeach() endfunction() +set(RunCMake_GENERATOR_PLATFORM_OLD "${RunCMake_GENERATOR_PLATFORM}") + +if(RunCMake_GENERATOR MATCHES "Visual Studio") + set(RunCMake_GENERATOR_PLATFORM "ARM") +endif() set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSROOT=${CMAKE_CURRENT_SOURCE_DIR} ) run_cmake(BadSYSROOT) unset(RunCMake_TEST_OPTIONS) +set(RunCMake_GENERATOR_PLATFORM "${RunCMake_GENERATOR_PLATFORM_OLD}") foreach(ndk IN LISTS TEST_ANDROID_NDK) # Load available toolchain versions and abis. @@ -70,6 +88,9 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) if(_versions MATCHES "clang") set(_versions "clang" ${_versions}) endif() + if(RunCMake_GENERATOR MATCHES "Visual Studio") + set(_versions "clang") + endif() list(REMOVE_DUPLICATES _versions) list(SORT _versions) set(_versions ";${_versions}") @@ -77,44 +98,58 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) list(REMOVE_DUPLICATES _abis_${vers}) endforeach() + set(ndk_arg -DCMAKE_ANDROID_NDK=${ndk}) + if(RunCMake_GENERATOR MATCHES "Visual Studio") + set(ndk_arg) + endif() + # Test failure cases. message(STATUS "ndk='${ndk}'") + if(RunCMake_GENERATOR MATCHES "Visual Studio") + set(RunCMake_GENERATOR_PLATFORM "ARM") + endif() set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_NDK=${ndk} + ${ndk_arg} -DCMAKE_ANDROID_ARCH_ABI=badabi ) run_cmake(ndk-badabi) + if(RunCMake_GENERATOR MATCHES "Visual Studio") + set(RunCMake_GENERATOR_PLATFORM "x86") + endif() set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_NDK=${ndk} + ${ndk_arg} -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_ANDROID_ARM_MODE=0 ) run_cmake(ndk-badarm) + if(RunCMake_GENERATOR MATCHES "Visual Studio") + set(RunCMake_GENERATOR_PLATFORM "ARM") + endif() if("armeabi" IN_LIST _abis_) set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_NDK=${ndk} + ${ndk_arg} -DCMAKE_ANDROID_ARM_NEON=0 ) run_cmake(ndk-badneon) endif() set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_NDK=${ndk} + ${ndk_arg} -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=badver ) run_cmake(ndk-badver) set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_NDK=${ndk} + ${ndk_arg} -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=1.0 ) run_cmake(ndk-badvernum) set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_NDK=${ndk} + ${ndk_arg} -DCMAKE_ANDROID_STL_TYPE=badstl ) run_cmake(ndk-badstl) @@ -122,7 +157,7 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) # Find a sysroot to test. file(GLOB _sysroots "${ndk}/platforms/android-[0-9][0-9]/arch-arm") - if(_sysroots) + if(_sysroots AND "armeabi" IN_LIST _abis_) list(GET _sysroots 0 _sysroot) set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android @@ -131,6 +166,7 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) run_cmake(ndk-sysroot-armeabi) unset(RunCMake_TEST_OPTIONS) endif() + set(RunCMake_GENERATOR_PLATFORM "${RunCMake_GENERATOR_PLATFORM_OLD}") # Find available STLs. set(stl_types @@ -157,23 +193,41 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) armeabi-v6 armeabi-v7a arm64-v8a - mips - mips64 x86 x86_64 ) + if(NOT RunCMake_GENERATOR MATCHES "Visual Studio") + list(APPEND abi_names mips mips64) + endif() + set(abi_to_arch_armeabi ARM) + set(abi_to_arch_armeabi-v6 ARM) + set(abi_to_arch_armeabi-v7a ARM) + set(abi_to_arch_arm64-v8a ARM64) + set(abi_to_arch_x86 x86) + set(abi_to_arch_x86_64 x64) # Test all combinations. foreach(vers IN LISTS _versions) foreach(stl IN LISTS stl_types) - foreach(config Release Debug) + set(configs Release Debug) + set(foreach_list "${configs}") + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(foreach_list ".") + endif() + foreach(config IN LISTS foreach_list) # Test this combination for all available abis. - message(STATUS "ndk='${ndk}' vers='${vers}' stl='${stl}' config='${config}'") + set(config_status " config='${config}'") + set(build_type_arg "-DCMAKE_BUILD_TYPE=${config}") + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(config_status) + string(REPLACE ";" "\\\\;" build_type_arg "-DCMAKE_CONFIGURATION_TYPES=${configs}") + endif() + message(STATUS "ndk='${ndk}' vers='${vers}' stl='${stl}'${config_status}") set(RunCMake_TEST_OPTIONS - -DCMAKE_ANDROID_NDK=${ndk} + ${ndk_arg} -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=${vers} -DCMAKE_ANDROID_STL_TYPE=${stl} - -DCMAKE_BUILD_TYPE=${config} + "${build_type_arg}" ) foreach(abi IN LISTS abi_names) # Skip ABIs not supported by this compiler. @@ -182,6 +236,9 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) endif() # Run the tests for this combination. + if(RunCMake_GENERATOR MATCHES "Visual Studio") + set(RunCMake_GENERATOR_PLATFORM "${abi_to_arch_${abi}}") + endif() if("${abi}" STREQUAL "armeabi") run_Android(ndk-armeabi-thumb) # default: -DCMAKE_ANDROID_ARCH_ABI=armeabi -DCMAKE_ANDROID_ARM_MODE=0 run_Android(ndk-armeabi-arm -DCMAKE_ANDROID_ARM_MODE=1) # default: -DCMAKE_ANDROID_ARCH_ABI=armeabi @@ -191,6 +248,7 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) run_Android(ndk-${abi}-neon -DCMAKE_ANDROID_ARCH_ABI=${abi} -DCMAKE_ANDROID_ARM_NEON=1) endif() endif() + set(RunCMake_GENERATOR_PLATFORM "${RunCMake_GENERATOR_PLATFORM_OLD}") endforeach() unset(RunCMake_TEST_OPTIONS) endforeach() diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index d96ab8648..32412aa84 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -96,7 +96,7 @@ add_executable(android_c android.c) add_executable(android_cxx android.cxx) add_library(android_cxx_lib SHARED android_lib.cxx) -set(objdump "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}objdump") +set(objdump "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}objdump${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}") if(NOT EXISTS "${objdump}") message(FATAL_ERROR "Expected tool missing:\n ${objdump}") endif() diff --git a/Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt b/Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt new file mode 100644 index 000000000..a3b3634e6 --- /dev/null +++ b/Tests/RunCMake/Android/ndk-arm64-v8a-stderr.txt @@ -0,0 +1,7 @@ +^(CMake Warning: + You are using Visual Studio tools for Android, which does not support + standalone executables\. However, the following executable targets do not + have the ANDROID_GUI property set, and thus will not be built as expected\. + They will be built as shared libraries with executable filenames: + + android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$ diff --git a/Tests/RunCMake/Android/ndk-armeabi-arm-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-arm-stderr.txt new file mode 100644 index 000000000..a3b3634e6 --- /dev/null +++ b/Tests/RunCMake/Android/ndk-armeabi-arm-stderr.txt @@ -0,0 +1,7 @@ +^(CMake Warning: + You are using Visual Studio tools for Android, which does not support + standalone executables\. However, the following executable targets do not + have the ANDROID_GUI property set, and thus will not be built as expected\. + They will be built as shared libraries with executable filenames: + + android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$ diff --git a/Tests/RunCMake/Android/ndk-armeabi-thumb-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-thumb-stderr.txt new file mode 100644 index 000000000..a3b3634e6 --- /dev/null +++ b/Tests/RunCMake/Android/ndk-armeabi-thumb-stderr.txt @@ -0,0 +1,7 @@ +^(CMake Warning: + You are using Visual Studio tools for Android, which does not support + standalone executables\. However, the following executable targets do not + have the ANDROID_GUI property set, and thus will not be built as expected\. + They will be built as shared libraries with executable filenames: + + android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$ diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stderr.txt new file mode 100644 index 000000000..a3b3634e6 --- /dev/null +++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stderr.txt @@ -0,0 +1,7 @@ +^(CMake Warning: + You are using Visual Studio tools for Android, which does not support + standalone executables\. However, the following executable targets do not + have the ANDROID_GUI property set, and thus will not be built as expected\. + They will be built as shared libraries with executable filenames: + + android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$ diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a-stderr.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-stderr.txt new file mode 100644 index 000000000..a3b3634e6 --- /dev/null +++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-stderr.txt @@ -0,0 +1,7 @@ +^(CMake Warning: + You are using Visual Studio tools for Android, which does not support + standalone executables\. However, the following executable targets do not + have the ANDROID_GUI property set, and thus will not be built as expected\. + They will be built as shared libraries with executable filenames: + + android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$ diff --git a/Tests/RunCMake/Android/ndk-x86-stderr.txt b/Tests/RunCMake/Android/ndk-x86-stderr.txt new file mode 100644 index 000000000..a3b3634e6 --- /dev/null +++ b/Tests/RunCMake/Android/ndk-x86-stderr.txt @@ -0,0 +1,7 @@ +^(CMake Warning: + You are using Visual Studio tools for Android, which does not support + standalone executables\. However, the following executable targets do not + have the ANDROID_GUI property set, and thus will not be built as expected\. + They will be built as shared libraries with executable filenames: + + android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$ diff --git a/Tests/RunCMake/Android/ndk-x86_64-stderr.txt b/Tests/RunCMake/Android/ndk-x86_64-stderr.txt new file mode 100644 index 000000000..a3b3634e6 --- /dev/null +++ b/Tests/RunCMake/Android/ndk-x86_64-stderr.txt @@ -0,0 +1,7 @@ +^(CMake Warning: + You are using Visual Studio tools for Android, which does not support + standalone executables\. However, the following executable targets do not + have the ANDROID_GUI property set, and thus will not be built as expected\. + They will be built as shared libraries with executable filenames: + + android_c, android_cxx, android_sysinc_c, android_sysinc_cxx)?$ diff --git a/Tests/RunCMake/BundleUtilities/ExecutableScripts.cmake b/Tests/RunCMake/BundleUtilities/ExecutableScripts.cmake new file mode 100644 index 000000000..78a9b66a9 --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/ExecutableScripts.cmake @@ -0,0 +1,18 @@ +include(BundleUtilities) + +set(BU_CHMOD_BUNDLE_ITEMS ON) + +function(check_script script) + fixup_bundle_item(${script} ${script} "" "") +endfunction() + +# Should not throw any errors +# Shell script +set(script_sh_EMBEDDED_ITEM ${CMAKE_CURRENT_LIST_DIR}/test.app/script.sh) +check_script(${CMAKE_CURRENT_LIST_DIR}/test.app/script.sh) +# Batch script +set(script_bat_EMBEDDED_ITEM ${CMAKE_CURRENT_LIST_DIR}/test.app/script.bat) +check_script(${CMAKE_CURRENT_LIST_DIR}/test.app/script.bat) +# Shell script without extension +set(script_EMBEDDED_ITEM ${CMAKE_CURRENT_LIST_DIR}/test.app/script) +check_script(${CMAKE_CURRENT_LIST_DIR}/test.app/script) diff --git a/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake b/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake index 14aaff197..df28102f2 100644 --- a/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake +++ b/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake @@ -9,3 +9,4 @@ run_cmake(CMP0080-WARN) run_cmake_command(CMP0080-COMMAND-OLD ${CMAKE_COMMAND} -DCMP0080_VALUE:STRING=OLD -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake) run_cmake_command(CMP0080-COMMAND-NEW ${CMAKE_COMMAND} -DCMP0080_VALUE:STRING=NEW -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake) run_cmake_command(CMP0080-COMMAND-WARN ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake) +run_cmake_command(ExecutableScripts ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ExecutableScripts.cmake) diff --git a/Tests/RunCMake/BundleUtilities/test.app/script b/Tests/RunCMake/BundleUtilities/test.app/script new file mode 100755 index 000000000..23bf47c06 --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/test.app/script @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Hello World" diff --git a/Tests/RunCMake/BundleUtilities/test.app/script.bat b/Tests/RunCMake/BundleUtilities/test.app/script.bat new file mode 100755 index 000000000..338ae039b --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/test.app/script.bat @@ -0,0 +1,3 @@ +@echo off
+
+echo "Hello world"
diff --git a/Tests/RunCMake/BundleUtilities/test.app/script.sh b/Tests/RunCMake/BundleUtilities/test.app/script.sh new file mode 100755 index 000000000..23bf47c06 --- /dev/null +++ b/Tests/RunCMake/BundleUtilities/test.app/script.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Hello World" diff --git a/Tests/RunCMake/CMP0019/CMP0019-NEW-stderr.txt b/Tests/RunCMake/CMP0019/CMP0019-NEW-stderr.txt new file mode 100644 index 000000000..66a58fb82 --- /dev/null +++ b/Tests/RunCMake/CMP0019/CMP0019-NEW-stderr.txt @@ -0,0 +1,6 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions.$ diff --git a/Tests/RunCMake/CMP0019/CMP0019-OLD-stderr.txt b/Tests/RunCMake/CMP0019/CMP0019-OLD-stderr.txt index 048762d00..a446211db 100644 --- a/Tests/RunCMake/CMP0019/CMP0019-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0019/CMP0019-OLD-stderr.txt @@ -1,4 +1,11 @@ -^CMake Deprecation Warning at CMP0019-OLD.cmake:[0-9]+ \(cmake_policy\): +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. ++ +CMake Deprecation Warning at CMP0019-OLD.cmake:[0-9]+ \(cmake_policy\): The OLD behavior for policy CMP0019 will be removed from a future version of CMake. diff --git a/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt b/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt index 1e4b47d0c..f7b9c0e88 100644 --- a/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt @@ -1,3 +1,10 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. ++ CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0019 is not set: Do not re-expand variables in include and link information. Run "cmake --help-policy CMP0019" for policy details. Use diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt new file mode 100644 index 000000000..66a58fb82 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt @@ -0,0 +1,6 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions.$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt new file mode 100644 index 000000000..66a58fb82 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt @@ -0,0 +1,6 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions.$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt new file mode 100644 index 000000000..66a58fb82 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-NEW-stderr.txt @@ -0,0 +1,6 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions.$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries-stderr.txt new file mode 100644 index 000000000..66a58fb82 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries-stderr.txt @@ -0,0 +1,6 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions.$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-stderr.txt new file mode 100644 index 000000000..66a58fb82 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-stderr.txt @@ -0,0 +1,6 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions.$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt index 6a6a0c782..87404d3a9 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt @@ -1,3 +1,10 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. ++ CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link interface. Run "cmake --help-policy CMP0022" for policy details. Use the diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt index 2f7dfbfb7..5d757200b 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-stderr.txt @@ -1,4 +1,11 @@ -^CMake Warning \(dev\) in CMakeLists.txt: +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. ++ +CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link interface. Run "cmake --help-policy CMP0022" for policy details. Use the cmake_policy command to set the policy and suppress this warning. diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt new file mode 100644 index 000000000..66a58fb82 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt @@ -0,0 +1,6 @@ +^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions.$ diff --git a/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake b/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake index 650c8a5c7..ae62e795f 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake +++ b/Tests/RunCMake/CMP0026/CMP0026-IMPORTED.cmake @@ -1,6 +1,7 @@ enable_language(CXX) +cmake_policy(SET CMP0111 OLD) add_library(someimportedlib SHARED IMPORTED) get_target_property(_loc someimportedlib LOCATION) diff --git a/Tests/RunCMake/CMP0026/CMakeLists.txt b/Tests/RunCMake/CMP0026/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/CMP0026/CMakeLists.txt +++ b/Tests/RunCMake/CMP0026/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0027/CMakeLists.txt b/Tests/RunCMake/CMP0027/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/CMP0027/CMakeLists.txt +++ b/Tests/RunCMake/CMP0027/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0028/CMakeLists.txt b/Tests/RunCMake/CMP0028/CMakeLists.txt index 144cdb4ee..4f867df1c 100644 --- a/Tests/RunCMake/CMP0028/CMakeLists.txt +++ b/Tests/RunCMake/CMP0028/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) # policy used at end of dir diff --git a/Tests/RunCMake/CMP0037/CMakeLists.txt b/Tests/RunCMake/CMP0037/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/CMP0037/CMakeLists.txt +++ b/Tests/RunCMake/CMP0037/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0041/CMakeLists.txt b/Tests/RunCMake/CMP0041/CMakeLists.txt index f452db177..a06591c31 100644 --- a/Tests/RunCMake/CMP0041/CMakeLists.txt +++ b/Tests/RunCMake/CMP0041/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0042/CMakeLists.txt b/Tests/RunCMake/CMP0042/CMakeLists.txt index f452db177..a06591c31 100644 --- a/Tests/RunCMake/CMP0042/CMakeLists.txt +++ b/Tests/RunCMake/CMP0042/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0043/CMakeLists.txt b/Tests/RunCMake/CMP0043/CMakeLists.txt index d027f3e0e..cc8a6f812 100644 --- a/Tests/RunCMake/CMP0043/CMakeLists.txt +++ b/Tests/RunCMake/CMP0043/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) # policy used at end of dir diff --git a/Tests/RunCMake/CMP0045/CMakeLists.txt b/Tests/RunCMake/CMP0045/CMakeLists.txt index f452db177..a06591c31 100644 --- a/Tests/RunCMake/CMP0045/CMakeLists.txt +++ b/Tests/RunCMake/CMP0045/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake new file mode 100644 index 000000000..564169d80 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake @@ -0,0 +1,9 @@ +# Prevent duplicate errors on some platforms. +set(CMAKE_IMPORT_LIBRARY_SUFFIX "placeholder") + +add_library(unknown_lib UNKNOWN IMPORTED) +add_library(static_lib STATIC IMPORTED) +add_library(shared_lib SHARED IMPORTED) + +add_executable(executable main.cpp) +target_link_libraries(executable unknown_lib static_lib shared_lib) diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-result.txt diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt new file mode 100644 index 000000000..ba5d9369f --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt @@ -0,0 +1,7 @@ +CMake Error in CMakeLists.txt: + IMPORTED_LOCATION not set for imported target "static_lib"( configuration + ".+")?. ++ +CMake Error in CMakeLists.txt: + IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration + ".+")?. diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW.cmake b/Tests/RunCMake/CMP0111/CMP0111-NEW.cmake new file mode 100644 index 000000000..d0c8dd3a1 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0111 NEW) +include(CMP0111-Common.cmake) diff --git a/Tests/RunCMake/CMP0111/CMP0111-OLD.cmake b/Tests/RunCMake/CMP0111/CMP0111-OLD.cmake new file mode 100644 index 000000000..d00847a27 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0111 OLD) +include(CMP0111-Common.cmake) diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt new file mode 100644 index 000000000..3abca0ab0 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt @@ -0,0 +1,29 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0111 is not set: An imported target missing its location property + fails during generation. Run "cmake --help-policy CMP0111" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + IMPORTED_LOCATION not set for imported target "unknown_lib"( configuration + ".+")?. +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0111 is not set: An imported target missing its location property + fails during generation. Run "cmake --help-policy CMP0111" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + IMPORTED_LOCATION not set for imported target "static_lib"( configuration + ".+")?. +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0111 is not set: An imported target missing its location property + fails during generation. Run "cmake --help-policy CMP0111" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration + ".+")?. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN.cmake b/Tests/RunCMake/CMP0111/CMP0111-WARN.cmake new file mode 100644 index 000000000..0efe48c58 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN.cmake @@ -0,0 +1 @@ +include(CMP0111-Common.cmake) diff --git a/Tests/RunCMake/CMP0111/CMakeLists.txt b/Tests/RunCMake/CMP0111/CMakeLists.txt new file mode 100644 index 000000000..9f19a7592 --- /dev/null +++ b/Tests/RunCMake/CMP0111/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.17) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0111/RunCMakeTest.cmake b/Tests/RunCMake/CMP0111/RunCMakeTest.cmake new file mode 100644 index 000000000..02e420a16 --- /dev/null +++ b/Tests/RunCMake/CMP0111/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0111-OLD) +run_cmake(CMP0111-NEW) +run_cmake(CMP0111-WARN) diff --git a/Tests/RunCMake/CMP0111/main.cpp b/Tests/RunCMake/CMP0111/main.cpp new file mode 100644 index 000000000..5047a34e3 --- /dev/null +++ b/Tests/RunCMake/CMP0111/main.cpp @@ -0,0 +1,3 @@ +int main() +{ +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index ec4c7b5a4..7000b7946 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -124,6 +124,7 @@ if(CMake_TEST_CUDA) PROPERTY LABELS "CUDA") endif() add_RunCMake_test(CMP0106) +add_RunCMake_test(CMP0111) # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode @@ -166,6 +167,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) -DPSEUDO_BC=$<TARGET_FILE:pseudo_BC> -DPSEUDO_PURIFY=$<TARGET_FILE:pseudo_purify> -DPSEUDO_VALGRIND=$<TARGET_FILE:pseudo_valgrind> + -DPSEUDO_CUDA_SANITIZER=$<TARGET_FILE:pseudo_cuda-memcheck> -DPSEUDO_BC_NOLOG=$<TARGET_FILE:pseudonl_BC> -DPSEUDO_PURIFY_NOLOG=$<TARGET_FILE:pseudonl_purify> -DPSEUDO_VALGRIND_NOLOG=$<TARGET_FILE:pseudonl_valgrind> @@ -209,6 +211,7 @@ add_RunCMake_test(DisallowedCommands) if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(ExportCompileCommands) endif() +add_RunCMake_test(ExcludeFromAll) add_RunCMake_test(ExternalData) add_RunCMake_test(FeatureSummary) add_RunCMake_test(FPHSA) @@ -235,6 +238,9 @@ add_RunCMake_test(GenEx-GENEX_EVAL) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorInstance) add_RunCMake_test(GeneratorPlatform) +if(XCODE_VERSION) + set(GeneratorToolset_ARGS -DXCODE_VERSION=${XCODE_VERSION}) +endif() add_RunCMake_test(GeneratorToolset) add_RunCMake_test(GetPrerequisites) add_RunCMake_test(GNUInstallDirs -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}) @@ -290,6 +296,7 @@ add_RunCMake_test(add_dependencies) add_RunCMake_test(add_executable) add_RunCMake_test(add_library) add_RunCMake_test(add_subdirectory) +add_RunCMake_test(add_test) add_RunCMake_test(build_command) add_executable(exit_code exit_code.c) set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>) @@ -301,9 +308,14 @@ add_RunCMake_test(export) add_RunCMake_test(cmake_language) add_RunCMake_test(cmake_minimum_required) add_RunCMake_test(cmake_parse_arguments) +# add_RunCMake_test(cmake_path) add_RunCMake_test(continue) add_executable(color_warning color_warning.c) -add_RunCMake_test(ctest_build -DCOLOR_WARNING=$<TARGET_FILE:color_warning>) +add_executable(fake_build_command fake_build_command.c) +add_RunCMake_test(ctest_build + -DCOLOR_WARNING=$<TARGET_FILE:color_warning> + -DFAKE_BUILD_COMMAND_EXE=$<TARGET_FILE:fake_build_command> +) add_RunCMake_test(ctest_cmake_error) add_RunCMake_test(ctest_configure) if(COVERAGE_COMMAND) @@ -318,6 +330,7 @@ add_RunCMake_test(ctest_update) add_RunCMake_test(ctest_upload) add_RunCMake_test(ctest_fixtures) add_RunCMake_test(file) +add_RunCMake_test(file-CHMOD) add_RunCMake_test(find_file) add_RunCMake_test(find_library -DCYGWIN=${CYGWIN}) add_RunCMake_test(find_package) @@ -381,6 +394,7 @@ function(add_RunCMake_test_try_compile) CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_STANDARD_DEFAULT CMake_TEST_CUDA + CMake_TEST_ISPC CMake_TEST_FILESYSTEM_1S CMAKE_OBJC_STANDARD_DEFAULT CMAKE_OBJCXX_STANDARD_DEFAULT @@ -391,7 +405,7 @@ function(add_RunCMake_test_try_compile) endforeach() add_RunCMake_test(try_compile) set_property(TEST RunCMake.try_compile APPEND - PROPERTY LABELS "CUDA") + PROPERTY LABELS "CUDA;ISPC") endfunction() add_RunCMake_test_try_compile() @@ -403,11 +417,12 @@ add_RunCMake_test(while) add_RunCMake_test(CMP0004) add_RunCMake_test(TargetPolicies) add_RunCMake_test(alias_targets) -add_RunCMake_test(interface_library) +add_RunCMake_test(InterfaceLibrary) add_RunCMake_test(no_install_prefix) add_RunCMake_test(configure_file) add_RunCMake_test(CTestTimeout -DTIMEOUT=${CTestTestTimeout_TIME}) add_RunCMake_test(CTestTimeoutAfterMatch) +add_RunCMake_test(DependencyGraph -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}) # ctresalloc links against CMakeLib and CTestLib, which means it can't be built # if CMake_TEST_EXTERNAL_CMAKE is activated (the compiler might be different.) @@ -523,14 +538,29 @@ add_RunCMake_test(target_compile_features) add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test(target_include_directories) add_RunCMake_test(target_sources) +add_RunCMake_test(CheckCompilerFlag -DCMake_TEST_CUDA=${CMake_TEST_CUDA} + -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) +add_RunCMake_test(CheckSourceCompiles -DCMake_TEST_CUDA=${CMake_TEST_CUDA} + -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) +add_RunCMake_test(CheckSourceRuns -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) +set_property(TEST RunCMake.CheckCompilerFlag + RunCMake.CheckSourceCompiles + RunCMake.CheckSourceRuns + APPEND PROPERTY LABELS "CUDA") +set_property(TEST RunCMake.CheckSourceCompiles + RunCMake.CheckCompilerFlag + APPEND PROPERTY LABELS "ISPC") add_RunCMake_test(CheckModules) add_RunCMake_test(CheckIPOSupported) if (CMAKE_SYSTEM_NAME MATCHES "(Linux|Darwin)" AND (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "GNU")) add_RunCMake_test(CheckLinkerFlag -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} - -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID} + -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + set_property(TEST RunCMake.CheckLinkerFlag APPEND PROPERTY LABELS "CUDA") endif() + add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCYGWIN=${CYGWIN} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) add_RunCMake_test(CommandLineTar) @@ -545,7 +575,10 @@ add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG=${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG} -DCMAKE_EXECUTABLE_FORMAT=${CMAKE_EXECUTABLE_FORMAT} + -DCMake_TEST_ISPC=${CMake_TEST_ISPC} ) +set_property(TEST RunCMake.install APPEND + PROPERTY LABELS "ISPC") add_RunCMake_test(file-GET_RUNTIME_DEPENDENCIES -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} @@ -555,6 +588,9 @@ add_RunCMake_test(file-GET_RUNTIME_DEPENDENCIES add_RunCMake_test(CPackCommandLine) add_RunCMake_test(CPackConfig) add_RunCMake_test(CPackInstallProperties) +if(XCODE_VERSION) + set(ExternalProject_ARGS -DXCODE_VERSION=${XCODE_VERSION}) +endif() add_RunCMake_test(ExternalProject) add_RunCMake_test(FetchContent) set(CTestCommandLine_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) @@ -623,6 +659,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") if(DEFINED CMake_TEST_CUDA) list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) endif() + if(DEFINED CMake_TEST_ISPC) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) + endif() if(CMAKE_Fortran_COMPILER) list(APPEND CompilerLauncher_ARGS -DCMake_TEST_Fortran=1) endif() @@ -631,8 +670,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") endif() add_RunCMake_test(CompilerLauncher) set_property(TEST RunCMake.CompilerLauncher APPEND - PROPERTY LABELS "CUDA") + PROPERTY LABELS "CUDA;ISPC") add_RunCMake_test(ctest_labels_for_subprojects) + add_RunCMake_test(CompilerArgs) endif() set(cpack_tests @@ -698,8 +738,8 @@ add_RunCMake_test(AutoExportDll add_RunCMake_test(AndroidMK) if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN) - if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja") - message(FATAL_ERROR "Android tests supported only by Makefile and Ninja generators") + if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja|Visual Studio 1[456]") + message(FATAL_ERROR "Android tests supported only by Makefile, Ninja, and Visual Studio >= 14 generators") endif() foreach(v TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN) if(CMake_${v}) @@ -725,5 +765,12 @@ endif() add_RunCMake_test("CTestCommandExpandLists") -add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) +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 -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA}) + +if(WIN32) + add_RunCMake_test(Win32GenEx) +endif() diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyDefault-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt +++ b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyDefault-result.txt diff --git a/Tests/RunCMake/CMakePresets/ArchToolsetStrategyDefault-stderr.txt b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyDefault-stderr.txt new file mode 100644 index 000000000..a3b79b638 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyDefault-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/ArchToolsetStrategyIgnore.cmake b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyIgnore.cmake new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyIgnore.cmake diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyNone-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt +++ b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyNone-result.txt diff --git a/Tests/RunCMake/CMakePresets/ArchToolsetStrategyNone-stderr.txt b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyNone-stderr.txt new file mode 100644 index 000000000..a3b79b638 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ArchToolsetStrategyNone-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 000000000..67c2d48d0 --- /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 000000000..54e41403e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CMakePresets.json.in @@ -0,0 +1,504 @@ +/* + * 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_BOOL_TRUE": true, + "TEST_BOOL_FALSE": false, + "TEST_TYPED_BOOL_TRUE": { + "type": "STRING", + "value": true + }, + "TEST_TYPED_BOOL_FALSE": { + "type": "STRING", + "value": false + }, + "TEST_UNTYPED_BOOL_TRUE": { + "value": true + }, + "TEST_UNTYPED_BOOL_FALSE": { + "value": false + }, + "TEST_PRESET_NAME": { + "type": "STRING", + "value": "x${presetName}x" + }, + "TEST_GENERATOR": { + "value": "x${generator}x" + }, + "TEST_DOLLAR": { + "value": "${dollar}" + }, + "TEST_SOURCE_DIR_NAME": "${sourceDirName}", + "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": "GoodNoSCachePrep", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceParentDir}/GoodNoSCachePrep-build" + }, + { + "name": "GoodNoSCache", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "GoodNoSourceArg", + "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": "VendorMacro", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "$vendor{unknown.unknownMacro}" + }, + { + "name": "InvalidGenerator", + "generator": "Invalid Generator", + "binaryDir": "${sourceDir}/build" + }, + { + "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": "ArchToolsetStrategyNone", + "generator": "@RunCMake_GENERATOR@", + "architecture": "a", + "toolset": "a", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "ArchToolsetStrategyBase", + "generator": "@RunCMake_GENERATOR@", + "architecture": { + "value": "a", + "strategy": "external" + }, + "toolset": { + "value": "a", + "strategy": "external" + }, + "binaryDir": "${sourceDir}/build" + }, + { + "name": "ArchToolsetStrategyDefault", + "inherits": "ArchToolsetStrategyBase", + "architecture": { + "strategy": "set" + }, + "toolset": { + "strategy": "set" + } + }, + { + "name": "ArchToolsetStrategyIgnore", + "inherits": "ArchToolsetStrategyBase" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/CacheOverride.cmake b/Tests/RunCMake/CMakePresets/CacheOverride.cmake new file mode 100644 index 000000000..d0ebe1754 --- /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/interface_library/IMPORTED_LIBNAME-non-imported-result.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance0-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-result.txt +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance0-result.txt diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance0-stderr.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance0-stderr.txt new file mode 100644 index 000000000..895afcb97 --- /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 000000000..346893688 --- /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/interface_library/add_custom_command-TARGET-result.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance1-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/add_custom_command-TARGET-result.txt +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance1-result.txt diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance1-stderr.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance1-stderr.txt new file mode 100644 index 000000000..1e59e92ed --- /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 000000000..fabd4af75 --- /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/interface_library/global-interface-result.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance2-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/global-interface-result.txt +++ b/Tests/RunCMake/CMakePresets/CyclicInheritance2-result.txt diff --git a/Tests/RunCMake/CMakePresets/CyclicInheritance2-stderr.txt b/Tests/RunCMake/CMakePresets/CyclicInheritance2-stderr.txt new file mode 100644 index 000000000..56e630b52 --- /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 000000000..0e1d7d418 --- /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 000000000..7fdb8b377 --- /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 000000000..7d1f388de --- /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 000000000..19c7db282 --- /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 000000000..500700eda --- /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 000000000..870f31c59 --- /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 000000000..5de76879a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DisableWarningFlags.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/WarningsBase.cmake) diff --git a/Tests/RunCMake/CMakePresets/DocumentationExample.cmake b/Tests/RunCMake/CMakePresets/DocumentationExample.cmake new file mode 100644 index 000000000..d459e9e23 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/DocumentationExample.cmake @@ -0,0 +1,5 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(FIRST_CACHE_VARIABLE "BOOL" "OFF") +test_variable(SECOND_CACHE_VARIABLE "UNINITIALIZED" "ON") +test_environment_variable(MY_ENVIRONMENT_VARIABLE "Test") diff --git a/Tests/RunCMake/interface_library/invalid_name-result.txt b/Tests/RunCMake/CMakePresets/DuplicatePresets-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/invalid_name-result.txt +++ b/Tests/RunCMake/CMakePresets/DuplicatePresets-result.txt diff --git a/Tests/RunCMake/CMakePresets/DuplicatePresets-stderr.txt b/Tests/RunCMake/CMakePresets/DuplicatePresets-stderr.txt new file mode 100644 index 000000000..c9361aea5 --- /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 000000000..cf388e73f --- /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/interface_library/invalid_signature-result.txt b/Tests/RunCMake/CMakePresets/EmptyCacheKey-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/invalid_signature-result.txt +++ b/Tests/RunCMake/CMakePresets/EmptyCacheKey-result.txt diff --git a/Tests/RunCMake/CMakePresets/EmptyCacheKey-stderr.txt b/Tests/RunCMake/CMakePresets/EmptyCacheKey-stderr.txt new file mode 100644 index 000000000..749d306de --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyCacheKey-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/EmptyCacheKey: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/EmptyCacheKey.json.in b/Tests/RunCMake/CMakePresets/EmptyCacheKey.json.in new file mode 100644 index 000000000..ea9c9e47a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyCacheKey.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "EmptyCacheKey", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "": "value" + } + } + ] +} diff --git a/Tests/RunCMake/interface_library/target_commands-result.txt b/Tests/RunCMake/CMakePresets/EmptyEnv-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/target_commands-result.txt +++ b/Tests/RunCMake/CMakePresets/EmptyEnv-result.txt diff --git a/Tests/RunCMake/CMakePresets/EmptyEnv-stderr.txt b/Tests/RunCMake/CMakePresets/EmptyEnv-stderr.txt new file mode 100644 index 000000000..723ac2161 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyEnv-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/EmptyEnv: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/EmptyEnv.json.in b/Tests/RunCMake/CMakePresets/EmptyEnv.json.in new file mode 100644 index 000000000..ef0d5758b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyEnv.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "EmptyEnv", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "MY_VAR": "$env{}" + } + } + ] +} diff --git a/Tests/RunCMake/interface_library/whitelist-result.txt b/Tests/RunCMake/CMakePresets/EmptyEnvKey-result.txt index d00491fd7..d00491fd7 100644 --- a/Tests/RunCMake/interface_library/whitelist-result.txt +++ b/Tests/RunCMake/CMakePresets/EmptyEnvKey-result.txt diff --git a/Tests/RunCMake/CMakePresets/EmptyEnvKey-stderr.txt b/Tests/RunCMake/CMakePresets/EmptyEnvKey-stderr.txt new file mode 100644 index 000000000..365f537dc --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyEnvKey-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/EmptyEnvKey: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/EmptyEnvKey.json.in b/Tests/RunCMake/CMakePresets/EmptyEnvKey.json.in new file mode 100644 index 000000000..d87c15907 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyEnvKey.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "EmptyEnvKey", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "environment": { + "": "value" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/EmptyPenv-result.txt b/Tests/RunCMake/CMakePresets/EmptyPenv-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyPenv-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/EmptyPenv-stderr.txt b/Tests/RunCMake/CMakePresets/EmptyPenv-stderr.txt new file mode 100644 index 000000000..880cee651 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyPenv-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/EmptyPenv: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/EmptyPenv.json.in b/Tests/RunCMake/CMakePresets/EmptyPenv.json.in new file mode 100644 index 000000000..9081fe513 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EmptyPenv.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "EmptyPenv", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "MY_VAR": "$penv{}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/EmptyPresetName-result.txt b/Tests/RunCMake/CMakePresets/EmptyPresetName-result.txt new file mode 100644 index 000000000..d00491fd7 --- /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 000000000..6970674c7 --- /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 000000000..fd4bedd75 --- /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 000000000..d00491fd7 --- /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 000000000..1d22b8723 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EnvCycle-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/EnvCycle: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/EnvCycle.json.in b/Tests/RunCMake/CMakePresets/EnvCycle.json.in new file mode 100644 index 000000000..25a134965 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/EnvCycle.json.in @@ -0,0 +1,14 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "EnvCycle", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "environment": { + "ENV_1": "$env{ENV_2}", + "ENV_2": "$env{ENV_1}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/ErrorDeprecated-result.txt b/Tests/RunCMake/CMakePresets/ErrorDeprecated-result.txt new file mode 100644 index 000000000..d00491fd7 --- /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 000000000..964a5042f --- /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 000000000..5de76879a --- /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 000000000..d00491fd7 --- /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 000000000..f76478c6d --- /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 000000000..5de76879a --- /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 000000000..d00491fd7 --- /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 000000000..322134549 --- /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 000000000..664b3eece --- /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 000000000..d00491fd7 --- /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 000000000..d2ddb900d --- /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 000000000..d681b2a28 --- /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 000000000..d00491fd7 --- /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 000000000..559e3c2bd --- /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 000000000..b52975842 --- /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 000000000..d00491fd7 --- /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 000000000..bb281beed --- /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 000000000..bcfa68b19 --- /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 000000000..d00491fd7 --- /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 000000000..9b346e78e --- /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 000000000..a8105603e --- /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 000000000..75003c770 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Good-stdout.txt @@ -0,0 +1,53 @@ +Preset CMake variables: + + TEST_BOOL_FALSE:BOOL="FALSE" + TEST_BOOL_TRUE:BOOL="TRUE" + 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_DIR_NAME="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" + TEST_TYPED_BOOL_FALSE:STRING="FALSE" + TEST_TYPED_BOOL_TRUE:STRING="TRUE" + TEST_UNTYPED_BOOL_FALSE="FALSE" + TEST_UNTYPED_BOOL_TRUE="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 000000000..73a618d54 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Good.cmake @@ -0,0 +1,52 @@ +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_BOOL_TRUE "BOOL" "TRUE") +test_variable(TEST_BOOL_FALSE "BOOL" "FALSE") +test_variable(TEST_TYPED_BOOL_TRUE "STRING" "TRUE") +test_variable(TEST_TYPED_BOOL_FALSE "STRING" "FALSE") +test_variable(TEST_UNTYPED_BOOL_TRUE "UNINITIALIZED" "TRUE") +test_variable(TEST_UNTYPED_BOOL_FALSE "UNINITIALIZED" "FALSE") +test_variable(TEST_PRESET_NAME "STRING" "xGoodx") +test_variable(TEST_GENERATOR "UNINITIALIZED" "x${CMAKE_GENERATOR}x") +test_variable(TEST_DOLLAR "UNINITIALIZED" "$") +test_variable(TEST_SOURCE_DIR_NAME "UNINITIALIZED" "Good") +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 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodBOM.cmake diff --git a/Tests/RunCMake/CMakePresets/GoodBOM.json.in b/Tests/RunCMake/CMakePresets/GoodBOM.json.in new file mode 100644 index 000000000..2152511a7 --- /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 000000000..9f928fe74 --- /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 000000000..49e7a2550 --- /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 000000000..f7fb2244b --- /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 000000000..4319e7216 --- /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 000000000..cfc93be55 --- /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 000000000..96fede094 --- /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 000000000..6430f4d9d --- /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 000000000..49e7a2550 --- /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 000000000..52318039c --- /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 000000000..cfc93be55 --- /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 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodNoArgs.cmake diff --git a/Tests/RunCMake/CMakePresets/GoodNoS.cmake b/Tests/RunCMake/CMakePresets/GoodNoS.cmake new file mode 100644 index 000000000..49e7a2550 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodNoS.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/GoodNoSCache.cmake b/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake new file mode 100644 index 000000000..df58e72e4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodNoSCache.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}/GoodNoSCachePrep-build") diff --git a/Tests/RunCMake/CMakePresets/GoodNoSCachePrep.cmake b/Tests/RunCMake/CMakePresets/GoodNoSCachePrep.cmake new file mode 100644 index 000000000..df58e72e4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodNoSCachePrep.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}/GoodNoSCachePrep-build") diff --git a/Tests/RunCMake/CMakePresets/GoodNoSourceArg.cmake b/Tests/RunCMake/CMakePresets/GoodNoSourceArg.cmake new file mode 100644 index 000000000..49e7a2550 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodNoSourceArg.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/GoodSpaces.cmake b/Tests/RunCMake/CMakePresets/GoodSpaces.cmake new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodSpaces.cmake diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromMain.cmake b/Tests/RunCMake/CMakePresets/GoodUserFromMain.cmake new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserFromMain.cmake diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromMain.json.in b/Tests/RunCMake/CMakePresets/GoodUserFromMain.json.in new file mode 100644 index 000000000..348443e0c --- /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 000000000..77b4ef624 --- /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 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserFromUser.cmake diff --git a/Tests/RunCMake/CMakePresets/GoodUserFromUser.json.in b/Tests/RunCMake/CMakePresets/GoodUserFromUser.json.in new file mode 100644 index 000000000..77b4ef624 --- /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 000000000..83196bed9 --- /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 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodUserOnly.cmake diff --git a/Tests/RunCMake/CMakePresets/GoodUserOnlyUser.json.in b/Tests/RunCMake/CMakePresets/GoodUserOnlyUser.json.in new file mode 100644 index 000000000..274f4c797 --- /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 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodWindowsBackslash.cmake diff --git a/Tests/RunCMake/CMakePresets/HighVersion-result.txt b/Tests/RunCMake/CMakePresets/HighVersion-result.txt new file mode 100644 index 000000000..d00491fd7 --- /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 000000000..d8622f212 --- /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 000000000..81078424e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HighVersion.json.in @@ -0,0 +1,4 @@ +{ + "version": 1000, + "configurePresets": [] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy-result.txt b/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy-stderr.txt new file mode 100644 index 000000000..4a4d4ce70 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy.json.in b/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy.json.in new file mode 100644 index 000000000..9ec2cee2e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidArchitectureStrategy.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidArchitectureStrategy", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": { + "strategy": {} + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidGenerator-result.txt b/Tests/RunCMake/CMakePresets/InvalidGenerator-result.txt new file mode 100644 index 000000000..d00491fd7 --- /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 000000000..c7dd19b15 --- /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 000000000..d00491fd7 --- /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 000000000..c7dd19b15 --- /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 000000000..d00491fd7 --- /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 000000000..97f387673 --- /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 000000000..77bd9a37a --- /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 000000000..d00491fd7 --- /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 000000000..2fe8c66e9 --- /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 000000000..2bb95d9c7 --- /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 000000000..d00491fd7 --- /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 000000000..95728752f --- /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 000000000..95e6e65b2 --- /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 000000000..d00491fd7 --- /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 000000000..8f6ff7c1d --- /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 000000000..08361da50 --- /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 000000000..d00491fd7 --- /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 000000000..89a424ab9 --- /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 000000000..2a5d9ba7c --- /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 000000000..d00491fd7 --- /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 000000000..2b0f5603e --- /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 000000000..facfd57c1 --- /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 000000000..d00491fd7 --- /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 000000000..e5c434d9b --- /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 000000000..fe51488c7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidRoot.json.in @@ -0,0 +1 @@ +[] diff --git a/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy-result.txt b/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy-stderr.txt new file mode 100644 index 000000000..fab376620 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy.json.in b/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy.json.in new file mode 100644 index 000000000..7d2ab1f35 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidToolsetStrategy.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "InvalidToolsetStrategy", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "toolset": { + "strategy": {} + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/InvalidVariableValue-result.txt b/Tests/RunCMake/CMakePresets/InvalidVariableValue-result.txt new file mode 100644 index 000000000..d00491fd7 --- /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 000000000..0ab07c3d0 --- /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 000000000..55c7644dd --- /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 000000000..d00491fd7 --- /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 000000000..6d9102a14 --- /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 000000000..30dcaf0ae --- /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 000000000..d00491fd7 --- /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 000000000..af923f0ba --- /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 000000000..2315b7298 --- /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 000000000..d00491fd7 --- /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 000000000..7e0fcfdd2 --- /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 000000000..e6e19bc6e --- /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 000000000..d00491fd7 --- /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 000000000..a43bf77be --- /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 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/JSONParseError.json.in diff --git a/Tests/RunCMake/CMakePresets/ListPresets-stdout.txt b/Tests/RunCMake/CMakePresets/ListPresets-stdout.txt new file mode 100644 index 000000000..1758f334d --- /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 000000000..2ef3797da --- /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": "$vendor{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 000000000..d00491fd7 --- /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 000000000..140381422 --- /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 000000000..1758f334d --- /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 000000000..d00491fd7 --- /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 000000000..eea1b99c1 --- /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 000000000..1758f334d --- /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 000000000..1758f334d --- /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 000000000..d00491fd7 --- /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 000000000..92b3723e1 --- /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 000000000..e03afa998 --- /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 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.cmake diff --git a/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.json.in b/Tests/RunCMake/CMakePresets/MinimumRequiredEmpty.json.in new file mode 100644 index 000000000..37740ef6a --- /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 000000000..d00491fd7 --- /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 000000000..6548cafe2 --- /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 000000000..da7960311 --- /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 000000000..d00491fd7 --- /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 000000000..6036fe3ae --- /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 000000000..a17cdf6a4 --- /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 000000000..d00491fd7 --- /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 000000000..bdee4cdeb --- /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 000000000..33a88164f --- /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 000000000..d00491fd7 --- /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 000000000..b5d3a393f --- /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 000000000..4a53f8dcc --- /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 000000000..d00491fd7 --- /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 000000000..c807ffc98 --- /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 000000000..c23ab89f2 --- /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 000000000..f2b3d4aea --- /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 000000000..d00491fd7 --- /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 000000000..aef30d2af --- /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 000000000..d00491fd7 --- /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 000000000..b525fc322 --- /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 000000000..8989cfd18 --- /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 000000000..d00491fd7 --- /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 000000000..6c0c9f77a --- /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 000000000..74f83b7e4 --- /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 000000000..d00491fd7 --- /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 000000000..0ee338a36 --- /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 000000000..373591dcd --- /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 000000000..d00491fd7 --- /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 000000000..5ff3d3339 --- /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 000000000..cb01a02df --- /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 000000000..61a2092b1 --- /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 000000000..d00491fd7 --- /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 000000000..7dafe623d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoSuchMacro-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/NoSuchMacro: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/NoSuchMacro.json.in b/Tests/RunCMake/CMakePresets/NoSuchMacro.json.in new file mode 100644 index 000000000..94d0b764b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoSuchMacro.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "NoSuchMacro", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${noexist}" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/NoSuchPreset-result.txt b/Tests/RunCMake/CMakePresets/NoSuchPreset-result.txt new file mode 100644 index 000000000..d00491fd7 --- /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 000000000..9a2d0d5bd --- /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 000000000..d00491fd7 --- /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 000000000..cdab32f7b --- /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 000000000..482700de5 --- /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 000000000..d00491fd7 --- /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 000000000..d4f07e499 --- /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 000000000..3fe8332e4 --- /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 000000000..a16d362f0 --- /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 000000000..5de76879a --- /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 000000000..d00491fd7 --- /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 000000000..6604a14c0 --- /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 000000000..d5892fc6d --- /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 000000000..1ffda3d62 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -0,0 +1,272 @@ +cmake_minimum_required(VERSION 3.19) # CMP0053 + +include(RunCMake) + +# Fix Visual Studio generator name +if(RunCMake_GENERATOR MATCHES "^(Visual Studio [0-9]+ [0-9]+) ") + set(RunCMake_GENERATOR "${CMAKE_MATCH_1}") +endif() + +set(RunCMake-check-file check.cmake) + +function(validate_schema file expected_result) + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" "${RunCMake_SOURCE_DIR}/validate_schema.py" "${file}" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _output + ERROR_VARIABLE _error + ) + if(NOT _result STREQUAL expected_result) + string(REPLACE "\n" "\n" _output_p "${_output}") + string(REPLACE "\n" "\n" _error_p "${_error}") + string(APPEND RunCMake_TEST_FAILED "Expected result of validating ${file}: ${expected_result}\nActual result: ${_result}\nOutput:\n${_output_p}\nError:\n${_error_p}") + endif() + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +function(run_cmake_presets name) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}") + set(_source_arg "${RunCMake_TEST_SOURCE_DIR}") + if(CMakePresets_SOURCE_ARG) + set(_source_arg "${CMakePresets_SOURCE_ARG}") + 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 +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +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) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +run_cmake_presets(NoPresets) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_presets(InvalidPresets) +run_cmake_presets(PresetNotObject) +run_cmake_presets(NoPresetName) +run_cmake_presets(InvalidPresetName) +run_cmake_presets(EmptyPresetName) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +run_cmake_presets(NoPresetGenerator) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_presets(InvalidPresetGenerator) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +run_cmake_presets(NoPresetBinaryDir) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +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) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +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) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_presets(InvalidArchitectureStrategy) +run_cmake_presets(UnknownArchitectureStrategy) +run_cmake_presets(InvalidToolsetStrategy) +run_cmake_presets(UnknownToolsetStrategy) +run_cmake_presets(EmptyCacheKey) +run_cmake_presets(EmptyEnvKey) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +run_cmake_presets(UnclosedMacro) +run_cmake_presets(NoSuchMacro) +run_cmake_presets(EnvCycle) +run_cmake_presets(EmptyEnv) +run_cmake_presets(EmptyPenv) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) + +# Test cmakeMinimumRequired field +run_cmake_presets(MinimumRequiredInvalid) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +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_SOURCE_ARG "../GoodBinaryRelative") +run_cmake_presets(GoodBinaryRelative) +unset(CMakePresets_SOURCE_ARG) +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) +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/GoodNoSCachePrep-build") +run_cmake_presets(GoodNoSCachePrep) +set(CMakePresets_SOURCE_ARG ".") +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_presets(GoodNoSCache) +unset(RunCMake_TEST_NO_CLEAN) +unset(CMakePresets_SOURCE_ARG) +unset(RunCMake_TEST_BINARY_DIR) +unset(CMakePresets_NO_S_ARG) +set(CMakePresets_NO_SOURCE_ARGS 1) +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/GoodNoSourceArg") +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_presets(GoodNoSourceArg) +unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_TEST_BINARY_DIR) +unset(CMakePresets_NO_SOURCE_ARGS) +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(VendorMacro) +run_cmake_presets(InvalidGenerator) + +# 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(ArchToolsetStrategyNone) + run_cmake_presets(ArchToolsetStrategyDefault) + run_cmake_presets(ArchToolsetStrategyIgnore) +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) + +# Test the example from the documentation +file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example) +string(REPLACE "\"generator\": \"Ninja\"" "\"generator\": \"@RunCMake_GENERATOR@\"" _example "${_example}") +file(WRITE "${RunCMake_BINARY_DIR}/example.json.in" "${_example}") +set(CMakePresets_FILE "${RunCMake_BINARY_DIR}/example.json.in") +run_cmake_presets(DocumentationExample --preset=default) diff --git a/Tests/RunCMake/CMakePresets/TestVariable.cmake b/Tests/RunCMake/CMakePresets/TestVariable.cmake new file mode 100644 index 000000000..934af5274 --- /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 000000000..d00491fd7 --- /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 000000000..f9481f091 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnclosedMacro-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/UnclosedMacro: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/UnclosedMacro.json.in b/Tests/RunCMake/CMakePresets/UnclosedMacro.json.in new file mode 100644 index 000000000..ad6cf7dc9 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnclosedMacro.json.in @@ -0,0 +1,10 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UnclosedMacro", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy-result.txt b/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy-stderr.txt b/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy-stderr.txt new file mode 100644 index 000000000..cf17881d7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy.json.in b/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy.json.in new file mode 100644 index 000000000..a3bf7c814 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownArchitectureStrategy.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UnknownArchitectureStrategy", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": { + "strategy": "unknown" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy-result.txt b/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy-stderr.txt b/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy-stderr.txt new file mode 100644 index 000000000..8f9be2998 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy: Invalid preset$ diff --git a/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy.json.in b/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy.json.in new file mode 100644 index 000000000..166870073 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/UnknownToolsetStrategy.json.in @@ -0,0 +1,13 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "UnknownToolsetStrategy", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "toolset": { + "strategy": "unknown" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/UseHiddenPreset-result.txt b/Tests/RunCMake/CMakePresets/UseHiddenPreset-result.txt new file mode 100644 index 000000000..d00491fd7 --- /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 000000000..45b4cd4ac --- /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 000000000..d00491fd7 --- /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 000000000..125265f0a --- /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 000000000..172cfbaba --- /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 000000000..172cfbaba --- /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 000000000..d00491fd7 --- /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 000000000..1071b1775 --- /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 000000000..365fafe07 --- /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 000000000..d00491fd7 --- /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 000000000..213215a41 --- /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 000000000..d9973d72b --- /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 000000000..1321a734f --- /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 000000000..d00491fd7 --- /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 000000000..8cacb0a26 --- /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 000000000..51298f525 --- /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 000000000..d00491fd7 --- /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 000000000..2e9801909 --- /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 000000000..d00491fd7 --- /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 000000000..a3113210a --- /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 000000000..d485ab384 --- /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 000000000..d485ab384 --- /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 000000000..d485ab384 --- /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 000000000..d485ab384 --- /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 000000000..d485ab384 --- /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 000000000..722e976b6 --- /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 000000000..722e976b6 --- /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 000000000..a1c61b49c --- /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 000000000..b3464d69e --- /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 000000000..b3464d69e --- /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 000000000..6e488a9d1 --- /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 000000000..5de76879a --- /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 000000000..40ec6ce44 --- /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 000000000..1a434dc25 --- /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/check.cmake b/Tests/RunCMake/CMakePresets/check.cmake new file mode 100644 index 000000000..bf43c7ea3 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/check.cmake @@ -0,0 +1,15 @@ +if(PYTHON_EXECUTABLE AND CMake_TEST_JSON_SCHEMA) + if(NOT CMakePresets_SCHEMA_EXPECTED_RESULT) + set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) + endif() + if(EXISTS "${RunCMake_TEST_SOURCE_DIR}/CMakePresets.json") + validate_schema("${RunCMake_TEST_SOURCE_DIR}/CMakePresets.json" "${CMakePresets_SCHEMA_EXPECTED_RESULT}") + endif() + + if(NOT CMakeUserPresets_SCHEMA_EXPECTED_RESULT) + set(CMakeUserPresets_SCHEMA_EXPECTED_RESULT 0) + endif() + if(EXISTS "${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json") + validate_schema("${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json" "${CMakeUserPresets_SCHEMA_EXPECTED_RESULT}") + endif() +endif() diff --git a/Tests/RunCMake/CMakePresets/main.c b/Tests/RunCMake/CMakePresets/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/CMakePresets/validate_schema.py b/Tests/RunCMake/CMakePresets/validate_schema.py new file mode 100644 index 000000000..c9f84ee17 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/validate_schema.py @@ -0,0 +1,17 @@ +import jsmin +import json +import jsonschema +import os.path +import sys + + +with open(sys.argv[1], "rb") as f: + contents = json.loads(jsmin.jsmin(f.read().decode("utf-8-sig"))) + +schema_file = os.path.join( + os.path.dirname(__file__), + "..", "..", "..", "Help", "manual", "presets", "schema.json") +with open(schema_file) as f: + schema = json.load(f) + +jsonschema.validate(contents, schema) diff --git a/Tests/RunCMake/CPack/DragNDrop/Accept.txt b/Tests/RunCMake/CPack/DragNDrop/Accept.txt new file mode 100644 index 000000000..975fbec82 --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/Accept.txt @@ -0,0 +1 @@ +y diff --git a/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake b/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake index 023e597ad..896fba7c2 100644 --- a/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake +++ b/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake @@ -5,6 +5,7 @@ function(getPackageContent FILE RESULT_VAR) file(REMOVE_RECURSE "${path_}/content") file(MAKE_DIRECTORY "${path_}/content") execute_process(COMMAND ${HDIUTIL_EXECUTABLE} attach -mountroot ${path_}/content -nobrowse ${FILE} + INPUT_FILE "${src_dir}/DragNDrop/Accept.txt" RESULT_VARIABLE attach_result_ ERROR_VARIABLE attach_error_ OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/Tests/RunCMake/CPack/DragNDrop/packaging_MONOLITHIC_default.cmake b/Tests/RunCMake/CPack/DragNDrop/packaging_MONOLITHIC_default.cmake new file mode 100644 index 000000000..ca278907c --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/packaging_MONOLITHIC_default.cmake @@ -0,0 +1,2 @@ +set(CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK ON) +set(CPACK_DMG_VOLUME_NAME "volume-name") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 064b4dca6..530bcdf5a 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -10,6 +10,7 @@ run_cpack_test(DEBUGINFO "RPM.DEBUGINFO;DEB.DEBUGINFO" true "COMPONENT") run_cpack_test_subtests(DEFAULT_PERMISSIONS "CMAKE_var_set;CPACK_var_set;both_set;invalid_CMAKE_var;invalid_CPACK_var" "RPM.DEFAULT_PERMISSIONS;DEB.DEFAULT_PERMISSIONS" false "MONOLITHIC;COMPONENT") run_cpack_test(DEPENDENCIES "RPM.DEPENDENCIES;DEB.DEPENDENCIES" true "COMPONENT") run_cpack_test(DIST "RPM.DIST" false "MONOLITHIC") +run_cpack_test(DMG_SLA "DragNDrop" false "MONOLITHIC") run_cpack_test(EMPTY_DIR "RPM.EMPTY_DIR;DEB.EMPTY_DIR;TGZ" true "MONOLITHIC;COMPONENT") run_cpack_test(VERSION "RPM.VERSION;DEB.VERSION" false "MONOLITHIC;COMPONENT") run_cpack_test(EXTRA "DEB.EXTRA" false "COMPONENT") @@ -46,3 +47,4 @@ run_cpack_test_subtests( "MONOLITHIC;COMPONENT" ) run_cpack_test(PROJECT_META "RPM.PROJECT_META;DEB.PROJECT_META" false "MONOLITHIC;COMPONENT") +run_cpack_test_package_target(PRE_POST_SCRIPTS "ZIP" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake index 70ad48b4b..6e841fc92 100644 --- a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake @@ -34,7 +34,7 @@ set(_expected_description [[ Description: This is the summary line This is the Debian package multiline description. . It must be formatted properly! Otherwise, the result `*.deb` - package become broken and cant be installed! + package become broken and cannot be installed! . It may contains `;` characters (even like this `;;;;`). Example: . diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake index 893eb0113..2a27b4622 100644 --- a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake @@ -5,7 +5,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is the summary line") set(_description [[This is the Debian package multiline description. It must be formatted properly! Otherwise, the result `*.deb` -package become broken and cant be installed! +package become broken and cannot be installed! It may contains `;` characters (even like this `;;;;`). Example: diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf b/Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf new file mode 100644 index 000000000..c1da71171 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf @@ -0,0 +1,7 @@ +{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}} +{\colortbl ;\red0\green0\blue255;} +{\*\generator Riched20 10.0.18362}\viewkind4\uc1 +\pard\sa200\sl276\slmult1\b\f0\fs22\lang9 LICENSE\b0\par +This is an installer created using CPack ({{\field{\*\fldinst{HYPERLINK https://cmake.org }}{\fldrslt{https://cmake.org\ul0\cf0}}}}\f0\fs22 ). No license provided.\par +\par +} diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA/English.menu.txt b/Tests/RunCMake/CPack/tests/DMG_SLA/English.menu.txt new file mode 100644 index 000000000..b2cbc2542 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA/English.menu.txt @@ -0,0 +1,9 @@ +English +Agree +Disagree +Print +Save... +You agree to the License Agreement terms when you click the "Agree" button. +Software License Agreement +This text cannot be saved. This disk may be full or locked or the file may be locked. +Unable to print. Make sure you have selected a printer. diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA/ExpectedFiles.cmake new file mode 100644 index 000000000..d1a3a5fb2 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt b/Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt new file mode 100644 index 000000000..0edd1f2c3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt @@ -0,0 +1,3 @@ +LIZENZ +------ +Dies ist ein Installationsprogramm, das mit erstellt wurde CPack (https://cmake.org). Keine Lizenz angegeben. diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt b/Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt new file mode 100644 index 000000000..77248183d --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt @@ -0,0 +1,9 @@ +German +Akzeptieren +Ablehnen +Drucken +Speichern... +Klicken Sie auf "Akzeptieren", wenn Sie mit den Bestimmungen des Software-Lizenzvertrages einverstanden sind. +Software-Lizenzvertrag +Dieser Text kann nicht gesichert werden. Diese Festplatte ist mšglicherweise voll oder geschŸtzt oder der Ordner ist geschŸtzt. +Es kann nicht gedruckt werden. Bitte stellen Sie sicher, dass ein Drucker ausgewŠhlt ist. diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA/VerifyResult.cmake new file mode 100644 index 000000000..010e14c73 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA/VerifyResult.cmake @@ -0,0 +1,33 @@ +set(dmg "${bin_dir}/${FOUND_FILE_1}") +execute_process(COMMAND hdiutil udifderez -xml "${dmg}" OUTPUT_VARIABLE out ERROR_VARIABLE err RESULT_VARIABLE res) +if(NOT res EQUAL 0) + string(REPLACE "\n" "\n " err " ${err}") + message(FATAL_ERROR "Running 'hdiutil udifderez -xml' on\n ${dmg}\nfailed with:\n${err}") +endif() +foreach(key "LPic" "STR#" "TEXT" "RTF ") + if(NOT out MATCHES "<key>${key}</key>") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${dmg}\ndid not show '${key}' key:\n${out}") + endif() +endforeach() +foreach(line + # LPic + "\tAAAAAgAAAAAAAAADAAEAAA==\n" + # STR# English first and last base64 lines + "\tAAkHRW5nbGlzaAVBZ3JlZQhEaXNhZ3JlZQVQcmludAdTYXZlLi4u\n" + "\tZCBhIHByaW50ZXIu\n" + # STR# German first and last base64 lines + "\tAAkGR2VybWFuC0FremVwdGllcmVuCEFibGVobmVuB0RydWNrZW4M\n" + "\tYXVzZ2V3wopobHQgaXN0Lg==\n" + # RTF English first and last base64 lines + "\te1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcbm91aWNvbXBh\n" + "\tdmlkZWQuXHBhcg1ccGFyDX0NDQ==\n" + # TEXT German first and last base64 lines + "\tTElaRU5aDS0tLS0tLQ1EaWVzIGlzdCBlaW4gSW5zdGFsbGF0aW9u\n" + "\tZ2ViZW4uDQ0=\n" + ) + if(NOT out MATCHES "${line}") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${dmg}\ndid not show '${line}':\n${out}") + endif() +endforeach() diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA/test.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA/test.cmake new file mode 100644 index 000000000..2804b0bb9 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA/test.cmake @@ -0,0 +1,3 @@ +install(FILES CMakeLists.txt DESTINATION foo) +set(CPACK_DMG_SLA_DIR "${CMAKE_CURRENT_LIST_DIR}") +set(CPACK_DMG_SLA_LANGUAGES English German) diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake index 6f7c4c224..3db80142f 100644 --- a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake @@ -29,3 +29,11 @@ expect_file(${CPACK_TEMPORARY_DIRECTORY}/f3/share/cpack-test/f3.txt) expect_file(${CPACK_TEMPORARY_DIRECTORY}/f4/share/cpack-test/f4.txt) message(STATUS "This status message is expected to be visible") + +set( + CPACK_EXTERNAL_BUILT_PACKAGES + ${CPACK_TEMPORARY_DIRECTORY}/f1/share/cpack-test/f1.txt + ${CPACK_TEMPORARY_DIRECTORY}/f2/share/cpack-test/f2.txt + ${CPACK_TEMPORARY_DIRECTORY}/f3/share/cpack-test/f3.txt + ${CPACK_TEMPORARY_DIRECTORY}/f4/share/cpack-test/f4.txt + ) diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt index 37d635fa4..587b2e810 100644 --- a/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt @@ -1 +1,11 @@ -- This status message is expected to be visible +CPack: - package: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/external-0\.1\.1-.*\.json generated\. +CPack: - checksum file: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/external-0\.1\.1-.*\.json\.sha1 generated\. +CPack: - package: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f1\.txt generated\. +CPack: - checksum file: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f1\.txt\.sha1 generated\. +CPack: - package: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f2\.txt generated\. +CPack: - checksum file: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f2\.txt\.sha1 generated\. +CPack: - package: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f3\.txt generated\. +CPack: - checksum file: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f3\.txt\.sha1 generated\. +CPack: - package: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f4\.txt generated\. +CPack: - checksum file: .*/Tests/RunCMake/External/CPack/EXTERNAL-build-stage_and_package-subtest/f4\.txt\.sha1 generated\. diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake index bc9766b15..d4781baad 100644 --- a/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake @@ -17,6 +17,7 @@ elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_bad") elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "stage_and_package") set(CPACK_EXTERNAL_ENABLE_STAGING 1) set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/create_package.cmake") + set(CPACK_PACKAGE_CHECKSUM SHA1) endif() file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" test1) diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ExpectedFiles.cmake new file mode 100644 index 000000000..63a36a36e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ExpectedFiles.cmake @@ -0,0 +1,19 @@ +set(SATU "/satu;/satu/CMakeLists.txt") +set(DUA "/dua;/dua/CMakeLists.txt") + +if(GENERATOR_TYPE STREQUAL ZIP) + set(_ext "zip") +elseif(GENERATOR_TYPE STREQUAL TGZ) + set(_ext "tar.gz") +endif() + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1 "*-satu.${_ext}") + set(EXPECTED_FILE_CONTENT_1_LIST ${SATU}) + set(EXPECTED_FILE_2 "*-dua.${_ext}") + set(EXPECTED_FILE_CONTENT_2_LIST ${DUA}) +else() + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST ${SATU} ${DUA}) +endif() diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_COMPONENT-stdout.txt b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_COMPONENT-stdout.txt new file mode 100644 index 000000000..319d0da14 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_COMPONENT-stdout.txt @@ -0,0 +1,4 @@ +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre\.cmake and generator ZIP +.* +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post\.cmake and generator ZIP +-- Built packages: .*/_CPack_Packages/.*/pre_post_scripts-.*-dua.zip;.*/_CPack_Packages/.*/pre_post_scripts-.*-satu.zip diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_MONOLITHIC-stdout.txt b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_MONOLITHIC-stdout.txt new file mode 100644 index 000000000..632c4d14c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_MONOLITHIC-stdout.txt @@ -0,0 +1,4 @@ +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre\.cmake and generator ZIP +.* +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post\.cmake and generator ZIP +-- Built packages: .*/_CPack_Packages/.*/pre_post_scripts-0\.1\.1-.*\.zip diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post.cmake new file mode 100644 index 000000000..cf0b1490f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post.cmake @@ -0,0 +1,2 @@ +message(STATUS "The message from ${CMAKE_CURRENT_LIST_FILE} and generator ${CPACK_GENERATOR}") +message(STATUS "Built packages: ${CPACK_PACKAGE_FILES}") diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre.cmake new file mode 100644 index 000000000..b04aa6bbf --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre.cmake @@ -0,0 +1 @@ +message(STATUS "The message from ${CMAKE_CURRENT_LIST_FILE} and generator ${CPACK_GENERATOR}") diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/test.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/test.cmake new file mode 100644 index 000000000..f1b6d5f8f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/test.cmake @@ -0,0 +1,9 @@ +install(FILES CMakeLists.txt DESTINATION satu COMPONENT satu) +install(FILES CMakeLists.txt DESTINATION dua COMPONENT dua) + +set(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/pre.cmake") +set(CPACK_POST_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/post.cmake") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL satu dua) +endif() diff --git a/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake index b3accb58f..35a93d6a4 100644 --- a/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake @@ -13,7 +13,7 @@ function(checkPackageURL FILE TAG EXPECTED_URL) endif() endforeach() if(NOT _seen_url) - message(FATAL_ERROR "The packge `${FILE}` do not have URL as expected") + message(FATAL_ERROR "The package `${FILE}` do not have URL as expected") endif() endfunction() diff --git a/Tests/RunCMake/CTest/CMakeLists.txt b/Tests/RunCMake/CTest/CMakeLists.txt index 73e6a785a..f1a83e8c4 100644 --- a/Tests/RunCMake/CTest/CMakeLists.txt +++ b/Tests/RunCMake/CTest/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) if(NOT NoProject) project(${RunCMake_TEST} NONE) endif() diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake index 761224a6d..ffc8f7893 100644 --- a/Tests/RunCMake/CTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake @@ -18,3 +18,23 @@ function(run_CMakeCTestArguments) run_cmake_command(CMakeCTestArguments-test ${CMAKE_COMMAND} --build . --config Debug --target "${test}") endfunction() run_CMakeCTestArguments() + +function(run_TestfileErrors) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestfileErrors-build) + run_cmake(TestfileErrors) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(TestfileErrors-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(TestfileErrors-test ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() +run_TestfileErrors() + +function(run_SingleConfig) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SingleConfig-build) + run_cmake(SingleConfig) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(SingleConfig-build ${CMAKE_COMMAND} --build .) + run_cmake_command(SingleConfig-test ${CMAKE_CTEST_COMMAND}) # No -C Debug required for single-config. +endfunction() +if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + run_SingleConfig() +endif() diff --git a/Tests/RunCMake/CTest/SingleConfig-test-stdout.txt b/Tests/RunCMake/CTest/SingleConfig-test-stdout.txt new file mode 100644 index 000000000..1c39ea156 --- /dev/null +++ b/Tests/RunCMake/CTest/SingleConfig-test-stdout.txt @@ -0,0 +1,8 @@ +^Test project [^ +]*/Tests/RunCMake/CTest/SingleConfig-build + Start 1: SingleConfig +1/1 Test #1: SingleConfig \.+ +Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/CTest/SingleConfig.cmake b/Tests/RunCMake/CTest/SingleConfig.cmake new file mode 100644 index 000000000..7c10e06be --- /dev/null +++ b/Tests/RunCMake/CTest/SingleConfig.cmake @@ -0,0 +1,6 @@ +include(CTest) + +# This should be ignored by single-config generators. +set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE INTERNAL "Supported configuration types") + +add_test(NAME SingleConfig COMMAND ${CMAKE_COMMAND} -E echo SingleConfig) diff --git a/Tests/RunCMake/CTest/TestfileErrors-Script.cmake b/Tests/RunCMake/CTest/TestfileErrors-Script.cmake new file mode 100644 index 000000000..d9fc7c89a --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-Script.cmake @@ -0,0 +1,4 @@ +message(SEND_ERROR "SEND_ERROR") +message(FATAL_ERROR "FATAL_ERROR") +# This shouldn't get printed because the script aborts on FATAL_ERROR +message(SEND_ERROR "reaching the unreachable") diff --git a/Tests/RunCMake/CTest/TestfileErrors-test-result.txt b/Tests/RunCMake/CTest/TestfileErrors-test-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-test-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt b/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt new file mode 100644 index 000000000..a3a476bf1 --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at [^ +]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:1 \(message\): + SEND_ERROR +Call Stack \(most recent call first\): + CTestTestfile.cmake:[0-9]+ \(include\) ++ +CMake Error at [^ +]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:2 \(message\): + FATAL_ERROR +Call Stack \(most recent call first\): + CTestTestfile.cmake:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CTest/TestfileErrors.cmake b/Tests/RunCMake/CTest/TestfileErrors.cmake new file mode 100644 index 000000000..676eb479d --- /dev/null +++ b/Tests/RunCMake/CTest/TestfileErrors.cmake @@ -0,0 +1,3 @@ +include(CTest) +add_test(NAME "unreachable" COMMAND ${CMAKE_COMMAND} -E true) +set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/TestfileErrors-Script.cmake) diff --git a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt index d95bb337c..97e2a10c1 100644 --- a/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at CTestTestfile.cmake:[0-9]+ \(subdirs\): subdirs called with incorrect number of arguments + -No tests were found!!!$ +Errors while running CTest$ diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt index ba4235def..19310b8ed 100644 --- a/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt @@ -1 +1,2 @@ +^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputSize/DartConfiguration.tcl Errors while running CTest diff --git a/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt b/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt new file mode 100644 index 000000000..0421e2803 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) + +project(${RunCMake_TEST} LANGUAGES NONE) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake new file mode 100644 index 000000000..095fd5445 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake @@ -0,0 +1,22 @@ + +enable_language (C) +include(CheckCompilerFlag) + +check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid C compile flag didn't fail.") +endif() + +if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") + check_compiler_flag(C "-x c" SHOULD_WORK) + if(NOT SHOULD_WORK) + message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-x c' check failed") + endif() +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + check_compiler_flag(C "-frtti" SHOULD_FAIL_RTTI) + if(SHOULD_FAIL_RTTI) + message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-frtti' check passed but should have failed") + endif() +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake new file mode 100644 index 000000000..a40699cad --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake @@ -0,0 +1,13 @@ + +enable_language (CUDA) +include(CheckCompilerFlag) + +check_compiler_flag(CUDA "-_this_is_not_a_flag_" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid CUDA compile flag didn't fail.") +endif() + +check_compiler_flag(CUDA "-DFOO" SHOULD_WORK) +if(NOT SHOULD_WORK) + message(SEND_ERROR "${CMAKE_CUDA_COMPILER_ID} compiler flag '-DFOO' check failed") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake new file mode 100644 index 000000000..bbc104e91 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake @@ -0,0 +1,15 @@ + +enable_language (CXX) +include(CheckCompilerFlag) + +check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid CXX compile flag didn't fail.") +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + check_compiler_flag(CXX "-x c++" SHOULD_WORK) + if(NOT SHOULD_WORK) + message(SEND_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed") + endif() +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake new file mode 100644 index 000000000..220ee2935 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake @@ -0,0 +1,14 @@ +enable_language (Fortran) +include(CheckCompilerFlag) + +check_compiler_flag(Fortran "-_this_is_not_a_flag_" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid Fortran compile flag didn't fail.") +endif() + +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + check_compiler_flag(Fortran "-Wall" SHOULD_WORK) + if(NOT SHOULD_WORK) + message(SEND_ERROR "${CMAKE_Fortran_COMPILER_ID} compiler flag '-Wall' check failed") + endif() +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckISPCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckISPCCompilerFlag.cmake new file mode 100644 index 000000000..662319ae6 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckISPCCompilerFlag.cmake @@ -0,0 +1,13 @@ + +enable_language (ISPC) +include(CheckCompilerFlag) + +check_compiler_flag(ISPC "-_this_is_not_a_flag_" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid ISPC compile flag didn't fail.") +endif() + +check_compiler_flag(ISPC "--woff" SHOULD_WORK) +if(NOT SHOULD_WORK) + message(SEND_ERROR "${CMAKE_ISPC_COMPILER_ID} compiler flag '--woff' check failed") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake new file mode 100644 index 000000000..e9344ca11 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake @@ -0,0 +1,12 @@ +enable_language (OBJC) +include(CheckCompilerFlag) + +check_compiler_flag(OBJC "-_this_is_not_a_flag_" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid OBJC compile flag didn't fail.") +endif() + +check_compiler_flag(OBJC "-Wall" SHOULD_WORK) +if(NOT SHOULD_WORK) + message(SEND_ERROR "${CMAKE_OBJC_COMPILER_ID} compiler flag '-Wall' check failed") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake new file mode 100644 index 000000000..503a1de0f --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake @@ -0,0 +1,12 @@ +enable_language (OBJCXX) +include(CheckCompilerFlag) + +check_compiler_flag(OBJCXX "-_this_is_not_a_flag_" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid OBJCXX compile flag didn't fail.") +endif() + +check_compiler_flag(OBJCXX "-Wall" SHOULD_WORK) +if(NOT SHOULD_WORK) + message(SEND_ERROR "${CMAKE_OBJCXX_COMPILER_ID} compiler flag '-Wall' check failed") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage-result.txt b/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage-stderr.txt b/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage-stderr.txt new file mode 100644 index 000000000..89d05650e --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*CheckCompilerFlag\.cmake:[0-9]+ \(message\): + check_compiler_flag: FAKE_LANG: unknown language. diff --git a/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage.cmake b/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage.cmake new file mode 100644 index 000000000..074195327 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/NonExistentLanguage.cmake @@ -0,0 +1,3 @@ + +include(CheckCompilerFlag) +check_compiler_flag(FAKE_LANG "int main() {return 0;}" SHOULD_BUILD) diff --git a/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage-result.txt b/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage-stderr.txt b/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage-stderr.txt new file mode 100644 index 000000000..23dd4a165 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*CheckCompilerFlag\.cmake:[0-9]+ \(message\): + check_compiler_flag: C: needs to be enabled before use. diff --git a/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage.cmake b/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage.cmake new file mode 100644 index 000000000..14769a254 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/NotEnabledLanguage.cmake @@ -0,0 +1,3 @@ + +include(CheckCompilerFlag) +check_compiler_flag(C "int main() {return 0;}" SHOULD_BUILD) diff --git a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake new file mode 100644 index 000000000..7a4e2cebb --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake @@ -0,0 +1,24 @@ +include(RunCMake) + +run_cmake(NotEnabledLanguage) +run_cmake(NonExistentLanguage) + +run_cmake(CheckCCompilerFlag) +run_cmake(CheckCXXCompilerFlag) + +if (APPLE) + run_cmake(CheckOBJCCompilerFlag) + run_cmake(CheckOBJCXXCompilerFlag) +endif() + +if (CMAKE_Fortran_COMPILER_ID) + run_cmake(CheckFortranCompilerFlag) +endif() + +if (CMake_TEST_CUDA) + run_cmake(CheckCUDACompilerFlag) +endif() + +if(CMake_TEST_ISPC) + run_cmake(CheckISPCCompilerFlag) +endif() diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake new file mode 100644 index 000000000..84d6dd92b --- /dev/null +++ b/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake @@ -0,0 +1,3 @@ + +set (CHECK_LANGUAGE CUDA) +include ("${CMAKE_CURRENT_SOURCE_DIR}/CheckLinkerFlag.cmake") diff --git a/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake index 224a2a3d0..6ec914806 100644 --- a/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake @@ -12,3 +12,7 @@ endif() if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU") run_cmake(CheckFortranLinkerFlag) endif() + +if (CMake_TEST_CUDA) + run_cmake(CheckCUDALinkerFlag) +endif() diff --git a/Tests/RunCMake/CheckModules/CMakeLists.txt b/Tests/RunCMake/CheckModules/CMakeLists.txt index 9872df2a1..842c5cf52 100644 --- a/Tests/RunCMake/CheckModules/CMakeLists.txt +++ b/Tests/RunCMake/CheckModules/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 2.8.12) cmake_policy(SET CMP0054 NEW) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CheckSourceCompiles/CMakeLists.txt b/Tests/RunCMake/CheckSourceCompiles/CMakeLists.txt new file mode 100644 index 000000000..0421e2803 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) + +project(${RunCMake_TEST} LANGUAGES NONE) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake new file mode 100644 index 000000000..cf461893c --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake @@ -0,0 +1,13 @@ + +enable_language (C) +include(CheckSourceCompiles) + +check_source_compiles(C "I don't build" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid C source didn't fail.") +endif() + +check_source_compiles(C "int main() {return 0;}" SHOULD_BUILD) +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid C source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake new file mode 100644 index 000000000..1e6e6b266 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake @@ -0,0 +1,27 @@ + +enable_language (CUDA) +include(CheckSourceCompiles) + +check_source_compiles(CUDA "I don't build" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid CUDA source didn't fail.") +endif() + +check_source_compiles(CUDA [=[ + #include <vector> + __device__ int d_func() { } + int main() { + return 0; + } +]=] + SHOULD_BUILD) +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid CUDA source.") +endif() + +check_source_compiles(CUDA "void l(char const (&x)[2]){}; int main() { l(\"\\n\"); return 0;}" + SHOULD_BUILD_COMPLEX) + +if(NOT SHOULD_BUILD_COMPLEX) + message(SEND_ERROR "Test fail for valid CUDA complex source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake new file mode 100644 index 000000000..ec01d42f7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake @@ -0,0 +1,26 @@ + +enable_language (CXX) +include(CheckSourceCompiles) + +check_source_compiles(CXX "I don't build" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid CXX source didn't fail.") +endif() + +check_source_compiles(CXX [=[ + #include <vector> + int main() { + return 0; + } +]=] + SHOULD_BUILD) +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid CXX source.") +endif() + +check_source_compiles(CXX "void l(char const (&x)[2]){}; int main() { l(\"\\n\"); return 0;}" + SHOULD_BUILD_COMPLEX) + +if(NOT SHOULD_BUILD_COMPLEX) + message(SEND_ERROR "Test fail for valid CXX complex source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake new file mode 100644 index 000000000..1d4e16d45 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake @@ -0,0 +1,14 @@ + + +enable_language (Fortran) +include(CheckSourceCompiles) + +check_source_compiles(Fortran [=[ + PROGRAM TEST_HAVE_PRINT + PRINT *, 'Hello' + END +]=] SHOULD_BUILD) + +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid Fortran source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckISPCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckISPCSourceCompiles.cmake new file mode 100644 index 000000000..74b83c083 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckISPCSourceCompiles.cmake @@ -0,0 +1,20 @@ + +enable_language (ISPC) +include(CheckSourceCompiles) + +check_source_compiles(ISPC "I don't build" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid ISPC source didn't fail.") +endif() + +check_source_compiles(ISPC [=[ + +float func(uniform int32, float a) +{ + return a / 2.25; +} +]=] + SHOULD_BUILD) +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid ISPC source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake new file mode 100644 index 000000000..2f53cfc4f --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake @@ -0,0 +1,14 @@ +enable_language (OBJC) +include(CheckSourceCompiles) + +check_source_compiles(OBJC [[ + #import <Foundation/Foundation.h> + int main() { + NSObject *foo; + return 0; + } +]] SHOULD_BUILD) + +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid OBJC source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake new file mode 100644 index 000000000..805d5136c --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake @@ -0,0 +1,17 @@ +enable_language (OBJCXX) +include(CheckSourceCompiles) + +check_source_compiles(OBJCXX [[ + #include <vector> + #import <Foundation/Foundation.h> + int main() { + std::vector<int> v; + NSObject *foo; + return 0; + } +]] SHOULD_BUILD) + + +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for OBJCXX source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage-result.txt b/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage-stderr.txt b/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage-stderr.txt new file mode 100644 index 000000000..bf2ea8233 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*CheckSourceCompiles\.cmake:[0-9]+ \(message\): + check_source_compiles: FAKE_LANG: unknown language. diff --git a/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage.cmake b/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage.cmake new file mode 100644 index 000000000..fc7de0697 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/NonExistentLanguage.cmake @@ -0,0 +1,3 @@ + +include(CheckSourceCompiles) +check_source_compiles(FAKE_LANG "int main() {return 0;}" SHOULD_BUILD) diff --git a/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage-result.txt b/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage-stderr.txt b/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage-stderr.txt new file mode 100644 index 000000000..ebc983ae3 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*CheckSourceCompiles\.cmake:[0-9]+ \(message\): + check_source_compiles: C: needs to be enabled before use. diff --git a/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage.cmake b/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage.cmake new file mode 100644 index 000000000..dec0db363 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/NotEnabledLanguage.cmake @@ -0,0 +1,3 @@ + +include(CheckSourceCompiles) +check_source_compiles(C "int main() {return 0;}" SHOULD_BUILD) diff --git a/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake b/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake new file mode 100644 index 000000000..6e9088f82 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake @@ -0,0 +1,25 @@ +include(RunCMake) + +run_cmake(NotEnabledLanguage) +run_cmake(NonExistentLanguage) +run_cmake(UnknownArgument) + +run_cmake(CheckCSourceCompiles) +run_cmake(CheckCXXSourceCompiles) + +if (APPLE) + run_cmake(CheckOBJCSourceCompiles) + run_cmake(CheckOBJCXXSourceCompiles) +endif() + +if (CMAKE_Fortran_COMPILER_ID) + run_cmake(CheckFortranSourceCompiles) +endif() + +if (CMake_TEST_CUDA) + run_cmake(CheckCUDASourceCompiles) +endif() + +if(CMake_TEST_ISPC) + run_cmake(CheckISPCSourceCompiles) +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/UnknownArgument-result.txt b/Tests/RunCMake/CheckSourceCompiles/UnknownArgument-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/UnknownArgument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckSourceCompiles/UnknownArgument-stderr.txt b/Tests/RunCMake/CheckSourceCompiles/UnknownArgument-stderr.txt new file mode 100644 index 000000000..a7e0af515 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/UnknownArgument-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at [^ +]*/Modules/Internal/CheckSourceCompiles.cmake:[0-9]+ \(message\): + Unknown argument: + + BAD + +Call Stack \(most recent call first\): + [^ +]*/Modules/CheckSourceCompiles.cmake:[0-9]+ \(cmake_check_source_compiles\) + UnknownArgument.cmake:[0-9]+ \(check_source_compiles\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckSourceCompiles/UnknownArgument.cmake b/Tests/RunCMake/CheckSourceCompiles/UnknownArgument.cmake new file mode 100644 index 000000000..3b861da7f --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/UnknownArgument.cmake @@ -0,0 +1,5 @@ + +enable_language (C) +include(CheckSourceCompiles) + +check_source_compiles(C "int main() {return 0;}" SHOULD_BUILD SRC_EXT C BAD) diff --git a/Tests/RunCMake/CheckSourceRuns/CMakeLists.txt b/Tests/RunCMake/CheckSourceRuns/CMakeLists.txt new file mode 100644 index 000000000..0421e2803 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) + +project(${RunCMake_TEST} LANGUAGES NONE) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake new file mode 100644 index 000000000..3029ac26b --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake @@ -0,0 +1,13 @@ + +enable_language (C) +include(CheckSourceRuns) + +check_source_runs(C "int main() {return 2;}" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "C check_source_runs succeeded, but should have failed.") +endif() + +check_source_runs(C "int main() {return 0;}" SHOULD_RUN) +if(NOT SHOULD_RUN) + message(SEND_ERROR "C check_source_runs failed for valid C executable.") +endif() diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake new file mode 100644 index 000000000..01e5ac83c --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake @@ -0,0 +1,21 @@ + +enable_language (CUDA) +include(CheckSourceRuns) + +check_source_runs(CUDA "int main() {return 2;}" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "CUDA check_source_runs succeeded, but should have failed.") +endif() + +check_source_runs(CUDA +[=[ + #include <vector> + __device__ __host__ void fake_function(); + __host__ int main() { + return 0; + } +]=] + SHOULD_RUN) +if(NOT SHOULD_RUN) + message(SEND_ERROR "CUDA check_source_runs failed for valid CUDA executable.") +endif() diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake new file mode 100644 index 000000000..d47ddda33 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake @@ -0,0 +1,20 @@ + +enable_language (CXX) +include(CheckSourceRuns) + +check_source_runs(CXX "int main() {return 2;}" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "CXX check_source_runs succeeded, but should have failed.") +endif() + +check_source_runs(CXX +[=[ + #include <vector> + int main() { + return 0; + } +]=] + SHOULD_RUN) +if(NOT SHOULD_RUN) + message(SEND_ERROR "CXX check_source_runs failed for valid C executable.") +endif() diff --git a/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake new file mode 100644 index 000000000..2a1fdfe19 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake @@ -0,0 +1,14 @@ + + +enable_language (Fortran) +include(CheckSourceRuns) + +check_source_runs(Fortran [=[ + PROGRAM TEST_HAVE_PRINT + PRINT *, 'Hello' + END +]=] SHOULD_BUILD) + +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid Fortran source.") +endif() diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake new file mode 100644 index 000000000..55f28f3a7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake @@ -0,0 +1,14 @@ +enable_language (OBJC) +include(CheckSourceRuns) + +check_source_runs(OBJC [[ + #import <Foundation/Foundation.h> + int main() { + NSObject *foo; + return 0; + } +]] SHOULD_BUILD) + +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for valid OBJC source.") +endif() diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake new file mode 100644 index 000000000..a218acdd7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake @@ -0,0 +1,17 @@ +enable_language (OBJCXX) +include(CheckSourceRuns) + +check_source_runs(OBJCXX [[ + #include <vector> + #import <Foundation/Foundation.h> + int main() { + std::vector<int> v; + NSObject *foo; + return 0; + } +]] SHOULD_BUILD) + + +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test fail for OBJCXX source.") +endif() diff --git a/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage-result.txt b/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage-stderr.txt b/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage-stderr.txt new file mode 100644 index 000000000..08ffc2d42 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*CheckSourceRuns\.cmake:[0-9]+ \(message\): + check_source_runs: FAKE_LANG: unknown language. diff --git a/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage.cmake b/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage.cmake new file mode 100644 index 000000000..830074036 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/NonExistentLanguage.cmake @@ -0,0 +1,3 @@ + +include(CheckSourceRuns) +check_source_runs(FAKE_LANG "int main() {return 0;}" SHOULD_BUILD) diff --git a/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage-result.txt b/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage-stderr.txt b/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage-stderr.txt new file mode 100644 index 000000000..b590763c4 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*CheckSourceRuns\.cmake:[0-9]+ \(message\): + check_source_runs: C: needs to be enabled before use. diff --git a/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage.cmake b/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage.cmake new file mode 100644 index 000000000..e16cec2cb --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/NotEnabledLanguage.cmake @@ -0,0 +1,3 @@ + +include(CheckSourceRuns) +check_source_runs(C "int main() {return 0;}" SHOULD_BUILD) diff --git a/Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake b/Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake new file mode 100644 index 000000000..c99ac8be2 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake @@ -0,0 +1,21 @@ +include(RunCMake) + +run_cmake(NotEnabledLanguage) +run_cmake(NonExistentLanguage) +run_cmake(UnknownArgument) + +run_cmake(CheckCSourceRuns) +run_cmake(CheckCXXSourceRuns) + +if (APPLE) + run_cmake(CheckOBJCSourceRuns) + run_cmake(CheckOBJCXXSourceRuns) +endif() + +if (CMAKE_Fortran_COMPILER_ID) + run_cmake(CheckFortranSourceRuns) +endif() + +if (CMake_TEST_CUDA) + run_cmake(CheckCUDASourceRuns) +endif() diff --git a/Tests/RunCMake/CheckSourceRuns/UnknownArgument-result.txt b/Tests/RunCMake/CheckSourceRuns/UnknownArgument-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/UnknownArgument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckSourceRuns/UnknownArgument-stderr.txt b/Tests/RunCMake/CheckSourceRuns/UnknownArgument-stderr.txt new file mode 100644 index 000000000..6824e7264 --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/UnknownArgument-stderr.txt @@ -0,0 +1,24 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/Internal/CheckSourceRuns.cmake:[0-9]+ \(message\): + Unknown argument: + + BAD + +Call Stack \(most recent call first\): + [^ +]*/Modules/CheckCSourceRuns.cmake:[0-9]+ \(cmake_check_source_runs\) + UnknownArgument.cmake:[0-9]+ \(check_c_source_runs\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Error at [^ +]*/Modules/Internal/CheckSourceRuns.cmake:[0-9]+ \(message\): + Unknown argument: + + BAD + +Call Stack \(most recent call first\): + [^ +]*/Modules/CheckSourceRuns.cmake:[0-9]+ \(cmake_check_source_runs\) + UnknownArgument.cmake:[0-9]+ \(check_source_runs\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckSourceRuns/UnknownArgument.cmake b/Tests/RunCMake/CheckSourceRuns/UnknownArgument.cmake new file mode 100644 index 000000000..927a6b06a --- /dev/null +++ b/Tests/RunCMake/CheckSourceRuns/UnknownArgument.cmake @@ -0,0 +1,7 @@ + +enable_language (C) +include(CheckCSourceRuns) +include(CheckSourceRuns) + +check_c_source_runs("int main() {return 0;}" C_SHOULD_BUILD BAD) +check_source_runs(C "int main() {return 0;}" SHOULD_BUILD SRC_EXT c BAD) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-fail-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-fail-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-fail-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-fail-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-fail-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-fail-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt b/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt index d2a28310d..f6d72a9f2 100644 --- a/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt +++ b/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt @@ -1,7 +1,19 @@ add_custom_command( - OUTPUT output.txt - COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt + OUTPUT output1.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output1.txt ) -add_custom_target(CustomTarget ALL DEPENDS output.txt) -add_custom_target(CustomTarget2 ALL DEPENDS output.txt) -add_custom_target(CustomTarget3 ALL DEPENDS output.txt) +add_custom_target(CustomTarget ALL DEPENDS output1.txt) + +add_custom_command( + OUTPUT output2.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand2 > output2.txt + ) +add_custom_target(CustomTarget2 ALL DEPENDS output2.txt) + +add_custom_command( + OUTPUT output3.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand2 > output3.txt + ) +add_custom_target(CustomTarget3 ALL DEPENDS output3.txt) + +add_custom_target(CustomTargetFail COMMAND DoesNotExist) diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt index 03286f1f7..e24e131b7 100644 --- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt +++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt @@ -1 +1 @@ -^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":1}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":true,"version":{.*}}$ +^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":2}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":true,"version":{.*}}$ diff --git a/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt deleted file mode 100644 index 4729ccb8f..000000000 --- a/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^Files ".*/compare_files/lf" to ".*/compare_files/crlf" are different.$ diff --git a/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt deleted file mode 100644 index 8a9ca81f8..000000000 --- a/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^Files "nonexistent_a" to "nonexistent_b" are different.$ diff --git a/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-result.txt b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-result.txt new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-result.txt @@ -0,0 +1 @@ +2 diff --git a/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-no-arg-result.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-no-arg-stderr.txt new file mode 100644 index 000000000..50d9b0332 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-no-arg-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error: cmake version .* +Usage: .* -E <command> \[arguments\.\.\.\] +Available commands: diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-no-directory-result.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-no-directory-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-no-directory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-no-directory-stderr.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-no-directory-stderr.txt new file mode 100644 index 000000000..21e60eec0 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-no-directory-stderr.txt @@ -0,0 +1 @@ +^CMake Error: failed to create link .* no such file or directory diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-non-existent-source-result.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-non-existent-source-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-non-existent-source-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-non-existent-source-stderr.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-non-existent-source-stderr.txt new file mode 100644 index 000000000..a3345712b --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-non-existent-source-stderr.txt @@ -0,0 +1 @@ +^failed to create hard link because source path .* does not exist diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-prereq-check.cmake b/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-prereq-check.cmake new file mode 100644 index 000000000..5b97aecc0 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-prereq-check.cmake @@ -0,0 +1,3 @@ +if(${actual_stderr_var} MATCHES "operation not permitted") + unset(msg) +endif() diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-result.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-stderr.txt b/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-stderr.txt new file mode 100644 index 000000000..a3345712b --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_hardlink-unresolved-symlink-stderr.txt @@ -0,0 +1 @@ +^failed to create hard link because source path .* does not exist diff --git a/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt index fc6291445..0fee56ce8 100644 --- a/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt +++ b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt @@ -1,9 +1,20 @@ cmake_minimum_required(VERSION 3.14) project(ExplicitDirs NONE) + add_custom_command( - OUTPUT output.txt - COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt + OUTPUT output1.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output1.txt ) -add_custom_target(CustomTarget ALL DEPENDS output.txt) -add_custom_target(CustomTarget2 ALL DEPENDS output.txt) -add_custom_target(CustomTarget3 ALL DEPENDS output.txt) +add_custom_target(CustomTarget ALL DEPENDS output1.txt) + +add_custom_command( + OUTPUT output2.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand2 > output2.txt + ) +add_custom_target(CustomTarget2 ALL DEPENDS output2.txt) + +add_custom_command( + OUTPUT output3.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand2 > output3.txt + ) +add_custom_target(CustomTarget3 ALL DEPENDS output3.txt) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index abb90509c..b23c8c26d 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -22,6 +22,7 @@ run_cmake_command(E_compare_files-different-eol ${CMAKE_COMMAND} -E compare_file run_cmake_command(E_compare_files-ignore-eol-same ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf) run_cmake_command(E_compare_files-ignore-eol-empty ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/empty1 ${RunCMake_SOURCE_DIR}/compare_files/empty2) run_cmake_command(E_compare_files-ignore-eol-nonexistent ${CMAKE_COMMAND} -E compare_files --ignore-eol nonexistent_a nonexistent_b) +run_cmake_command(E_compare_files-invalid-arguments ${CMAKE_COMMAND} -E compare_files file1.txt file2.txt file3.txt) run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append) run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename) run_cmake_command(E_server-arg ${CMAKE_COMMAND} -E server --extra-arg) @@ -66,6 +67,32 @@ run_cmake_command(install-bad-dir run_cmake_command(install-options-to-vars ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-install-options-to-vars --strip --prefix /var/test --config sample --component pack) +run_cmake_command(install-default-dir-permissions-all + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions u=rwx,g=rx,o=rx) +run_cmake_command(install-default-dir-permissions-afew + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions u=rwx,g=rx) +run_cmake_command(install-default-dir-permissions-none + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars) +run_cmake_command(install-default-dir-permissions-invalid-comma1 + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions u=rwxg=,x) +run_cmake_command(install-default-dir-permissions-invalid-comma2 + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions u=rwxg,=x) +run_cmake_command(install-default-dir-permissions-comma-at-the-end + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions u=rwx,) +run_cmake_command(install-default-dir-permissions-invalid-assignment + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions u=rwx,=x) +run_cmake_command(install-default-dir-permissions-assignment-at-the-end + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions u=rwx,g=) +run_cmake_command(install-default-dir-permissions-assignment-at-the-beginning + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-permissions-install-options-to-vars + --default-directory-permissions =u=rwx,g=rx) run_cmake_command(cache-bad-entry ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-entry/) @@ -134,6 +161,8 @@ function(run_BuildDir) ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget) run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build -t CustomTarget2 --target CustomTarget3) + run_cmake_command(BuildDir--build-multiple-targets-fail ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -t CustomTargetFail --target CustomTarget3) run_cmake_command(BuildDir--build-multiple-targets-jobs ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget CustomTarget2 -j2 --target CustomTarget3) run_cmake_command(BuildDir--build-multiple-targets-with-clean-first ${CMAKE_COMMAND} -E chdir .. @@ -319,6 +348,42 @@ run_cmake_command(E_create_symlink-no-replace-dir ${CMAKE_COMMAND} -E create_symlink T . ) +#create hard link tests +run_cmake_command(E_create_hardlink-no-arg + ${CMAKE_COMMAND} -E create_hardlink + ) + +set(dir ${RunCMake_BINARY_DIR}/hardlink_tests) +file(REMOVE_RECURSE "${dir}") +file(MAKE_DIRECTORY ${dir}) + +run_cmake_command(E_create_hardlink-non-existent-source + ${CMAKE_COMMAND} -E create_hardlink ${dir}/I_dont_exist ${dir}/link + ) + +file(TOUCH ${dir}/1) + +run_cmake_command(E_create_hardlink-ok + ${CMAKE_COMMAND} -E create_hardlink ${dir}/1 ${dir}/1-link + ) + +run_cmake_command(E_create_hardlink-no-directory + ${CMAKE_COMMAND} -E create_hardlink ${dir}/1 ${dir}/a/1-link + ) + +#On Windows, if the user does not have sufficient privileges +#don't fail this test +set(RunCMake_DEFAULT_stderr "(operation not permitted)?") +run_cmake_command(E_create_hardlink-unresolved-symlink-prereq + ${CMAKE_COMMAND} -E create_symlink ${dir}/1 ${dir}/1-symlink + ) +file(REMOVE ${dir}/1) + +run_cmake_command(E_create_hardlink-unresolved-symlink + ${CMAKE_COMMAND} -E create_hardlink ${dir}/1-symlink ${dir}/1s-link + ) +unset(RunCMake_DEFAULT_stderr) + set(in ${RunCMake_SOURCE_DIR}/copy_input) set(out ${RunCMake_BINARY_DIR}/copy_output) file(REMOVE_RECURSE "${out}") @@ -717,15 +782,15 @@ function(run_llvm_rc) file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake_command(llvm_rc_no_args ${CMAKE_COMMAND} -E cmake_llvm_rc) run_cmake_command(llvm_rc_no_-- ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test") - run_cmake_command(llvm_rc_empty_preprocessor ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp -- ${CMAKE_COMMAND} -E echo "This is a test") - run_cmake_command(llvm_rc_failing_first_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -P FailedProgram.cmake -- ${CMAKE_COMMAND} -E echo "This is a test") - run_cmake_command(llvm_rc_failing_second_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -P FailedProgram.cmake ) + run_cmake_command(llvm_rc_empty_preprocessor ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ++ ${CMAKE_COMMAND} -E echo "This is a test") + run_cmake_command(llvm_rc_failing_first_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -P FailedProgram.cmake ++ ${CMAKE_COMMAND} -E echo "This is a test") + run_cmake_command(llvm_rc_failing_second_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" ++ ${CMAKE_COMMAND} -P FailedProgram.cmake ) if(EXISTS ${RunCMake_TEST_BINARY_DIR}/test.tmp) message(SEND_ERROR "${test} - FAILED:\n" "test.tmp was not deleted") endif() file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir") - run_cmake_command(llvm_rc_full_run ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -E copy test.tmp SOURCE_DIR/llvmrc.result ) + run_cmake_command(llvm_rc_full_run ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" ++ ${CMAKE_COMMAND} -E copy test.tmp SOURCE_DIR/llvmrc.result ) if(EXISTS ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/test.tmp) message(SEND_ERROR "${test} - FAILED:\n" "test.tmp was not deleted") diff --git a/Tests/RunCMake/CommandLine/dir-permissions-install-options-to-vars/cmake_install.cmake b/Tests/RunCMake/CommandLine/dir-permissions-install-options-to-vars/cmake_install.cmake new file mode 100644 index 000000000..42ef7456f --- /dev/null +++ b/Tests/RunCMake/CommandLine/dir-permissions-install-options-to-vars/cmake_install.cmake @@ -0,0 +1,3 @@ +if(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS) + message("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS is ${CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS}") +endif() diff --git a/Tests/RunCMake/interface_library/genex_link-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-afew-result.txt index 573541ac9..573541ac9 100644 --- a/Tests/RunCMake/interface_library/genex_link-result.txt +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-afew-result.txt diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-afew-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-afew-stderr.txt new file mode 100644 index 000000000..42f4b3f85 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-afew-stderr.txt @@ -0,0 +1 @@ +CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS is OWNER_READ;OWNER_WRITE;OWNER_EXECUTE;GROUP_READ;GROUP_EXECUTE diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-all-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-all-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-all-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-all-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-all-stderr.txt new file mode 100644 index 000000000..813d9c366 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-all-stderr.txt @@ -0,0 +1 @@ +CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS is OWNER_READ;OWNER_WRITE;OWNER_EXECUTE;GROUP_READ;GROUP_EXECUTE;WORLD_READ;WORLD_EXECUTE diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-beginning-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-beginning-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-beginning-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-beginning-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-beginning-stderr.txt new file mode 100644 index 000000000..1b8095240 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-beginning-stderr.txt @@ -0,0 +1 @@ +--default-directory-permissions is in incorrect format diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-end-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-end-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-end-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-end-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-end-stderr.txt new file mode 100644 index 000000000..6680932e1 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-assignment-at-the-end-stderr.txt @@ -0,0 +1 @@ +CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS is OWNER_READ;OWNER_WRITE;OWNER_EXECUTE diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-comma-at-the-end-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-comma-at-the-end-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-comma-at-the-end-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-comma-at-the-end-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-comma-at-the-end-stderr.txt new file mode 100644 index 000000000..1b8095240 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-comma-at-the-end-stderr.txt @@ -0,0 +1 @@ +--default-directory-permissions is in incorrect format diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-assignment-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-assignment-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-assignment-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-assignment-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-assignment-stderr.txt new file mode 100644 index 000000000..1b8095240 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-assignment-stderr.txt @@ -0,0 +1 @@ +--default-directory-permissions is in incorrect format diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma1-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma1-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma1-stderr.txt new file mode 100644 index 000000000..1b8095240 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma1-stderr.txt @@ -0,0 +1 @@ +--default-directory-permissions is in incorrect format diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma2-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma2-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma2-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma2-stderr.txt new file mode 100644 index 000000000..1b8095240 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-invalid-comma2-stderr.txt @@ -0,0 +1 @@ +--default-directory-permissions is in incorrect format diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-none-result.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-none-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-none-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/install-default-dir-permissions-none-stderr.txt b/Tests/RunCMake/CommandLine/install-default-dir-permissions-none-stderr.txt new file mode 100644 index 000000000..10f32932e --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-default-dir-permissions-none-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py index e617b7632..1ee005ede 100755 --- a/Tests/RunCMake/CommandLine/trace-json-v1-check.py +++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py @@ -56,7 +56,7 @@ with open(trace_file, 'r') as fp: assert sorted(vers.keys()) == ['version'] assert sorted(vers['version'].keys()) == ['major', 'minor'] assert vers['version']['major'] == 1 - assert vers['version']['minor'] == 0 + assert vers['version']['minor'] == 1 for i in fp.readlines(): line = json.loads(i) diff --git a/Tests/RunCMake/CompatibleInterface/CMakeLists.txt b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt index f452db177..ebab7a357 100644 --- a/Tests/RunCMake/CompatibleInterface/CMakeLists.txt +++ b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake index 0196611ca..64b52d9e1 100644 --- a/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.3) project(CompatibleInterface) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake index 5772856cc..f072eb0bc 100644 --- a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake @@ -5,5 +5,5 @@ add_library(bar UNKNOWN IMPORTED) set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING INCLUDE_DIRECTORIES) add_executable(user main.cpp) -set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES bar_inc) +set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/bar_inc) target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompilerArgs/C.cmake b/Tests/RunCMake/CompilerArgs/C.cmake new file mode 100644 index 000000000..96b004bda --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/C.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.c) diff --git a/Tests/RunCMake/interface_library/CMakeLists.txt b/Tests/RunCMake/CompilerArgs/CMakeLists.txt index 12cd3c775..18dfd2686 100644 --- a/Tests/RunCMake/interface_library/CMakeLists.txt +++ b/Tests/RunCMake/CompilerArgs/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.2) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompilerArgs/CXX.cmake b/Tests/RunCMake/CompilerArgs/CXX.cmake new file mode 100644 index 000000000..3d2ee0012 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/CXX.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/CompilerArgs/FindCCompiler.cmake b/Tests/RunCMake/CompilerArgs/FindCCompiler.cmake new file mode 100644 index 000000000..aeaaf7f7e --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/FindCCompiler.cmake @@ -0,0 +1,2 @@ +enable_language(C) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/C_comp.cmake" "set(temp_CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerArgs/FindCXXCompiler.cmake b/Tests/RunCMake/CompilerArgs/FindCXXCompiler.cmake new file mode 100644 index 000000000..663ac83f9 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/FindCXXCompiler.cmake @@ -0,0 +1,2 @@ +enable_language(CXX) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CXX_comp.cmake" "set(temp_CMAKE_CXX_COMPILER \"${CMAKE_CXX_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake new file mode 100644 index 000000000..9e5a18ad3 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake @@ -0,0 +1,58 @@ +include(RunCMake) + +function(find_compiler lang) + # Detect the compiler in use in the current environment. + run_cmake(Find${lang}Compiler) + # Use the detected compiler + include(${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/${lang}_comp.cmake) + if(NOT temp_CMAKE_${lang}_COMPILER) + message(FATAL_ERROR "FindCompiler provided no compiler!") + endif() + # Create a toolchain file + set(__test_compiler_var CMAKE_${lang}_COMPILER) + set(__test_compiler "${temp_CMAKE_${lang}_COMPILER}") + configure_file(${RunCMake_SOURCE_DIR}/toolchain.cmake.in + ${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake @ONLY) +endfunction() + +function(run_compiler_env lang) + # Use the correct compiler + include(${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/${lang}_comp.cmake) + + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-env-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + # Set the compiler + if(lang STREQUAL "C") + set(ENV{CC} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") + else() + set(ENV{${lang}} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") + endif() + + run_cmake(${lang}) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) +endfunction() + +function(run_compiler_tc lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-tc-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(RunCMake_TEST_OPTIONS + -DCMAKE_TOOLCHAIN_FILE=${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake) + run_cmake(${lang}) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) +endfunction() + +set(langs C CXX) + +foreach(lang ${langs}) + find_compiler(${lang}) + run_compiler_env(${lang}) + run_compiler_tc(${lang}) +endforeach() diff --git a/Tests/RunCMake/CompilerArgs/main.c b/Tests/RunCMake/CompilerArgs/main.c new file mode 100644 index 000000000..b52613531 --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/main.c @@ -0,0 +1,10 @@ +#ifndef FOO1 +# error Missing FOO1 +#endif +#ifndef FOO2 +# error Missing FOO2 +#endif +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/CompilerArgs/main.cxx b/Tests/RunCMake/CompilerArgs/main.cxx new file mode 100644 index 000000000..db90e933e --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/main.cxx @@ -0,0 +1,10 @@ +#ifndef FOO1 +# error Missing FOO1 +#endif +#ifndef FOO2 +# error Missing FOO2 +#endif +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/CompilerArgs/toolchain.cmake.in b/Tests/RunCMake/CompilerArgs/toolchain.cmake.in new file mode 100644 index 000000000..ff776397c --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/toolchain.cmake.in @@ -0,0 +1 @@ +set(@__test_compiler_var@ "@__test_compiler@" -DFOO1 -DFOO2) diff --git a/Tests/RunCMake/CompilerChange/CMakeLists.txt b/Tests/RunCMake/CompilerChange/CMakeLists.txt index b4b30165f..14c47ad6b 100644 --- a/Tests/RunCMake/CompilerChange/CMakeLists.txt +++ b/Tests/RunCMake/CompilerChange/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) if(NOT RunCMake_TEST) set(RunCMake_TEST "$ENV{RunCMake_TEST}") # needed when cache is deleted endif() diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/ISPC-Build-stdout.txt new file mode 100644 index 000000000..3313e31f6 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-common.cmake b/Tests/RunCMake/CompilerLauncher/ISPC-common.cmake new file mode 100644 index 000000000..a6e576e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-common.cmake @@ -0,0 +1,8 @@ +enable_language(ISPC) +enable_language(CXX) +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() +add_executable(main main.cxx test.ispc) diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/ISPC-env-Build-stdout.txt new file mode 100644 index 000000000..3313e31f6 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/ISPC-env-launch-Build-stdout.txt new file mode 100644 index 000000000..3313e31f6 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-env.cmake b/Tests/RunCMake/CompilerLauncher/ISPC-env.cmake new file mode 100644 index 000000000..4afd9190c --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-env.cmake @@ -0,0 +1 @@ +include(ISPC-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/ISPC-launch-Build-stdout.txt new file mode 100644 index 000000000..3313e31f6 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/ISPC-launch-env.cmake new file mode 100644 index 000000000..f50fb6500 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(ISPC-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/ISPC-launch.cmake b/Tests/RunCMake/CompilerLauncher/ISPC-launch.cmake new file mode 100644 index 000000000..b0cafbe7f --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(ISPC.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/ISPC.cmake b/Tests/RunCMake/CompilerLauncher/ISPC.cmake new file mode 100644 index 000000000..83efa8096 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/ISPC.cmake @@ -0,0 +1,2 @@ +set(CMAKE_ISPC_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") +include(ISPC-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index 69fff2091..293d71199 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -29,6 +29,9 @@ endif() if(CMake_TEST_Fortran) list(APPEND langs Fortran) endif() +if(CMake_TEST_ISPC) + list(APPEND langs ISPC) +endif() if(CMake_TEST_OBJC) list(APPEND langs OBJC OBJCXX) endif() diff --git a/Tests/RunCMake/CompilerLauncher/test.ispc b/Tests/RunCMake/CompilerLauncher/test.ispc new file mode 100644 index 000000000..b061f40a5 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/test.ispc @@ -0,0 +1,4 @@ + +float func(float a, float b) { + return a + b / 2.; +} diff --git a/Tests/RunCMake/CompilerNotFound/CMakeLists.txt b/Tests/RunCMake/CompilerNotFound/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/CompilerNotFound/CMakeLists.txt +++ b/Tests/RunCMake/CompilerNotFound/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Configure/CMakeLists.txt b/Tests/RunCMake/Configure/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/Configure/CMakeLists.txt +++ b/Tests/RunCMake/Configure/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/DependencyGraph/CMakeLists.txt b/Tests/RunCMake/DependencyGraph/CMakeLists.txt new file mode 100644 index 000000000..b646c4ac6 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeCommon.cmake b/Tests/RunCMake/DependencyGraph/OptimizeCommon.cmake new file mode 100644 index 000000000..4954bc46c --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeCommon.cmake @@ -0,0 +1,40 @@ +enable_language(C) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY out) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY out) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY out) + +add_library(SharedTop SHARED mylib.c) +add_library(StaticTop STATIC mylib.c) +add_library(StaticMiddle STATIC mylib.c) + +add_library(StaticNone STATIC mylib.c) +add_library(StaticPreBuild STATIC mylib.c) +add_library(StaticPreLink STATIC mylib.c) +add_library(StaticPostBuild STATIC mylib.c) +add_library(StaticCc STATIC mylibcc.c) + +add_custom_command(TARGET StaticPreBuild PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E true) +add_custom_command(TARGET StaticPreLink PRE_LINK + COMMAND ${CMAKE_COMMAND} -E true) +add_custom_command(TARGET StaticPostBuild POST_BUILD + COMMAND ${CMAKE_COMMAND} -E true) +add_custom_command(OUTPUT mylibcc.c + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/mylib.c ${CMAKE_BINARY_DIR}/mylibcc.c) + +target_link_libraries(SharedTop PRIVATE StaticMiddle) +target_link_libraries(StaticTop PRIVATE StaticMiddle) +target_link_libraries(StaticMiddle PRIVATE StaticNone StaticPreBuild StaticPreLink StaticPostBuild StaticCc) + +if(OPTIMIZE_TOP) + set_target_properties(SharedTop StaticTop PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() +if(OPTIMIZE_MIDDLE) + set_target_properties(StaticMiddle PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() + +include(WriteTargets.cmake) +write_targets() diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-check.cmake new file mode 100644 index 000000000..1020cb344 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-check.cmake @@ -0,0 +1,5 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-both.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both.cmake new file mode 100644 index 000000000..581fd46e6 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-both.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-check.cmake new file mode 100644 index 000000000..5c7e8cd1e --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-check.cmake @@ -0,0 +1,6 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${CMiddle_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle.cmake new file mode 100644 index 000000000..581fd46e6 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-middle.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-check.cmake new file mode 100644 index 000000000..5c7e8cd1e --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-check.cmake @@ -0,0 +1,6 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${CMiddle_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-none.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none.cmake new file mode 100644 index 000000000..581fd46e6 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-none.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-check.cmake new file mode 100644 index 000000000..1020cb344 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-check.cmake @@ -0,0 +1,5 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${FortranTop_TARGET_FILE} + ${FortranBottom_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-stderr.txt b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortran-top.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top.cmake new file mode 100644 index 000000000..581fd46e6 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortran-top.cmake @@ -0,0 +1 @@ +include(OptimizeFortranCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeFortranCommon.cmake b/Tests/RunCMake/DependencyGraph/OptimizeFortranCommon.cmake new file mode 100644 index 000000000..354d3fc53 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeFortranCommon.cmake @@ -0,0 +1,25 @@ +enable_language(C) +enable_language(Fortran) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY out) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY out) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY out) + +add_library(FortranTop STATIC mylib.f90) +add_library(CMiddle STATIC mylib.c) +add_library(FortranBottom STATIC mylib.f90) + +target_link_libraries(FortranTop PRIVATE CMiddle) +target_link_libraries(CMiddle PRIVATE FortranBottom) + +if(OPTIMIZE_TOP) + set_target_properties(FortranTop PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() +if(OPTIMIZE_MIDDLE) + set_target_properties(CMiddle PROPERTIES + OPTIMIZE_DEPENDENCIES TRUE) +endif() + +include(WriteTargets.cmake) +write_targets() diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-both-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-both-build-check.cmake new file mode 100644 index 000000000..312de0425 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-both-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-both.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-both.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-both.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-middle-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle-build-check.cmake new file mode 100644 index 000000000..312de0425 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-middle.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-middle.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-none-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-none-build-check.cmake new file mode 100644 index 000000000..312de0425 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-none-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-none.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-none.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-none.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-top-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-top-build-check.cmake new file mode 100644 index 000000000..312de0425 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-top-build-check.cmake @@ -0,0 +1,11 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${SharedTop_TARGET_FILE} + ${SharedTop_TARGET_LINKER_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeShared-top.cmake b/Tests/RunCMake/DependencyGraph/OptimizeShared-top.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeShared-top.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-both-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both-build-check.cmake new file mode 100644 index 000000000..5222ed7f4 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both-build-check.cmake @@ -0,0 +1,8 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-both.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-both.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle-build-check.cmake new file mode 100644 index 000000000..5cba2238a --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle-build-check.cmake @@ -0,0 +1,10 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-middle.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-none-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none-build-check.cmake new file mode 100644 index 000000000..5cba2238a --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none-build-check.cmake @@ -0,0 +1,10 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticMiddle_TARGET_FILE} + ${StaticNone_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-none.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-none.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-top-build-check.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top-build-check.cmake new file mode 100644 index 000000000..5222ed7f4 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top-build-check.cmake @@ -0,0 +1,8 @@ +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +check_files(${RunCMake_TEST_BINARY_DIR}/out + ${StaticTop_TARGET_FILE} + ${StaticPreBuild_TARGET_FILE} + ${StaticPreLink_TARGET_FILE} + ${StaticPostBuild_TARGET_FILE} + ${StaticCc_TARGET_FILE} + ) diff --git a/Tests/RunCMake/DependencyGraph/OptimizeStatic-top.cmake b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top.cmake new file mode 100644 index 000000000..c150e6279 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/OptimizeStatic-top.cmake @@ -0,0 +1 @@ +include(OptimizeCommon.cmake) diff --git a/Tests/RunCMake/DependencyGraph/Property.cmake b/Tests/RunCMake/DependencyGraph/Property.cmake new file mode 100644 index 000000000..08fdd2b3b --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/Property.cmake @@ -0,0 +1,24 @@ +enable_language(C) + +add_library(Unset STATIC mylib.c) + +set(CMAKE_OPTIMIZE_DEPENDENCIES TRUE) +add_library(SetTrue STATIC mylib.c) + +set(CMAKE_OPTIMIZE_DEPENDENCIES FALSE) +add_library(SetFalse STATIC mylib.c) + +get_property(_set TARGET Unset PROPERTY OPTIMIZE_DEPENDENCIES SET) +if(_set) + message(SEND_ERROR "OPTIMIZE_DEPENDENCIES property should not be set on Unset target") +endif() + +get_property(_true TARGET SetTrue PROPERTY OPTIMIZE_DEPENDENCIES) +if(NOT _true STREQUAL "TRUE") + message(SEND_ERROR "OPTIMIZE_DEPENDENCIES property should be TRUE on SetTrue target") +endif() + +get_property(_false TARGET SetFalse PROPERTY OPTIMIZE_DEPENDENCIES) +if(NOT _false STREQUAL "FALSE") + message(SEND_ERROR "OPTIMIZE_DEPENDENCIES property should be FALSE on SetFalse target") +endif() diff --git a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake new file mode 100644 index 000000000..cb0d541b7 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake @@ -0,0 +1,60 @@ +include(RunCMake) + +function(check_files dir) + set(expected ${ARGN}) + list(FILTER expected EXCLUDE REGEX "^$") + list(REMOVE_DUPLICATES expected) + list(SORT expected) + + file(GLOB_RECURSE glob "${dir}/*") + set(actual) + foreach(i IN LISTS glob) + if(NOT i MATCHES "(\\.manifest$)|(\\.exp$)|(\\.tds$)") + list(APPEND actual ${i}) + endif() + endforeach() + list(REMOVE_DUPLICATES actual) + list(SORT actual) + + if(NOT "${expected}" STREQUAL "${actual}") + string(REPLACE ";" "\n " expected_formatted "${expected}") + string(REPLACE ";" "\n " actual_formatted "${actual}") + string(APPEND RunCMake_TEST_FAILED "Actual files did not match expected\nExpected:\n ${expected_formatted}\nActual:\n ${actual_formatted}\n") + endif() + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +function(run_cmake_build name) + set(RunCMake_TEST_NO_CLEAN TRUE) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) + file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}) + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + run_cmake(${name}) + set(RunCMake_TEST_OPTIONS) + run_cmake_command(${name}-build ${CMAKE_COMMAND} + --build ${RunCMake_TEST_BINARY_DIR} + --config Release + --target ${ARGN}) +endfunction() + +function(run_optimize_test name) + set(RunCMake_TEST_OPTIONS) + run_cmake_build(${name}-none ${ARGN}) + set(RunCMake_TEST_OPTIONS -DOPTIMIZE_TOP=TRUE) + run_cmake_build(${name}-top ${ARGN}) + set(RunCMake_TEST_OPTIONS -DOPTIMIZE_MIDDLE=TRUE) + run_cmake_build(${name}-middle ${ARGN}) + set(RunCMake_TEST_OPTIONS -DOPTIMIZE_TOP=TRUE -DOPTIMIZE_MIDDLE=TRUE) + run_cmake_build(${name}-both ${ARGN}) +endfunction() + +run_cmake(Property) + +run_optimize_test(OptimizeShared SharedTop) +run_optimize_test(OptimizeStatic StaticTop) +if(CMAKE_Fortran_COMPILER) + run_optimize_test(OptimizeFortran FortranTop) +endif() diff --git a/Tests/RunCMake/DependencyGraph/WriteTargets.cmake b/Tests/RunCMake/DependencyGraph/WriteTargets.cmake new file mode 100644 index 000000000..e1012c119 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/WriteTargets.cmake @@ -0,0 +1,16 @@ +function(write_targets) + set(_input "") + + get_property(_targets DIRECTORY . PROPERTY BUILDSYSTEM_TARGETS) + foreach(_t IN LISTS _targets) + get_property(_type TARGET "${_t}" PROPERTY TYPE) + if(_type STREQUAL "SHARED_LIBRARY") + string(APPEND _input "set(${_t}_TARGET_FILE [==[$<TARGET_FILE:${_t}>]==])\n") + string(APPEND _input "set(${_t}_TARGET_LINKER_FILE [==[$<TARGET_LINKER_FILE:${_t}>]==])\n") + elseif(_type STREQUAL "STATIC_LIBRARY") + string(APPEND _input "set(${_t}_TARGET_FILE [==[$<TARGET_FILE:${_t}>]==])\n") + endif() + endforeach() + + file(GENERATE OUTPUT target_files.cmake CONTENT "${_input}" CONDITION $<CONFIG:Release>) +endfunction() diff --git a/Tests/RunCMake/DependencyGraph/mylib.c b/Tests/RunCMake/DependencyGraph/mylib.c new file mode 100644 index 000000000..5422fe307 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/mylib.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void mylib(void) +{ +} diff --git a/Tests/RunCMake/DependencyGraph/mylib.f90 b/Tests/RunCMake/DependencyGraph/mylib.f90 new file mode 100644 index 000000000..104768f89 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/mylib.f90 @@ -0,0 +1,3 @@ +function mylib_fortran() + mylib_fortran = 42 +end function mylib_fortran diff --git a/Tests/RunCMake/DisallowedCommands/CMakeLists.txt b/Tests/RunCMake/DisallowedCommands/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/DisallowedCommands/CMakeLists.txt +++ b/Tests/RunCMake/DisallowedCommands/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/ExcludeFromAll/CMakeLists.txt new file mode 100644 index 000000000..74b3ff8de --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExcludeFromAll/RunCMakeTest.cmake b/Tests/RunCMake/ExcludeFromAll/RunCMakeTest.cmake new file mode 100644 index 000000000..2b4fc8931 --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/RunCMakeTest.cmake @@ -0,0 +1,26 @@ +include(RunCMake) + +function(run_single_config_test label config exclude_from_all_value expectation) + set(case single-config) + message("-- Starting ${case} test: ${label}") + set(full_case_name "${case}-build-${config}") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${full_case_name}/") + run_cmake_with_options(${case} + -DCMAKE_BUILD_TYPE=${config} + -DTOOL_EXCLUDE_FROM_ALL=${exclude_from_all_value}) + set(RunCMake_TEST_NO_CLEAN 1) + include(${RunCMake_TEST_BINARY_DIR}/target_files_${config}.cmake) + run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config ${config}) +endfunction() + +run_single_config_test("explictly not excluded" Debug 0 "should_exist") +run_single_config_test("excluded" Debug 1 "should_not_exist") + +if(RunCMake_GENERATOR MATCHES "^(Xcode|Visual Studio)") + run_cmake(error-on-mixed-config) +else() + run_single_config_test("explicitly not excluded with genex" + Release $<CONFIG:Debug> "should_exist") + run_single_config_test("excluded with genex" + Debug $<CONFIG:Debug> "should_not_exist") +endif() diff --git a/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-result.txt b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-stderr.txt b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-stderr.txt new file mode 100644 index 000000000..6dc785f3f --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config-stderr.txt @@ -0,0 +1,3 @@ +CMake Error in CMakeLists.txt: + The EXCLUDE_FROM_ALL property of target "release_only_tool" varies by + configuration. This is not supported by the "[^"]+" diff --git a/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config.cmake b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config.cmake new file mode 100644 index 000000000..6c0ed1d4a --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/error-on-mixed-config.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "") + +add_executable(release_only_tool main.c) +set_property(TARGET release_only_tool PROPERTY EXCLUDE_FROM_ALL "$<NOT:$<CONFIG:Release>>") diff --git a/Tests/RunCMake/ExcludeFromAll/main.c b/Tests/RunCMake/ExcludeFromAll/main.c new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/ExcludeFromAll/single-config-build-check.cmake b/Tests/RunCMake/ExcludeFromAll/single-config-build-check.cmake new file mode 100644 index 000000000..1c455f256 --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/single-config-build-check.cmake @@ -0,0 +1,17 @@ +if(expectation STREQUAL "should_not_exist") + set(should_exist FALSE) +elseif(expectation STREQUAL "should_exist") + set(should_exist TRUE) +else() + message(FATAL_ERROR "Encountered unknown expectation: ${expectation}") +endif() + +if(EXISTS "${TARGET_FILE_tool_${config}}") + if(NOT should_exist) + message(FATAL_ERROR "${TARGET_FILE_tool_${config}} should not exist.") + endif() +else() + if(should_exist) + message(FATAL_ERROR "${TARGET_FILE_tool_${config}} should exist.") + endif() +endif() diff --git a/Tests/RunCMake/ExcludeFromAll/single-config.cmake b/Tests/RunCMake/ExcludeFromAll/single-config.cmake new file mode 100644 index 000000000..aa49c214e --- /dev/null +++ b/Tests/RunCMake/ExcludeFromAll/single-config.cmake @@ -0,0 +1,7 @@ +enable_language(C) +add_executable(tool main.c) +set_property(TARGET tool PROPERTY EXCLUDE_FROM_ALL "${TOOL_EXCLUDE_FROM_ALL}") + +file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/target_files_$<CONFIG>.cmake" CONTENT [[ +set(TARGET_FILE_tool_$<CONFIG> [==[$<TARGET_FILE:tool>]==]) +]]) diff --git a/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt b/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt +++ b/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExternalData/CMakeLists.txt b/Tests/RunCMake/ExternalData/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/ExternalData/CMakeLists.txt +++ b/Tests/RunCMake/ExternalData/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake b/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake index 38683f12e..bfed4fa7c 100644 --- a/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake @@ -1,4 +1,9 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + cmake_policy(SET CMP0114 NEW) +else() + cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. +endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake index 264c3f04c..039dec6a1 100644 --- a/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake @@ -1,4 +1,9 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + cmake_policy(SET CMP0114 NEW) +else() + cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. +endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep1-result.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep1-stderr.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep1-stderr.txt new file mode 100644 index 000000000..3188910a0 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep1-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + ExternalProject 'proj' step 'custom' is marked INDEPENDENT but depends on + step 'configure' that is not marked INDEPENDENT. +Call Stack \(most recent call first\): + BadIndependentStep1.cmake:[0-9]+ \(ExternalProject_Add_Step\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep1.cmake b/Tests/RunCMake/ExternalProject/BadIndependentStep1.cmake new file mode 100644 index 000000000..c81eb07c3 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep1.cmake @@ -0,0 +1,14 @@ +include(ExternalProject) +cmake_policy(SET CMP0114 NEW) + +ExternalProject_Add(proj + SOURCE_DIR "." + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +ExternalProject_Add_Step(proj custom + DEPENDEES configure + INDEPENDENT 1 + ) diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep2-result.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep2-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep2-stderr.txt b/Tests/RunCMake/ExternalProject/BadIndependentStep2-stderr.txt new file mode 100644 index 000000000..0b87e5e5f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep2-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + ExternalProject 'proj' step 'update' is marked INDEPENDENT but depends on + step 'custom' that is not marked INDEPENDENT. +Call Stack \(most recent call first\): + BadIndependentStep2.cmake:[0-9]+ \(ExternalProject_Add_Step\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/BadIndependentStep2.cmake b/Tests/RunCMake/ExternalProject/BadIndependentStep2.cmake new file mode 100644 index 000000000..4a530eace --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BadIndependentStep2.cmake @@ -0,0 +1,13 @@ +include(ExternalProject) +cmake_policy(SET CMP0114 NEW) + +ExternalProject_Add(proj + SOURCE_DIR "." + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +ExternalProject_Add_Step(proj custom + DEPENDERS update + ) diff --git a/Tests/RunCMake/ExternalProject/CMakeLists.txt b/Tests/RunCMake/ExternalProject/CMakeLists.txt index c585733b6..933a57a4d 100644 --- a/Tests/RunCMake/ExternalProject/CMakeLists.txt +++ b/Tests/RunCMake/ExternalProject/CMakeLists.txt @@ -1,3 +1,6 @@ -cmake_minimum_required(VERSION ${CMAKE_VERSION}) +cmake_minimum_required(VERSION 3.18) project(${RunCMake_TEST} NONE) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND NOT RunCMake_TEST STREQUAL "Xcode-CMP0114") + cmake_policy(SET CMP0114 NEW) +endif() include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityResume.cmake b/Tests/RunCMake/ExternalProject/DownloadInactivityResume.cmake new file mode 100644 index 000000000..d34482dd7 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityResume.cmake @@ -0,0 +1,5 @@ +include(ExternalProject) +ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "") diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-result.txt b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-stdout.txt b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-stdout.txt new file mode 100644 index 000000000..323814792 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout-build-stdout.txt @@ -0,0 +1 @@ +(Timeout was reached)? diff --git a/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout.cmake b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout.cmake new file mode 100644 index 000000000..d34482dd7 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadInactivityTimeout.cmake @@ -0,0 +1,5 @@ +include(ExternalProject) +ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "") diff --git a/Tests/RunCMake/ExternalProject/DownloadServer.py b/Tests/RunCMake/ExternalProject/DownloadServer.py new file mode 100644 index 000000000..63b7fa725 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadServer.py @@ -0,0 +1,53 @@ +from http.server import HTTPServer, BaseHTTPRequestHandler +import argparse +import time +import subprocess +import sys +import os +import threading +args = None +outerthread = None + +barrier = threading.Barrier(2) + +class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + def do_GET(self): + barrier.wait() + self.send_response(200) + self.end_headers() + data = b'D' + + if args.speed_limit: + slow_deadline = time.time()+args.limit_duration + + while time.time() < slow_deadline: + self.wfile.write(data) + if args.speed_limit: + time.sleep(1.1) + + data = data * 100 + self.wfile.write(data) + self.close_connection = True + +def runServer(fileName): + httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler) + with open(fileName,"w") as f: + f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1])) + httpd.handle_request() + os.remove(fileName) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--speed_limit', help='transfer rate limitation', action='store_true',default=False) + parser.add_argument('--limit_duration', help='duration of the transfer rate limitation',default=1, type=float) + parser.add_argument('--file', help='file to write the url to connect to') + parser.add_argument('--subprocess', action='store_true') + args = parser.parse_args() + if not args.subprocess: + subprocess.Popen([sys.executable]+sys.argv+['--subprocess'],stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL,stdout=subprocess.DEVNULL) + else: + serverThread = threading.Thread(target=runServer,args=(args.file,)) + serverThread.daemon = True + serverThread.start() + barrier.wait(60) + serverThread.join(20) diff --git a/Tests/RunCMake/ExternalProject/DownloadTimeout-build-result.txt b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-result.txt new file mode 100644 index 000000000..c20fd86c7 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-result.txt @@ -0,0 +1 @@ +^[^0] diff --git a/Tests/RunCMake/ExternalProject/DownloadTimeout-build-stderr.txt b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadTimeout-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/ExternalProject/DownloadTimeout.cmake b/Tests/RunCMake/ExternalProject/DownloadTimeout.cmake new file mode 100644 index 000000000..c90b4bada --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DownloadTimeout.cmake @@ -0,0 +1,5 @@ +include(ExternalProject) +set(source_dir "${CMAKE_CURRENT_BINARY_DIR}/DownloadTimeout") +file(REMOVE_RECURSE "${source_dir}") +file(MAKE_DIRECTORY "${source_dir}") +ExternalProject_Add(MyProj URL "http://cmake.org/invalid_file.tar.gz") diff --git a/Tests/RunCMake/ExternalProject/MultiCommand.cmake b/Tests/RunCMake/ExternalProject/MultiCommand.cmake index a8dbfea5d..dbf67eb71 100644 --- a/Tests/RunCMake/ExternalProject/MultiCommand.cmake +++ b/Tests/RunCMake/ExternalProject/MultiCommand.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.9) - include(ExternalProject) # Verify COMMAND keyword is recognised after various *_COMMAND options @@ -20,10 +18,6 @@ ExternalProject_Add(multiCommand COMMAND "${CMAKE_COMMAND}" -E echo "install 2" ) -# Workaround for issue 17229 (missing dependency between update and patch steps) -ExternalProject_Add_StepTargets(multiCommand NO_DEPENDS update) -ExternalProject_Add_StepDependencies(multiCommand patch multiCommand-update) - # Force all steps to be re-run by removing timestamps from any previous run ExternalProject_Get_Property(multiCommand STAMP_DIR) file(REMOVE_RECURSE "${STAMP_DIR}") diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-Common.cmake index 57626d679..176e28beb 100644 --- a/Tests/RunCMake/ExternalProject/NO_DEPENDS.cmake +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-Common.cmake @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8.12) include(ExternalProject RESULT_VARIABLE GOO) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-result.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-stderr.txt new file mode 100644 index 000000000..c6bf767fa --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + The 'NO_DEPENDS' option is no longer allowed. It has been superseded by + the per-step 'INDEPENDENT' option. See policy CMP0114. +Call Stack \(most recent call first\): + NO_DEPENDS-CMP0114-NEW-Direct.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake new file mode 100644 index 000000000..7ec1a0050 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake @@ -0,0 +1,4 @@ +cmake_policy(SET CMP0114 NEW) +include(ExternalProject) +ExternalProject_Add(BAR SOURCE_DIR . TEST_COMMAND echo test) +ExternalProject_Add_StepTargets(BAR NO_DEPENDS test) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-result.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-stderr.txt new file mode 100644 index 000000000..5a5ba891d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-stderr.txt @@ -0,0 +1,16 @@ +^CMake Error at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + ExternalProject 'FOO' option 'INDEPENDENT_STEP_TARGETS' is set to + + download;patch;update;configure;build + + but the option is no longer allowed. It has been superseded by the + per-step 'INDEPENDENT' option. See policy CMP0114. +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_mkdir_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-NEW.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW.cmake new file mode 100644 index 000000000..9622a600c --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 NEW) +include(NO_DEPENDS-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD-stderr.txt new file mode 100644 index 000000000..2b0feb6e4 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD-stderr.txt @@ -0,0 +1,61 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "configure" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-OLD.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "build" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-OLD.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "install" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-OLD.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "test" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + NO_DEPENDS-CMP0114-OLD.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/ExternalProject/NO_DEPENDS-CMP0114-OLD.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD.cmake new file mode 100644 index 000000000..c20d443c5 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 OLD) +include(NO_DEPENDS-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN-stderr.txt new file mode 100644 index 000000000..bbf7178f2 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN-stderr.txt @@ -0,0 +1,119 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject 'FOO' option INDEPENDENT_STEP_TARGETS is set to + + download;patch;update;configure;build + + but the option is deprecated in favor of policy CMP0114. +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_mkdir_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "configure" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "build" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject 'BAR' option INDEPENDENT_STEP_TARGETS is set to + + install + + but the option is deprecated in favor of policy CMP0114. +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_mkdir_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "install" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(cmake_language\) + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set: ExternalProject step targets fully adopt their + steps. Run "cmake --help-policy CMP0114" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + ExternalProject target 'BAR' would depend on the targets for step\(s\) + 'test;bar' under policy CMP0114, but this is being left out for + compatibility since the policy is not set. Also, the NO_DEPENDS option is + deprecated in favor of policy CMP0114. +Call Stack \(most recent call first\): + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + NO_DEPENDS-CMP0114-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Using NO_DEPENDS for "test" step might break parallel builds +Call Stack \(most recent call first\): + [^ +]*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_step_add_target\) + NO_DEPENDS-CMP0114-Common.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) + NO_DEPENDS-CMP0114-WARN.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/ExternalProject/NO_DEPENDS-CMP0114-WARN.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN.cmake new file mode 100644 index 000000000..3d9642df0 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-WARN.cmake @@ -0,0 +1,2 @@ +# Policy CMP0114 not set. +include(NO_DEPENDS-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt b/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt deleted file mode 100644 index 928d88a9c..000000000 --- a/Tests/RunCMake/ExternalProject/NO_DEPENDS-stderr.txt +++ /dev/null @@ -1,36 +0,0 @@ -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "configure" step might break parallel builds -Call Stack \(most recent call first\): - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_configure_command\) - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "build" step might break parallel builds -Call Stack \(most recent call first\): - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_build_command\) - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "install" step might break parallel builds -Call Stack \(most recent call first\): - .*/Modules/ExternalProject.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - .*/Modules/ExternalProject.cmake:[0-9]+:EVAL:2 \(ExternalProject_Add_Step\) - .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_install_command\) - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. - -CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+. \(message\): - Using NO_DEPENDS for "test" step might break parallel builds -Call Stack \(most recent call first\): - NO_DEPENDS.cmake:[0-9]+ \(ExternalProject_Add_StepTargets\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 0d1da26b5..598671f82 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -1,5 +1,13 @@ +cmake_minimum_required(VERSION 3.12) include(RunCMake) +# We do not contact any remote URLs, but may use a local one. +# Remove any proxy configuration that may change behavior. +unset(ENV{http_proxy}) +unset(ENV{https_proxy}) + +run_cmake(BadIndependentStep1) +run_cmake(BadIndependentStep2) run_cmake(IncludeScope-Add) run_cmake(IncludeScope-Add_Step) run_cmake(NoOptions) @@ -8,12 +16,52 @@ run_cmake(SourceMissing) run_cmake(CMAKE_CACHE_ARGS) run_cmake(CMAKE_CACHE_DEFAULT_ARGS) run_cmake(CMAKE_CACHE_mix) -run_cmake(NO_DEPENDS) +if(NOT XCODE_VERSION OR XCODE_VERSION VERSION_LESS 12) + run_cmake(NO_DEPENDS-CMP0114-WARN) + run_cmake(NO_DEPENDS-CMP0114-OLD) +endif() +run_cmake(NO_DEPENDS-CMP0114-NEW) +run_cmake(NO_DEPENDS-CMP0114-NEW-Direct) run_cmake(Add_StepDependencies) run_cmake(Add_StepDependencies_iface) run_cmake(Add_StepDependencies_iface_step) run_cmake(Add_StepDependencies_no_target) run_cmake(UsesTerminal) +if(XCODE_VERSION AND XCODE_VERSION VERSION_GREATER_EQUAL 12) + run_cmake(Xcode-CMP0114) +endif() + +macro(check_steps_missing proj) + set(steps "${ARGN}") + foreach(step ${steps}) + if(EXISTS ${RunCMake_TEST_BINARY_DIR}/${proj}-${step}-mark) + string(APPEND RunCMake_TEST_FAILED "${proj} '${step}' step ran but should not have\n") + endif() + endforeach() +endmacro() + +macro(check_steps_present proj) + set(steps "${ARGN}") + foreach(step ${steps}) + if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/${proj}-${step}-mark) + string(APPEND RunCMake_TEST_FAILED "${proj} '${step}' step did not run but should have\n") + endif() + endforeach() +endmacro() + +function(run_steps_CMP0114 val) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Steps-CMP0114-${val}-build) + run_cmake(Steps-CMP0114-${val}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Steps-CMP0114-${val}-build-download ${CMAKE_COMMAND} --build . --target proj1-download) + run_cmake_command(Steps-CMP0114-${val}-build-update ${CMAKE_COMMAND} --build . --target proj1-update) + run_cmake_command(Steps-CMP0114-${val}-build-install ${CMAKE_COMMAND} --build . --target proj1-install) + run_cmake_command(Steps-CMP0114-${val}-build-test ${CMAKE_COMMAND} --build . --target proj1-test) +endfunction() +if(NOT XCODE_VERSION OR XCODE_VERSION VERSION_LESS 12) + run_steps_CMP0114(OLD) +endif() +run_steps_CMP0114(NEW) # Run both cmake and build steps. We always do a clean before the # build to ensure that the download step re-runs each time. @@ -27,6 +75,50 @@ function(__ep_test_with_build testName) run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .) endfunction() +find_package(Python3) +function(__ep_test_with_build_with_server testName) + if(NOT Python3_EXECUTABLE) + return() + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_TIMEOUT 20) + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + set(URL_FILE ${RunCMake_BINARY_DIR}/${testName}.url) + if(EXISTS "${URL_FILE}") + file(REMOVE "${URL_FILE}") + endif() + execute_process( + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/DownloadServer.py --file "${URL_FILE}" ${ARGN} + OUTPUT_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt + ERROR_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt + RESULT_VARIABLE result + TIMEOUT 30 + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Failed to start download server:\n ${result}") + endif() + + foreach(i RANGE 1 8) + if(EXISTS ${URL_FILE}) + break() + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${i}) + endforeach() + + if(NOT EXISTS ${URL_FILE}) + message(FATAL_ERROR "Failed to load download server URL from:\n ${URL_FILE}") + endif() + + file(READ ${URL_FILE} SERVER_URL) + message(STATUS "URL : ${URL_FILE} - ${SERVER_URL}") + run_cmake_with_options(${testName} ${CMAKE_COMMAND} -DSERVER_URL=${SERVER_URL} ) + run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean) + run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .) +endfunction() + __ep_test_with_build(MultiCommand) set(RunCMake_TEST_OUTPUT_MERGE 1) @@ -38,6 +130,9 @@ set(RunCMake_TEST_OUTPUT_MERGE 0) if(NOT RunCMake_GENERATOR MATCHES "Visual Studio") __ep_test_with_build(LogOutputOnFailure) __ep_test_with_build(LogOutputOnFailureMerged) + __ep_test_with_build(DownloadTimeout) + __ep_test_with_build_with_server(DownloadInactivityTimeout --speed_limit --limit_duration 40) + __ep_test_with_build_with_server(DownloadInactivityResume --speed_limit --limit_duration 1) endif() # We can't test the substitution when using the old MSYS due to diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-Common.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-Common.cmake new file mode 100644 index 000000000..210edb151 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-Common.cmake @@ -0,0 +1,34 @@ +include(ExternalProject) + +ExternalProject_Add(proj0 + SOURCE_DIR "." + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj0-download-mark + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj0-configure-mark + BUILD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj0-build-mark + INSTALL_COMMAND "" + ) + +cmake_policy(GET CMP0114 cmp0114) +if(cmp0114 STREQUAL "NEW") + set(step_targets "update;test") + set(independent_step_targets "") +else() + set(step_targets "install;test") + set(independent_step_targets "download;update") +endif() + +ExternalProject_Add(proj1 + DEPENDS proj0 + SOURCE_DIR "." + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-download-mark + UPDATE_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-update-mark + PATCH_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-patch-mark + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-configure-mark + BUILD_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-build-mark + INSTALL_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-install-mark + TEST_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/proj1-test-mark + TEST_EXCLUDE_FROM_MAIN 1 # Along with 'STEP_TARGETS test', implies 'STEP_TARGETS install' + UPDATE_DISCONNECTED 1 # Along with 'STEP_TARGETS update', implies 'STEP_TARGETS download' + STEP_TARGETS ${step_targets} + INDEPENDENT_STEP_TARGETS ${independent_step_targets} + ) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-download-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-download-check.cmake new file mode 100644 index 000000000..1439f0216 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-download-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download) +check_steps_missing(proj1 update patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-install-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-install-check.cmake new file mode 100644 index 000000000..c1c9c8f3b --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-install-check.cmake @@ -0,0 +1,3 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install) +check_steps_missing(proj1 test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-test-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-test-check.cmake new file mode 100644 index 000000000..fe256f200 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-test-check.cmake @@ -0,0 +1,2 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-update-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-update-check.cmake new file mode 100644 index 000000000..63e2e1dcf --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW-build-update-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download update) +check_steps_missing(proj1 patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW.cmake new file mode 100644 index 000000000..9d8e99ee1 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 NEW) +include(Steps-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-download-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-download-check.cmake new file mode 100644 index 000000000..1439f0216 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-download-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download) +check_steps_missing(proj1 update patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-install-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-install-check.cmake new file mode 100644 index 000000000..c1c9c8f3b --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-install-check.cmake @@ -0,0 +1,3 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install) +check_steps_missing(proj1 test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-test-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-test-check.cmake new file mode 100644 index 000000000..fe256f200 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-test-check.cmake @@ -0,0 +1,2 @@ +check_steps_present(proj0 download configure build) +check_steps_present(proj1 download patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-update-check.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-update-check.cmake new file mode 100644 index 000000000..63e2e1dcf --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD-build-update-check.cmake @@ -0,0 +1,3 @@ +check_steps_missing(proj0 download configure build) +check_steps_present(proj1 download update) +check_steps_missing(proj1 patch configure build install test) diff --git a/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD.cmake b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD.cmake new file mode 100644 index 000000000..0b51ad8d6 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Steps-CMP0114-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0114 OLD) +include(Steps-CMP0114-Common.cmake) diff --git a/Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt b/Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt new file mode 100644 index 000000000..a616185c9 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set to NEW. In order to support the Xcode "new build + system", this project must be updated to set policy CMP0114 to NEW. + + Since CMake is generating for the Xcode "new build system", + ExternalProject_Add will use policy CMP0114's NEW behavior anyway, but the + generated build system may not match what the project intends. +Call Stack \(most recent call first\): + Xcode-CMP0114.cmake:[0-9]+ \(ExternalProject_Add\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake b/Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake new file mode 100644 index 000000000..5039daaca --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake @@ -0,0 +1,2 @@ +include(ExternalProject) +ExternalProject_Add(MyProj SOURCE_DIR .) diff --git a/Tests/RunCMake/FPHSA/CMakeLists.txt b/Tests/RunCMake/FPHSA/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/FPHSA/CMakeLists.txt +++ b/Tests/RunCMake/FPHSA/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FPHSA/FindPseudoRange.cmake b/Tests/RunCMake/FPHSA/FindPseudoRange.cmake new file mode 100644 index 000000000..ad0342c65 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindPseudoRange.cmake @@ -0,0 +1,7 @@ +# pseudo find_module + +set(FOOBAR TRUE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PseudoRange REQUIRED_VARS FOOBAR VERSION_VAR PseudoRange_VERSION + HANDLE_VERSION_RANGE) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index 8e390908a..28b8570d0 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -55,3 +55,13 @@ run_cmake(required_and_optional_components) run_cmake(all_optional_components) list(APPEND RunCMake_TEST_OPTIONS "-DUseComponents_REQUIRE_VARS=TRUE") run_cmake(required_components_with_vars) + +# check handling of version range +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=2.3.4.5") +run_cmake(range_ignored) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudoRange_VERSION=2.0") +run_cmake(range_no-range) +run_cmake(range_1-3) +run_cmake(range_1-2-include) +run_cmake(range_1-2-exclude) +run_cmake(range_3-4) diff --git a/Tests/RunCMake/FPHSA/range_1-2-exclude-result.txt b/Tests/RunCMake/FPHSA/range_1-2-exclude-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-exclude-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/range_1-2-exclude-stderr.txt b/Tests/RunCMake/FPHSA/range_1-2-exclude-stderr.txt new file mode 100644 index 000000000..8e34630c2 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-exclude-stderr.txt @@ -0,0 +1,2 @@ + Could NOT find PseudoRange: Found unsuitable version "2\.0", required range + is "1.0...<2.0" \(found TRUE\) diff --git a/Tests/RunCMake/FPHSA/range_1-2-exclude.cmake b/Tests/RunCMake/FPHSA/range_1-2-exclude.cmake new file mode 100644 index 000000000..0cba368a7 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-exclude.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0...<2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_1-2-include.cmake b/Tests/RunCMake/FPHSA/range_1-2-include.cmake new file mode 100644 index 000000000..467267f6e --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-include.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0...2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_1-3.cmake b/Tests/RunCMake/FPHSA/range_1-3.cmake new file mode 100644 index 000000000..f1506c581 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-3.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0...3.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_3-4-result.txt b/Tests/RunCMake/FPHSA/range_3-4-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_3-4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/range_3-4-stderr.txt b/Tests/RunCMake/FPHSA/range_3-4-stderr.txt new file mode 100644 index 000000000..8ea19ce73 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_3-4-stderr.txt @@ -0,0 +1,2 @@ + Could NOT find PseudoRange: Found unsuitable version "2\.0", required range + is "3.0...4.0" \(found TRUE\) diff --git a/Tests/RunCMake/FPHSA/range_3-4.cmake b/Tests/RunCMake/FPHSA/range_3-4.cmake new file mode 100644 index 000000000..dd1931447 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_3-4.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 3.0...4.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_ignored-stderr.txt b/Tests/RunCMake/FPHSA/range_ignored-stderr.txt new file mode 100644 index 000000000..43f233669 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_ignored-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + `find_package\(\)` specify a version range but the module Pseudo does not + support this capability. Only the lower endpoint of the range will be + used. diff --git a/Tests/RunCMake/FPHSA/range_ignored.cmake b/Tests/RunCMake/FPHSA/range_ignored.cmake new file mode 100644 index 000000000..ff1ad15b2 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_ignored.cmake @@ -0,0 +1 @@ +find_package(Pseudo 1.0...2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_no-range.cmake b/Tests/RunCMake/FPHSA/range_no-range.cmake new file mode 100644 index 000000000..24896b1c2 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_no-range.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0 REQUIRED) diff --git a/Tests/RunCMake/FeatureSummary/CMakeLists.txt b/Tests/RunCMake/FeatureSummary/CMakeLists.txt index 72abfc809..74b3ff8de 100644 --- a/Tests/RunCMake/FeatureSummary/CMakeLists.txt +++ b/Tests/RunCMake/FeatureSummary/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FetchContent/DirOverrides.cmake b/Tests/RunCMake/FetchContent/DirOverrides.cmake index 50eef161b..ad61a00df 100644 --- a/Tests/RunCMake/FetchContent/DirOverrides.cmake +++ b/Tests/RunCMake/FetchContent/DirOverrides.cmake @@ -4,18 +4,23 @@ include(FetchContent) FetchContent_Declare( t1 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedSrc - DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedBin + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> <BINARY_DIR> ) FetchContent_Populate(t1) if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedSrc) message(FATAL_ERROR "Saved details SOURCE_DIR override failed") endif() +if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedBin) + message(FATAL_ERROR "Saved details BINARY_DIR override failed") +endif() # Test direct population FetchContent_Populate( t2 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/directSrc - DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/directBin + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR> <BINARY_DIR> ) if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/directSrc) message(FATAL_ERROR "Direct details SOURCE_DIR override failed") @@ -44,3 +49,19 @@ FetchContent_Populate( if(IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedNobuildDir-build) message(FATAL_ERROR "Direct details BINARY_DIR override failed") endif() + +# Test overriding the source directory by reusing the one from t1 +set(FETCHCONTENT_SOURCE_DIR_T5 ${CMAKE_CURRENT_BINARY_DIR}/savedSrc) +FetchContent_Declare( + t5 + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doesNotExist + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/wontBeCreated + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E false +) +FetchContent_Populate(t5) +if(NOT "${t5_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedSrc") + message(FATAL_ERROR "Wrong SOURCE_DIR returned: ${t5_SOURCE_DIR}") +endif() +if(NOT "${t5_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/wontBeCreated") + message(FATAL_ERROR "Wrong BINARY_DIR returned: ${t5_BINARY_DIR}") +endif() diff --git a/Tests/RunCMake/FetchContent/DirOverridesDisconnected.cmake b/Tests/RunCMake/FetchContent/DirOverridesDisconnected.cmake new file mode 100644 index 000000000..768a82e7b --- /dev/null +++ b/Tests/RunCMake/FetchContent/DirOverridesDisconnected.cmake @@ -0,0 +1,18 @@ +include(FetchContent) + +# Test using saved details. We are re-using a SOURCE_DIR from a previous test +# so the download command should not be executed. +FetchContent_Declare( + t1 + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedSrc + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedBin + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E false +) +FetchContent_Populate(t1) + +if(NOT "${t1_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedSrc") + message(FATAL_ERROR "Wrong SOURCE_DIR returned: ${t1_SOURCE_DIR}") +endif() +if(NOT "${t1_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedBin") + message(FATAL_ERROR "Wrong BINARY_DIR returned: ${t1_BINARY_DIR}") +endif() diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectory.cmake b/Tests/RunCMake/FetchContent/ManualSourceDirectory.cmake new file mode 100644 index 000000000..83fcc4b42 --- /dev/null +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectory.cmake @@ -0,0 +1,8 @@ +include(FetchContent) + +FetchContent_Declare( + WithProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/ADirThatDoesNotExist +) + +FetchContent_MakeAvailable(WithProject) diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-result.txt b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-stderr.txt b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-stderr.txt new file mode 100644 index 000000000..7ecb06b49 --- /dev/null +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing-stderr.txt @@ -0,0 +1,2 @@ + *Manually specified source directory is missing: ++ *FETCHCONTENT_SOURCE_DIR_WITHPROJECT --> .*/ADirThatDoesNotExist diff --git a/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake new file mode 100644 index 000000000..0e24c1a1c --- /dev/null +++ b/Tests/RunCMake/FetchContent/ManualSourceDirectoryMissing.cmake @@ -0,0 +1,8 @@ +include(FetchContent) + +FetchContent_Declare( + WithProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject +) + +FetchContent_MakeAvailable(WithProject) diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index f3ed3e2d6..3eb331f6b 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -10,12 +10,32 @@ run_cmake(DownloadFile) run_cmake(SameGenerator) run_cmake(VarDefinitions) run_cmake(GetProperties) -run_cmake(DirOverrides) run_cmake(UsesTerminalOverride) run_cmake(MakeAvailable) run_cmake(MakeAvailableTwice) run_cmake(MakeAvailableUndeclared) +run_cmake_with_options(ManualSourceDirectory + -D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT=${CMAKE_CURRENT_LIST_DIR}/WithProject" +) +run_cmake_with_options(ManualSourceDirectoryMissing + -D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT=${CMAKE_CURRENT_LIST_DIR}/ADirThatDoesNotExist" +) + +function(run_FetchContent_DirOverrides) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DirOverrides-build) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(DirOverrides) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_with_options(DirOverridesDisconnected + -D FETCHCONTENT_FULLY_DISCONNECTED=YES + ) +endfunction() +run_FetchContent_DirOverrides() + set(RunCMake_TEST_OUTPUT_MERGE 1) run_cmake(PreserveEmptyArgs) set(RunCMake_TEST_OUTPUT_MERGE 0) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index a3dd9ffc3..c66757f84 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -12,7 +12,7 @@ def read_codemodel_json_data(filename): def check_objects(o, g): assert is_list(o) assert len(o) == 1 - check_index_object(o[0], "codemodel", 2, 1, check_object_codemodel(g)) + check_index_object(o[0], "codemodel", 2, 2, check_object_codemodel(g)) def check_backtrace(t, b, backtrace): btg = t["backtraceGraph"] @@ -42,6 +42,16 @@ def check_backtrace(t, b, backtrace): assert b is None +def check_backtraces(t, actual, expected): + assert is_list(actual) + assert is_list(expected) + assert len(actual) == len(expected) + + i = 0 + while i < len(actual): + check_backtrace(t, actual[i], expected[i]) + i += 1 + def check_directory(c): def _check(actual, expected): assert is_dict(actual) @@ -421,6 +431,19 @@ def check_target(c): missing_exception=lambda e: "Precompile header: %s" % e["header"], extra_exception=lambda a: "Precompile header: %s" % a["header"]) + if "languageStandard" in expected: + expected_keys.append("languageStandard") + + def check_language_standard(actual, expected): + assert is_dict(actual) + expected_keys = ["backtraces", "standard"] + assert actual["standard"] == expected["standard"] + check_backtraces(obj, actual["backtraces"], expected["backtraces"]) + + assert sorted(actual.keys()) == sorted(expected_keys) + + check_language_standard(actual["languageStandard"], expected["languageStandard"]) + if expected["defines"] is not None: expected_keys.append("defines") @@ -499,6 +522,7 @@ def gen_check_directories(c, g): read_codemodel_json_data("directories/custom.json"), read_codemodel_json_data("directories/cxx.json"), read_codemodel_json_data("directories/imported.json"), + read_codemodel_json_data("directories/interface.json"), read_codemodel_json_data("directories/object.json"), read_codemodel_json_data("directories/dir.json"), read_codemodel_json_data("directories/dir_dir.json"), @@ -544,6 +568,8 @@ def gen_check_targets(c, g, inSource): read_codemodel_json_data("targets/zero_check_cxx.json"), read_codemodel_json_data("targets/cxx_lib.json"), read_codemodel_json_data("targets/cxx_exe.json"), + read_codemodel_json_data("targets/cxx_standard_compile_feature_exe.json"), + read_codemodel_json_data("targets/cxx_standard_exe.json"), read_codemodel_json_data("targets/cxx_shared_lib.json"), read_codemodel_json_data("targets/cxx_shared_exe.json"), read_codemodel_json_data("targets/cxx_static_lib.json"), @@ -569,6 +595,10 @@ def gen_check_targets(c, g, inSource): read_codemodel_json_data("targets/link_imported_object_exe.json"), read_codemodel_json_data("targets/link_imported_interface_exe.json"), + read_codemodel_json_data("targets/all_build_interface.json"), + read_codemodel_json_data("targets/zero_check_interface.json"), + read_codemodel_json_data("targets/iface_srcs.json"), + read_codemodel_json_data("targets/all_build_custom.json"), read_codemodel_json_data("targets/zero_check_custom.json"), read_codemodel_json_data("targets/custom_tgt.json"), @@ -592,6 +622,12 @@ def gen_check_targets(c, g, inSource): e["sources"] = precompile_header_data["sources"] e["sourceGroups"] = precompile_header_data["sourceGroups"] + if os.path.exists(os.path.join(reply_dir, "..", "..", "..", "..", "cxx", "cxx_std_11.txt")): + for e in expected: + if e["name"] == "cxx_standard_compile_feature_exe": + language_standard_data = read_codemodel_json_data("targets/cxx_standard_compile_feature_exe_languagestandard.json") + e["compileGroups"][0]["languageStandard"] = language_standard_data["languageStandard"] + if not os.path.exists(os.path.join(reply_dir, "..", "..", "..", "..", "ipo_enabled.txt")): for e in expected: try: @@ -691,6 +727,7 @@ def gen_check_projects(c, g): read_codemodel_json_data("projects/alias.json"), read_codemodel_json_data("projects/object.json"), read_codemodel_json_data("projects/imported.json"), + read_codemodel_json_data("projects/interface.json"), read_codemodel_json_data("projects/custom.json"), read_codemodel_json_data("projects/external.json"), ] diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json index ebe717aea..a51b6eb8d 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json @@ -7,6 +7,8 @@ "^ALL_BUILD::@a56b12a3f5c0529fb296$", "^ZERO_CHECK::@a56b12a3f5c0529fb296$", "^cxx_exe::@a56b12a3f5c0529fb296$", + "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$", + "^cxx_standard_exe::@a56b12a3f5c0529fb296$", "^cxx_lib::@a56b12a3f5c0529fb296$", "^cxx_shared_exe::@a56b12a3f5c0529fb296$", "^cxx_shared_lib::@a56b12a3f5c0529fb296$", diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json new file mode 100644 index 000000000..b10d49605 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json @@ -0,0 +1,14 @@ +{ + "source": "^interface$", + "build": "^interface$", + "parentSource": "^\\.$", + "childSources": null, + "targetIds": [ + "^ALL_BUILD::@25b7fa8ea00134654b85$", + "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "^iface_srcs::@25b7fa8ea00134654b85$" + ], + "projectName": "Interface", + "minimumCMakeVersion": "3.12", + "hasInstallRule": null +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json index c14495349..736d1f5a3 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json @@ -7,6 +7,7 @@ "^custom$", "^cxx$", "^imported$", + "^interface$", "^object$", "^.*/Tests/RunCMake/FileAPIExternalSource$", "^dir$" diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json index f3aac63db..4d0cdc056 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json @@ -6,6 +6,7 @@ "Custom", "Cxx", "Imported", + "Interface", "Object", "External" ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/cxx.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/cxx.json index 296ae6c25..363e8530c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/cxx.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/cxx.json @@ -10,6 +10,8 @@ "^ZERO_CHECK::@a56b12a3f5c0529fb296$", "^cxx_lib::@a56b12a3f5c0529fb296$", "^cxx_exe::@a56b12a3f5c0529fb296$", + "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$", + "^cxx_standard_exe::@a56b12a3f5c0529fb296$", "^cxx_shared_lib::@a56b12a3f5c0529fb296$", "^cxx_shared_exe::@a56b12a3f5c0529fb296$", "^cxx_static_lib::@a56b12a3f5c0529fb296$", diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/interface.json new file mode 100644 index 000000000..2a2276762 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/interface.json @@ -0,0 +1,13 @@ +{ + "name": "Interface", + "parentName": "codemodel-v2", + "childNames": null, + "directorySources": [ + "^interface$" + ], + "targetIds": [ + "^ALL_BUILD::@25b7fa8ea00134654b85$", + "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "^iface_srcs::@25b7fa8ea00134654b85$" + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_cxx.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_cxx.json index 92a794444..1f443b12a 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_cxx.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_cxx.json @@ -80,6 +80,14 @@ "backtrace": null }, { + "id": "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$", + "backtrace": null + }, + { + "id": "^cxx_standard_exe::@a56b12a3f5c0529fb296$", + "backtrace": null + }, + { "id": "^cxx_shared_lib::@a56b12a3f5c0529fb296$", "backtrace": null }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_interface.json new file mode 100644 index 000000000..fa2a6e5d1 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_interface.json @@ -0,0 +1,79 @@ +{ + "name": "ALL_BUILD", + "id": "^ALL_BUILD::@25b7fa8ea00134654b85$", + "directorySource": "^interface$", + "projectName": "Interface", + "type": "UTILITY", + "isGeneratorProvided": true, + "sources": [ + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD$", + "isGenerated": true, + "sourceGroupName": "", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD\\.rule$", + "isGenerated": true, + "sourceGroupName": "CMake Rules", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD$" + ] + }, + { + "name": "CMake Rules", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ALL_BUILD\\.rule$" + ] + } + ], + "compileGroups": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": null, + "artifacts": null, + "build": "^interface$", + "source": "^interface$", + "install": null, + "link": null, + "archive": null, + "dependencies": [ + { + "id": "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "backtrace": null + }, + { + "id": "^iface_srcs::@25b7fa8ea00134654b85$", + "backtrace": null + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json index b4def78c5..d023f99a7 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json @@ -116,6 +116,14 @@ "backtrace": null }, { + "id": "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$", + "backtrace": null + }, + { + "id": "^cxx_standard_exe::@a56b12a3f5c0529fb296$", + "backtrace": null + }, + { "id": "^cxx_shared_lib::@a56b12a3f5c0529fb296$", "backtrace": null }, @@ -168,6 +176,10 @@ "backtrace": null }, { + "id": "^iface_srcs::@25b7fa8ea00134654b85$", + "backtrace": null + }, + { "id": "^custom_exe::@c11385ffed57b860da63$", "backtrace": null }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json index e7ab55ba3..c9e652b2a 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json @@ -119,7 +119,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 37, + "line": 38, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_compile_feature_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_compile_feature_exe.json new file mode 100644 index 000000000..d6d573f8b --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_compile_feature_exe.json @@ -0,0 +1,110 @@ +{ + "name": "cxx_standard_compile_feature_exe", + "id": "^cxx_standard_compile_feature_exe::@a56b12a3f5c0529fb296$", + "directorySource": "^cxx$", + "projectName": "Cxx", + "type": "EXECUTABLE", + "isGeneratorProvided": null, + "sources": [ + { + "path": "^empty\\.cxx$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": "CXX", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 26, + "command": "add_executable", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "Source Files", + "sourcePaths": [ + "^empty\\.cxx$" + ] + } + ], + "compileGroups": [ + { + "language": "CXX", + "languageStandard" : + { + "backtraces": [ + [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 27, + "command": "set_property", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + ], + "standard" : "98" + }, + "sourcePaths": [ + "^empty\\.cxx$" + ], + "includes": null, + "defines": null, + "compileCommandFragments": null + } + ], + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 26, + "command": "add_executable", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": "^cxx_standard_compile_feature_exe(\\.exe)?$", + "artifacts": [ + { + "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_standard_compile_feature_exe(\\.exe)?$", + "_dllExtra": false + }, + { + "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_standard_compile_feature_exe\\.pdb$", + "_dllExtra": true + } + ], + "build": "^cxx$", + "source": "^cxx$", + "install": null, + "link": { + "language": "CXX", + "lto": null, + "commandFragments": null + }, + "archive": null, + "dependencies": [ + { + "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$", + "backtrace": null + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_compile_feature_exe_languagestandard.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_compile_feature_exe_languagestandard.json new file mode 100644 index 000000000..0c4eabb09 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_compile_feature_exe_languagestandard.json @@ -0,0 +1,36 @@ +{ + "languageStandard" : + { + "backtraces": [ + [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 29, + "command": "target_compile_features", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 30, + "command": "target_compile_features", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + ], + "standard" : "11" + } +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_exe.json new file mode 100644 index 000000000..9cb28321a --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_standard_exe.json @@ -0,0 +1,110 @@ +{ + "name": "cxx_standard_exe", + "id": "^cxx_standard_exe::@a56b12a3f5c0529fb296$", + "directorySource": "^cxx$", + "projectName": "Cxx", + "type": "EXECUTABLE", + "isGeneratorProvided": null, + "sources": [ + { + "path": "^empty\\.cxx$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": "CXX", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 23, + "command": "add_executable", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "Source Files", + "sourcePaths": [ + "^empty\\.cxx$" + ] + } + ], + "compileGroups": [ + { + "language": "CXX", + "languageStandard" : + { + "backtraces": [ + [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 24, + "command": "set_property", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + ], + "standard" : "17" + }, + "sourcePaths": [ + "^empty\\.cxx$" + ], + "includes": null, + "defines": null, + "compileCommandFragments": null + } + ], + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 23, + "command": "add_executable", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": "^cxx_standard_exe(\\.exe)?$", + "artifacts": [ + { + "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_standard_exe(\\.exe)?$", + "_dllExtra": false + }, + { + "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_standard_exe\\.pdb$", + "_dllExtra": true + } + ], + "build": "^cxx$", + "source": "^cxx$", + "install": null, + "link": { + "language": "CXX", + "lto": null, + "commandFragments": null + }, + "archive": null, + "dependencies": [ + { + "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$", + "backtrace": null + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/iface_srcs.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/iface_srcs.json new file mode 100644 index 000000000..97d7ccd77 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/iface_srcs.json @@ -0,0 +1,67 @@ +{ + "name": "iface_srcs", + "id": "^iface_srcs::@25b7fa8ea00134654b85$", + "directorySource": "^interface$", + "projectName": "Interface", + "type": "INTERFACE_LIBRARY", + "isGeneratorProvided": null, + "sources": [ + { + "path": "^empty\\.c$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": 3, + "command": "add_library", + "hasParent": true + }, + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "Source Files", + "sourcePaths": [ + "^empty\\.c$" + ] + } + ], + "compileGroups": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": 3, + "command": "add_library", + "hasParent": true + }, + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": null, + "artifacts": null, + "build": "^interface$", + "source": "^interface$", + "install": null, + "link": null, + "archive": null, + "dependencies": [ + { + "id": "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "backtrace": null + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json index 312f4c5ab..451e8d482 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 5, + "line": 6, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 5, + "line": 6, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json index 7d0e6df6d..cbd4346c8 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_interface_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 23, + "line": 29, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 23, + "line": 29, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json index 4aec5249b..d92a81076 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_object_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 18, + "line": 24, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 18, + "line": 24, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json index f5846ec9d..1197a73cc 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_shared_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 9, + "line": 14, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 9, + "line": 14, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json index 29a16958f..42564e047 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_imported_static_exe.json @@ -14,7 +14,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 13, + "line": 19, "command": "add_executable", "hasParent": true }, @@ -49,7 +49,7 @@ "backtrace": [ { "file": "^imported/CMakeLists\\.txt$", - "line": 13, + "line": 19, "command": "add_executable", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_interface.json new file mode 100644 index 000000000..fdd4b2a56 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_interface.json @@ -0,0 +1,70 @@ +{ + "name": "ZERO_CHECK", + "id": "^ZERO_CHECK::@25b7fa8ea00134654b85$", + "directorySource": "^interface$", + "projectName": "Interface", + "type": "UTILITY", + "isGeneratorProvided": true, + "sources": [ + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK$", + "isGenerated": true, + "sourceGroupName": "", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK\\.rule$", + "isGenerated": true, + "sourceGroupName": "CMake Rules", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK$" + ] + }, + { + "name": "CMake Rules", + "sourcePaths": [ + "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/interface/CMakeFiles/ZERO_CHECK\\.rule$" + ] + } + ], + "compileGroups": null, + "backtrace": [ + { + "file": "^interface/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": null, + "artifacts": null, + "build": "^interface$", + "source": "^interface$", + "install": null, + "link": null, + "archive": null, + "dependencies": null +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index c98a84c26..240595442 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -18,6 +18,7 @@ add_subdirectory(cxx) add_subdirectory(alias) add_subdirectory(object) add_subdirectory(imported) +add_subdirectory(interface) add_subdirectory(custom) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../FileAPIExternalSource" "${CMAKE_CURRENT_BINARY_DIR}/../FileAPIExternalBuild") add_subdirectory(dir) diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt index fa51195fe..76235f5c5 100644 --- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt @@ -19,3 +19,14 @@ target_link_options(cxx_exe PUBLIC TargetLinkOptions) target_link_directories(cxx_exe PUBLIC "${CMAKE_BINARY_DIR}/TargetLinkDir") target_precompile_headers(cxx_exe PUBLIC ../empty.h) + +add_executable(cxx_standard_exe ../empty.cxx) +set_property(TARGET cxx_standard_exe PROPERTY CXX_STANDARD 17) + +add_executable(cxx_standard_compile_feature_exe ../empty.cxx) +set_property(TARGET cxx_standard_compile_feature_exe PROPERTY CXX_STANDARD 98) +if(CMAKE_CXX_STANDARD_DEFAULT AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION) + target_compile_features(cxx_standard_compile_feature_exe PRIVATE cxx_std_11) + target_compile_features(cxx_standard_compile_feature_exe PRIVATE cxx_decltype) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_std_11.txt" "") +endif() diff --git a/Tests/RunCMake/FileAPI/imported/CMakeLists.txt b/Tests/RunCMake/FileAPI/imported/CMakeLists.txt index d36d88ba8..f79d87c82 100644 --- a/Tests/RunCMake/FileAPI/imported/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/imported/CMakeLists.txt @@ -1,15 +1,21 @@ project(Imported) add_library(imported_lib UNKNOWN IMPORTED) +set_target_properties(imported_lib PROPERTIES IMPORTED_LOCATION "imported_unk${CMAKE_STATIC_LIBRARY_SUFFIX}") add_executable(imported_exe IMPORTED) add_executable(link_imported_exe ../empty.c) target_link_libraries(link_imported_exe PRIVATE imported_lib) add_library(imported_shared_lib SHARED IMPORTED) +set_target_properties(imported_shared_lib PROPERTIES + IMPORTED_LOCATION "imported_shared${CMAKE_SHARED_LIBRARY_SUFFIX}" + IMPORTED_IMPLIB "imported_shared${CMAKE_IMPORT_LIBRARY_SUFFIX}" +) add_executable(link_imported_shared_exe ../empty.c) target_link_libraries(link_imported_shared_exe PRIVATE imported_shared_lib) add_library(imported_static_lib STATIC IMPORTED) +set_target_properties(imported_static_lib PROPERTIES IMPORTED_LOCATION "imported_static${CMAKE_STATIC_LIBRARY_SUFFIX}") add_executable(link_imported_static_exe ../empty.c) target_link_libraries(link_imported_static_exe PRIVATE imported_static_lib) diff --git a/Tests/RunCMake/FileAPI/interface/CMakeLists.txt b/Tests/RunCMake/FileAPI/interface/CMakeLists.txt new file mode 100644 index 000000000..97948c56c --- /dev/null +++ b/Tests/RunCMake/FileAPI/interface/CMakeLists.txt @@ -0,0 +1,3 @@ +project(Interface) +add_library(iface_none INTERFACE) +add_library(iface_srcs INTERFACE ../empty.c) diff --git a/Tests/RunCMake/File_Archive/RunCMakeTest.cmake b/Tests/RunCMake/File_Archive/RunCMakeTest.cmake index 2bd0cd892..3908f4243 100644 --- a/Tests/RunCMake/File_Archive/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Archive/RunCMakeTest.cmake @@ -16,3 +16,11 @@ run_cmake(zip-filtered) run_cmake(unsupported-format) run_cmake(zip-with-bad-compression) run_cmake(7zip-with-bad-compression) + +run_cmake(unsupported-compression-level) +run_cmake(argument-validation-compression-level-1) +run_cmake(argument-validation-compression-level-2) +run_cmake(gnutar-gz-compression-level) +run_cmake(pax-xz-compression-level) +run_cmake(pax-zstd-compression-level) +run_cmake(paxr-bz2-compression-level) diff --git a/Tests/RunCMake/File_Archive/argument-validation-compression-level-1-result.txt b/Tests/RunCMake/File_Archive/argument-validation-compression-level-1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/File_Archive/argument-validation-compression-level-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Archive/argument-validation-compression-level-1-stderr.txt b/Tests/RunCMake/File_Archive/argument-validation-compression-level-1-stderr.txt new file mode 100644 index 000000000..d7bc79a14 --- /dev/null +++ b/Tests/RunCMake/File_Archive/argument-validation-compression-level-1-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at compression-level.cmake:39 \(file\): + file compression level 100 should be in range 0 to 9 +Call Stack \(most recent call first\): + argument-validation-compression-level-1.cmake:8 \(check_compression_level\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Archive/argument-validation-compression-level-1.cmake b/Tests/RunCMake/File_Archive/argument-validation-compression-level-1.cmake new file mode 100644 index 000000000..adedc34db --- /dev/null +++ b/Tests/RunCMake/File_Archive/argument-validation-compression-level-1.cmake @@ -0,0 +1,8 @@ +set(OUTPUT_NAME "test.tar.gz") + +set(ARCHIVE_FORMAT gnutar) +set(COMPRESSION_TYPE GZip) + +include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake) + +check_compression_level("100") diff --git a/Tests/RunCMake/File_Archive/argument-validation-compression-level-2-result.txt b/Tests/RunCMake/File_Archive/argument-validation-compression-level-2-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/File_Archive/argument-validation-compression-level-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Archive/argument-validation-compression-level-2-stderr.txt b/Tests/RunCMake/File_Archive/argument-validation-compression-level-2-stderr.txt new file mode 100644 index 000000000..0f7bd9ef9 --- /dev/null +++ b/Tests/RunCMake/File_Archive/argument-validation-compression-level-2-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at compression-level.cmake:39 \(file\): + file compression level high should be in range 0 to 9 +Call Stack \(most recent call first\): + argument-validation-compression-level-2.cmake:8 \(check_compression_level\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Archive/argument-validation-compression-level-2.cmake b/Tests/RunCMake/File_Archive/argument-validation-compression-level-2.cmake new file mode 100644 index 000000000..fa6d3fd9f --- /dev/null +++ b/Tests/RunCMake/File_Archive/argument-validation-compression-level-2.cmake @@ -0,0 +1,8 @@ +set(OUTPUT_NAME "test.tar.gz") + +set(ARCHIVE_FORMAT gnutar) +set(COMPRESSION_TYPE GZip) + +include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake) + +check_compression_level("high") diff --git a/Tests/RunCMake/File_Archive/compression-level.cmake b/Tests/RunCMake/File_Archive/compression-level.cmake new file mode 100644 index 000000000..2f5141df1 --- /dev/null +++ b/Tests/RunCMake/File_Archive/compression-level.cmake @@ -0,0 +1,85 @@ +foreach(parameter OUTPUT_NAME ARCHIVE_FORMAT) + if(NOT DEFINED ${parameter}) + message(FATAL_ERROR "missing required parameter ${parameter}") + endif() +endforeach() + +set(COMPRESS_DIR compress_dir) +set(FULL_COMPRESS_DIR ${CMAKE_CURRENT_BINARY_DIR}/${COMPRESS_DIR}) + +set(DECOMPRESS_DIR decompress_dir) +set(FULL_DECOMPRESS_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DECOMPRESS_DIR}) + +set(FULL_OUTPUT_NAME ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}) + +set(CHECK_FILES + "f1.txt" + "d1/f1.txt" + "d 2/f1.txt" + "d + 3/f1.txt" + "d_4/f1.txt" + "d-4/f1.txt" + "My Special Directory/f1.txt" +) + +function(check_compression_level COMPRESSION_LEVEL) + foreach(file ${CHECK_FILES}) + configure_file(${CMAKE_CURRENT_LIST_FILE} ${FULL_COMPRESS_DIR}/${file} COPYONLY) + endforeach() + + if(UNIX) + execute_process(COMMAND ln -sf f1.txt ${FULL_COMPRESS_DIR}/d1/f2.txt) + list(APPEND CHECK_FILES "d1/f2.txt") + endif() + + file(REMOVE ${FULL_OUTPUT_NAME}) + file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR}) + file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR}) + + file(ARCHIVE_CREATE + OUTPUT ${FULL_OUTPUT_NAME} + FORMAT "${ARCHIVE_FORMAT}" + COMPRESSION "${COMPRESSION_TYPE}" + COMPRESSION_LEVEL ${COMPRESSION_LEVEL} + VERBOSE + PATHS ${COMPRESS_DIR}) + + file(ARCHIVE_EXTRACT + INPUT ${FULL_OUTPUT_NAME} + ${DECOMPRESSION_OPTIONS} + DESTINATION ${FULL_DECOMPRESS_DIR} + VERBOSE) + + if(CUSTOM_CHECK_FILES) + set(CHECK_FILES ${CUSTOM_CHECK_FILES}) + endif() + + foreach(file ${CHECK_FILES}) + set(input ${FULL_COMPRESS_DIR}/${file}) + set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) + + if(NOT EXISTS ${input}) + message(SEND_ERROR "Cannot find input file ${output}") + endif() + + if(NOT EXISTS ${output}) + message(SEND_ERROR "Cannot find output file ${output}") + endif() + + file(MD5 ${input} input_md5) + file(MD5 ${output} output_md5) + + if(NOT input_md5 STREQUAL output_md5) + message(SEND_ERROR "Files \"${input}\" and \"${output}\" are different") + endif() + endforeach() + + foreach(file ${NOT_EXISTING_FILES_CHECK}) + set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) + + if(EXISTS ${output}) + message(SEND_ERROR "File ${output} exists but it shouldn't") + endif() + endforeach() + +endfunction() diff --git a/Tests/RunCMake/File_Archive/gnutar-gz-compression-level.cmake b/Tests/RunCMake/File_Archive/gnutar-gz-compression-level.cmake new file mode 100644 index 000000000..4106db595 --- /dev/null +++ b/Tests/RunCMake/File_Archive/gnutar-gz-compression-level.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.gz") + +set(ARCHIVE_FORMAT gnutar) +set(COMPRESSION_TYPE GZip) + +include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake) + +check_compression_level("1") +check_compression_level("5") +check_compression_level("9") diff --git a/Tests/RunCMake/File_Archive/pax-xz-compression-level.cmake b/Tests/RunCMake/File_Archive/pax-xz-compression-level.cmake new file mode 100644 index 000000000..d241adb94 --- /dev/null +++ b/Tests/RunCMake/File_Archive/pax-xz-compression-level.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.xz") + +set(ARCHIVE_FORMAT pax) +set(COMPRESSION_TYPE XZ) + +include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake) + +check_compression_level("1") +check_compression_level("5") +check_compression_level("9") diff --git a/Tests/RunCMake/File_Archive/pax-zstd-compression-level.cmake b/Tests/RunCMake/File_Archive/pax-zstd-compression-level.cmake new file mode 100644 index 000000000..73fd84dd2 --- /dev/null +++ b/Tests/RunCMake/File_Archive/pax-zstd-compression-level.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.zstd") + +set(ARCHIVE_FORMAT pax) +set(COMPRESSION_TYPE Zstd) + +include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake) + +check_compression_level("1") +check_compression_level("5") +check_compression_level("9") diff --git a/Tests/RunCMake/File_Archive/paxr-bz2-compression-level.cmake b/Tests/RunCMake/File_Archive/paxr-bz2-compression-level.cmake new file mode 100644 index 000000000..05ea3fce7 --- /dev/null +++ b/Tests/RunCMake/File_Archive/paxr-bz2-compression-level.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.bz2") + +set(ARCHIVE_FORMAT paxr) +set(COMPRESSION_TYPE BZip2) + +include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake) + +check_compression_level("1") +check_compression_level("5") +check_compression_level("9") diff --git a/Tests/RunCMake/File_Archive/roundtrip.cmake b/Tests/RunCMake/File_Archive/roundtrip.cmake index 063836791..404925663 100644 --- a/Tests/RunCMake/File_Archive/roundtrip.cmake +++ b/Tests/RunCMake/File_Archive/roundtrip.cmake @@ -90,3 +90,20 @@ function(check_magic EXPECTED) "Actual [${ACTUAL}] does not match expected [${EXPECTED}]") endif() endfunction() + + +function(check_compression_level COMPRESSION_LEVEL) + file(ARCHIVE_CREATE + OUTPUT "${FULL_OUTPUT_NAME}_compression_level" + FORMAT "${ARCHIVE_FORMAT}" + COMPRESSION_LEVEL ${COMPRESSION_LEVEL} + COMPRESSION "${COMPRESSION_TYPE}" + VERBOSE + PATHS ${COMPRESS_DIR}) + + file(ARCHIVE_EXTRACT + INPUT "${FULL_OUTPUT_NAME}_compression_level" + ${DECOMPRESSION_OPTIONS} + DESTINATION ${FULL_DECOMPRESS_DIR} + VERBOSE) +endfunction() diff --git a/Tests/RunCMake/File_Archive/unsupported-compression-level-result.txt b/Tests/RunCMake/File_Archive/unsupported-compression-level-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/File_Archive/unsupported-compression-level-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Archive/unsupported-compression-level-stderr.txt b/Tests/RunCMake/File_Archive/unsupported-compression-level-stderr.txt new file mode 100644 index 000000000..860b4229a --- /dev/null +++ b/Tests/RunCMake/File_Archive/unsupported-compression-level-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at compression-level.cmake:39 \(file\): + file compression level is not supported for compression "None" +Call Stack \(most recent call first\): + unsupported-compression-level.cmake:7 \(check_compression_level\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Archive/unsupported-compression-level.cmake b/Tests/RunCMake/File_Archive/unsupported-compression-level.cmake new file mode 100644 index 000000000..ea06d1d00 --- /dev/null +++ b/Tests/RunCMake/File_Archive/unsupported-compression-level.cmake @@ -0,0 +1,7 @@ +set(OUTPUT_NAME "test.7z") + +set(ARCHIVE_FORMAT 7zip) + +include(${CMAKE_CURRENT_LIST_DIR}/compression-level.cmake) + +check_compression_level("1") diff --git a/Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt b/Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt new file mode 100644 index 000000000..08c2adabb --- /dev/null +++ b/Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt @@ -0,0 +1 @@ +^foo-\$<CONFIG>$ diff --git a/Tests/RunCMake/File_Configure/AngleBracketsContent.cmake b/Tests/RunCMake/File_Configure/AngleBracketsContent.cmake new file mode 100644 index 000000000..04c63bb63 --- /dev/null +++ b/Tests/RunCMake/File_Configure/AngleBracketsContent.cmake @@ -0,0 +1,6 @@ +file(CONFIGURE + OUTPUT "file.txt" + CONTENT "foo-$<CONFIG>" +) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/file.txt out) +message("${out}") diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt deleted file mode 100644 index acda6541a..000000000 --- a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at BadArgGeneratorExpressionContent.cmake:[0-9]+ \(file\): - file CONFIGURE called with CONTENT containing a "<". This character is not - allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake deleted file mode 100644 index 75fe9e5d1..000000000 --- a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake +++ /dev/null @@ -1,4 +0,0 @@ -file(CONFIGURE - OUTPUT "file.txt" - CONTENT "foo-$<CONFIG>" -) diff --git a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake index 0337014eb..e79de795f 100644 --- a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake @@ -1,7 +1,7 @@ include(RunCMake) +run_cmake(AngleBracketsContent) run_cmake(BadArg) -run_cmake(BadArgGeneratorExpressionContent) run_cmake(BadArgGeneratorExpressionOutput) run_cmake(DirOutput) run_cmake(NewLineStyle-NoArg) diff --git a/Tests/RunCMake/File_Generate/AdjacentInOut.cmake b/Tests/RunCMake/File_Generate/AdjacentInOut.cmake new file mode 100644 index 000000000..828c2ee69 --- /dev/null +++ b/Tests/RunCMake/File_Generate/AdjacentInOut.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0070 NEW) +if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/AdjacentInOut.txt") + message(FATAL_ERROR "CMake should not re-run during the build!") +endif() +configure_file(AdjacentInOut.in ${CMAKE_CURRENT_BINARY_DIR}/AdjacentInOut.txt.tmp) +file(GENERATE OUTPUT AdjacentInOut.txt INPUT ${CMAKE_CURRENT_BINARY_DIR}/AdjacentInOut.txt.tmp) diff --git a/Tests/RunCMake/File_Generate/AdjacentInOut.in b/Tests/RunCMake/File_Generate/AdjacentInOut.in new file mode 100644 index 000000000..bfbbda73c --- /dev/null +++ b/Tests/RunCMake/File_Generate/AdjacentInOut.in @@ -0,0 +1 @@ +Sample Text File diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt index dbabaa97b..a7a231b12 100644 --- a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt +++ b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt @@ -1,4 +1,18 @@ -^CMake Warning \(dev\) in CMakeLists.txt: +^(CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative + paths. Run "cmake --help-policy CMP0070" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + file\(GENERATE\) given relative OUTPUT path: + + relative-output-WARN.txt + + This is not defined behavior unless CMP0070 is set to NEW. For + compatibility with older versions of CMake, the previous undefined behavior + will be used. +This warning is for project developers. Use -Wno-dev to suppress it. ++)+ +CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative paths. Run "cmake --help-policy CMP0070" for policy details. Use the cmake_policy command to set the policy and suppress this warning. diff --git a/Tests/RunCMake/File_Generate/CMakeLists.txt b/Tests/RunCMake/File_Generate/CMakeLists.txt index bc0cf5d16..3178de583 100644 --- a/Tests/RunCMake/File_Generate/CMakeLists.txt +++ b/Tests/RunCMake/File_Generate/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) if(NOT TEST_FILE) set(TEST_FILE ${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/File_Generate/GenerateSource.cmake b/Tests/RunCMake/File_Generate/GenerateSource.cmake index 147a7f66a..d5504e330 100644 --- a/Tests/RunCMake/File_Generate/GenerateSource.cmake +++ b/Tests/RunCMake/File_Generate/GenerateSource.cmake @@ -10,3 +10,6 @@ file(GENERATE ) add_executable(mn "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") + +add_subdirectory(GenerateSource) +target_link_libraries(mn PRIVATE ObjLib) diff --git a/Tests/RunCMake/File_Generate/GenerateSource/CMakeLists.txt b/Tests/RunCMake/File_Generate/GenerateSource/CMakeLists.txt new file mode 100644 index 000000000..bca892278 --- /dev/null +++ b/Tests/RunCMake/File_Generate/GenerateSource/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(ObjLib OBJECT) + +target_sources(ObjLib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/ObjLib.cpp") + +# Ensure re-generation +file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/ObjLib.cpp") + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ObjLib.cpp" CONTENT "") diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index 94aaca84a..48fb71c7c 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -4,6 +4,10 @@ run_cmake(CMP0070-NEW) run_cmake(CMP0070-OLD) run_cmake(CMP0070-WARN) +run_cmake(SourceProperty) +run_cmake(SourceProperty-CMP0070-NEW) +run_cmake(SourceProperty-CMP0070-OLD) + run_cmake(CommandConflict) if(RunCMake_GENERATOR_IS_MULTI_CONFIG) run_cmake(OutputConflict) @@ -29,6 +33,13 @@ foreach(l CXX C) endif() endforeach() +run_cmake(Target) +file(READ "${RunCMake_BINARY_DIR}/Target-build/sub1/output.txt" sub_1) +file(READ "${RunCMake_BINARY_DIR}/Target-build/sub2/output.txt" sub_2) +if(NOT sub_1 MATCHES "first" OR NOT sub_2 MATCHES "second") + message(SEND_ERROR "Wrong target used by TARGET argument! ${sub_1} ${sub_2}") +endif() + set(timeformat "%Y%j%H%M%S") file(REMOVE "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt") @@ -72,6 +83,7 @@ if (UNIX AND EXISTS /bin/sh) if (NOT script_output STREQUAL SUCCESS) message(SEND_ERROR "Generated script did not execute correctly:\n${script_output}\n====\n${script_error}") endif() + unset(RunCMake_TEST_NO_CLEAN) endif() if (RunCMake_GENERATOR MATCHES Makefiles) @@ -104,3 +116,10 @@ if (RunCMake_GENERATOR MATCHES Makefiles) message(SEND_ERROR "File did not re-generate: \"${RunCMake_BINARY_DIR}/ReRunCMake-build/output_file.txt\"") endif() endif() + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AdjacentInOut-build) +run_cmake(AdjacentInOut) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(AdjacentInOut-nowork ${CMAKE_COMMAND} --build .) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-result.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-stderr.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-stderr.txt new file mode 100644 index 000000000..2c385c48f --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at SourceProperty-CMP0070-NEW.cmake:[0-9]+ \(add_library\): + Cannot find source file: + +.*\/relative-output-NEW\.c + + Tried extensions \.c \.C.* +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW.cmake b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW.cmake new file mode 100644 index 000000000..d2b3e0c0a --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-NEW.cmake @@ -0,0 +1,8 @@ +enable_language(C) +add_library(foo) + +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT relative-output-NEW.c CONTENT "") +target_sources(foo PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/relative-output-NEW.c" +) diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-result.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt new file mode 100644 index 000000000..fcb53a781 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD-stderr.txt @@ -0,0 +1,23 @@ +^CMake Deprecation Warning at SourceProperty-CMP0070-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0070 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at SourceProperty-CMP0070-OLD.cmake:[0-9]+ \(add_library\): + Cannot find source file: + +.*\/relative-output-OLD\.c + + Tried extensions \.c \.C.* +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD.cmake b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD.cmake new file mode 100644 index 000000000..48eae1e45 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-CMP0070-OLD.cmake @@ -0,0 +1,8 @@ +enable_language(C) +add_library(foo) + +cmake_policy(SET CMP0070 OLD) +file(GENERATE OUTPUT relative-output-OLD.c CONTENT "") +target_sources(foo PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/relative-output-OLD.c" +) diff --git a/Tests/RunCMake/File_Generate/SourceProperty-stderr.txt b/Tests/RunCMake/File_Generate/SourceProperty-stderr.txt new file mode 100644 index 000000000..47ec651fb --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at SourceProperty.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0070 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/File_Generate/SourceProperty.cmake b/Tests/RunCMake/File_Generate/SourceProperty.cmake new file mode 100644 index 000000000..231c67022 --- /dev/null +++ b/Tests/RunCMake/File_Generate/SourceProperty.cmake @@ -0,0 +1,14 @@ +enable_language(C) +add_library(SourceProperty) + +cmake_policy(SET CMP0070 OLD) +file(GENERATE OUTPUT relative-output-OLD.c CONTENT "") +target_sources(SourceProperty PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/relative-output-OLD.c" +) + +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT relative-output-NEW.c CONTENT "") +target_sources(SourceProperty PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/relative-output-NEW.c" +) diff --git a/Tests/RunCMake/File_Generate/Target.cmake b/Tests/RunCMake/File_Generate/Target.cmake new file mode 100644 index 000000000..16e8457d0 --- /dev/null +++ b/Tests/RunCMake/File_Generate/Target.cmake @@ -0,0 +1,2 @@ +add_subdirectory(sub1) +add_subdirectory(sub2) diff --git a/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt b/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt new file mode 100644 index 000000000..34c51a437 --- /dev/null +++ b/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(library IMPORTED STATIC) +set_property(TARGET library PROPERTY COMPILE_DEFINITIONS "first") + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + CONTENT "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>" + TARGET library +) diff --git a/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt b/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt new file mode 100644 index 000000000..09b81aca3 --- /dev/null +++ b/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(library IMPORTED STATIC) +set_property(TARGET library PROPERTY COMPILE_DEFINITIONS "second") + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + CONTENT "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>" + TARGET library +) diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-OLD-stderr.txt b/Tests/RunCMake/FindOpenGL/CMP0072-OLD-stderr.txt new file mode 100644 index 000000000..68d23d48c --- /dev/null +++ b/Tests/RunCMake/FindOpenGL/CMP0072-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0072-OLD.cmake:1 \(cmake_policy\): + The OLD behavior for policy CMP0072 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/FindPkgConfig/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt index 72abfc809..74b3ff8de 100644 --- a/Tests/RunCMake/FindPkgConfig/CMakeLists.txt +++ b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake index fc3a7664b..aa293d55a 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake @@ -20,7 +20,7 @@ endif() unset(FOO_MODULE_NAME) -# verify variable get's also set on subsequent run +# verify variable gets also set on subsequent run pkg_search_module(FOO REQUIRED foo bletch bar) if(NOT FOO_MODULE_NAME STREQUAL "bletch") diff --git a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake index 5f5f7f5a4..2bdf91329 100644 --- a/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindSWIG/RunCMakeTest.cmake @@ -2,3 +2,6 @@ include(RunCMake) run_cmake(components) run_cmake(missing-components) +run_cmake(version) +run_cmake(version-exact) +run_cmake(version-range) diff --git a/Tests/RunCMake/FindSWIG/version-exact.cmake b/Tests/RunCMake/FindSWIG/version-exact.cmake new file mode 100644 index 000000000..ec3651fba --- /dev/null +++ b/Tests/RunCMake/FindSWIG/version-exact.cmake @@ -0,0 +1,17 @@ +cmake_minimum_required (VERSION 3.18...3.19) + +find_package (SWIG) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG") +endif() + +# clean-up SWIG variables +unset (SWIG_EXECUTABLE CACHE) +unset (SWIG_DIR CACHE) + +set (version ${SWIG_VERSION}) + +find_package (SWIG ${SWIG_VERSION} EXACT) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG with version ${version} EXACT") +endif() diff --git a/Tests/RunCMake/FindSWIG/version-range.cmake b/Tests/RunCMake/FindSWIG/version-range.cmake new file mode 100644 index 000000000..7ba113447 --- /dev/null +++ b/Tests/RunCMake/FindSWIG/version-range.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required (VERSION 3.18...3.19) + +find_package (SWIG) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG") +endif() + +# clean-up SWIG variables +unset (SWIG_EXECUTABLE CACHE) +unset (SWIG_DIR CACHE) + +## Specify a range including current SWIG version +string (REGEX MATCH "^([0-9]+)" upper_version "${SWIG_VERSION}") +math (EXPR upper_version "${upper_version} + 1") + +find_package (SWIG 1.0...${upper_version}.0) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG with version range 1.0...${upper_version}.0") +endif() + +# clean-up SWIG variables +unset (SWIG_EXECUTABLE CACHE) +unset (SWIG_DIR CACHE) + +## Specify a range excluding current SWIG version +set (range 1.0...<${SWIG_VERSION}) +find_package (SWIG ${range}) +if (SWIG_FOUND) + message (FATAL_ERROR "Unexpectedly find SWIG with version range ${range}") +endif() diff --git a/Tests/RunCMake/FindSWIG/version.cmake b/Tests/RunCMake/FindSWIG/version.cmake new file mode 100644 index 000000000..a4f1c390e --- /dev/null +++ b/Tests/RunCMake/FindSWIG/version.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required (VERSION 3.18...3.19) + +find_package (SWIG 1.0) +if (NOT SWIG_FOUND) + message (FATAL_ERROR "Failed to find SWIG with version 1.0") +endif() diff --git a/Tests/RunCMake/GNUInstallDirs/Opt-Debian-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Opt-Debian-stderr.txt new file mode 100644 index 000000000..546fb5cc2 --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/Opt-Debian-stderr.txt @@ -0,0 +1,30 @@ +^CMAKE_INSTALL_BINDIR='bin' +CMAKE_INSTALL_DATADIR='share' +CMAKE_INSTALL_DATAROOTDIR='share' +CMAKE_INSTALL_DOCDIR='share/doc/Opt' +CMAKE_INSTALL_INCLUDEDIR='include' +CMAKE_INSTALL_INFODIR='share/info' +CMAKE_INSTALL_LIBDIR='lib' +CMAKE_INSTALL_LIBEXECDIR='libexec' +CMAKE_INSTALL_LOCALEDIR='share/locale' +CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' +CMAKE_INSTALL_MANDIR='share/man' +CMAKE_INSTALL_SBINDIR='sbin' +CMAKE_INSTALL_SHAREDSTATEDIR='com' +CMAKE_INSTALL_SYSCONFDIR='etc' +CMAKE_INSTALL_FULL_BINDIR='/opt/Opt/bin' +CMAKE_INSTALL_FULL_DATADIR='/opt/Opt/share' +CMAKE_INSTALL_FULL_DATAROOTDIR='/opt/Opt/share' +CMAKE_INSTALL_FULL_DOCDIR='/opt/Opt/share/doc/Opt' +CMAKE_INSTALL_FULL_INCLUDEDIR='/opt/Opt/include' +CMAKE_INSTALL_FULL_INFODIR='/opt/Opt/share/info' +CMAKE_INSTALL_FULL_LIBDIR='/opt/Opt/lib' +CMAKE_INSTALL_FULL_LIBEXECDIR='/opt/Opt/libexec' +CMAKE_INSTALL_FULL_LOCALEDIR='/opt/Opt/share/locale' +CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var/opt/Opt' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run/opt/Opt' +CMAKE_INSTALL_FULL_MANDIR='/opt/Opt/share/man' +CMAKE_INSTALL_FULL_SBINDIR='/opt/Opt/sbin' +CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/opt/Opt/com' +CMAKE_INSTALL_FULL_SYSCONFDIR='/etc/opt/Opt'$ diff --git a/Tests/RunCMake/GNUInstallDirs/Root-Debian-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Root-Debian-stderr.txt new file mode 100644 index 000000000..25f80d3f6 --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/Root-Debian-stderr.txt @@ -0,0 +1,30 @@ +^CMAKE_INSTALL_BINDIR='usr/bin' +CMAKE_INSTALL_DATADIR='usr/share' +CMAKE_INSTALL_DATAROOTDIR='usr/share' +CMAKE_INSTALL_DOCDIR='usr/share/doc/Root' +CMAKE_INSTALL_INCLUDEDIR='usr/include' +CMAKE_INSTALL_INFODIR='usr/share/info' +CMAKE_INSTALL_LIBDIR='usr/lib' +CMAKE_INSTALL_LIBEXECDIR='usr/libexec' +CMAKE_INSTALL_LOCALEDIR='usr/share/locale' +CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' +CMAKE_INSTALL_MANDIR='usr/share/man' +CMAKE_INSTALL_SBINDIR='usr/sbin' +CMAKE_INSTALL_SHAREDSTATEDIR='usr/com' +CMAKE_INSTALL_SYSCONFDIR='etc' +CMAKE_INSTALL_FULL_BINDIR='/usr/bin' +CMAKE_INSTALL_FULL_DATADIR='/usr/share' +CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/share' +CMAKE_INSTALL_FULL_DOCDIR='/usr/share/doc/Root' +CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/include' +CMAKE_INSTALL_FULL_INFODIR='/usr/share/info' +CMAKE_INSTALL_FULL_LIBDIR='/usr/lib' +CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/libexec' +CMAKE_INSTALL_FULL_LOCALEDIR='/usr/share/locale' +CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run' +CMAKE_INSTALL_FULL_MANDIR='/usr/share/man' +CMAKE_INSTALL_FULL_SBINDIR='/usr/sbin' +CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/com' +CMAKE_INSTALL_FULL_SYSCONFDIR='/etc'$ diff --git a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake index eb2c1a2a6..529e10a22 100644 --- a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake +++ b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake @@ -4,6 +4,8 @@ if(SYSTEM_NAME STREQUAL "FreeBSD") set(variant "-FreeBSD") elseif(SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$") set(variant "-BSD") +elseif(EXISTS "/etc/debian_version") + set(variant "-Debian") else() set(variant "") endif() diff --git a/Tests/RunCMake/GNUInstallDirs/Usr-Debian-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Usr-Debian-stderr.txt new file mode 100644 index 000000000..89578ee56 --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/Usr-Debian-stderr.txt @@ -0,0 +1,30 @@ +^CMAKE_INSTALL_BINDIR='bin' +CMAKE_INSTALL_DATADIR='share' +CMAKE_INSTALL_DATAROOTDIR='share' +CMAKE_INSTALL_DOCDIR='share/doc/Usr' +CMAKE_INSTALL_INCLUDEDIR='include' +CMAKE_INSTALL_INFODIR='share/info' +CMAKE_INSTALL_LIBDIR='lib/arch' +CMAKE_INSTALL_LIBEXECDIR='lib/arch' +CMAKE_INSTALL_LOCALEDIR='share/locale' +CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' +CMAKE_INSTALL_MANDIR='share/man' +CMAKE_INSTALL_SBINDIR='sbin' +CMAKE_INSTALL_SHAREDSTATEDIR='com' +CMAKE_INSTALL_SYSCONFDIR='etc' +CMAKE_INSTALL_FULL_BINDIR='/usr/bin' +CMAKE_INSTALL_FULL_DATADIR='/usr/share' +CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/share' +CMAKE_INSTALL_FULL_DOCDIR='/usr/share/doc/Usr' +CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/include' +CMAKE_INSTALL_FULL_INFODIR='/usr/share/info' +CMAKE_INSTALL_FULL_LIBDIR='/usr/lib/arch' +CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/lib/arch' +CMAKE_INSTALL_FULL_LOCALEDIR='/usr/share/locale' +CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run' +CMAKE_INSTALL_FULL_MANDIR='/usr/share/man' +CMAKE_INSTALL_FULL_SBINDIR='/usr/sbin' +CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/com' +CMAKE_INSTALL_FULL_SYSCONFDIR='/etc'$ diff --git a/Tests/RunCMake/GNUInstallDirs/UsrLocal-Debian-stderr.txt b/Tests/RunCMake/GNUInstallDirs/UsrLocal-Debian-stderr.txt new file mode 100644 index 000000000..30795c8a9 --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/UsrLocal-Debian-stderr.txt @@ -0,0 +1,30 @@ +^CMAKE_INSTALL_BINDIR='bin' +CMAKE_INSTALL_DATADIR='share' +CMAKE_INSTALL_DATAROOTDIR='share' +CMAKE_INSTALL_DOCDIR='share/doc/UsrLocal' +CMAKE_INSTALL_INCLUDEDIR='include' +CMAKE_INSTALL_INFODIR='share/info' +CMAKE_INSTALL_LIBDIR='lib' +CMAKE_INSTALL_LIBEXECDIR='libexec' +CMAKE_INSTALL_LOCALEDIR='share/locale' +CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' +CMAKE_INSTALL_MANDIR='share/man' +CMAKE_INSTALL_SBINDIR='sbin' +CMAKE_INSTALL_SHAREDSTATEDIR='com' +CMAKE_INSTALL_SYSCONFDIR='etc' +CMAKE_INSTALL_FULL_BINDIR='/usr/local/bin' +CMAKE_INSTALL_FULL_DATADIR='/usr/local/share' +CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/local/share' +CMAKE_INSTALL_FULL_DOCDIR='/usr/local/share/doc/UsrLocal' +CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/local/include' +CMAKE_INSTALL_FULL_INFODIR='/usr/local/share/info' +CMAKE_INSTALL_FULL_LIBDIR='/usr/local/lib' +CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/local/libexec' +CMAKE_INSTALL_FULL_LOCALEDIR='/usr/local/share/locale' +CMAKE_INSTALL_FULL_LOCALSTATEDIR='/usr/local/var' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/usr/local/var/run' +CMAKE_INSTALL_FULL_MANDIR='/usr/local/share/man' +CMAKE_INSTALL_FULL_SBINDIR='/usr/local/sbin' +CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/local/com' +CMAKE_INSTALL_FULL_SYSCONFDIR='/usr/local/etc'$ diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/COMPILE_LANGUAGE-TARGET_PROPERTY.cmake b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/COMPILE_LANGUAGE-TARGET_PROPERTY.cmake new file mode 100644 index 000000000..293dddacc --- /dev/null +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/COMPILE_LANGUAGE-TARGET_PROPERTY.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +add_library (lib SHARED empty.c) +set_target_properties(lib PROPERTIES + INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:C>:/usr/include>" + COMPILE_DEFINITIONS "$<$<COMPILE_LANGUAGE:C>:DEF>" + COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:C>:-O>") + +add_custom_target(drive + COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:lib,INCLUDE_DIRECTORIES> + $<TARGET_PROPERTY:lib,COMPILE_DEFINITIONS> + $<TARGET_PROPERTY:lib,COMPILE_OPTIONS>) + +add_custom_command(TARGET drive PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:lib,INCLUDE_DIRECTORIES> + $<TARGET_PROPERTY:lib,COMPILE_DEFINITIONS> + $<TARGET_PROPERTY:lib,COMPILE_OPTIONS>) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/RunCMakeTest.cmake index 6691fdfca..15a5e79eb 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-COMPILE_LANGUAGE/RunCMakeTest.cmake @@ -8,3 +8,4 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(COMPILE_LANGUAGE-TARGET_PROPERTY) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/COMPILE_LANG_AND_ID-TARGET_PROPERTY.cmake b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/COMPILE_LANG_AND_ID-TARGET_PROPERTY.cmake new file mode 100644 index 000000000..6a718d64a --- /dev/null +++ b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/COMPILE_LANG_AND_ID-TARGET_PROPERTY.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +add_library (lib SHARED empty.c) +set_target_properties(lib PROPERTIES + INCLUDE_DIRECTORIES "$<$<COMPILE_LANG_AND_ID:C,GNU>:/usr/include>" + COMPILE_DEFINITIONS "$<$<COMPILE_LANG_AND_ID:C,GNU>:DEF>" + COMPILE_OPTIONS "$<$<COMPILE_LANG_AND_ID:C,GNU>:-O>") + +add_custom_target(drive + COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:lib,INCLUDE_DIRECTORIES> + $<TARGET_PROPERTY:lib,COMPILE_DEFINITIONS> + $<TARGET_PROPERTY:lib,COMPILE_OPTIONS>) + +add_custom_command(TARGET drive PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:lib,INCLUDE_DIRECTORIES> + $<TARGET_PROPERTY:lib,COMPILE_DEFINITIONS> + $<TARGET_PROPERTY:lib,COMPILE_OPTIONS>) diff --git a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/RunCMakeTest.cmake index a0a7bb9be..68bd05d2e 100644 --- a/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-COMPILE_LANG_AND_ID/RunCMakeTest.cmake @@ -8,3 +8,4 @@ run_cmake(COMPILE_LANG_AND_ID-add_executable) run_cmake(COMPILE_LANG_AND_ID-add_library) run_cmake(COMPILE_LANG_AND_ID-add_test) run_cmake(COMPILE_LANG_AND_ID-unknown-lang) +run_cmake(COMPILE_LANG_AND_ID-TARGET_PROPERTY) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake index ccec63374..55b0f9b24 100644 --- a/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake @@ -2,8 +2,10 @@ include(RunCMake) run_cmake(TARGET_FILE-recursion) run_cmake(OUTPUT_NAME-recursion) -run_cmake(TARGET_FILE_PREFIX) +run_cmake(TARGET_FILE_DIR-dependency) +run_cmake(TARGET_FILE_DIR-no-dependency) run_cmake(TARGET_FILE_PREFIX-imported-target) +run_cmake(TARGET_FILE_PREFIX) run_cmake(TARGET_FILE_PREFIX-non-valid-target) run_cmake(TARGET_LINKER_FILE_PREFIX-non-valid-target) run_cmake(TARGET_FILE_SUFFIX) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-result.txt b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-stderr.txt b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-stderr.txt new file mode 100644 index 000000000..0a79032e3 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency-stderr.txt @@ -0,0 +1,6 @@ +.*Policy CMP0112 is not set.* +.*Dependency being added to target.* +.*exec1.* +CMake Error: The inter-target dependency graph.* +.*"exec1" of type EXECUTABLE + depends on "copyFile" \(strong\) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency.cmake new file mode 100644 index 000000000..e18ccd96e --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-dependency.cmake @@ -0,0 +1,12 @@ +set(CMAKE_POLICY_WARNING_CMP0112 TRUE) + +enable_language (C) + +add_executable (exec1 empty.c) + +add_custom_target(copyFile + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" + "$<TARGET_FILE_DIR:exec1>/$<TARGET_FILE_BASE_NAME:exec1>_e.c" +) +add_dependencies(exec1 copyFile) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-no-dependency.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-no-dependency.cmake new file mode 100644 index 000000000..e048e1020 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/TARGET_FILE_DIR-no-dependency.cmake @@ -0,0 +1,12 @@ +cmake_policy(SET CMP0112 NEW) + +enable_language (C) + +add_executable (exec1 empty.c) + +add_custom_target(copyFile + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" + "$<TARGET_FILE_DIR:exec1>/$<TARGET_FILE_BASE_NAME:exec1>_e.c" +) +add_dependencies(exec1 copyFile) diff --git a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake index b3977f1ba..5a5a7bf9f 100644 --- a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake @@ -26,7 +26,7 @@ function(run_GEH) endforeach() endfunction() -# remove these flags from the enviornment if they have been set +# remove these flags from the environment if they have been set # so the tests run the correct env set(env_cxx_flags $ENV{CXXFLAGS}) if(env_cxx_flags) diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt index 42dd0ce50..130de2b70 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt @@ -10,15 +10,6 @@ Call Stack \(most recent call first\): CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): Error evaluating generator expression: - \$<CONFIG:Foo,Bar> - - \$<CONFIG> expression requires one or zero parameters. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ -CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): - Error evaluating generator expression: - \$<CONFIG:Foo-Bar> Expression syntax not recognized. diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake index 5c22aaabe..1735ab72c 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake @@ -1,6 +1,5 @@ add_custom_target(check ALL COMMAND check $<CONFIG:.> - $<CONFIG:Foo,Bar> $<CONFIG:Foo-Bar> $<$<CONFIG:Foo-Nested>:foo> VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/CMakeLists.txt b/Tests/RunCMake/GeneratorExpression/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/GeneratorExpression/CMakeLists.txt +++ b/Tests/RunCMake/GeneratorExpression/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorExpression/CONFIG-empty-entries-check.cmake b/Tests/RunCMake/GeneratorExpression/CONFIG-empty-entries-check.cmake new file mode 100644 index 000000000..b43256bdf --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CONFIG-empty-entries-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/CONFIG-empty-entries-generated.txt" content) + +set(expected "1234") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/CONFIG-empty-entries.cmake b/Tests/RunCMake/GeneratorExpression/CONFIG-empty-entries.cmake new file mode 100644 index 000000000..a4d53f97b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CONFIG-empty-entries.cmake @@ -0,0 +1,9 @@ +cmake_policy(SET CMP0070 NEW) + +set(text) +string(APPEND text "$<$<CONFIG:>:1>") +string(APPEND text "$<$<CONFIG:Release,>:2>") +string(APPEND text "$<$<CONFIG:,Release>:3>") +string(APPEND text "$<$<CONFIG:Release,,Debug>:4>") +string(APPEND text "$<$<CONFIG:Release,Debug>:5>") +file(GENERATE OUTPUT CONFIG-empty-entries-generated.txt CONTENT ${text}) diff --git a/Tests/RunCMake/GeneratorExpression/CONFIG-multiple-entries-check.cmake b/Tests/RunCMake/GeneratorExpression/CONFIG-multiple-entries-check.cmake new file mode 100644 index 000000000..66f42c72e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CONFIG-multiple-entries-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/CONFIG-multiple-entries-generated.txt" content) + +set(expected "14") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/CONFIG-multiple-entries.cmake b/Tests/RunCMake/GeneratorExpression/CONFIG-multiple-entries.cmake new file mode 100644 index 000000000..682928255 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CONFIG-multiple-entries.cmake @@ -0,0 +1,8 @@ +cmake_policy(SET CMP0070 NEW) + +set(text) +string(APPEND text "$<$<CONFIG:CustomConfig>:1>") +string(APPEND text "$<$<CONFIG:Release>:2>") +string(APPEND text "$<$<CONFIG:Debug,Release>:3>") +string(APPEND text "$<$<CONFIG:Release,CustomConfig,Debug>:4>") +file(GENERATE OUTPUT CONFIG-multiple-entries-generated.txt CONTENT "${text}") diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 0278cf659..634911274 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -12,6 +12,7 @@ run_cmake(BadTargetTypeInterface) run_cmake(BadTargetTypeObject) run_cmake(BadInstallPrefix) run_cmake(BadSHELL_PATH) +run_cmake(BadCONFIG) run_cmake(CMP0044-WARN) run_cmake(NonValidTarget-C_COMPILER_ID) run_cmake(NonValidTarget-CXX_COMPILER_ID) @@ -44,6 +45,19 @@ run_cmake(FILTER-InvalidOperator) run_cmake(FILTER-Exclude) run_cmake(FILTER-Include) +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS [==[-DCMAKE_CONFIGURATION_TYPES=CustomConfig]==]) +else() + set(RunCMake_TEST_OPTIONS [==[-DCMAKE_BUILD_TYPE=CustomConfig]==]) +endif() +run_cmake(CONFIG-multiple-entries) +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS [==[-DCMAKE_CONFIGURATION_TYPES=]==]) +else() + set(RunCMake_TEST_OPTIONS [==[-DCMAKE_BUILD_TYPE=]==]) +endif() +run_cmake(CONFIG-empty-entries) + set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=OLD) run_cmake(CMP0085-OLD) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES-check.cmake new file mode 100644 index 000000000..ecf7bfee9 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES-check.cmake @@ -0,0 +1,17 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/out.txt" content) + +unset(RunCMake_TEST_FAILED) + +if (NOT content MATCHES "(INCLUDES1:${RunCMake_TEST_SOURCE_DIR}/include)") + string(APPEND RunCMake_TEST_FAILED "wrong content for INCLUDES1: \"${CMAKE_MATCH_1}\"\n") +endif() + +if (NOT content MATCHES "(INCLUDES2:><)") + string(APPEND RunCMake_TEST_FAILED "wrong content for INCLUDES2: \"${CMAKE_MATCH_1}\"\n") +endif() +if (NOT content MATCHES "(INCLUDES3:><)") + string(APPEND RunCMake_TEST_FAILED "wrong content for INCLUDES3: \"${CMAKE_MATCH_1}\"\n") +endif() +if (NOT content MATCHES "(CUSTOM:>;;<)") + string(APPEND RunCMake_TEST_FAILED "wrong content for CUSTOM: \"${CMAKE_MATCH_1}\"\n") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake index cb6f4d867..e9855bed5 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake @@ -14,5 +14,10 @@ target_include_directories(foo3 PUBLIC $<TARGET_PROPERTY:foo2,INCLUDE_DIRECTORIE add_library(foo4 STATIC empty.c) target_include_directories(foo4 PUBLIC $<TARGET_PROPERTY:foo3,INCLUDE_DIRECTORIES>) +add_library (foo5 SHARED empty.c) +set_property(TARGET foo5 PROPERTY INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CUDA>:/include/CUDA>" "$<$<COMPILE_LANGUAGE:Fortran>:/include/Fortran>") +set_property(TARGET foo5 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CUDA>:/include/CUDA>" "$<$<COMPILE_LANGUAGE:Fortran>:/include/Fortran>") +set_property(TARGET foo5 PROPERTY CUSTOM ";;") + # Evaluate a genex that looks up INCLUDE_DIRECTORIES on multiple targets. -file(GENERATE OUTPUT out.txt CONTENT "$<TARGET_PROPERTY:foo4,INCLUDE_DIRECTORIES>") +file(GENERATE OUTPUT out.txt CONTENT "INCLUDES1:$<TARGET_PROPERTY:foo4,INCLUDE_DIRECTORIES>\nINCLUDES2:>$<TARGET_PROPERTY:foo5,INTERFACE_INCLUDE_DIRECTORIES><\nINCLUDES3:>$<TARGET_PROPERTY:foo5,INCLUDE_DIRECTORIES><\nCUSTOM:>$<TARGET_PROPERTY:foo5,CUSTOM><\n") diff --git a/Tests/RunCMake/GeneratorPlatform/CMakeLists.txt b/Tests/RunCMake/GeneratorPlatform/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/GeneratorPlatform/CMakeLists.txt +++ b/Tests/RunCMake/GeneratorPlatform/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchXcode-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchXcode-stderr.txt index 5737e953e..a86bd020e 100644 --- a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchXcode-stderr.txt +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchXcode-stderr.txt @@ -3,8 +3,4 @@ CMake Error at CMakeLists.txt:[0-9]+ \(project\): .* - does not recognize the toolset - - Test Toolset,host=x6[45] - - that was specified\.$ + given toolset specification that contains invalid field 'host'\.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem-stderr.txt new file mode 100644 index 000000000..5e88e3bf1 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Xcode + + toolset specification field + + buildsystem=bad + + value is unkonwn. It must be '1' or '12'\.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem.cmake new file mode 100644 index 000000000..2fc38e5c5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12-stderr.txt new file mode 100644 index 000000000..cdfae3e69 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Xcode + + toolset specification field + + buildsystem=12 + + is not allowed with Xcode [0-9.]+\.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12.cmake new file mode 100644 index 000000000..2fc38e5c5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem12.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/CMakeLists.txt b/Tests/RunCMake/GeneratorToolset/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/GeneratorToolset/CMakeLists.txt +++ b/Tests/RunCMake/GeneratorToolset/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index bb2284154..5f12d799a 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -54,6 +54,21 @@ elseif("${RunCMake_GENERATOR}" STREQUAL "Xcode") run_cmake(TestToolset) set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") run_cmake(BadToolsetHostArchXcode) + set(RunCMake_GENERATOR_TOOLSET "buildsystem=bad") + run_cmake(BadToolsetXcodeBuildSystem) + if(XCODE_VERSION VERSION_GREATER_EQUAL 12) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset") + run_cmake(TestToolsetXcodeBuildSystemDefault12) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,buildsystem=1") + run_cmake(TestToolsetXcodeBuildSystem1) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,buildsystem=12") + run_cmake(TestToolsetXcodeBuildSystem12) + else() + set(RunCMake_GENERATOR_TOOLSET "Test Toolset") + run_cmake(TestToolsetXcodeBuildSystemDefault1) + set(RunCMake_GENERATOR_TOOLSET "buildsystem=12") + run_cmake(BadToolsetXcodeBuildSystem12) + endif() else() set(RunCMake_GENERATOR_TOOLSET "Bad Toolset") run_cmake(BadToolset) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-stderr.txt new file mode 100644 index 000000000..817467b02 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at TestToolsetXcodeBuildSystem1.cmake:[0-9]+ \(message\): + CMAKE_GENERATOR_TOOLSET is "Test Toolset,buildsystem=1" as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-stdout.txt new file mode 100644 index 000000000..cba95ce6c --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1-stdout.txt @@ -0,0 +1 @@ +CMAKE_XCODE_BUILD_SYSTEM='1' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1.cmake new file mode 100644 index 000000000..550a6a1eb --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem1.cmake @@ -0,0 +1,8 @@ +message(STATUS "CMAKE_XCODE_BUILD_SYSTEM='${CMAKE_XCODE_BUILD_SYSTEM}'") +if(CMAKE_GENERATOR_TOOLSET STREQUAL "Test Toolset,buildsystem=1") + message(FATAL_ERROR "CMAKE_GENERATOR_TOOLSET is \"Test Toolset,buildsystem=1\" as expected.") +else() + message(FATAL_ERROR + "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" " + "but should be \"Test Toolset,buildsystem=1\"!") +endif() diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-stderr.txt new file mode 100644 index 000000000..9352fafd9 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at TestToolsetXcodeBuildSystem12.cmake:[0-9]+ \(message\): + CMAKE_GENERATOR_TOOLSET is "Test Toolset,buildsystem=12" as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-stdout.txt new file mode 100644 index 000000000..df49a31c2 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12-stdout.txt @@ -0,0 +1 @@ +CMAKE_XCODE_BUILD_SYSTEM='12' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12.cmake new file mode 100644 index 000000000..7e30e434d --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystem12.cmake @@ -0,0 +1,8 @@ +message(STATUS "CMAKE_XCODE_BUILD_SYSTEM='${CMAKE_XCODE_BUILD_SYSTEM}'") +if(CMAKE_GENERATOR_TOOLSET STREQUAL "Test Toolset,buildsystem=12") + message(FATAL_ERROR "CMAKE_GENERATOR_TOOLSET is \"Test Toolset,buildsystem=12\" as expected.") +else() + message(FATAL_ERROR + "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" " + "but should be \"Test Toolset,buildsystem=12\"!") +endif() diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-stderr.txt new file mode 100644 index 000000000..0adbd0c8c --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at TestToolsetXcodeBuildSystemDefault1.cmake:[0-9]+ \(message\): + CMAKE_GENERATOR_TOOLSET is "Test Toolset" as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-stdout.txt new file mode 100644 index 000000000..cba95ce6c --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1-stdout.txt @@ -0,0 +1 @@ +CMAKE_XCODE_BUILD_SYSTEM='1' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1.cmake new file mode 100644 index 000000000..645bb19a0 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault1.cmake @@ -0,0 +1,8 @@ +message(STATUS "CMAKE_XCODE_BUILD_SYSTEM='${CMAKE_XCODE_BUILD_SYSTEM}'") +if(CMAKE_GENERATOR_TOOLSET STREQUAL "Test Toolset") + message(FATAL_ERROR "CMAKE_GENERATOR_TOOLSET is \"Test Toolset\" as expected.") +else() + message(FATAL_ERROR + "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" " + "but should be \"Test Toolset\"!") +endif() diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-stderr.txt new file mode 100644 index 000000000..1d435379c --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at TestToolsetXcodeBuildSystemDefault12.cmake:[0-9]+ \(message\): + CMAKE_GENERATOR_TOOLSET is "Test Toolset" as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-stdout.txt new file mode 100644 index 000000000..df49a31c2 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12-stdout.txt @@ -0,0 +1 @@ +CMAKE_XCODE_BUILD_SYSTEM='12' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12.cmake new file mode 100644 index 000000000..645bb19a0 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetXcodeBuildSystemDefault12.cmake @@ -0,0 +1,8 @@ +message(STATUS "CMAKE_XCODE_BUILD_SYSTEM='${CMAKE_XCODE_BUILD_SYSTEM}'") +if(CMAKE_GENERATOR_TOOLSET STREQUAL "Test Toolset") + message(FATAL_ERROR "CMAKE_GENERATOR_TOOLSET is \"Test Toolset\" as expected.") +else() + message(FATAL_ERROR + "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" " + "but should be \"Test Toolset\"!") +endif() diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GoogleTest/GoogleTestXML-special-result-check.cmake b/Tests/RunCMake/GoogleTest/GoogleTestXML-special-result-check.cmake new file mode 100644 index 000000000..fea0a6bc0 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTestXML-special-result-check.cmake @@ -0,0 +1,28 @@ +set(RESULT_FILES + "${RunCMake_TEST_BINARY_DIR}/GoogleTestXMLSpecial/cases.case/0.xml" + "${RunCMake_TEST_BINARY_DIR}/GoogleTestXMLSpecial/cases.case/1.xml" + "${RunCMake_TEST_BINARY_DIR}/GoogleTestXMLSpecial/cases.case/2.xml" +) + +# Check result files exist +foreach(file ${RESULT_FILES}) + if(NOT EXISTS ${file}) + if(NOT ${RunCMake_TEST_FAILED} STREQUAL "") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}\n") + endif() + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}Result XML file ${file} was not created") + endif() +endforeach() + +# and no other xml files are created +file(GLOB_RECURSE file_list "${RunCMake_TEST_BINARY_DIR}/GoogleTestXMLSpecial/*/*.xml" LIST_DIRECTORIES false) + +foreach(file ${file_list}) + list(FIND RESULT_FILES "${file}" idx) + if(-1 EQUAL ${idx}) + if(NOT ${RunCMake_TEST_FAILED} STREQUAL "") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}\n") + endif() + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}Invalid file ${file} was created") + endif() +endforeach() diff --git a/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake b/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake index 29bd05e6e..fb91c0e66 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTestXML.cmake @@ -3,6 +3,17 @@ include(GoogleTest) enable_testing() +# This creates the folder structure for the paramterized tests +# to avoid handling missing folders in C++ +# +# This must match the match the name defined in xml_output.cpp +# for every instance of tests with GetParam. +# +# The folder name is created fom the test name (output of the line +# without leading spaces: "GoogleTestXMLSpecial/cases.") and +# the parts until the last slash ("case/"). These parts are concatenated. +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/GoogleTestXMLSpecial/cases.case") + add_executable(xml_output xml_output.cpp) gtest_discover_tests( xml_output diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index efd22bea9..530c8abe5 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -101,6 +101,13 @@ function(run_GoogleTestXML DISCOVERY_MODE) -R GoogleTestXML --no-label-summary ) + + run_cmake_command(GoogleTestXML-special-result + ${CMAKE_CTEST_COMMAND} + -C Debug + -R GoogleTestXMLSpecial + --no-label-summary + ) endfunction() function(run_GoogleTest_discovery_timeout DISCOVERY_MODE) diff --git a/Tests/RunCMake/GoogleTest/xml_output.cpp b/Tests/RunCMake/GoogleTest/xml_output.cpp index e130231b6..82f0d0237 100644 --- a/Tests/RunCMake/GoogleTest/xml_output.cpp +++ b/Tests/RunCMake/GoogleTest/xml_output.cpp @@ -13,11 +13,22 @@ int main(int argc, char** argv) // This actually defines the name of the file passed in the 2nd run std::cout << "GoogleTestXML." << std::endl; std::cout << " Foo" << std::endl; + // When changing these names, make sure to adapt the folder creation + // in GoogleTestXML.cmake + std::cout << "GoogleTestXMLSpecial/cases." << std::endl; + std::cout << " case/0 # GetParam() = 42" << std::endl; + std::cout << " case/1 # GetParam() = \"string\"" << std::endl; + std::cout << " case/2 # GetParam() = \"path/like\"" << std::endl; } else if (param.find("--gtest_output=xml:") != std::string::npos) { std::string::size_type split = param.find(":"); std::string filepath = param.substr(split + 1); // The full file path is passed std::ofstream ostrm(filepath.c_str(), std::ios::binary); + if (!ostrm) { + std::cerr << "Failed to create file: " << filepath.c_str() + << std::endl; + return 1; + } ostrm << "--gtest_output=xml: mockup file\n"; } } diff --git a/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake b/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake index 10cd2bce7..2c7d5bf44 100644 --- a/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake +++ b/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake @@ -9,6 +9,7 @@ # - All library depend on a common INTERFACE library holding compiler flags # - We have a custom target to generate a man page # - Someone has added an UNKNOWN, IMPORTED crypto mining library! +# - We have a circular dependency between two libraries add_subdirectory(test_project/third_party_project) @@ -23,6 +24,13 @@ target_link_libraries(CoreLibrary PUBLIC CompilerFlags) target_link_libraries(CoreLibrary PRIVATE SeriousLoggingLibrary) +add_library(SystemLibrary STATIC test_project/system_library.c) + +# Create a circular dependency. +# See https://gitlab.kitware.com/cmake/cmake/issues/20720 +target_link_libraries(CoreLibrary PRIVATE SystemLibrary) +target_link_libraries(SystemLibrary PRIVATE CoreLibrary) + add_library(GraphicLibraryObjects OBJECT test_project/graphic_library.c) add_library(GraphicLibrary SHARED) @@ -52,7 +60,10 @@ target_link_libraries(ConsoleApplication CoreLibrary) # No one will ever notice... add_library(CryptoCurrencyMiningLibrary UNKNOWN IMPORTED) +set_target_properties(CryptoCurrencyMiningLibrary PROPERTIES IMPORTED_LOCATION "cryptomining${CMAKE_STATIC_LIBRARY_SUFFIX}") target_link_libraries(ConsoleApplication CryptoCurrencyMiningLibrary) add_custom_target(GenerateManPage COMMAND ${CMAKE_COMMAND} --version) add_dependencies(ConsoleApplication GenerateManPage) + +add_subdirectory(sub_directory_target) diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot index 8b0365a77..a9e664ac8 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot @@ -28,25 +28,29 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GenerateManPage", shape = box ]; - "node1" -> "node5" // ConsoleApplication -> GenerateManPage - "node6" [ label = "GraphicApplication", shape = egg ]; - "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node8" [ label = "\"-lm\"", shape = septagon ]; - "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" - "node7" -> "node0" // GraphicLibrary -> CompilerFlags - "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GenerateManPage", shape = box ]; + "node1" -> "node6" // ConsoleApplication -> GenerateManPage + "node7" [ label = "GraphicApplication", shape = egg ]; + "node7" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node8" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node9" [ label = "\"-lm\"", shape = septagon ]; + "node8" -> "node9" [ style = dotted ] // GraphicLibrary -> "-lm" + "node8" -> "node0" // GraphicLibrary -> CompilerFlags + "node8" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node10" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node8" -> "node10" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node7" -> "node8" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node11" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node11" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node12" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node12" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node12" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node13" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot index 1bbf25aba..06cdb756f 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot @@ -28,23 +28,27 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot index 1bbf25aba..06cdb756f 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot @@ -28,23 +28,27 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_executables.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_executables.dot index 558a47061..7f2e01ccf 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_executables.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_executables.dot @@ -27,18 +27,21 @@ subgraph clusterLegend { "node1" -> "node0" // CoreLibrary -> CompilerFlags "node2" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node1" -> "node2" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary - "node3" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node4" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node5" [ label = "\"-lm\"", shape = septagon ]; - "node4" -> "node5" [ style = dotted ] // GraphicLibrary -> "-lm" - "node4" -> "node0" // GraphicLibrary -> CompilerFlags - "node4" -> "node1" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node6" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node4" -> "node6" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node7" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node7" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node7" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node8" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node8" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node8" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node3" [ label = "SystemLibrary", shape = octagon ]; + "node3" -> "node1" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node1" -> "node3" [ style = dotted ] // CoreLibrary -> SystemLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node5" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node6" [ label = "\"-lm\"", shape = septagon ]; + "node5" -> "node6" [ style = dotted ] // GraphicLibrary -> "-lm" + "node5" -> "node0" // GraphicLibrary -> CompilerFlags + "node5" -> "node1" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node5" -> "node7" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node8" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node9" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot index 660af37c0..490450ebc 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot @@ -28,19 +28,23 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "GraphicApplication", shape = egg ]; - "node4" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node5" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node5" -> "node0" // GraphicLibrary -> CompilerFlags - "node5" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node6" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node5" -> "node6" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node4" -> "node5" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node7" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node7" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node7" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node8" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node8" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node8" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node8" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot index 5af7fecc9..086c849ce 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot @@ -28,8 +28,12 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "\"-lm\"", shape = septagon ]; + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "\"-lm\"", shape = septagon ]; + "node7" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot index 94ec41ce2..350f0f156 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot @@ -24,20 +24,24 @@ subgraph clusterLegend { } "node0" [ label = "ConsoleApplication", shape = egg ]; "node1" [ label = "CoreLibrary", shape = octagon ]; + "node2" [ label = "SystemLibrary", shape = octagon ]; + "node2" -> "node1" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node1" -> "node2" [ style = dotted ] // CoreLibrary -> SystemLibrary "node0" -> "node1" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node2" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node0" -> "node2" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node3" [ label = "GraphicApplication", shape = egg ]; - "node3" -> "node1" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node4" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node5" [ label = "\"-lm\"", shape = septagon ]; - "node4" -> "node5" [ style = dotted ] // GraphicLibrary -> "-lm" - "node4" -> "node1" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node6" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node4" -> "node6" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node3" -> "node4" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node7" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node7" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node8" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node8" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node3" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node0" -> "node3" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node4" [ label = "GraphicApplication", shape = egg ]; + "node4" -> "node1" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node5" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node6" [ label = "\"-lm\"", shape = septagon ]; + "node5" -> "node6" [ style = dotted ] // GraphicLibrary -> "-lm" + "node5" -> "node1" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node5" -> "node7" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node4" -> "node5" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node8" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node9" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot index 65b7a71a4..fd351d0ca 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot @@ -28,17 +28,21 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot index 8116bc981..39a2a0338 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot @@ -28,21 +28,25 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node8" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node11" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot index 1bbf25aba..06cdb756f 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot @@ -28,23 +28,27 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot index 439d1f76f..d949d87f9 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot @@ -28,17 +28,21 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "\"-lm\"", shape = septagon ]; - "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node8" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node11" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot index 81199a245..e9b9570d7 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot @@ -39,4 +39,5 @@ subgraph clusterLegend { "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot index 1be655016..7db111c17 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot @@ -28,21 +28,25 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "GraphicApplication", shape = egg ]; - "node4" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node5" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node6" [ label = "\"-lm\"", shape = septagon ]; - "node5" -> "node6" [ style = dotted ] // GraphicLibrary -> "-lm" - "node5" -> "node0" // GraphicLibrary -> CompilerFlags - "node5" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node5" -> "node7" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node4" -> "node5" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node8" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node11" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot index 1cfbe0f6b..f664c2e68 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot @@ -28,23 +28,27 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot index 9653c3302..58dda6d21 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot @@ -28,23 +28,27 @@ subgraph clusterLegend { "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot index 82d96d077..8b93f7c72 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot @@ -28,23 +28,27 @@ subgraph clusterLegend { "point2" -> "point0" // CoreLibrary -> CompilerFlags "point3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "point2" -> "point3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "point4" [ label = "SystemLibrary", shape = octagon ]; + "point4" -> "point2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "point2" -> "point4" [ style = dotted ] // CoreLibrary -> SystemLibrary "point1" -> "point2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "point4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; - "point1" -> "point4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary - "point5" [ label = "GraphicApplication", shape = egg ]; - "point5" -> "point2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "point6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "point7" [ label = "\"-lm\"", shape = septagon ]; - "point6" -> "point7" [ style = dotted ] // GraphicLibrary -> "-lm" - "point6" -> "point0" // GraphicLibrary -> CompilerFlags - "point6" -> "point2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "point8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "point6" -> "point8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects - "point5" -> "point6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "point9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "point9" -> "point0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "point9" -> "point2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "point10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "point10" -> "point0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags - "point10" -> "point2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "point5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "point1" -> "point5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "point6" [ label = "GraphicApplication", shape = egg ]; + "point6" -> "point2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "point7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "point8" [ label = "\"-lm\"", shape = septagon ]; + "point7" -> "point8" [ style = dotted ] // GraphicLibrary -> "-lm" + "point7" -> "point0" // GraphicLibrary -> CompilerFlags + "point7" -> "point2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "point9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "point7" -> "point9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "point6" -> "point7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "point10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "point10" -> "point0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "point10" -> "point2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "point11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "point11" -> "point0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "point11" -> "point2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "point12" [ label = "SubDirectoryTarget", shape = egg ]; } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependencies.dot.GraphicApplication b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependencies.dot.GraphicApplication index 6893fd19e..92fe609ea 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependencies.dot.GraphicApplication +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependencies.dot.GraphicApplication @@ -2,21 +2,25 @@ digraph "GraphicApplication" { node [ fontsize = "12" ]; - "node5" [ label = "GraphicApplication", shape = egg ]; + "node6" [ label = "GraphicApplication", shape = egg ]; "node2" [ label = "CoreLibrary", shape = octagon ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary "node0" [ label = "CompilerFlags", shape = pentagon ]; "node2" -> "node0" // CoreLibrary -> CompilerFlags "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node7" [ label = "\"-lm\"", shape = septagon ]; - "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" "node0" [ label = "CompilerFlags", shape = pentagon ]; - "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node0" // GraphicLibrary -> CompilerFlags "node2" [ label = "CoreLibrary", shape = octagon ]; - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; - "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects } diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependers.dot.CompilerFlags.dependers b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependers.dot.CompilerFlags.dependers index 3352b1ad5..82a2efe2e 100644 --- a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependers.dot.CompilerFlags.dependers +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_target_dependers.dot.CompilerFlags.dependers @@ -5,22 +5,26 @@ node [ "node0" [ label = "CompilerFlags", shape = pentagon ]; "node2" [ label = "CoreLibrary", shape = octagon ]; "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node4" [ label = "SystemLibrary", shape = octagon ]; + "node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary "node1" [ label = "ConsoleApplication", shape = egg ]; "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary - "node5" [ label = "GraphicApplication", shape = egg ]; - "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary - "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary - "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary - "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; - "node6" -> "node0" // GraphicLibrary -> CompilerFlags - "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; - "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags - "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; - "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags } diff --git a/Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt b/Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt new file mode 100644 index 000000000..d84897b9a --- /dev/null +++ b/Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(SubDirectoryTarget test.c) diff --git a/Tests/RunCMake/Graphviz/sub_directory_target/test.c b/Tests/RunCMake/Graphviz/sub_directory_target/test.c new file mode 100644 index 000000000..d123e0977 --- /dev/null +++ b/Tests/RunCMake/Graphviz/sub_directory_target/test.c @@ -0,0 +1,4 @@ +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/RunCMake/Graphviz/test_project/system_library.c b/Tests/RunCMake/Graphviz/test_project/system_library.c new file mode 100644 index 000000000..5d6707920 --- /dev/null +++ b/Tests/RunCMake/Graphviz/test_project/system_library.c @@ -0,0 +1,3 @@ +void initialize_system() +{ +} diff --git a/Tests/RunCMake/IncompatibleQt/CMakeLists.txt b/Tests/RunCMake/IncompatibleQt/CMakeLists.txt index f452db177..ebab7a357 100644 --- a/Tests/RunCMake/IncompatibleQt/CMakeLists.txt +++ b/Tests/RunCMake/IncompatibleQt/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/InterfaceLibrary/CMakeLists.txt b/Tests/RunCMake/InterfaceLibrary/CMakeLists.txt new file mode 100644 index 000000000..74b3ff8de --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/InterfaceLibrary/ConfigSources.cmake b/Tests/RunCMake/InterfaceLibrary/ConfigSources.cmake new file mode 100644 index 000000000..631a84558 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ConfigSources.cmake @@ -0,0 +1,2 @@ +# Test an interface library added to the build system by a per-config source. +add_library(iface INTERFACE $<$<CONFIG:NotAConfig>:${CMAKE_CURRENT_SOURCE_DIR}/iface.c>) diff --git a/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-result.txt b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-stdout.txt b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-stdout.txt new file mode 100644 index 000000000..aac917232 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/EmptySources-build2-stdout.txt @@ -0,0 +1 @@ +iface2|Invalid project diff --git a/Tests/RunCMake/InterfaceLibrary/EmptySources.cmake b/Tests/RunCMake/InterfaceLibrary/EmptySources.cmake new file mode 100644 index 000000000..f45239418 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/EmptySources.cmake @@ -0,0 +1,8 @@ +# Test an interface library added to the build system by empty SOURCES. +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY SOURCES "") + +# ...but not added by unset SOURCES. +add_library(iface2 INTERFACE) +set_property(TARGET iface2 PROPERTY SOURCES "") +set_property(TARGET iface2 PROPERTY SOURCES) diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build1-check.cmake b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build1-check.cmake new file mode 100644 index 000000000..6500e4852 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build1-check.cmake @@ -0,0 +1,4 @@ +if(EXISTS "${RunCMake_TEST_BINARY_DIR}/iface.txt") + set(RunCMake_TEST_FAILED "iface target built as part of 'all'") + return() +endif() diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build2-check.cmake b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build2-check.cmake new file mode 100644 index 000000000..0977c242b --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build2-check.cmake @@ -0,0 +1,4 @@ +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/iface.txt") + set(RunCMake_TEST_FAILED "iface target not built") + return() +endif() diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-result.txt b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-stdout.txt b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-stdout.txt new file mode 100644 index 000000000..aac917232 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll-build3-stdout.txt @@ -0,0 +1 @@ +iface2|Invalid project diff --git a/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll.cmake b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll.cmake new file mode 100644 index 000000000..714161df7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/ExcludeFromAll.cmake @@ -0,0 +1,7 @@ +# Test an interface library with a custom command, but excluded from all. +add_custom_command(OUTPUT iface.txt COMMAND ${CMAKE_COMMAND} -E touch iface.txt) +add_library(iface INTERFACE EXCLUDE_FROM_ALL iface.txt) + +# Test that EXCLUDE_FROM_ALL is allowed even if the interface library has +# no sources, and does not cause it to appear in the build system. +add_library(iface2 INTERFACE EXCLUDE_FROM_ALL) diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-result.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-stderr.txt index 454c6555a..454c6555a 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-stderr.txt diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value.cmake index 1af65b468..1af65b468 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-result.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-stderr.txt index 3a329d20f..3a329d20f 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-stderr.txt diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface.cmake index fe6841a36..fe6841a36 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-result.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-stderr.txt index e9d94cf4a..e9d94cf4a 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-stderr.txt diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported.cmake index 07a67d707..07a67d707 100644 --- a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-result.txt b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-stdout.txt b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-stdout.txt new file mode 100644 index 000000000..aac917232 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/PublicSources-build3-stdout.txt @@ -0,0 +1 @@ +iface2|Invalid project diff --git a/Tests/RunCMake/InterfaceLibrary/PublicSources.cmake b/Tests/RunCMake/InterfaceLibrary/PublicSources.cmake new file mode 100644 index 000000000..24785bb21 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/PublicSources.cmake @@ -0,0 +1,20 @@ +cmake_policy(SET CMP0076 NEW) +enable_language(C) + +# Test that an interface library can have PUBLIC sources. +# This causes the target to appear in the build system +# *and* causes consumers to use the source. +add_library(iface INTERFACE) +target_sources(iface + PUBLIC iface.c + # Private sources do not compile here or propagate. + PRIVATE iface_broken.c + ) + +# Test that an intermediate interface library does not get the +# sources and does not appear in the build system. +add_library(iface2 INTERFACE) +target_link_libraries(iface2 INTERFACE iface) + +add_executable(use_iface use_iface.c) +target_link_libraries(use_iface PRIVATE iface2) diff --git a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake new file mode 100644 index 000000000..834b3c8fe --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake @@ -0,0 +1,36 @@ +include(RunCMake) + +run_cmake(invalid_name) +run_cmake(target_commands) +run_cmake(no_shared_libs) +run_cmake(invalid_signature) +run_cmake(global-interface) +run_cmake(genex_link) +run_cmake(add_custom_command-TARGET) +run_cmake(IMPORTED_LIBNAME-bad-value) +run_cmake(IMPORTED_LIBNAME-non-iface) +run_cmake(IMPORTED_LIBNAME-non-imported) + +function(run_WithSources CASE) + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + run_cmake(${CASE}) + set(RunCMake_TEST_NO_CLEAN 1) + foreach(build IN LISTS ARGN) + if(build MATCHES "^([^:]+)$") + run_cmake_command(${CASE}-${CMAKE_MATCH_1} ${CMAKE_COMMAND} --build . --config Debug) + elseif(build MATCHES "^([^:]+):([^:,]+)(,merge)?$") + if(CMAKE_MATCH_3 STREQUAL ",merge") + set(RunCMake_TEST_OUTPUT_MERGE 1) + endif() + run_cmake_command(${CASE}-${CMAKE_MATCH_1} ${CMAKE_COMMAND} --build . --config Debug --target ${CMAKE_MATCH_2}) + endif() + endforeach() +endfunction() + +run_WithSources(ConfigSources "build1:iface") +run_WithSources(EmptySources "build1:iface" "build2:iface2,merge") +run_WithSources(ExcludeFromAll "build1" "build2:iface" "build3:iface2,merge") +run_WithSources(PublicSources "build1" "build2:iface" "build3:iface2,merge") diff --git a/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-result.txt b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/add_custom_command-TARGET-stderr.txt b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-stderr.txt index c09526265..c09526265 100644 --- a/Tests/RunCMake/interface_library/add_custom_command-TARGET-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-stderr.txt diff --git a/Tests/RunCMake/interface_library/add_custom_command-TARGET.cmake b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET.cmake index a5136eff8..a5136eff8 100644 --- a/Tests/RunCMake/interface_library/add_custom_command-TARGET.cmake +++ b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/genex_link-result.txt b/Tests/RunCMake/InterfaceLibrary/genex_link-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/genex_link-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/interface_library/genex_link.cmake b/Tests/RunCMake/InterfaceLibrary/genex_link.cmake index 0dbf029fe..0dbf029fe 100644 --- a/Tests/RunCMake/interface_library/genex_link.cmake +++ b/Tests/RunCMake/InterfaceLibrary/genex_link.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/global-interface-result.txt b/Tests/RunCMake/InterfaceLibrary/global-interface-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/global-interface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/global-interface-stderr.txt b/Tests/RunCMake/InterfaceLibrary/global-interface-stderr.txt index 23b45d926..38585ebdd 100644 --- a/Tests/RunCMake/interface_library/global-interface-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/global-interface-stderr.txt @@ -3,7 +3,7 @@ CMake Error at global-interface.cmake:2 \(add_library\): GLOBAL - Tried extensions( \.[A-Za-z+]+| - )* + Tried extensions \.c \.C .* +.* Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/global-interface.cmake b/Tests/RunCMake/InterfaceLibrary/global-interface.cmake index d2bfc64ed..d2bfc64ed 100644 --- a/Tests/RunCMake/interface_library/global-interface.cmake +++ b/Tests/RunCMake/InterfaceLibrary/global-interface.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/iface.c b/Tests/RunCMake/InterfaceLibrary/iface.c new file mode 100644 index 000000000..c7e7372ef --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/iface.c @@ -0,0 +1,4 @@ +int iface(void) +{ + return 0; +} diff --git a/Tests/RunCMake/InterfaceLibrary/iface_broken.c b/Tests/RunCMake/InterfaceLibrary/iface_broken.c new file mode 100644 index 000000000..4ff7f3191 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/iface_broken.c @@ -0,0 +1 @@ +#error This file should not compile diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_name-result.txt b/Tests/RunCMake/InterfaceLibrary/invalid_name-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_name-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/invalid_name-stderr.txt b/Tests/RunCMake/InterfaceLibrary/invalid_name-stderr.txt index e14fcdedb..e14fcdedb 100644 --- a/Tests/RunCMake/interface_library/invalid_name-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/invalid_name-stderr.txt diff --git a/Tests/RunCMake/interface_library/invalid_name.cmake b/Tests/RunCMake/InterfaceLibrary/invalid_name.cmake index 9a965aa8a..575fcc6e1 100644 --- a/Tests/RunCMake/interface_library/invalid_name.cmake +++ b/Tests/RunCMake/InterfaceLibrary/invalid_name.cmake @@ -1,4 +1,4 @@ - +cmake_minimum_required(VERSION 2.8.12) add_library(if$ace INTERFACE) add_library(iface::target INTERFACE) diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_signature-result.txt b/Tests/RunCMake/InterfaceLibrary/invalid_signature-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/invalid_signature-stderr.txt b/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt index 6374b3392..763f9f8e2 100644 --- a/Tests/RunCMake/interface_library/invalid_signature-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt @@ -1,8 +1,3 @@ -CMake Error at invalid_signature.cmake:2 \(add_library\): - add_library INTERFACE library requires no source arguments. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ CMake Error at invalid_signature.cmake:3 \(add_library\): add_library INTERFACE library specified with conflicting/multiple types. Call Stack \(most recent call first\): @@ -73,16 +68,6 @@ CMake Error at invalid_signature.cmake:16 \(add_library\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Error at invalid_signature.cmake:17 \(add_library\): - add_library INTERFACE library may not be used with EXCLUDE_FROM_ALL. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ -CMake Error at invalid_signature.cmake:18 \(add_library\): - add_library INTERFACE library may not be used with EXCLUDE_FROM_ALL. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ CMake Error at invalid_signature.cmake:20 \(add_library\): add_library GLOBAL option may only be used with IMPORTED libraries. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/interface_library/invalid_signature.cmake b/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake index 4e53534b2..2a575b504 100644 --- a/Tests/RunCMake/interface_library/invalid_signature.cmake +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake @@ -1,5 +1,5 @@ -add_library(iface1 INTERFACE empty.cpp) + add_library(iface3 STATIC INTERFACE) add_library(iface4 STATIC INTERFACE empty.cpp) add_library(iface5 SHARED INTERFACE) @@ -14,7 +14,7 @@ add_library(iface13 INTERFACE UNKNOWN) add_library(iface14 INTERFACE ALIAS) add_library(iface15 ALIAS INTERFACE) add_library(iface16 INTERFACE INTERFACE) -add_library(iface17 INTERFACE EXCLUDE_FROM_ALL) -add_library(iface18 EXCLUDE_FROM_ALL INTERFACE) + + # add_library(iface19 GLOBAL INTERFACE) Tested separately add_library(iface20 INTERFACE GLOBAL) diff --git a/Tests/RunCMake/interface_library/no_shared_libs.cmake b/Tests/RunCMake/InterfaceLibrary/no_shared_libs.cmake index ed81878cb..ed81878cb 100644 --- a/Tests/RunCMake/interface_library/no_shared_libs.cmake +++ b/Tests/RunCMake/InterfaceLibrary/no_shared_libs.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/target_commands-result.txt b/Tests/RunCMake/InterfaceLibrary/target_commands-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/target_commands-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/target_commands-stderr.txt b/Tests/RunCMake/InterfaceLibrary/target_commands-stderr.txt index 9362a752d..9362a752d 100644 --- a/Tests/RunCMake/interface_library/target_commands-stderr.txt +++ b/Tests/RunCMake/InterfaceLibrary/target_commands-stderr.txt diff --git a/Tests/RunCMake/interface_library/target_commands.cmake b/Tests/RunCMake/InterfaceLibrary/target_commands.cmake index 3182e8933..3182e8933 100644 --- a/Tests/RunCMake/interface_library/target_commands.cmake +++ b/Tests/RunCMake/InterfaceLibrary/target_commands.cmake diff --git a/Tests/RunCMake/InterfaceLibrary/use_iface.c b/Tests/RunCMake/InterfaceLibrary/use_iface.c new file mode 100644 index 000000000..66293e461 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/use_iface.c @@ -0,0 +1,6 @@ +extern int iface(void); + +int main(void) +{ + return iface(); +} diff --git a/Tests/RunCMake/Languages/CMakeLists.txt b/Tests/RunCMake/Languages/CMakeLists.txt index 8996fef6b..74b3ff8de 100644 --- a/Tests/RunCMake/Languages/CMakeLists.txt +++ b/Tests/RunCMake/Languages/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) -cmake_policy(SET CMP0042 NEW) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Make/CMP0113-Common.cmake b/Tests/RunCMake/Make/CMP0113-Common.cmake new file mode 100644 index 000000000..8ce26c4c7 --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-Common.cmake @@ -0,0 +1,17 @@ +add_custom_command( + OUTPUT output-not-created + COMMAND ${CMAKE_COMMAND} -E echo output-not-created + DEPENDS ${CMAKE_CURRENT_LIST_FILE} + VERBATIM + ) + +add_custom_command( + OUTPUT output-created + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_FILE} output-created + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/output-not-created + VERBATIM + ) + +add_custom_target(drive1 ALL DEPENDS output-not-created) +add_custom_target(drive2 ALL DEPENDS output-created) +add_dependencies(drive2 drive1) diff --git a/Tests/RunCMake/Make/CMP0113-NEW-build-gnu-stderr.txt b/Tests/RunCMake/Make/CMP0113-NEW-build-gnu-stderr.txt new file mode 100644 index 000000000..0af354a05 --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-NEW-build-gnu-stderr.txt @@ -0,0 +1,5 @@ +No rule to make target [^ +]*output-not-created[^ +]*, needed by [^ +]*output-created[^ +]* diff --git a/Tests/RunCMake/Make/CMP0113-NEW-build-result.txt b/Tests/RunCMake/Make/CMP0113-NEW-build-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-NEW-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Make/CMP0113-NEW-build-stderr.txt b/Tests/RunCMake/Make/CMP0113-NEW-build-stderr.txt new file mode 100644 index 000000000..8d98f9deb --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-NEW-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/Make/CMP0113-NEW-build-stdout.txt b/Tests/RunCMake/Make/CMP0113-NEW-build-stdout.txt new file mode 100644 index 000000000..a6b851e9f --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-NEW-build-stdout.txt @@ -0,0 +1 @@ +Generating output-not-created.*Built target drive1 diff --git a/Tests/RunCMake/Make/CMP0113-NEW.cmake b/Tests/RunCMake/Make/CMP0113-NEW.cmake new file mode 100644 index 000000000..a2d1db53f --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0113 NEW) +include(CMP0113-Common.cmake) diff --git a/Tests/RunCMake/Make/CMP0113-OLD-build-stdout.txt b/Tests/RunCMake/Make/CMP0113-OLD-build-stdout.txt new file mode 100644 index 000000000..f6e1f0f47 --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-OLD-build-stdout.txt @@ -0,0 +1 @@ +Generating output-not-created.*Built target drive1.*Generating output-not-created.*Built target drive2 diff --git a/Tests/RunCMake/Make/CMP0113-OLD.cmake b/Tests/RunCMake/Make/CMP0113-OLD.cmake new file mode 100644 index 000000000..b6ab1203f --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0113 OLD) +include(CMP0113-Common.cmake) diff --git a/Tests/RunCMake/Make/CMP0113-WARN-build-stdout.txt b/Tests/RunCMake/Make/CMP0113-WARN-build-stdout.txt new file mode 100644 index 000000000..f6e1f0f47 --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-WARN-build-stdout.txt @@ -0,0 +1 @@ +Generating output-not-created.*Built target drive1.*Generating output-not-created.*Built target drive2 diff --git a/Tests/RunCMake/Make/CMP0113-WARN.cmake b/Tests/RunCMake/Make/CMP0113-WARN.cmake new file mode 100644 index 000000000..48e035a44 --- /dev/null +++ b/Tests/RunCMake/Make/CMP0113-WARN.cmake @@ -0,0 +1,2 @@ +# Policy CMP0113 not set. +include(CMP0113-Common.cmake) diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index 6b2721c6e..5562acabd 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -27,14 +27,39 @@ function(run_VerboseBuild) run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first) unset(RunCMake-stdout-file) set(_backup_lang "$ENV{LANG}") + set(_backup_lc_Messages "$ENV{LC_MESSAGES}") if(MAKE_IS_GNU) set(RunCMake-stdout-file VerboseBuild-nowork-gnu-stdout.txt) set(ENV{LANG} "C") + set(ENV{LC_MESSAGES} "C") endif() run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose) set(ENV{LANG} "${_backup_lang}") + set(ENV{LC_MESSAGES} "${_backup_lc_messages}") endfunction() run_VerboseBuild() run_cmake(CustomCommandDepfile-ERROR) run_cmake(IncludeRegexSubdir) + +function(run_CMP0113 val) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0113-${val}-build) + run_cmake(CMP0113-${val}) + set(RunCMake_TEST_NO_CLEAN 1) + set(_backup_lang "$ENV{LANG}") + set(_backup_lc_Messages "$ENV{LC_MESSAGES}") + if(MAKE_IS_GNU) + set(RunCMake-stderr-file CMP0113-${val}-build-gnu-stderr.txt) + set(ENV{LANG} "C") + set(ENV{LC_MESSAGES} "C") + endif() + run_cmake_command(CMP0113-${val}-build ${CMAKE_COMMAND} --build .) + set(ENV{LANG} "${_backup_lang}") + set(ENV{LC_MESSAGES} "${_backup_lc_messages}") +endfunction() + +if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_CMP0113(WARN) + run_CMP0113(OLD) + run_CMP0113(NEW) +endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/ExcludeFromAll-all-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/ExcludeFromAll-all-build-check.cmake new file mode 100644 index 000000000..a4d2758bd --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/ExcludeFromAll-all-build-check.cmake @@ -0,0 +1,9 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_release_only_tool_Release} + ${TARGET_EXE_FILE_release_only_tool_Release} + + EXCLUDE + ${TARGET_FILE_release_only_tool_Debug} + ${TARGET_EXE_FILE_release_only_tool_Debug} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/ExcludeFromAll.cmake b/Tests/RunCMake/NinjaMultiConfig/ExcludeFromAll.cmake new file mode 100644 index 000000000..52f84ea92 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/ExcludeFromAll.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "") +set(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "") +set(CMAKE_CROSS_CONFIGS "all" CACHE STRING "") +set(CMAKE_DEFAULT_CONFIGS "all" CACHE STRING "") + +add_executable(release_only_tool main.c) +set_property(TARGET release_only_tool PROPERTY EXCLUDE_FROM_ALL "$<NOT:$<CONFIG:Release>>") + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(release_only_tool) diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 8496d6373..6699a0990 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -284,6 +284,11 @@ run_ninja(Install default-install build.ninja install) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/install") run_ninja(Install all-install build.ninja install:all) +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build) +run_cmake_configure(ExcludeFromAll) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(ExcludeFromAll all "" all:all) + # FIXME Get this working #set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutoMocExecutable-build) #run_cmake_configure(AutoMocExecutable) diff --git a/Tests/RunCMake/ObjectLibrary/MissingSource-stderr.txt b/Tests/RunCMake/ObjectLibrary/MissingSource-stderr.txt index 411cd7cb7..5c7882d68 100644 --- a/Tests/RunCMake/ObjectLibrary/MissingSource-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/MissingSource-stderr.txt @@ -3,7 +3,7 @@ CMake Error at MissingSource.cmake:1 \(add_library\): missing.c - Tried extensions( \.[A-Za-z+]+| - )* + Tried extensions \.c \.C .* +.* Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObsoleteQtMacros/CMakeLists.txt b/Tests/RunCMake/ObsoleteQtMacros/CMakeLists.txt index 65ac8e8db..44b5d30c0 100644 --- a/Tests/RunCMake/ObsoleteQtMacros/CMakeLists.txt +++ b/Tests/RunCMake/ObsoleteQtMacros/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST}) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt b/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt index 90afc127e..c3922d623 100644 --- a/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt +++ b/Tests/RunCMake/PositionIndependentCode/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} CXX) # MSVC creates extra targets which pollute the stderr unless we set this. diff --git a/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates-check.cmake new file mode 100644 index 000000000..81449ca62 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates-check.cmake @@ -0,0 +1,17 @@ +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json empty_dir_commands + REGEX "command.*-fpch-instantiate-templates.*empty.dir/cmake_pch[A-Za-z0-9_.]*.h") +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json foo_dir_commands + REGEX "command.*-fpch-instantiate-templates.*foo.dir/cmake_pch[A-Za-z0-9_.]*.h") + +list(LENGTH empty_dir_commands empty_dir_commands_size) +list(LENGTH foo_dir_commands foo_dir_commands_size) + +if (empty_dir_commands_size EQUAL 0) + set(RunCMake_TEST_FAILED "empty target should have -fpch-instantiate-templates compile option present") + return() +endif() + +if (foo_dir_commands_size GREATER 0) + set(RunCMake_TEST_FAILED "foo target should not have -fpch-instantiate-templates compile option present") + return() +endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates.cmake b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates.cmake new file mode 100644 index 000000000..3aebbe0c0 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchInstantiateTemplates.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +add_library(empty empty.c) +target_precompile_headers(empty PUBLIC + <stdio.h> + <string.h> +) + +add_library(foo foo.c) +target_precompile_headers(foo PUBLIC + <stdio.h> + <string.h> +) +set_target_properties(foo PROPERTIES PCH_INSTANTIATE_TEMPLATES OFF) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index 381b800a6..74670bafc 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -20,4 +20,9 @@ run_test(PchReuseFromSubdir) run_cmake(PchMultilanguage) if(RunCMake_GENERATOR MATCHES "Make|Ninja") run_cmake(PchWarnInvalid) + + if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.0) + run_cmake(PchInstantiateTemplates) + endif() endif() diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index cb20fb1f3..7d96e503d 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -153,7 +153,9 @@ function(run_cmake test) "|contact PGI Sales at" "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" + "|[^\n]*objc[^\n]*: Class AMSupportURL[^\n]* One of the two will be used. Which one is undefined." "|[^\n]*is a member of multiple groups" + "|[^\n]*offset in archive not a multiple of 8" "|[^\n]*from Time Machine by path" "|[^\n]*Bullseye Testing Technology" ")[^\n]*\n)+" diff --git a/Tests/RunCMake/SourceProperties/CMakeLists.txt b/Tests/RunCMake/SourceProperties/CMakeLists.txt index a17c8cd13..e93f0b69e 100644 --- a/Tests/RunCMake/SourceProperties/CMakeLists.txt +++ b/Tests/RunCMake/SourceProperties/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} C) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt index aecd4d333..141d66d1e 100644 --- a/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt +++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt @@ -19,6 +19,6 @@ CMake Error at CMP0053-Dollar-OLD.cmake:6 \(message\): -->\${\$}<-- - syntax error, unexpected \$, expecting } \(7\) + syntax error, unexpected \$, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithCarriageReturn-stderr.txt b/Tests/RunCMake/Syntax/NameWithCarriageReturn-stderr.txt index 7448b59cc..71b9c3cbd 100644 --- a/Tests/RunCMake/Syntax/NameWithCarriageReturn-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithCarriageReturn-stderr.txt @@ -7,6 +7,6 @@ \${var\\rwith\\rcarriagereturn} - syntax error, unexpected cal_SYMBOL, expecting } \(7\) + syntax error, unexpected cal_SYMBOL, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-stderr.txt index f5e03edb2..c43e1be97 100644 --- a/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-stderr.txt @@ -7,6 +7,6 @@ \${var\\rwith\\rcarriagereturn} - syntax error, unexpected cal_SYMBOL, expecting } \(7\) + syntax error, unexpected cal_SYMBOL, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithEscapedSpaces-stderr.txt b/Tests/RunCMake/Syntax/NameWithEscapedSpaces-stderr.txt index fa16a8a5f..3a2613592 100644 --- a/Tests/RunCMake/Syntax/NameWithEscapedSpaces-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithEscapedSpaces-stderr.txt @@ -7,6 +7,6 @@ \${var\\ with\\ escaped\\ space} - syntax error, unexpected cal_SYMBOL, expecting } \(7\) + syntax error, unexpected cal_SYMBOL, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-stderr.txt index 07cbf24c5..0f40649c5 100644 --- a/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-stderr.txt @@ -7,6 +7,6 @@ \${var\\ with\\ escaped\\ space} - syntax error, unexpected cal_SYMBOL, expecting } \(7\) + syntax error, unexpected cal_SYMBOL, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithNewline-stderr.txt b/Tests/RunCMake/Syntax/NameWithNewline-stderr.txt index 5cc111b5c..77bd470fa 100644 --- a/Tests/RunCMake/Syntax/NameWithNewline-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithNewline-stderr.txt @@ -7,6 +7,6 @@ \${var\\nwith\\nnewline} - syntax error, unexpected cal_SYMBOL, expecting } \(7\) + syntax error, unexpected cal_SYMBOL, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithNewlineQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithNewlineQuoted-stderr.txt index 0067c2f3a..1d14b1d46 100644 --- a/Tests/RunCMake/Syntax/NameWithNewlineQuoted-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithNewlineQuoted-stderr.txt @@ -7,6 +7,6 @@ \${var\\nwith\\nnewline} - syntax error, unexpected cal_SYMBOL, expecting } \(7\) + syntax error, unexpected cal_SYMBOL, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithSpaces-stderr.txt b/Tests/RunCMake/Syntax/NameWithSpaces-stderr.txt index 04bc2260a..cf6dad5d3 100644 --- a/Tests/RunCMake/Syntax/NameWithSpaces-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithSpaces-stderr.txt @@ -7,6 +7,6 @@ \${var - syntax error, unexpected \$end, expecting } \(5\) + syntax error, unexpected \$end, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithSpacesQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithSpacesQuoted-stderr.txt index 66cf9a26a..6e3744a62 100644 --- a/Tests/RunCMake/Syntax/NameWithSpacesQuoted-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithSpacesQuoted-stderr.txt @@ -7,6 +7,6 @@ \${var with space} - syntax error, unexpected cal_SYMBOL, expecting } \(17\) + syntax error, unexpected cal_SYMBOL, expecting } \(3\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithTabs-stderr.txt b/Tests/RunCMake/Syntax/NameWithTabs-stderr.txt index e8880965b..70e7c125b 100644 --- a/Tests/RunCMake/Syntax/NameWithTabs-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithTabs-stderr.txt @@ -7,6 +7,6 @@ \${var - syntax error, unexpected \$end, expecting } \(5\) + syntax error, unexpected \$end, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/NameWithTabsQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithTabsQuoted-stderr.txt index b02007484..e18268ac5 100644 --- a/Tests/RunCMake/Syntax/NameWithTabsQuoted-stderr.txt +++ b/Tests/RunCMake/Syntax/NameWithTabsQuoted-stderr.txt @@ -7,6 +7,6 @@ \${var with tab} - syntax error, unexpected cal_SYMBOL, expecting } \(15\) + syntax error, unexpected cal_SYMBOL, expecting } \(3\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt index d7861e2eb..144b57c1e 100644 --- a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt +++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt @@ -15,6 +15,6 @@ CMake Error at ParenInENV.cmake:2 \(message\): -->\$ENV{e - syntax error, unexpected \$end, expecting } \(9\) + syntax error, unexpected \$end, expecting } \(10\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/ParenInVarName1-stderr.txt b/Tests/RunCMake/Syntax/ParenInVarName1-stderr.txt index 81b17174b..18ca946fd 100644 --- a/Tests/RunCMake/Syntax/ParenInVarName1-stderr.txt +++ b/Tests/RunCMake/Syntax/ParenInVarName1-stderr.txt @@ -7,6 +7,6 @@ CMake Error at ParenInVarName1.cmake:4 \(message\): -->\${e\(x\)}<-- - syntax error, unexpected cal_SYMBOL, expecting } \(10\) + syntax error, unexpected cal_SYMBOL, expecting } \(6\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace0-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedBrace0-stderr.txt index 1e0ce493b..cf63dbe77 100644 --- a/Tests/RunCMake/Syntax/UnterminatedBrace0-stderr.txt +++ b/Tests/RunCMake/Syntax/UnterminatedBrace0-stderr.txt @@ -7,6 +7,6 @@ CMake Error at UnterminatedBrace0.cmake:2 \(set\): \${ - syntax error, unexpected \$end, expecting } \(2\) + syntax error, unexpected \$end, expecting } \(3\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace1-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedBrace1-stderr.txt index 4e3c2b563..0e6f7864e 100644 --- a/Tests/RunCMake/Syntax/UnterminatedBrace1-stderr.txt +++ b/Tests/RunCMake/Syntax/UnterminatedBrace1-stderr.txt @@ -7,7 +7,7 @@ CMake Warning \(dev\) at UnterminatedBrace1.cmake:3 \(set\): \${ - syntax error, unexpected \$end, expecting } \(2\) + syntax error, unexpected \$end, expecting } \(3\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/TargetObjects/CMakeLists.txt b/Tests/RunCMake/TargetObjects/CMakeLists.txt index be9d4038d..44b5d30c0 100644 --- a/Tests/RunCMake/TargetObjects/CMakeLists.txt +++ b/Tests/RunCMake/TargetObjects/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST}) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetPolicies/CMakeLists.txt b/Tests/RunCMake/TargetPolicies/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/TargetPolicies/CMakeLists.txt +++ b/Tests/RunCMake/TargetPolicies/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 2454f25ff..b3f3a5ea7 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -32,6 +32,8 @@ \* CMP0104 \* CMP0105 \* CMP0108 + \* CMP0112 + \* CMP0113 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetProperties/CMakeLists.txt b/Tests/RunCMake/TargetProperties/CMakeLists.txt index be9d4038d..44b5d30c0 100644 --- a/Tests/RunCMake/TargetProperties/CMakeLists.txt +++ b/Tests/RunCMake/TargetProperties/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST}) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt index 90afc127e..c3922d623 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} CXX) # MSVC creates extra targets which pollute the stderr unless we set this. diff --git a/Tests/RunCMake/TargetSources/CMakeLists.txt b/Tests/RunCMake/TargetSources/CMakeLists.txt index f452db177..a06591c31 100644 --- a/Tests/RunCMake/TargetSources/CMakeLists.txt +++ b/Tests/RunCMake/TargetSources/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake index f26ec2ea5..85e658742 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake @@ -2,6 +2,6 @@ set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c file(STRINGS ${unitybuild_c} unitybuild_c_strings) string(REGEX MATCH ".*#include.*s3.c.*#include.*s1.c.*#include.*s2.c.*" matched_code ${unitybuild_c_strings}) if(NOT matched_code) - set(RunCMake_TEST_FAILED "Generated unity file doesn't include expected oder of source files") + set(RunCMake_TEST_FAILED "Generated unity file doesn't include expected order of source files") return() endif() diff --git a/Tests/RunCMake/VS10Project/InterfaceLibSources-check.cmake b/Tests/RunCMake/VS10Project/InterfaceLibSources-check.cmake new file mode 100644 index 000000000..bcdc10105 --- /dev/null +++ b/Tests/RunCMake/VS10Project/InterfaceLibSources-check.cmake @@ -0,0 +1,25 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/iface.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(found_iface_h 0) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "<([A-Za-z0-9_]+) +Include=.*iface\\.h") + set(rule "${CMAKE_MATCH_1}") + if(NOT rule STREQUAL "None") + set(RunCMake_TEST_FAILED "iface.h referenced as ${rule} instead of None in\n ${vcProjectFile}") + return() + endif() + if(found_iface_h) + set(RunCMake_TEST_FAILED "iface.h referenced multiple times in\n ${vcProjectFile}") + return() + endif() + set(found_iface_h 1) + endif() +endforeach() +if(NOT found_iface_h) + set(RunCMake_TEST_FAILED "iface.h not referenced in\n ${vcProjectFile}") +endif() diff --git a/Tests/RunCMake/VS10Project/InterfaceLibSources.cmake b/Tests/RunCMake/VS10Project/InterfaceLibSources.cmake new file mode 100644 index 000000000..3672be18c --- /dev/null +++ b/Tests/RunCMake/VS10Project/InterfaceLibSources.cmake @@ -0,0 +1 @@ +add_library(iface INTERFACE iface.h) diff --git a/Tests/RunCMake/VS10Project/LanguageStandard-check.cmake b/Tests/RunCMake/VS10Project/LanguageStandard-check.cmake new file mode 100644 index 000000000..85e28581b --- /dev/null +++ b/Tests/RunCMake/VS10Project/LanguageStandard-check.cmake @@ -0,0 +1,23 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(found_LanguageStandard_stdcpp17 0) +set(found_LanguageStandard_C_stdc11 0) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "<LanguageStandard>stdcpp17</LanguageStandard>") + set(found_LanguageStandard_stdcpp17 1) + endif() + if(line MATCHES "<LanguageStandard_C>stdc11</LanguageStandard_C>") + set(found_LanguageStandard_C_stdc11 1) + endif() +endforeach() +if(NOT found_LanguageStandard_stdcpp17) + string(APPEND RunCMake_TEST_FAILED "LanguageStandard stdcpp17 not found in\n ${vcProjectFile}\n") +endif() +if(NOT found_LanguageStandard_C_stdc11) + string(APPEND RunCMake_TEST_FAILED "LanguageStandard_C stdc11 not found in\n ${vcProjectFile}\n") +endif() diff --git a/Tests/RunCMake/VS10Project/LanguageStandard.cmake b/Tests/RunCMake/VS10Project/LanguageStandard.cmake new file mode 100644 index 000000000..f8b62e2e6 --- /dev/null +++ b/Tests/RunCMake/VS10Project/LanguageStandard.cmake @@ -0,0 +1,5 @@ +enable_language(C) +enable_language(CXX) + +add_library(foo empty.c empty.cxx) +target_compile_features(foo PRIVATE c_std_11 cxx_std_17) diff --git a/Tests/RunCMake/VS10Project/NoImpLib-check.cmake b/Tests/RunCMake/VS10Project/NoImpLib-check.cmake new file mode 100644 index 000000000..50722b22e --- /dev/null +++ b/Tests/RunCMake/VS10Project/NoImpLib-check.cmake @@ -0,0 +1,23 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(found_ImportLibrary 0) +set(found_TargetExt_dll 0) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "<ImportLibrary>") + set(found_ImportLibrary 1) + endif() + if(line MATCHES "<TargetExt[^\n]*\\.dll") + set(found_TargetExt_dll 1) + endif() +endforeach() +if(found_ImportLibrary) + string(APPEND RunCMake_TEST_FAILED "ImportLibrary incorrectly found in\n ${vcProjectFile}\n") +endif() +if(NOT found_TargetExt_dll) + string(APPEND RunCMake_TEST_FAILED "TargetExt not found in\n ${vcProjectFile}\n") +endif() diff --git a/Tests/RunCMake/VS10Project/NoImpLib.cmake b/Tests/RunCMake/VS10Project/NoImpLib.cmake new file mode 100644 index 000000000..2c11eac60 --- /dev/null +++ b/Tests/RunCMake/VS10Project/NoImpLib.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_IMPORT_LIBRARY_SUFFIX "") +add_library(foo SHARED empty.c) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 93ef60343..133dacc17 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -3,9 +3,15 @@ cmake_policy(SET CMP0057 NEW) include(RunCMake) cmake_policy(SET CMP0054 NEW) +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) + run_cmake(LanguageStandard) +endif() + run_cmake(VsCsharpSourceGroup) run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) +run_cmake(InterfaceLibSources) +run_cmake(NoImpLib) run_cmake(RuntimeLibrary) run_cmake(SourceGroupCMakeLists) run_cmake(SourceGroupTreeCMakeLists) diff --git a/Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake b/Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake index 416220b83..0d82d3feb 100644 --- a/Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake +++ b/Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake @@ -31,6 +31,6 @@ if (NOT "${OVERRIDEN_TOOLSET}" STREQUAL "MyCustomToolset") endif() if ("${NORMAL_TOOLSET}" STREQUAL "MyCustomToolset") - set(RunCMake_TEST_FAILED "Main toolset was overriden (it shouldn't)") + set(RunCMake_TEST_FAILED "Main toolset was overridden (it shouldn't)") return() endif() diff --git a/Tests/RunCMake/VS10Project/iface.h b/Tests/RunCMake/VS10Project/iface.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/VS10Project/iface.h diff --git a/Tests/RunCMake/VSSolution/CMakeLists.txt b/Tests/RunCMake/VSSolution/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/VSSolution/CMakeLists.txt +++ b/Tests/RunCMake/VSSolution/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Win32GenEx/CMakeLists.txt b/Tests/RunCMake/Win32GenEx/CMakeLists.txt new file mode 100644 index 000000000..b646c4ac6 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Win32GenEx/RunCMakeTest.cmake b/Tests/RunCMake/Win32GenEx/RunCMakeTest.cmake new file mode 100644 index 000000000..d5529b022 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/RunCMakeTest.cmake @@ -0,0 +1,28 @@ +include(RunCMake) + +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Win32GenEx-build) + run_cmake(Win32GenEx) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Win32GenEx-debug-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Debug) + run_cmake_command(Win32GenEx-release-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Release) + unset(RunCMake_TEST_NO_CLEAN) +else() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Win32GenEx-debug-build) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + run_cmake(Win32GenEx-debug) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Win32GenEx-debug-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}) + unset(RunCMake_TEST_NO_CLEAN) + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Win32GenEx-release-build) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + run_cmake(Win32GenEx-release) + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Win32GenEx-release-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}) + unset(RunCMake_TEST_NO_CLEAN) +endif() diff --git a/Tests/RunCMake/Win32GenEx/Win32GenEx-debug.cmake b/Tests/RunCMake/Win32GenEx/Win32GenEx-debug.cmake new file mode 100644 index 000000000..74c5bd8a2 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/Win32GenEx-debug.cmake @@ -0,0 +1 @@ +include(Win32GenEx.cmake) diff --git a/Tests/RunCMake/Win32GenEx/Win32GenEx-release.cmake b/Tests/RunCMake/Win32GenEx/Win32GenEx-release.cmake new file mode 100644 index 000000000..74c5bd8a2 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/Win32GenEx-release.cmake @@ -0,0 +1 @@ +include(Win32GenEx.cmake) diff --git a/Tests/RunCMake/Win32GenEx/Win32GenEx.cmake b/Tests/RunCMake/Win32GenEx/Win32GenEx.cmake new file mode 100644 index 000000000..80f8b8019 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/Win32GenEx.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_executable(Win32GenEx main.c) +set_target_properties(Win32GenEx PROPERTIES + WIN32_EXECUTABLE $<CONFIG:Release> + ) +target_compile_definitions(Win32GenEx PRIVATE $<$<CONFIG:Release>:USE_WIN32_MAIN>) diff --git a/Tests/RunCMake/Win32GenEx/main.c b/Tests/RunCMake/Win32GenEx/main.c new file mode 100644 index 000000000..1cf9f8116 --- /dev/null +++ b/Tests/RunCMake/Win32GenEx/main.c @@ -0,0 +1,14 @@ +#ifdef USE_WIN32_MAIN +# include <windows.h> + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nShowCmd) +{ + return 0; +} +#else +int main(void) +{ + return 0; +} +#endif diff --git a/Tests/RunCMake/XcodeProject/CMakeLists.txt b/Tests/RunCMake/XcodeProject/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/XcodeProject/CMakeLists.txt +++ b/Tests/RunCMake/XcodeProject/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake index 288735e87..3d8fa1792 100644 --- a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake +++ b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake @@ -5,15 +5,18 @@ project(DeploymentTarget C) if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "9.1") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "9.0") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") diff --git a/Tests/RunCMake/XcodeProject/InterfaceLibSources-check.cmake b/Tests/RunCMake/XcodeProject/InterfaceLibSources-check.cmake new file mode 100644 index 000000000..613951a46 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/InterfaceLibSources-check.cmake @@ -0,0 +1,16 @@ +set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/InterfaceLibSources.xcodeproj/project.pbxproj") +if(NOT EXISTS "${xcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.") + return() +endif() + +set(found_iface_h 0) +file(STRINGS "${xcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "PBXFileReference.*explicitFileType.*sourcecode\\.c\\.h.*iface\\.h") + set(found_iface_h 1) + endif() +endforeach() +if(NOT found_iface_h) + set(RunCMake_TEST_FAILED "iface.h not referenced in\n ${xcProjectFile}") +endif() diff --git a/Tests/RunCMake/XcodeProject/InterfaceLibSources.cmake b/Tests/RunCMake/XcodeProject/InterfaceLibSources.cmake new file mode 100644 index 000000000..3672be18c --- /dev/null +++ b/Tests/RunCMake/XcodeProject/InterfaceLibSources.cmake @@ -0,0 +1 @@ +add_library(iface INTERFACE iface.h) diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake new file mode 100644 index 000000000..7abc58bf4 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase.cmake @@ -0,0 +1,132 @@ +enable_language(C) + +set(prototypes [[ +#include <stdio.h> +#include <zlib.h> +#include <resolv.h> +int func1(); +int func2(); +int func3(); +int func4(); +int func5(); +int func6(); +int func7(); +]]) +set(prototypes_objc [[ +#import <CoreFoundation/CoreFoundation.h> +]]) +set(impl [[ +{ + printf("%p %p\n", compress, res_close); + return func1() + func2() + func3() + func4() + func5() + func6() + func7(); +} +]]) +set(impl_objc [[ +{ + CFStringRef cfStr = CFSTR("This is a string"); + printf("%p %p %ld\n", compress, res_close, (long)CFStringGetLength(cfStr)); + return func1() + func2() + func3() + func4() + func5() + func6() + func7(); +} +]]) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/mainOuter.m + "${prototypes}\n${prototypes_objc}\nint main(int argc, char** argv) ${impl_objc}" +) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/funcOuter.c + "${prototypes}\nint funcOuter() ${impl}" +) + +foreach(i RANGE 1 5) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/func${i}.c + "int func${i}() { return 32 + ${i}; }\n" + ) +endforeach() + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/CMakeLists.txt +[[ +cmake_minimum_required(VERSION 3.18) +project(ExternalFrameworks) +add_library(staticFrameworkExt STATIC func6.c) +add_library(sharedFrameworkExt SHARED func7.c) +set_target_properties(staticFrameworkExt PROPERTIES FRAMEWORK TRUE) +set_target_properties(sharedFrameworkExt PROPERTIES FRAMEWORK TRUE) +]] +) + +foreach(i RANGE 6 7) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/func${i}.c + "int func${i}() { return 32 + ${i}; }\n" + ) +endforeach() + +add_custom_target(prebuildDependencies ALL + COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks -B ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build -G Xcode + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build --target staticFrameworkExt sharedFrameworkExt --config Debug +) +add_executable(app1 mainOuter.m) +add_library(static1 STATIC funcOuter.c) +add_library(shared1 SHARED funcOuter.c) +add_library(module1 MODULE funcOuter.c) +add_library(obj1 OBJECT funcOuter.c) +add_library(staticFramework1 STATIC funcOuter.c) +add_library(sharedFramework1 SHARED funcOuter.c) +set_target_properties(staticFramework1 PROPERTIES FRAMEWORK TRUE) +set_target_properties(sharedFramework1 PROPERTIES FRAMEWORK TRUE) +add_dependencies(app1 prebuildDependencies) +add_dependencies(static1 prebuildDependencies) +add_dependencies(shared1 prebuildDependencies) +add_dependencies(module1 prebuildDependencies) +add_dependencies(obj1 prebuildDependencies) +add_dependencies(staticFramework1 prebuildDependencies) +add_dependencies(sharedFramework1 prebuildDependencies) + +add_library(static2 STATIC func1.c) +add_library(shared2 SHARED func2.c) +add_library(obj2 OBJECT func3.c) +add_library(staticFramework2 STATIC func4.c) +add_library(sharedFramework2 SHARED func5.c) +set_target_properties(staticFramework2 PROPERTIES FRAMEWORK TRUE) +set_target_properties(sharedFramework2 PROPERTIES FRAMEWORK TRUE) + +# Pick some external libraries that are always present in the Xcode SDK +find_library(libz z REQUIRED) +find_library(libresolv resolv REQUIRED) +find_library(CoreFoundation CoreFoundation REQUIRED) +add_library(imported2 UNKNOWN IMPORTED) +set_target_properties(imported2 PROPERTIES IMPORTED_LOCATION ${libz}) + +# Save these for the check script to use +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/foundLibs.cmake " +set(libz \"${libz}\") +set(libresolv \"${libresolv}\") +set(CoreFoundation \"${CoreFoundation}\") +") + +set(mainTargets + app1 + static1 + shared1 + module1 + obj1 + staticFramework1 + sharedFramework1 +) +set(linkToThings + static2 + shared2 + obj2 + staticFramework2 + sharedFramework2 + imported2 + ${libresolv} + ${CoreFoundation} + "${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build/Debug/sharedFrameworkExt.framework" + "${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/build/Debug/staticFrameworkExt.framework" +) + +foreach(mainTarget IN LISTS mainTargets) + foreach(linkTo IN LISTS linkToThings) + target_link_libraries(${mainTarget} PRIVATE ${linkTo}) + endforeach() +endforeach() diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake new file mode 100644 index 000000000..d07a25be0 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY-check.cmake @@ -0,0 +1,19 @@ +include(${RunCMake_TEST_SOURCE_DIR}/LinkBinariesBuildPhase_Funcs.cmake) +include(${RunCMake_TEST_BINARY_DIR}/foundLibs.cmake) + +# obj2 --> Embeds func3.o in the link flags, but obj2 is part of the path +# ${libz} --> This is for imported2 + +foreach(mainTarget IN ITEMS app1 shared1 module1 sharedFramework1) + checkFlags(OTHER_LDFLAGS ${mainTarget} + "obj2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt" + "static2;shared2;staticFramework2;sharedFramework2" + ) +endforeach() + +foreach(mainTarget IN ITEMS static1 staticFramework1) + checkFlags(OTHER_LIBTOOLFLAGS ${mainTarget} + "obj2" + "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt" + ) +endforeach() diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY.cmake new file mode 100644 index 000000000..f9dd6430f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_BUILT_ONLY.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/LinkBinariesBuildPhase.cmake) diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake new file mode 100644 index 000000000..e72bf4dc9 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_Funcs.cmake @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.18...3.19) + +macro(returnOnError errorMsg) + if(NOT "${errorMsg}" STREQUAL "") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}\n${errorMsg}" PARENT_SCOPE) + return() + endif() +endmacro() + +function(getTargetFlags mainTarget projFlagsVar flagsVar errorVar) + # The flags variables in the project file might span over multiple lines + # so we can't easily read the flags directly from there. Instead, we use + # the xcodebuild -showBuildSettings option to report it on a single line. + execute_process( + COMMAND ${CMAKE_COMMAND} + --build ${RunCMake_TEST_BINARY_DIR} + --target ${mainTarget} + --config Debug + -- + -showBuildSettings + COMMAND grep ${projFlagsVar} + OUTPUT_VARIABLE flagsContents + RESULT_VARIABLE result + ) + + if(result) + set(${errorVar} "Failed to get flags for ${mainTarget}: ${result}" PARENT_SCOPE) + else() + unset(${errorVar} PARENT_SCOPE) + endif() + set(${flagsVar} "${flagsContents}" PARENT_SCOPE) +endfunction() + +function(checkFlags projFlagsVar mainTarget present absent) + getTargetFlags(${mainTarget} ${projFlagsVar} flags errorMsg) + returnOnError("${errorMsg}") + + foreach(linkTo IN LISTS present) + string(REGEX MATCH "${linkTo}" result "${flags}") + if("${result}" STREQUAL "") + string(APPEND RunCMake_TEST_FAILED + "\n${mainTarget} ${projFlagsVar} is missing ${linkTo}" + ) + endif() + endforeach() + + foreach(linkTo IN LISTS absent) + string(REGEX MATCH "${linkTo}" result "${flags}") + if(NOT "${result}" STREQUAL "") + string(APPEND RunCMake_TEST_FAILED + "\n${mainTarget} ${projFlagsVar} unexpectedly contains ${linkTo}" + ) + endif() + endforeach() + + set(RunCMake_TEST_FAILED ${RunCMake_TEST_FAILED} PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID-result.txt b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID-stderr.txt b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID-stderr.txt new file mode 100644 index 000000000..066430434 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID-stderr.txt @@ -0,0 +1 @@ +CMake Error: Invalid value for XCODE_LINK_BUILD_PHASE_MODE: INVALID diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID.cmake new file mode 100644 index 000000000..0a20d204a --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_INVALID.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) + +add_executable(app main.cpp) +set_target_properties(app PROPERTIES XCODE_LINK_BUILD_PHASE_MODE INVALID) diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake new file mode 100644 index 000000000..e1484e790 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION-check.cmake @@ -0,0 +1,19 @@ +include(${RunCMake_TEST_SOURCE_DIR}/LinkBinariesBuildPhase_Funcs.cmake) +include(${RunCMake_TEST_BINARY_DIR}/foundLibs.cmake) + +# obj2 --> Embeds func3.o in the link flags, but obj2 is part of the path +# ${libz} --> This is for imported2 + +foreach(mainTarget IN ITEMS app1 shared1 module1 sharedFramework1) + checkFlags(OTHER_LDFLAGS ${mainTarget} + "obj2" + "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt" + ) +endforeach() + +foreach(mainTarget IN ITEMS static1 staticFramework1) + checkFlags(OTHER_LIBTOOLFLAGS ${mainTarget} + "obj2" + "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt" + ) +endforeach() diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION.cmake new file mode 100644 index 000000000..f9dd6430f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_KNOWN_LOCATION.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/LinkBinariesBuildPhase.cmake) diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake new file mode 100644 index 000000000..260167607 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE-check.cmake @@ -0,0 +1,19 @@ +include(${RunCMake_TEST_SOURCE_DIR}/LinkBinariesBuildPhase_Funcs.cmake) +include(${RunCMake_TEST_BINARY_DIR}/foundLibs.cmake) + +# obj2 --> Embeds func3.o in the link flags, but obj2 is part of the path +# ${libz} --> This is for imported2 + +foreach(mainTarget IN ITEMS app1 shared1 module1 sharedFramework1) + checkFlags(OTHER_LDFLAGS ${mainTarget} + "static2;shared2;staticFramework2;sharedFramework2;obj2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt" + "" + ) +endforeach() + +foreach(mainTarget IN ITEMS static1 staticFramework1) + checkFlags(OTHER_LIBTOOLFLAGS ${mainTarget} + "obj2" + "static2;shared2;staticFramework2;sharedFramework2;${libz};${libresolv};CoreFoundation;sharedFrameworkExt;staticFrameworkExt" + ) +endforeach() diff --git a/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE.cmake b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE.cmake new file mode 100644 index 000000000..f9dd6430f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/LinkBinariesBuildPhase_NONE.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/LinkBinariesBuildPhase.cmake) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 342dbbcdc..62163acd8 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -2,6 +2,7 @@ include(RunCMake) run_cmake(ExplicitCMakeLists) run_cmake(ImplicitCMakeLists) +run_cmake(InterfaceLibSources) run_cmake(XcodeFileType) run_cmake(XcodeAttributeLocation) @@ -9,6 +10,10 @@ run_cmake(XcodeAttributeGenex) run_cmake(XcodeAttributeGenexError) run_cmake(XcodeGenerateTopLevelProjectOnly) +if(XCODE_VERSION VERSION_GREATER_EQUAL 12) + run_cmake(XcodeDuplicateCustomCommand) +endif() + function(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeGenerateTopLevelProjectOnlyWithObjectLibrary-build) run_cmake(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary) @@ -18,6 +23,19 @@ endfunction() XcodeGenerateTopLevelProjectOnlyWithObjectLibrary() +function(LinkBinariesBuildPhase mode) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/LinkBinariesBuildPhase_${mode}-build) + set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_LINK_BUILD_PHASE_MODE=${mode}") + run_cmake(LinkBinariesBuildPhase_${mode}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(LinkBinariesBuildPhase_${mode}-build ${CMAKE_COMMAND} --build .) +endfunction() + +LinkBinariesBuildPhase(NONE) +LinkBinariesBuildPhase(BUILT_ONLY) +LinkBinariesBuildPhase(KNOWN_LOCATION) +run_cmake(LinkBinariesBuildPhase_INVALID) + run_cmake(XcodeObjectNeedsEscape) run_cmake(XcodeObjectNeedsQuote) run_cmake(XcodeOptimizationFlags) @@ -119,8 +137,8 @@ if(NOT XCODE_VERSION VERSION_LESS 5) file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(XcodeBundles) - run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) - run_cmake_command(XcodeBundles-install ${CMAKE_COMMAND} --build . --target install) + run_cmake_command(XcodeBundles-build-macOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-macOS ${CMAKE_COMMAND} --build . --target install) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) @@ -136,8 +154,8 @@ if(NOT XCODE_VERSION VERSION_LESS 5) file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(XcodeBundles) - run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) - run_cmake_command(XcodeBundles-install ${CMAKE_COMMAND} --build . --target install) + run_cmake_command(XcodeBundles-build-iOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-iOS ${CMAKE_COMMAND} --build . --target install) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) @@ -155,8 +173,8 @@ if(NOT XCODE_VERSION VERSION_LESS 7) file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(XcodeBundles) - run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) - run_cmake_command(XcodeBundles-install ${CMAKE_COMMAND} --build . --target install) + run_cmake_command(XcodeBundles-build-watchOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-watchOS ${CMAKE_COMMAND} --build . --target install) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) @@ -174,8 +192,8 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1) file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(XcodeBundles) - run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .) - run_cmake_command(XcodeBundles-install ${CMAKE_COMMAND} --build . --target install) + run_cmake_command(XcodeBundles-build-tvOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-tvOS ${CMAKE_COMMAND} --build . --target install) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) @@ -188,7 +206,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7) unset(RunCMake_TEST_OPTIONS) endif() -if(NOT XCODE_VERSION VERSION_LESS 6) +if(XCODE_VERSION VERSION_GREATER_EQUAL 6 AND XCODE_VERSION VERSION_LESS 12) # XcodeIOSInstallCombined set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) set(RunCMake_TEST_NO_CLEAN 1) @@ -309,10 +327,10 @@ endif() if(XCODE_VERSION VERSION_GREATER_EQUAL 8) function(XcodeRemoveExcessiveISystemSDK SDK) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeRemoveExcessiveISystemSDK-${SDK}-build) - set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS") + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_OSX_SYSROOT=${SDK}") run_cmake(XcodeRemoveExcessiveISystem) set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(XcodeRemoveExcessiveISystemSDK-${SDK}-build ${CMAKE_COMMAND} --build . -- -sdk ${SDK}) + run_cmake_command(XcodeRemoveExcessiveISystemSDK-${SDK}-build ${CMAKE_COMMAND} --build .) endfunction() XcodeRemoveExcessiveISystemSDK(iphoneos) diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index 8c0b470c2..bc14874ad 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -4,12 +4,14 @@ cmake_minimum_required(VERSION 3.3) enable_language(C) if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") endif() if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") diff --git a/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt index 92c9a2948..402f9d54d 100644 --- a/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt +++ b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt @@ -1 +1,3 @@ -BUILD AGGREGATE TARGET ZERO_CHECK +BUILD AGGREGATE TARGET ZERO_CHECK|PhaseScriptExecution [^ +]*/ZERO_CHECK.build/Script-[^ +]*in target 'ZERO_CHECK' from project 'XcodeDependOnZeroCheck' diff --git a/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand-result.txt b/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand-stderr.txt b/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand-stderr.txt new file mode 100644 index 000000000..02af7835a --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand-stderr.txt @@ -0,0 +1,13 @@ +^CMake Error in CMakeLists.txt: + The custom command generating + + [^ +]*/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand-build/out.txt + + is attached to multiple targets: + + drive[0-9] + drive[0-9] + + but none of these is a common dependency of the other\(s\). This is not + allowed by the Xcode "new build system". diff --git a/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand.cmake b/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand.cmake new file mode 100644 index 000000000..3ef13122c --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeDuplicateCustomCommand.cmake @@ -0,0 +1,3 @@ +add_custom_command(OUTPUT out.txt COMMAND false) +add_custom_target(drive1 DEPENDS out.txt) +add_custom_target(drive2 DEPENDS out.txt) diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake index c2210332e..19f8e2fb4 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake @@ -10,6 +10,7 @@ if(NOT IOS) message(FATAL_ERROR "IOS variable is not set") endif() +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake index 172f2e85e..7d14d195f 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake @@ -6,6 +6,7 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 9) set(CMAKE_OSX_DEPLOYMENT_TARGET 10) endif() +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake index 038a89057..974ae47eb 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake @@ -6,6 +6,7 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 9) set(CMAKE_OSX_DEPLOYMENT_TARGET 10) endif() +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake index ab31387cd..75da7b1c4 100644 --- a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.5) +cmake_minimum_required(VERSION 3.3) project(XcodeInstallIOS) diff --git a/Tests/RunCMake/XcodeProject/iface.h b/Tests/RunCMake/XcodeProject/iface.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/XcodeProject/iface.h diff --git a/Tests/RunCMake/XcodeProject/main.cpp b/Tests/RunCMake/XcodeProject/main.cpp index c94753f84..f8b643afb 100644 --- a/Tests/RunCMake/XcodeProject/main.cpp +++ b/Tests/RunCMake/XcodeProject/main.cpp @@ -1,4 +1,4 @@ -int main(int argc, const char* argv[]) +int main() { return 0; } diff --git a/Tests/RunCMake/XcodeProject/main.m b/Tests/RunCMake/XcodeProject/main.m index 6dc190ad8..3e70e5079 100644 --- a/Tests/RunCMake/XcodeProject/main.m +++ b/Tests/RunCMake/XcodeProject/main.m @@ -1,3 +1,3 @@ -int main(int argc, const char * argv[]) { +int main(void) { return 1; } diff --git a/Tests/RunCMake/add_dependencies/CMakeLists.txt b/Tests/RunCMake/add_dependencies/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/add_dependencies/CMakeLists.txt +++ b/Tests/RunCMake/add_dependencies/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-Common-AlphaNumeric.cmake new file mode 100644 index 000000000..c2ab433d8 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "abcdefghijklmnopqrstuvwxyz0123456789") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-Common-BracketArgument.cmake new file mode 100644 index 000000000..77cd3eb1e --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-BracketArgument.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "[=[InBracketBeforeSemi;InBracketAfterSemi]=]") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-EscapedSpecialChars.cmake new file mode 100644 index 000000000..268b622e6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME \(\)\ \# ) +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-FormerInvalidSpecialChars.cmake new file mode 100644 index 000000000..65bca1052 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "$[] #;\t\n\"\\") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-Common-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 000000000..ec90e134a --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME " SurroundedByWhitespace ") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-OtherSpecialChars.cmake new file mode 100644 index 000000000..f74c3b5dc --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "!§%&/ü:*😤~") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-Common-Quote.cmake new file mode 100644 index 000000000..a1ddb66b7 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-Quote.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "BeforeQuote\"\"AfterEscapedQuote") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-Common-Semicolon.cmake new file mode 100644 index 000000000..11fd4fbfa --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-Semicolon.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "BeforeSemi;AfterSemi") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-Space.cmake b/Tests/RunCMake/add_test/CMP0110-Common-Space.cmake new file mode 100644 index 000000000..38dd28e54 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-Space.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "BeforeSpace AfterSpace") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-Common-ValidSpecialChars.cmake new file mode 100644 index 000000000..bfd082b98 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +set(TEST_NAME "abc_.+-012") +include(CMP0110-Common.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Common.cmake b/Tests/RunCMake/add_test/CMP0110-Common.cmake new file mode 100644 index 000000000..915d17164 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Common.cmake @@ -0,0 +1,9 @@ +include(CTest) +add_test( + NAME "${TEST_NAME}" + COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/CMP0110-Test.cmake" +) +set_property( + TEST "${TEST_NAME}" + PROPERTY ENVIRONMENT CMAKE_add_test_ENVVAR=1 +) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric-ctest-stdout.txt new file mode 100644 index 000000000..ed939bf40 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric.cmake new file mode 100644 index 000000000..7ea704213 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-AlphaNumeric.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument-ctest-stdout.txt new file mode 100644 index 000000000..7364d5634 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \[=\[InBracketBeforeSemi;InBracketAfterSemi\]=\] \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument.cmake new file mode 100644 index 000000000..baef07c32 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-BracketArgument.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-BracketArgument.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..80435b619 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \(\) # \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars.cmake new file mode 100644 index 000000000..c9b06bd6c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-EscapedSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..5ad8694c8 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \$\[\] .+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars.cmake new file mode 100644 index 000000000..86ddf14f5 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-FormerInvalidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialCharsMC.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialCharsMC.cmake new file mode 100644 index 000000000..f9b556a72 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-FormerInvalidSpecialCharsMC.cmake @@ -0,0 +1 @@ +include(CMP0110-NEW-FormerInvalidSpecialChars.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-GeneratorExpressionSyntax.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-GeneratorExpressionSyntax.cmake new file mode 100644 index 000000000..079053699 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-GeneratorExpressionSyntax.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-GeneratorExpressionSyntax.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace-ctest-stdout.txt new file mode 100644 index 000000000..78379cd1b --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: [ ]SurroundedByWhitespace[ ] \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 000000000..2d636a87a --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-LeadingAndTrailingWhitespace.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..8ee3ea9c2 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: !§%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars.cmake new file mode 100644 index 000000000..d77a6ce76 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-OtherSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Quote-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-Quote-ctest-stdout.txt new file mode 100644 index 000000000..23dafd459 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Quote-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeQuote""AfterEscapedQuote \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-Quote.cmake new file mode 100644 index 000000000..2e7a6e162 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Quote.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-Quote.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-Semicolon.cmake new file mode 100644 index 000000000..1c6e1b147 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Semicolon.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-Semicolon.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-Space.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-Space.cmake new file mode 100644 index 000000000..38afb8524 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-Space.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-Space.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..ae1a0b112 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars.cmake new file mode 100644 index 000000000..62bb6384a --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-NEW-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 NEW) +include(CMP0110-Common-ValidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric-ctest-stdout.txt new file mode 100644 index 000000000..ed939bf40 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric.cmake new file mode 100644 index 000000000..bf4e82b2b --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-AlphaNumeric.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument-ctest-stdout.txt new file mode 100644 index 000000000..093f5d426 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: InBracketBeforeSemi;InBracketAfterSemi \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument.cmake new file mode 100644 index 000000000..05dfeb49e --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-BracketArgument.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-BracketArgument.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt new file mode 100644 index 000000000..296e4262b --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars-ctest-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error\. Function missing ending "\)"\. End of file reached\. + + +Errors while running CTest diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars.cmake new file mode 100644 index 000000000..1f0c99f9a --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-EscapedSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stderr.txt new file mode 100644 index 000000000..c656b4c7f --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..d3b0fac31 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \$\[\] \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars.cmake new file mode 100644 index 000000000..883c5b6e1 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-FormerInvalidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-stderr.txt new file mode 100644 index 000000000..06ad9270d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC-ctest-stderr.txt @@ -0,0 +1,3 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error. Function missing ending "\)". Instead found unterminated + string with text "\\ NOT_AVAILABLE\) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC.cmake new file mode 100644 index 000000000..47e03bc86 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-FormerInvalidSpecialCharsMC.cmake @@ -0,0 +1 @@ +include(CMP0110-OLD-FormerInvalidSpecialChars.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-GeneratorExpressionSyntax.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-GeneratorExpressionSyntax.cmake new file mode 100644 index 000000000..7ee6b5061 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-GeneratorExpressionSyntax.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-GeneratorExpressionSyntax.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace-ctest-stdout.txt new file mode 100644 index 000000000..870483ea6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: SurroundedByWhitespace \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 000000000..a20d21153 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-LeadingAndTrailingWhitespace.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..8ee3ea9c2 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: !§%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars.cmake new file mode 100644 index 000000000..0e88183e0 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-OtherSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Quote-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Quote-ctest-stdout.txt new file mode 100644 index 000000000..23dafd459 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Quote-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeQuote""AfterEscapedQuote \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-Quote.cmake new file mode 100644 index 000000000..c910a7cc9 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Quote.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-Quote.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stderr.txt new file mode 100644 index 000000000..0d4376889 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSemi diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stdout.txt new file mode 100644 index 000000000..0a6ebedb3 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSemi \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon.cmake new file mode 100644 index 000000000..283aeed81 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Semicolon.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-Semicolon.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stderr.txt new file mode 100644 index 000000000..2ded1d442 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSpace diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stdout.txt new file mode 100644 index 000000000..059c62557 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSpace \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-Space.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-Space.cmake new file mode 100644 index 000000000..46f7c26fd --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-Space.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-Space.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..ae1a0b112 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars.cmake new file mode 100644 index 000000000..ffc6462f4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-OLD-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0110 OLD) +include(CMP0110-Common-ValidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-Test.cmake b/Tests/RunCMake/add_test/CMP0110-Test.cmake new file mode 100644 index 000000000..3f1dfade3 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-Test.cmake @@ -0,0 +1,3 @@ +if(NOT DEFINED ENV{CMAKE_add_test_ENVVAR}) + message(FATAL_ERROR "Setting property on test did not succeed!") +endif() diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric-ctest-stdout.txt new file mode 100644 index 000000000..ed939bf40 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abcdefghijklmnopqrstuvwxyz0123456789 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric.cmake new file mode 100644 index 000000000..d2af2aa0a --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-AlphaNumeric.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-AlphaNumeric.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-ctest-stdout.txt new file mode 100644 index 000000000..093f5d426 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: InBracketBeforeSemi;InBracketAfterSemi \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-stderr.txt new file mode 100644 index 000000000..19e60c1ed --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\[=\[InBracketBeforeSemi;InBracketAfterSemi\]=\]´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument.cmake new file mode 100644 index 000000000..7887658e0 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-BracketArgument.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-BracketArgument.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt new file mode 100644 index 000000000..296e4262b --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-ctest-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error\. Function missing ending "\)"\. End of file reached\. + + +Errors while running CTest diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-stderr.txt new file mode 100644 index 000000000..057f2d666 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\(\) #´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars.cmake new file mode 100644 index 000000000..ca2746267 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-EscapedSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-EscapedSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stderr.txt new file mode 100644 index 000000000..c656b4c7f --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..d3b0fac31 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: \$\[\] \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-stderr.txt new file mode 100644 index 000000000..4f20ab9ef --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\$\[\] #;[ ] + + "\\´ + +This warning is for project developers\. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars.cmake new file mode 100644 index 000000000..3b689c2b3 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-FormerInvalidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt new file mode 100644 index 000000000..d197c913c --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-stderr.txt new file mode 100644 index 000000000..06ad9270d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-ctest-stderr.txt @@ -0,0 +1,3 @@ +CMake Error at CTestTestfile.cmake:[0-9]+: + Parse error. Function missing ending "\)". Instead found unterminated + string with text "\\ NOT_AVAILABLE\) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-stderr.txt new file mode 100644 index 000000000..4f20ab9ef --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `\$\[\] #;[ ] + + "\\´ + +This warning is for project developers\. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC.cmake new file mode 100644 index 000000000..f77ff5c85 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-FormerInvalidSpecialCharsMC.cmake @@ -0,0 +1 @@ +include(CMP0110-WARN-FormerInvalidSpecialChars.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-GeneratorExpressionSyntax.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-GeneratorExpressionSyntax.cmake new file mode 100644 index 000000000..77c9ed237 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-GeneratorExpressionSyntax.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-GeneratorExpressionSyntax.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-ctest-stdout.txt new file mode 100644 index 000000000..870483ea6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: SurroundedByWhitespace \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-stderr.txt new file mode 100644 index 000000000..a392fed78 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + ` SurroundedByWhitespace ´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace.cmake new file mode 100644 index 000000000..322bb4a99 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-LeadingAndTrailingWhitespace.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-LeadingAndTrailingWhitespace.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..8ee3ea9c2 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: !§%&/ü:\*😤~ \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars.cmake new file mode 100644 index 000000000..19fa6e633 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-OtherSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-OtherSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Quote-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-ctest-stdout.txt new file mode 100644 index 000000000..23dafd459 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeQuote""AfterEscapedQuote \.+[ ]+Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Quote-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-stderr.txt new file mode 100644 index 000000000..39f3a925b --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Quote-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `BeforeQuote""AfterEscapedQuote´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Quote.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-Quote.cmake new file mode 100644 index 000000000..33aaad0b4 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Quote.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-Quote.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stderr.txt new file mode 100644 index 000000000..0d4376889 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSemi diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stdout.txt new file mode 100644 index 000000000..0a6ebedb3 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSemi \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-stderr.txt new file mode 100644 index 000000000..5101618bb --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `BeforeSemi;AfterSemi´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon.cmake new file mode 100644 index 000000000..c5da394f6 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Semicolon.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-Semicolon.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-result.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-result.txt new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stderr.txt new file mode 100644 index 000000000..2ded1d442 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: AfterSpace diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stdout.txt new file mode 100644 index 000000000..059c62557 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: BeforeSpace \.+\*\*\*Not Run diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space-stderr.txt b/Tests/RunCMake/add_test/CMP0110-WARN-Space-stderr.txt new file mode 100644 index 000000000..862eaa209 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0110 is not set: add_test\(\) supports arbitrary characters in test + names\. Run "cmake --help-policy CMP0110" for policy details\. Use the + cmake_policy command to set the policy and suppress this warning\. + + The following name given to add_test\(\) is invalid if CMP0110 is not set or + set to OLD: + + `BeforeSpace AfterSpace´ + +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-Space.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-Space.cmake new file mode 100644 index 000000000..1f3234c65 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-Space.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-Space.cmake) diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars-ctest-stdout.txt b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars-ctest-stdout.txt new file mode 100644 index 000000000..ae1a0b112 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars-ctest-stdout.txt @@ -0,0 +1 @@ +Test #[0-9]+: abc_\.\+-012 \.+[ ]*Passed diff --git a/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars.cmake b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars.cmake new file mode 100644 index 000000000..687c89940 --- /dev/null +++ b/Tests/RunCMake/add_test/CMP0110-WARN-ValidSpecialChars.cmake @@ -0,0 +1,2 @@ +# CMP0110 not set +include(CMP0110-Common-ValidSpecialChars.cmake) diff --git a/Tests/RunCMake/add_test/CMakeLists.txt b/Tests/RunCMake/add_test/CMakeLists.txt new file mode 100644 index 000000000..ee8fc2969 --- /dev/null +++ b/Tests/RunCMake/add_test/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/add_test/RunCMakeTest.cmake b/Tests/RunCMake/add_test/RunCMakeTest.cmake new file mode 100644 index 000000000..bf6cbff65 --- /dev/null +++ b/Tests/RunCMake/add_test/RunCMakeTest.cmake @@ -0,0 +1,35 @@ +include(RunCMake) + +set(ENV{CTEST_OUTPUT_ON_FAILURE} 1) + +function(run_case CASE_NAME) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0110-${CASE_NAME}-build) + run_cmake(CMP0110-${CASE_NAME}) + # Run ctest on the generated CTestTestfile.cmake. + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(CMP0110-${CASE_NAME}-ctest ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() + +set(cases + AlphaNumeric + ValidSpecialChars + OtherSpecialChars + EscapedSpecialChars + Space + LeadingAndTrailingWhitespace + Semicolon + Quote + BracketArgument + ) + +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + list(APPEND cases FormerInvalidSpecialCharsMC) +else() + list(APPEND cases FormerInvalidSpecialChars) +endif() + +foreach(case IN LISTS cases) + run_case(WARN-${case}) + run_case(OLD-${case}) + run_case(NEW-${case}) +endforeach() diff --git a/Tests/RunCMake/alias_targets/CMakeLists.txt b/Tests/RunCMake/alias_targets/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/alias_targets/CMakeLists.txt +++ b/Tests/RunCMake/alias_targets/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/alias_targets/invalid-name.cmake b/Tests/RunCMake/alias_targets/invalid-name.cmake index bbd39e3b6..01983e54f 100644 --- a/Tests/RunCMake/alias_targets/invalid-name.cmake +++ b/Tests/RunCMake/alias_targets/invalid-name.cmake @@ -1,4 +1,4 @@ - +cmake_minimum_required(VERSION 2.8.12) enable_language(CXX) add_library(foo empty.cpp) diff --git a/Tests/RunCMake/build_command/CMakeLists.txt b/Tests/RunCMake/build_command/CMakeLists.txt index 73e6a785a..f1a83e8c4 100644 --- a/Tests/RunCMake/build_command/CMakeLists.txt +++ b/Tests/RunCMake/build_command/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) if(NOT NoProject) project(${RunCMake_TEST} NONE) endif() diff --git a/Tests/RunCMake/cmake_language/CallInvalidCommand.cmake b/Tests/RunCMake/cmake_language/CallInvalidCommand.cmake deleted file mode 100644 index 8bee6f264..000000000 --- a/Tests/RunCMake/cmake_language/CallInvalidCommand.cmake +++ /dev/null @@ -1,2 +0,0 @@ - -cmake_language(CALL ${COMMAND}) diff --git a/Tests/RunCMake/cmake_language/RunCMakeTest.cmake b/Tests/RunCMake/cmake_language/RunCMakeTest.cmake index 5fb93c8d8..6480b2e0c 100644 --- a/Tests/RunCMake/cmake_language/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_language/RunCMakeTest.cmake @@ -2,7 +2,16 @@ include(RunCMake) run_cmake(no_parameters) run_cmake(unknown_meta_operation) -run_cmake(call_invalid_command) +foreach(command IN ITEMS + "function" "ENDFUNCTION" + "macro" "endMACRO" + "if" "elseif" "else" "endif" + "while" "endwhile" + "foreach" "endforeach" + ) + message(STATUS "Running call_invalid_command for ${command}...") + run_cmake_with_options(call_invalid_command -Dcommand=${command}) +endforeach() run_cmake(call_valid_command) run_cmake(call_double_evaluation) run_cmake(call_expanded_command) @@ -23,3 +32,53 @@ run_cmake(eval_message_fatal_error) run_cmake(eval_no_code) run_cmake(eval_no_parameters) run_cmake(eval_variable_outside_message) +run_cmake(defer_call) +run_cmake(defer_call_add_subdirectory) +run_cmake(defer_call_enable_language) +run_cmake(defer_call_ids) +foreach(command IN ITEMS + "function" "endfunction" + "macro" "endmacro" + "if" "elseif" "else" "endif" + "while" "endwhile" + "foreach" "endforeach" + "return" + ) + message(STATUS "Running defer_call_invalid_command for ${command}...") + run_cmake_with_options(defer_call_invalid_command -Dcommand=${command}) +endforeach() +run_cmake(defer_call_invalid_directory) +run_cmake(defer_call_error) +run_cmake(defer_call_missing_directory) +run_cmake(defer_call_policy_PUSH) +run_cmake(defer_call_syntax_error) +run_cmake_with_options(defer_call_trace --trace-expand) +run_cmake_with_options(defer_call_trace_json --trace --trace-format=json-v1) +run_cmake(defer_cancel_call_unknown_argument) +run_cmake(defer_cancel_call_invalid_directory) +run_cmake(defer_cancel_call_id) +run_cmake(defer_cancel_call_id_var) +run_cmake(defer_directory_empty) +run_cmake(defer_directory_missing) +run_cmake(defer_directory_multiple) +run_cmake(defer_id_empty) +run_cmake(defer_id_missing) +run_cmake(defer_id_multiple) +run_cmake(defer_id_var_empty) +run_cmake(defer_id_var_missing) +run_cmake(defer_id_var_multiple) +run_cmake(defer_get_call_ids_missing_var) +run_cmake(defer_get_call_ids_too_many_args) +run_cmake(defer_get_call_ids_invalid_directory) +run_cmake(defer_get_call_ids_id) +run_cmake(defer_get_call_ids_id_var) +run_cmake(defer_get_call_missing_id) +run_cmake(defer_get_call_missing_var) +run_cmake(defer_get_call_too_many_args) +run_cmake(defer_get_call_id_empty) +run_cmake(defer_get_call_unknown_argument) +run_cmake(defer_get_call_id) +run_cmake(defer_get_call_id_var) +run_cmake(defer_missing_arg) +run_cmake(defer_missing_call) +run_cmake(defer_unknown_option) diff --git a/Tests/RunCMake/cmake_language/call_expand_command_name.cmake b/Tests/RunCMake/cmake_language/call_expand_command_name.cmake index e03bb1fd2..f74d303a0 100644 --- a/Tests/RunCMake/cmake_language/call_expand_command_name.cmake +++ b/Tests/RunCMake/cmake_language/call_expand_command_name.cmake @@ -1,2 +1,2 @@ set (my_call "CALL") -cmake_language (${my_call} message "OK!") +cmake_language (${my_call} ${empty} message "OK!") diff --git a/Tests/RunCMake/cmake_language/call_expanded_command.cmake b/Tests/RunCMake/cmake_language/call_expanded_command.cmake index e76e61231..c52468d18 100644 --- a/Tests/RunCMake/cmake_language/call_expanded_command.cmake +++ b/Tests/RunCMake/cmake_language/call_expanded_command.cmake @@ -3,4 +3,4 @@ function (itsok) endfunction() set (cmd CALL itsok) -cmake_language (${cmd}) +cmake_language (${empty} ${cmd}) diff --git a/Tests/RunCMake/cmake_language/call_expanded_command_and_arguments-stderr.txt b/Tests/RunCMake/cmake_language/call_expanded_command_and_arguments-stderr.txt index e87e9bc27..82411d2e3 100644 --- a/Tests/RunCMake/cmake_language/call_expanded_command_and_arguments-stderr.txt +++ b/Tests/RunCMake/cmake_language/call_expanded_command_and_arguments-stderr.txt @@ -1,4 +1,4 @@ CMake Error at call_expanded_command_and_arguments.cmake:2 \(cmake_language\): - cmake_language called with incorrect number of arguments + cmake_language CALL command's arguments must be literal Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/cmake_language/call_invalid_command-result.txt b/Tests/RunCMake/cmake_language/call_invalid_command-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/call_invalid_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/call_invalid_command-stderr.txt b/Tests/RunCMake/cmake_language/call_invalid_command-stderr.txt new file mode 100644 index 000000000..4439842ed --- /dev/null +++ b/Tests/RunCMake/cmake_language/call_invalid_command-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at call_invalid_command.cmake:1 \(cmake_language\): + cmake_language invalid command specified: [A-Za-z_]+ +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/call_invalid_command.cmake b/Tests/RunCMake/cmake_language/call_invalid_command.cmake index 88bf08c2d..f2138957d 100644 --- a/Tests/RunCMake/cmake_language/call_invalid_command.cmake +++ b/Tests/RunCMake/cmake_language/call_invalid_command.cmake @@ -1,14 +1 @@ - -foreach (command IN ITEMS "function" "ENDFUNCTION" - "macro" "endMACRO" - "if" "elseif" "else" "endif" - "while" "endwhile" - "foreach" "endforeach") - execute_process(COMMAND "${CMAKE_COMMAND}" -DCOMMAND=${command} - -P "${CMAKE_CURRENT_SOURCE_DIR}/CallInvalidCommand.cmake" - OUTPUT_QUIET ERROR_QUIET - RESULT_VARIABLE result) - if (NOT result) - message (SEND_ERROR "cmake_language(CALL ${command}) unexpectedly successfull.") - endif() -endforeach() +cmake_language(CALL ${command}) diff --git a/Tests/RunCMake/cmake_language/call_message.cmake b/Tests/RunCMake/cmake_language/call_message.cmake index 31aefdf21..3b98c80d9 100644 --- a/Tests/RunCMake/cmake_language/call_message.cmake +++ b/Tests/RunCMake/cmake_language/call_message.cmake @@ -1 +1 @@ -cmake_language(CALL message WORKS!) +cmake_language(CALL ${empty} message WORKS!) diff --git a/Tests/RunCMake/cmake_language/call_no_parameters-stderr.txt b/Tests/RunCMake/cmake_language/call_no_parameters-stderr.txt index 9e2c08fd7..f6a04587f 100644 --- a/Tests/RunCMake/cmake_language/call_no_parameters-stderr.txt +++ b/Tests/RunCMake/cmake_language/call_no_parameters-stderr.txt @@ -1,2 +1,2 @@ CMake Error at call_no_parameters.cmake:1 \(cmake_language\): - cmake_language called with incorrect number of arguments + cmake_language CALL missing command name diff --git a/Tests/RunCMake/cmake_language/defer_call-stderr.txt b/Tests/RunCMake/cmake_language/defer_call-stderr.txt new file mode 100644 index 000000000..7e8d8ca15 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call-stderr.txt @@ -0,0 +1,15 @@ +^CMake Deprecation Warning at defer_call/CMakeLists.txt:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0053 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. ++ +CMake Warning at defer_call/CMakeLists.txt:3 \(message\): + Double-Deferred Warning In Subdirectory: + + '[^']*/Tests/RunCMake/cmake_language/defer_call/CMakeLists.txt:DEFERRED:id3' +Call Stack \(most recent call first\): + defer_call/CMakeLists.txt:DEFERRED$ diff --git a/Tests/RunCMake/cmake_language/defer_call-stdout.txt b/Tests/RunCMake/cmake_language/defer_call-stdout.txt new file mode 100644 index 000000000..fcf9f29e5 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call-stdout.txt @@ -0,0 +1,8 @@ +-- Immediate Message In Subdirectory: ids='__0;__1' +-- Deferred Message In Subdirectory: '[^']*/Tests/RunCMake/cmake_language/defer_call/CMakeLists.txt:DEFERRED:id1' +-- Deferred Message In Included File: '[^']*/Tests/RunCMake/cmake_language/defer_call/include.cmake:1' +-- Immediate Message: ids='__0;__1;__2;__3;__4' +-- First Deferred Message +-- Deferred Message From Subdirectory +-- Deferred Message: ids='__4;__5' +-- Final Deferred Message diff --git a/Tests/RunCMake/cmake_language/defer_call.cmake b/Tests/RunCMake/cmake_language/defer_call.cmake new file mode 100644 index 000000000..2e9595f8a --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call.cmake @@ -0,0 +1,12 @@ +set(message_command "message") +set(final_message "This should not be printed because variable evaluation is deferred too.") +cmake_language(DEFER CALL ${message_command} STATUS "First Deferred Message") +add_subdirectory(defer_call) +cmake_language(DEFER CALL cmake_language DEFER CALL "${final_message_command}" STATUS "${final_message}") +cmake_language(DEFER CALL cmake_language DEFER GET_CALL_IDS ids) +cmake_language(DEFER CALL cmake_language EVAL CODE [[message(STATUS "Deferred Message: ids='${ids}'")]]) +cmake_language(DEFER GET_CALL_IDS ids) +message(STATUS "Immediate Message: ids='${ids}'") +set(final_message_command "message") +set(final_message "Final Deferred Message") +set(subdir_message "Deferred Message From Subdirectory") diff --git a/Tests/RunCMake/cmake_language/defer_call/CMakeLists.txt b/Tests/RunCMake/cmake_language/defer_call/CMakeLists.txt new file mode 100644 index 000000000..544b9f48d --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_policy(SET CMP0053 OLD) +cmake_language(DEFER ID id1 CALL message STATUS "Deferred Message In Subdirectory: '${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}'") +cmake_language(DEFER ID id2 CALL + cmake_language DEFER ID id3 CALL + message WARNING "Double-Deferred Warning In Subdirectory:\n '${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}'") +cmake_language(DEFER ID id4 CALL include "${CMAKE_CURRENT_LIST_DIR}/include.cmake") + +set(subdir_message "This should not be printed because variable evaluation is in deferred scope.") +cmake_language(DEFER DIRECTORY .. CALL message STATUS "${subdir_message}") +cmake_language(DEFER DIRECTORY .. GET_CALL_IDS ids) +message(STATUS "Immediate Message In Subdirectory: ids='${ids}'") diff --git a/Tests/RunCMake/cmake_language/defer_call/include.cmake b/Tests/RunCMake/cmake_language/defer_call/include.cmake new file mode 100644 index 000000000..272c61b98 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call/include.cmake @@ -0,0 +1 @@ +message(STATUS "Deferred Message In Included File: '${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}'") diff --git a/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-result.txt b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-stderr.txt new file mode 100644 index 000000000..ec20b8f77 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at defer_call_add_subdirectory.cmake:1 \(add_subdirectory\): + Subdirectories may not be created during deferred execution. +Call Stack \(most recent call first\): + CMakeLists.txt:DEFERRED ++ +CMake Error at defer_call_add_subdirectory.cmake:2 \(subdirs\): + Subdirectories may not be created during deferred execution. +Call Stack \(most recent call first\): + CMakeLists.txt:DEFERRED$ diff --git a/Tests/RunCMake/cmake_language/defer_call_add_subdirectory.cmake b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory.cmake new file mode 100644 index 000000000..6b7ee6392 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory.cmake @@ -0,0 +1,2 @@ +cmake_language(DEFER CALL add_subdirectory defer_call_add_subdirectory) +cmake_language(DEFER CALL subdirs defer_call_add_subdirectory) diff --git a/Tests/RunCMake/cmake_language/defer_call_add_subdirectory/CMakeLists.txt b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_add_subdirectory/CMakeLists.txt diff --git a/Tests/RunCMake/cmake_language/defer_call_enable_language-result.txt b/Tests/RunCMake/cmake_language/defer_call_enable_language-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_enable_language-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_enable_language-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_enable_language-stderr.txt new file mode 100644 index 000000000..65a0b99cc --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_enable_language-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at defer_call_enable_language.cmake:1 \(enable_language\): + Languages may not be enabled during deferred execution. +Call Stack \(most recent call first\): + CMakeLists.txt:DEFERRED ++ +CMake Error at defer_call_enable_language.cmake:2 \(project\): + Languages may not be enabled during deferred execution. +Call Stack \(most recent call first\): + CMakeLists.txt:DEFERRED$ diff --git a/Tests/RunCMake/cmake_language/defer_call_enable_language.cmake b/Tests/RunCMake/cmake_language/defer_call_enable_language.cmake new file mode 100644 index 000000000..eb43f8070 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_enable_language.cmake @@ -0,0 +1,2 @@ +cmake_language(DEFER CALL enable_language C) +cmake_language(DEFER CALL project foo C) diff --git a/Tests/RunCMake/cmake_language/defer_call_error-result.txt b/Tests/RunCMake/cmake_language/defer_call_error-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_error-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_error-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_error-stderr.txt new file mode 100644 index 000000000..63ce145c9 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_error-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at defer_call_error.cmake:2 \(message\): + Deferred Error +Call Stack \(most recent call first\): + CMakeLists.txt:DEFERRED ++ +CMake Error at defer_call_error/CMakeLists.txt:2 \(message\): + Deferred Error from Subdirectory +Call Stack \(most recent call first\): + CMakeLists.txt:DEFERRED$ diff --git a/Tests/RunCMake/cmake_language/defer_call_error.cmake b/Tests/RunCMake/cmake_language/defer_call_error.cmake new file mode 100644 index 000000000..083e82ac1 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_error.cmake @@ -0,0 +1,3 @@ +# Error message backtrace points here but call stack shows DEFERRED execution. +cmake_language(DEFER CALL message SEND_ERROR "Deferred Error") +add_subdirectory(defer_call_error) diff --git a/Tests/RunCMake/cmake_language/defer_call_error/CMakeLists.txt b/Tests/RunCMake/cmake_language/defer_call_error/CMakeLists.txt new file mode 100644 index 000000000..0acac6920 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_error/CMakeLists.txt @@ -0,0 +1,2 @@ +# Error message backtrace points here but call stack shows DEFERRED execution in parent. +cmake_language(DEFER DIRECTORY .. CALL message SEND_ERROR "Deferred Error from Subdirectory") diff --git a/Tests/RunCMake/cmake_language/defer_call_ids-stdout.txt b/Tests/RunCMake/cmake_language/defer_call_ids-stdout.txt new file mode 100644 index 000000000..2fd194dc9 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_ids-stdout.txt @@ -0,0 +1,13 @@ +-- Immediate Message: ids='message0;getCallIds1;messageIds1;cancelCall;getCallIds2;messageIds2;toBeCancelled;message3' +-- Immediate Message: message0='message;STATUS;First Deferred Message' +-- Immediate Message: getCallIds1='cmake_language;DEFER;GET_CALL_IDS;ids' +-- Immediate Message: messageIds1='cmake_language;EVAL;CODE;message\(STATUS "Deferred Message: ids='\${ids}'"\)' +-- Immediate Message: cancelCall='cmake_language;DEFER;CANCEL_CALL;toBeCancelled' +-- Immediate Message: getCallIds2='cmake_language;DEFER;GET_CALL_IDS;ids' +-- Immediate Message: messageIds2='cmake_language;EVAL;CODE;message\(STATUS "Deferred Message: ids='\${ids}'"\)' +-- Immediate Message: toBeCancelled='message;STATUS;Cancelled Message' +-- Immediate Message: message3='message;STATUS;Final Deferred Message' +-- First Deferred Message +-- Deferred Message: ids='messageIds1;cancelCall;getCallIds2;messageIds2;toBeCancelled;message3' +-- Deferred Message: ids='messageIds2;message3' +-- Final Deferred Message diff --git a/Tests/RunCMake/cmake_language/defer_call_ids.cmake b/Tests/RunCMake/cmake_language/defer_call_ids.cmake new file mode 100644 index 000000000..287489417 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_ids.cmake @@ -0,0 +1,14 @@ +cmake_language(DEFER ID message0 CALL message STATUS "First Deferred Message") +cmake_language(DEFER ID getCallIds1 CALL cmake_language DEFER GET_CALL_IDS ids) +cmake_language(DEFER ID messageIds1 CALL cmake_language EVAL CODE [[message(STATUS "Deferred Message: ids='${ids}'")]]) +cmake_language(DEFER ID cancelCall CALL cmake_language DEFER CANCEL_CALL toBeCancelled) +cmake_language(DEFER ID getCallIds2 CALL cmake_language DEFER GET_CALL_IDS ids) +cmake_language(DEFER ID messageIds2 CALL cmake_language EVAL CODE [[message(STATUS "Deferred Message: ids='${ids}'")]]) +cmake_language(DEFER ID toBeCancelled CALL message STATUS "Cancelled Message") +cmake_language(DEFER ID message3 CALL message STATUS "Final Deferred Message") +cmake_language(DEFER GET_CALL_IDS ids) +message(STATUS "Immediate Message: ids='${ids}'") +foreach(id ${ids}) + cmake_language(DEFER GET_CALL ${id} call) + message(STATUS "Immediate Message: ${id}='${call}'") +endforeach() diff --git a/Tests/RunCMake/cmake_language/defer_call_invalid_command-result.txt b/Tests/RunCMake/cmake_language/defer_call_invalid_command-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_invalid_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_invalid_command-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_invalid_command-stderr.txt new file mode 100644 index 000000000..4cdbf0c4c --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_invalid_command-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_call_invalid_command.cmake:1 \(cmake_language\): + cmake_language invalid command specified: [A-Za-z_]+ +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_call_invalid_command.cmake b/Tests/RunCMake/cmake_language/defer_call_invalid_command.cmake new file mode 100644 index 000000000..d6cc93629 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_invalid_command.cmake @@ -0,0 +1 @@ +cmake_language(DEFER CALL ${command}) diff --git a/Tests/RunCMake/cmake_language/defer_call_invalid_directory-result.txt b/Tests/RunCMake/cmake_language/defer_call_invalid_directory-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_invalid_directory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_invalid_directory-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_invalid_directory-stderr.txt new file mode 100644 index 000000000..afe9a0e54 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_invalid_directory-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at defer_call_invalid_directory.cmake:2 \(cmake_language\): + cmake_language DEFER CALL may not be scheduled in directory: + + [^ +]*/Tests/RunCMake/cmake_language/defer_call_invalid_directory-build/defer_call_invalid_directory + + at this time. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_call_invalid_directory.cmake b/Tests/RunCMake/cmake_language/defer_call_invalid_directory.cmake new file mode 100644 index 000000000..cc1eb8d64 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_invalid_directory.cmake @@ -0,0 +1,2 @@ +add_subdirectory(defer_call_invalid_directory) +cmake_language(DEFER DIRECTORY defer_call_invalid_directory CALL message "Should not be allowed.") diff --git a/Tests/RunCMake/cmake_language/defer_call_invalid_directory/CMakeLists.txt b/Tests/RunCMake/cmake_language/defer_call_invalid_directory/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_invalid_directory/CMakeLists.txt diff --git a/Tests/RunCMake/cmake_language/defer_call_missing_directory-result.txt b/Tests/RunCMake/cmake_language/defer_call_missing_directory-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_missing_directory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_missing_directory-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_missing_directory-stderr.txt new file mode 100644 index 000000000..db4f90e7e --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_missing_directory-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at defer_call_missing_directory.cmake:1 \(cmake_language\): + cmake_language DEFER DIRECTORY: + + [^ +]*/Tests/RunCMake/cmake_language/does_not_exist + + is not known. It may not have been processed yet. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_call_missing_directory.cmake b/Tests/RunCMake/cmake_language/defer_call_missing_directory.cmake new file mode 100644 index 000000000..01f4c40b9 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_missing_directory.cmake @@ -0,0 +1 @@ +cmake_language(DEFER DIRECTORY does_not_exist CALL message "Should not be allowed.") diff --git a/Tests/RunCMake/cmake_language/defer_call_policy_PUSH-result.txt b/Tests/RunCMake/cmake_language/defer_call_policy_PUSH-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_policy_PUSH-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_policy_PUSH-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_policy_PUSH-stderr.txt new file mode 100644 index 000000000..923be13fa --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_policy_PUSH-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.txt:DEFERRED: + cmake_policy PUSH without matching POP$ diff --git a/Tests/RunCMake/cmake_language/defer_call_policy_PUSH.cmake b/Tests/RunCMake/cmake_language/defer_call_policy_PUSH.cmake new file mode 100644 index 000000000..66cb760f2 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_policy_PUSH.cmake @@ -0,0 +1 @@ +cmake_language(DEFER CALL cmake_policy PUSH) diff --git a/Tests/RunCMake/cmake_language/defer_call_syntax_error-result.txt b/Tests/RunCMake/cmake_language/defer_call_syntax_error-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_syntax_error-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_call_syntax_error-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_syntax_error-stderr.txt new file mode 100644 index 000000000..80db4aa04 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_syntax_error-stderr.txt @@ -0,0 +1,13 @@ +^CMake Error at defer_call_syntax_error.cmake:2 \(message\): + Syntax error in cmake code at + + [^ +]*/Tests/RunCMake/cmake_language/defer_call_syntax_error.cmake:2 + + when parsing string + + Deferred \\X Error + + Invalid character escape '\\X'. +Call Stack \(most recent call first\): + CMakeLists.txt:DEFERRED$ diff --git a/Tests/RunCMake/cmake_language/defer_call_syntax_error.cmake b/Tests/RunCMake/cmake_language/defer_call_syntax_error.cmake new file mode 100644 index 000000000..c3c044bc8 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_syntax_error.cmake @@ -0,0 +1,2 @@ +# Argument syntax error evaluated at deferred call site. +cmake_language(DEFER CALL message "Deferred \X Error") diff --git a/Tests/RunCMake/cmake_language/defer_call_trace-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_trace-stderr.txt new file mode 100644 index 000000000..b61b236df --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_trace-stderr.txt @@ -0,0 +1,8 @@ +[^ +]*/Tests/RunCMake/cmake_language/defer_call_trace.cmake\(2\): cmake_language\(DEFER CALL message Deferred Message \) +[^ +]*/Tests/RunCMake/cmake_language/defer_call_trace.cmake\(3\): message\(Immediate Message \) +Immediate Message +[^ +]*/Tests/RunCMake/cmake_language/defer_call_trace.cmake\(2\):DEFERRED:__0: message\(Deferred Message \) +Deferred Message$ diff --git a/Tests/RunCMake/cmake_language/defer_call_trace.cmake b/Tests/RunCMake/cmake_language/defer_call_trace.cmake new file mode 100644 index 000000000..5ed383f95 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_trace.cmake @@ -0,0 +1,3 @@ +# The --trace and --trace-expand output point here for deferred call. +cmake_language(DEFER CALL message "Deferred Message") +message("Immediate Message") diff --git a/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt new file mode 100644 index 000000000..647beb05c --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt @@ -0,0 +1,5 @@ +{"args":\["DEFER","CALL","message","Deferred Message"\],"cmd":"cmake_language","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"line":2,"time":[0-9.]+} +{"args":\["Immediate Message"\],"cmd":"message","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"line":3,"time":[0-9.]+} +Immediate Message +{"args":\["Deferred Message"],"cmd":"message","defer":"__0","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":1,"line":2,"time":[0-9.]+} +Deferred Message$ diff --git a/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake b/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake new file mode 100644 index 000000000..5ed383f95 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake @@ -0,0 +1,3 @@ +# The --trace and --trace-expand output point here for deferred call. +cmake_language(DEFER CALL message "Deferred Message") +message("Immediate Message") diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_id-result.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_id-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_id-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_id-stderr.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_id-stderr.txt new file mode 100644 index 000000000..8a13c0db5 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_id-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_cancel_call_id.cmake:1 \(cmake_language\): + cmake_language DEFER CANCEL_CALL does not accept ID or ID_VAR. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_id.cmake b/Tests/RunCMake/cmake_language/defer_cancel_call_id.cmake new file mode 100644 index 000000000..6e5b5c89f --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_id.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID id CANCEL_CALL) diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_id_var-result.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_id_var-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_id_var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_id_var-stderr.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_id_var-stderr.txt new file mode 100644 index 000000000..5783c50cc --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_id_var-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_cancel_call_id_var.cmake:1 \(cmake_language\): + cmake_language DEFER CANCEL_CALL does not accept ID or ID_VAR. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_id_var.cmake b/Tests/RunCMake/cmake_language/defer_cancel_call_id_var.cmake new file mode 100644 index 000000000..9f7522138 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_id_var.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID_VAR id_var CANCEL_CALL) diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory-result.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory-stderr.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory-stderr.txt new file mode 100644 index 000000000..cacbf9a21 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at defer_cancel_call_invalid_directory.cmake:2 \(cmake_language\): + cmake_language DEFER CANCEL_CALL may not update directory: + + [^ +]*/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory-build/defer_cancel_call_invalid_directory + + at this time. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory.cmake b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory.cmake new file mode 100644 index 000000000..29a8fc210 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory.cmake @@ -0,0 +1,2 @@ +add_subdirectory(defer_cancel_call_invalid_directory) +cmake_language(DEFER DIRECTORY defer_cancel_call_invalid_directory CANCEL_CALL _) diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory/CMakeLists.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_invalid_directory/CMakeLists.txt diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument-result.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument-stderr.txt b/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument-stderr.txt new file mode 100644 index 000000000..eb8f2b9fc --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at defer_cancel_call_unknown_argument.cmake:1 \(cmake_language\): + cmake_language DEFER CANCEL_CALL unknown argument: + + UNKNOWN +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument.cmake b/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument.cmake new file mode 100644 index 000000000..fbc6309a8 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_cancel_call_unknown_argument.cmake @@ -0,0 +1 @@ +cmake_language(DEFER CANCEL_CALL UNKNOWN) diff --git a/Tests/RunCMake/cmake_language/defer_directory_empty-result.txt b/Tests/RunCMake/cmake_language/defer_directory_empty-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_empty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_directory_empty-stderr.txt b/Tests/RunCMake/cmake_language/defer_directory_empty-stderr.txt new file mode 100644 index 000000000..587dfa97e --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_empty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_directory_empty.cmake:1 \(cmake_language\): + cmake_language DEFER DIRECTORY may not be empty +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_directory_empty.cmake b/Tests/RunCMake/cmake_language/defer_directory_empty.cmake new file mode 100644 index 000000000..f4e45536a --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_empty.cmake @@ -0,0 +1 @@ +cmake_language(DEFER DIRECTORY "") diff --git a/Tests/RunCMake/cmake_language/defer_directory_missing-result.txt b/Tests/RunCMake/cmake_language/defer_directory_missing-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_missing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_directory_missing-stderr.txt b/Tests/RunCMake/cmake_language/defer_directory_missing-stderr.txt new file mode 100644 index 000000000..1db8e995b --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_missing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_directory_missing.cmake:1 \(cmake_language\): + cmake_language DEFER DIRECTORY missing value +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_directory_missing.cmake b/Tests/RunCMake/cmake_language/defer_directory_missing.cmake new file mode 100644 index 000000000..fbdb17792 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_missing.cmake @@ -0,0 +1 @@ +cmake_language(DEFER DIRECTORY) diff --git a/Tests/RunCMake/cmake_language/defer_directory_multiple-result.txt b/Tests/RunCMake/cmake_language/defer_directory_multiple-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_multiple-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_directory_multiple-stderr.txt b/Tests/RunCMake/cmake_language/defer_directory_multiple-stderr.txt new file mode 100644 index 000000000..f4d09b922 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_multiple-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_directory_multiple.cmake:1 \(cmake_language\): + cmake_language DEFER given multiple DIRECTORY arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_directory_multiple.cmake b/Tests/RunCMake/cmake_language/defer_directory_multiple.cmake new file mode 100644 index 000000000..baf037bf5 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_directory_multiple.cmake @@ -0,0 +1 @@ +cmake_language(DEFER DIRECTORY . DIRECTORY x CALL message "Should not be allowed.") diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_id-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_id-stderr.txt new file mode 100644 index 000000000..e161a5fac --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_id.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL does not accept ID or ID_VAR. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id.cmake b/Tests/RunCMake/cmake_language/defer_get_call_id.cmake new file mode 100644 index 000000000..7a395ea63 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID id GET_CALL) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id_empty-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_id_empty-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id_empty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id_empty-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_id_empty-stderr.txt new file mode 100644 index 000000000..c7c534ba0 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id_empty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_id_empty.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL id may not be empty +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id_empty.cmake b/Tests/RunCMake/cmake_language/defer_get_call_id_empty.cmake new file mode 100644 index 000000000..4f39f2d0e --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id_empty.cmake @@ -0,0 +1 @@ +cmake_language(DEFER GET_CALL "" var) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id_var-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_id_var-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id_var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id_var-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_id_var-stderr.txt new file mode 100644 index 000000000..2cfd94274 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id_var-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_id_var.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL does not accept ID or ID_VAR. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_id_var.cmake b/Tests/RunCMake/cmake_language/defer_get_call_id_var.cmake new file mode 100644 index 000000000..ade0815a3 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_id_var.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID_VAR id_var GET_CALL) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_id-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_id-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_id-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_id-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_id-stderr.txt new file mode 100644 index 000000000..072ee45eb --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_id-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_ids_id.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL_IDS does not accept ID or ID_VAR. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_id.cmake b/Tests/RunCMake/cmake_language/defer_get_call_ids_id.cmake new file mode 100644 index 000000000..4eb2555a3 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_id.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID id GET_CALL_IDS) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var-stderr.txt new file mode 100644 index 000000000..e4a288c77 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_ids_id_var.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL_IDS does not accept ID or ID_VAR. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var.cmake b/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var.cmake new file mode 100644 index 000000000..c27de79af --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_id_var.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID_VAR id_var GET_CALL_IDS) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory-stderr.txt new file mode 100644 index 000000000..edebe32f7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at defer_get_call_ids_invalid_directory.cmake:2 \(cmake_language\): + cmake_language DEFER GET_CALL_IDS may not access directory: + + [^ +]*/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory-build/defer_get_call_ids_invalid_directory + + at this time. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory.cmake b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory.cmake new file mode 100644 index 000000000..81f098ea5 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory.cmake @@ -0,0 +1,2 @@ +add_subdirectory(defer_get_call_ids_invalid_directory) +cmake_language(DEFER DIRECTORY defer_get_call_ids_invalid_directory GET_CALL_IDS var) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory/CMakeLists.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_invalid_directory/CMakeLists.txt diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var-stderr.txt new file mode 100644 index 000000000..a2951cf2f --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_ids_missing_var.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL_IDS missing output variable +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var.cmake b/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var.cmake new file mode 100644 index 000000000..b171f04d0 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_missing_var.cmake @@ -0,0 +1 @@ +cmake_language(DEFER GET_CALL_IDS) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args-stderr.txt new file mode 100644 index 000000000..56915199f --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_ids_too_many_args.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL_IDS given too many arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args.cmake b/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args.cmake new file mode 100644 index 000000000..0158684f3 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_ids_too_many_args.cmake @@ -0,0 +1 @@ +cmake_language(DEFER GET_CALL_IDS var extra) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_missing_id-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_missing_id-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_missing_id-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_missing_id-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_missing_id-stderr.txt new file mode 100644 index 000000000..081aa95f7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_missing_id-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_missing_id.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL missing id +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_missing_id.cmake b/Tests/RunCMake/cmake_language/defer_get_call_missing_id.cmake new file mode 100644 index 000000000..0542abca2 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_missing_id.cmake @@ -0,0 +1 @@ +cmake_language(DEFER GET_CALL) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_missing_var-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_missing_var-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_missing_var-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_missing_var-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_missing_var-stderr.txt new file mode 100644 index 000000000..1b2641f20 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_missing_var-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_missing_var.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL missing output variable +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_missing_var.cmake b/Tests/RunCMake/cmake_language/defer_get_call_missing_var.cmake new file mode 100644 index 000000000..7916d290d --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_missing_var.cmake @@ -0,0 +1 @@ +cmake_language(DEFER GET_CALL id) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_too_many_args-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_too_many_args-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_too_many_args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_too_many_args-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_too_many_args-stderr.txt new file mode 100644 index 000000000..b6ee2d64b --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_too_many_args-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_get_call_too_many_args.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL given too many arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_too_many_args.cmake b/Tests/RunCMake/cmake_language/defer_get_call_too_many_args.cmake new file mode 100644 index 000000000..ed6577907 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_too_many_args.cmake @@ -0,0 +1 @@ +cmake_language(DEFER GET_CALL id var extra) diff --git a/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument-result.txt b/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument-stderr.txt b/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument-stderr.txt new file mode 100644 index 000000000..ac165965b --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at defer_get_call_unknown_argument.cmake:1 \(cmake_language\): + cmake_language DEFER GET_CALL unknown argument: + + UNKNOWN +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument.cmake b/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument.cmake new file mode 100644 index 000000000..d0caa39d6 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_get_call_unknown_argument.cmake @@ -0,0 +1 @@ +cmake_language(DEFER GET_CALL UNKNOWN var) diff --git a/Tests/RunCMake/cmake_language/defer_id_empty-result.txt b/Tests/RunCMake/cmake_language/defer_id_empty-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_empty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_id_empty-stderr.txt b/Tests/RunCMake/cmake_language/defer_id_empty-stderr.txt new file mode 100644 index 000000000..1e7f7725e --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_empty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_id_empty.cmake:1 \(cmake_language\): + cmake_language DEFER ID may not be empty +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_id_empty.cmake b/Tests/RunCMake/cmake_language/defer_id_empty.cmake new file mode 100644 index 000000000..326762c1a --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_empty.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID "") diff --git a/Tests/RunCMake/cmake_language/defer_id_missing-result.txt b/Tests/RunCMake/cmake_language/defer_id_missing-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_missing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_id_missing-stderr.txt b/Tests/RunCMake/cmake_language/defer_id_missing-stderr.txt new file mode 100644 index 000000000..cef5f0e2c --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_missing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_id_missing.cmake:1 \(cmake_language\): + cmake_language DEFER ID missing value +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_id_missing.cmake b/Tests/RunCMake/cmake_language/defer_id_missing.cmake new file mode 100644 index 000000000..4de687d51 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_missing.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID) diff --git a/Tests/RunCMake/cmake_language/defer_id_multiple-result.txt b/Tests/RunCMake/cmake_language/defer_id_multiple-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_multiple-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_id_multiple-stderr.txt b/Tests/RunCMake/cmake_language/defer_id_multiple-stderr.txt new file mode 100644 index 000000000..172552116 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_multiple-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_id_multiple.cmake:1 \(cmake_language\): + cmake_language DEFER given multiple ID arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_id_multiple.cmake b/Tests/RunCMake/cmake_language/defer_id_multiple.cmake new file mode 100644 index 000000000..69187af41 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_multiple.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID a ID b CALL message "Should not be allowed.") diff --git a/Tests/RunCMake/cmake_language/defer_id_var_empty-result.txt b/Tests/RunCMake/cmake_language/defer_id_var_empty-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_empty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_id_var_empty-stderr.txt b/Tests/RunCMake/cmake_language/defer_id_var_empty-stderr.txt new file mode 100644 index 000000000..bb5cd4386 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_empty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_id_var_empty.cmake:1 \(cmake_language\): + cmake_language DEFER ID_VAR may not be empty +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_id_var_empty.cmake b/Tests/RunCMake/cmake_language/defer_id_var_empty.cmake new file mode 100644 index 000000000..c7198f54b --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_empty.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID_VAR "") diff --git a/Tests/RunCMake/cmake_language/defer_id_var_missing-result.txt b/Tests/RunCMake/cmake_language/defer_id_var_missing-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_missing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_id_var_missing-stderr.txt b/Tests/RunCMake/cmake_language/defer_id_var_missing-stderr.txt new file mode 100644 index 000000000..f4e0d6e05 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_missing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_id_var_missing.cmake:1 \(cmake_language\): + cmake_language DEFER ID_VAR missing variable name +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_id_var_missing.cmake b/Tests/RunCMake/cmake_language/defer_id_var_missing.cmake new file mode 100644 index 000000000..359d14936 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_missing.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID_VAR) diff --git a/Tests/RunCMake/cmake_language/defer_id_var_multiple-result.txt b/Tests/RunCMake/cmake_language/defer_id_var_multiple-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_multiple-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_id_var_multiple-stderr.txt b/Tests/RunCMake/cmake_language/defer_id_var_multiple-stderr.txt new file mode 100644 index 000000000..4368b06ea --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_multiple-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_id_var_multiple.cmake:1 \(cmake_language\): + cmake_language DEFER given multiple ID_VAR arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_id_var_multiple.cmake b/Tests/RunCMake/cmake_language/defer_id_var_multiple.cmake new file mode 100644 index 000000000..665ea9481 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_id_var_multiple.cmake @@ -0,0 +1 @@ +cmake_language(DEFER ID_VAR a ID_VAR b CALL message "Should not be allowed.") diff --git a/Tests/RunCMake/cmake_language/defer_missing_arg-result.txt b/Tests/RunCMake/cmake_language/defer_missing_arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_missing_arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_missing_arg-stderr.txt b/Tests/RunCMake/cmake_language/defer_missing_arg-stderr.txt new file mode 100644 index 000000000..3e656cd64 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_missing_arg-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_missing_arg.cmake:1 \(cmake_language\): + cmake_language DEFER requires at least one argument +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_missing_arg.cmake b/Tests/RunCMake/cmake_language/defer_missing_arg.cmake new file mode 100644 index 000000000..737a8c89d --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_missing_arg.cmake @@ -0,0 +1 @@ +cmake_language(DEFER) diff --git a/Tests/RunCMake/cmake_language/defer_missing_call-result.txt b/Tests/RunCMake/cmake_language/defer_missing_call-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_missing_call-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_missing_call-stderr.txt b/Tests/RunCMake/cmake_language/defer_missing_call-stderr.txt new file mode 100644 index 000000000..7eeef7677 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_missing_call-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at defer_missing_call.cmake:1 \(cmake_language\): + cmake_language DEFER must be followed by a CALL argument +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_missing_call.cmake b/Tests/RunCMake/cmake_language/defer_missing_call.cmake new file mode 100644 index 000000000..0b330efb6 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_missing_call.cmake @@ -0,0 +1 @@ +cmake_language(DEFER DIRECTORY .) diff --git a/Tests/RunCMake/cmake_language/defer_unknown_option-result.txt b/Tests/RunCMake/cmake_language/defer_unknown_option-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_unknown_option-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_language/defer_unknown_option-stderr.txt b/Tests/RunCMake/cmake_language/defer_unknown_option-stderr.txt new file mode 100644 index 000000000..95d87c6dc --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_unknown_option-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at defer_unknown_option.cmake:1 \(cmake_language\): + cmake_language DEFER unknown option: + + UNKNOWN +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_language/defer_unknown_option.cmake b/Tests/RunCMake/cmake_language/defer_unknown_option.cmake new file mode 100644 index 000000000..876b3f14e --- /dev/null +++ b/Tests/RunCMake/cmake_language/defer_unknown_option.cmake @@ -0,0 +1 @@ +cmake_language(DEFER UNKNOWN) diff --git a/Tests/RunCMake/cmake_language/no_parameters-stderr.txt b/Tests/RunCMake/cmake_language/no_parameters-stderr.txt index 194bbe355..1862c7717 100644 --- a/Tests/RunCMake/cmake_language/no_parameters-stderr.txt +++ b/Tests/RunCMake/cmake_language/no_parameters-stderr.txt @@ -1,2 +1,2 @@ CMake Error at no_parameters.cmake:1 \(cmake_language\): - cmake_language called with incorrect number of arguments + cmake_language CALL missing command name diff --git a/Tests/RunCMake/cmake_minimum_required/Before2812-stderr.txt b/Tests/RunCMake/cmake_minimum_required/Before2812-stderr.txt new file mode 100644 index 000000000..7d40dcb04 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Before2812-stderr.txt @@ -0,0 +1,26 @@ +^CMake Deprecation Warning at Before2812.cmake:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at Before2812.cmake:2 \(cmake_policy\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at Before2812.cmake:6 \(cmake_policy\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_minimum_required/Before2812.cmake b/Tests/RunCMake/cmake_minimum_required/Before2812.cmake new file mode 100644 index 000000000..220e359d4 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Before2812.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 2.8.11) +cmake_policy(VERSION 2.6) +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) # simulate pre-3.18 install(EXPORT)-generated call +cmake_policy(POP) +cmake_policy(VERSION 2.8.11) diff --git a/Tests/RunCMake/cmake_minimum_required/CMakeLists.txt b/Tests/RunCMake/cmake_minimum_required/CMakeLists.txt index e8db6b05b..667561ea7 100644 --- a/Tests/RunCMake/cmake_minimum_required/CMakeLists.txt +++ b/Tests/RunCMake/cmake_minimum_required/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) -include(${RunCMake_TEST}.cmake) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt index a874466d3..81d26d260 100644 --- a/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt +++ b/Tests/RunCMake/cmake_minimum_required/CompatBefore24-stderr.txt @@ -1,3 +1,12 @@ +^CMake Deprecation Warning at CompatBefore24.cmake:1 \(cmake_minimum_required\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ CMake Error in CMakeLists.txt: You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less than 2.4. This version of CMake only supports backwards compatibility with diff --git a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake index 1030211e7..3a959bb2f 100644 --- a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake @@ -4,6 +4,7 @@ run_cmake(Before24) run_cmake(CompatBefore24) run_cmake(Future) run_cmake(PolicyBefore24) +run_cmake(Before2812) run_cmake(Range) run_cmake(RangeBad) run_cmake(Unknown) diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/ABSOLUTE_PATH.cmake b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH.cmake new file mode 100644 index 000000000..4fd3c7df8 --- /dev/null +++ b/Tests/RunCMake/cmake_path/ABSOLUTE_PATH.cmake @@ -0,0 +1,39 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "../../a/d") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f") +if (NOT path STREQUAL "/x/y/a/f/../../a/d") + list (APPEND errors "'${path}' instead of '/x/y/a/f/../../a/d'") +endif() + +set (path "../../a/d") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f" NORMALIZE) +if (NOT path STREQUAL "/x/y/a/d") + list (APPEND errors "'${path}' instead of '/x/y/a/d'") +endif() + +set (path "../../a/d") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f" NORMALIZE OUTPUT_VARIABLE output) +if (NOT path STREQUAL "../../a/d") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/x/y/a/d") + list (APPEND errors "'${output}' instead of '/x/y/a/d'") +endif() + +set (path "/a/d/../e") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f") +if (NOT path STREQUAL "/a/d/../e") + list (APPEND errors "'${path}' instead of '/a/d/../e'") +endif() + +set (path "/a/d/../e") +cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/x/y/a/f" NORMALIZE) +if (NOT path STREQUAL "/a/e") + list (APPEND errors "'${path}' instead of '/a/e'") +endif() + + +check_errors (ABSOLUTE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/APPEND-wrong-path-result.txt b/Tests/RunCMake/cmake_path/APPEND-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/APPEND.cmake b/Tests/RunCMake/cmake_path/APPEND.cmake new file mode 100644 index 000000000..565b26dde --- /dev/null +++ b/Tests/RunCMake/cmake_path/APPEND.cmake @@ -0,0 +1,77 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +cmake_path (APPEND path "/a/b" "c") +if (NOT path STREQUAL "/a/b/c") + list (APPEND errors "'${path}' instead of '/a/b/c'") +endif() + +set (path "/a/b") +cmake_path (APPEND path "c") +if (NOT path STREQUAL "/a/b/c") + list (APPEND errors "'${path}' instead of '/a/b/c'") +endif() + +cmake_path (APPEND path "x/y" "z" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/b/c") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/a/b/c/x/y/z") + list (APPEND errors "'${output}' instead of '/a/b/c/x/y/z'") +endif() + +set (path "a") +cmake_path (APPEND path "") +if (NOT path STREQUAL "a/") + list (APPEND errors "'${path}' instead of 'a/'") +endif() + +cmake_path (APPEND path "/b") +if (NOT path STREQUAL "/b") + list (APPEND errors "'${path}' instead of '/b'") +endif() + +if (WIN32) + set (path "a") + cmake_path (APPEND path "c:/b") + if (NOT path STREQUAL "c:/b") + list (APPEND errors "'${path}' instead of 'c:/b'") + endif() + + set (path "a") + cmake_path (APPEND path "c:") + if (NOT path STREQUAL "c:") + list (APPEND errors "'${path}' instead of 'c:'") + endif() + cmake_path (APPEND path "") + if (NOT path STREQUAL "c:") + list (APPEND errors "'${path}' instead of 'c:'") + endif() + + set (path "c:a") + cmake_path (APPEND path "/b") + if (NOT path STREQUAL "c:/b") + list (APPEND errors "'${path}' instead of 'c:/b'") + endif() + + set (path "c:a") + cmake_path (APPEND path "c:b") + if (NOT path STREQUAL "c:a/b") + list (APPEND errors "'${path}' instead of 'c:a/b'") + endif() + + set (path "//host") + cmake_path (APPEND path "b") + if (NOT path STREQUAL "//host/b") + list (APPEND errors "'${path}' instead of '//host/b'") + endif() + + set (path "//host/") + cmake_path (APPEND path "b") + if (NOT path STREQUAL "//host/b") + list (APPEND errors "'${path}' instead of '//host/b'") + endif() +endif() + +check_errors (APPEND ${errors}) diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake b/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake new file mode 100644 index 000000000..b9320f365 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake @@ -0,0 +1,43 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +cmake_path(CMAKE_PATH path "/x/y/z/../../a/d") +if (NOT path STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of '/x/y/z/../../a/d'") +endif() +cmake_path(CMAKE_PATH path NORMALIZE "/x/y/z/../../a/d") +if (NOT path STREQUAL "/x/a/d") + list (APPEND errors "'${path}' instead of '/x/a/d'") +endif() + +if (WIN32) + cmake_path(CMAKE_PATH path "/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of '/x/y/z/../../a/d'") + endif() + cmake_path(CMAKE_PATH path NORMALIZE "/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "/x/a/d") + list (APPEND errors "'${path}' instead of '/x/a/d'") + endif() + + cmake_path(CMAKE_PATH path "//?/c:/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "c:/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of 'c:/x/y/z/../../a/d'") + endif() + cmake_path(CMAKE_PATH path NORMALIZE "//?/c:/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "c:/x/a/d") + list (APPEND errors "'${path}' instead of 'c:/x/a/d'") + endif() + + cmake_path(CMAKE_PATH path "\\\\?\\UNC/host/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "//host/x/y/z/../../a/d") + list (APPEND errors "'${path}' instead of '//host/x/y/z/../../a/d'") + endif() + cmake_path(CMAKE_PATH path NORMALIZE "\\\\?\\UNC\\host/x\\y/z\\..\\../a/d") + if (NOT path STREQUAL "//host/x/a/d") + list (APPEND errors "'${path}' instead of '//host/x/a/d'") + endif() +endif() + +check_errors (CMAKE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/CMakeLists.txt b/Tests/RunCMake/cmake_path/CMakeLists.txt new file mode 100644 index 000000000..1f195c69e --- /dev/null +++ b/Tests/RunCMake/cmake_path/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18...3.19) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-invalid-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-missing-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-invalid-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-missing-output-result.txt b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-result.txt b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-stderr.txt b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-stderr.txt new file mode 100644 index 000000000..674d94264 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at COMPARE-wrong-operator.cmake:[0-9]+ \(cmake_path\): + cmake_path COMPARE called with an unknown comparison operator: FOO. diff --git a/Tests/RunCMake/cmake_path/COMPARE-wrong-operator.cmake b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator.cmake new file mode 100644 index 000000000..7da5d29c8 --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE-wrong-operator.cmake @@ -0,0 +1,3 @@ + +set (path "/a/b") +cmake_path(COMPARE path FOO "/other" output) diff --git a/Tests/RunCMake/cmake_path/COMPARE.cmake b/Tests/RunCMake/cmake_path/COMPARE.cmake new file mode 100644 index 000000000..bc6b9b46c --- /dev/null +++ b/Tests/RunCMake/cmake_path/COMPARE.cmake @@ -0,0 +1,22 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a///b/c") +cmake_path(COMPARE path EQUAL "a/b/c" output) +if (NOT output) + list (APPEND errors "'${path}' not equal to 'a/b/c'") +endif() + +set (path "a/b/d/../c") +cmake_path(COMPARE path NOT_EQUAL "a/b/c" output) +if (NOT output) + list (APPEND errors "'${path}' equal to 'a/b/c'") +endif() +cmake_path(NORMAL_PATH path) +cmake_path(COMPARE path EQUAL "a/b/c" output) +if (NOT output) + list (APPEND errors "'${path}' not equal to 'a/b/c'") +endif() + +check_errors (COMPARE ${errors}) diff --git a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt b/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONCAT.cmake b/Tests/RunCMake/cmake_path/CONCAT.cmake new file mode 100644 index 000000000..62b5eb001 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONCAT.cmake @@ -0,0 +1,20 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "/a/b") +cmake_path (CONCAT path "cd") +if (NOT path STREQUAL "/a/bcd") + list (APPEND errors "'${path}' instead of 'a/bcd'") +endif() + +set (path "/a/b") +cmake_path (CONCAT path "cd" "ef" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/b") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/a/bcdef") + list (APPEND errors "'${output}' instead of 'a/bcdef'") +endif() + +check_errors (CONCAT ${errors}) diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-invalid-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-missing-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_CMAKE_PATH_LIST-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-invalid-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-missing-output-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-TO_NATIVE_PATH_LIST-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-result.txt b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-stderr.txt b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-stderr.txt new file mode 100644 index 000000000..9aa75ec69 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at CONVERT-wrong-operator.cmake:[0-9]+ \(cmake_path\): + cmake_path CONVERT called with an unknown action: FOO. diff --git a/Tests/RunCMake/cmake_path/CONVERT-wrong-operator.cmake b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator.cmake new file mode 100644 index 000000000..12ffccc32 --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT-wrong-operator.cmake @@ -0,0 +1,2 @@ + +cmake_path(CONVERT "/a/b" FOO output) diff --git a/Tests/RunCMake/cmake_path/CONVERT.cmake b/Tests/RunCMake/cmake_path/CONVERT.cmake new file mode 100644 index 000000000..b08bc26cf --- /dev/null +++ b/Tests/RunCMake/cmake_path/CONVERT.cmake @@ -0,0 +1,110 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +cmake_path(CONVERT "/x/y/z/../../a/d" TO_CMAKE_PATH_LIST output) +if (NOT output STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d'") +endif() +cmake_path(CONVERT "/x/y/z/../../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) +if (NOT output STREQUAL "/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d'") +endif() + +if (WIN32) + cmake_path(CONVERT "/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d'") + endif() + cmake_path(CONVERT "/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d'") + endif() + + cmake_path(CONVERT "//?/c:/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "c:/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of 'c:/x/y/z/../../a/d'") + endif() + cmake_path(CONVERT "//?/c:/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "c:/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of 'c:/x/a/d'") + endif() + + cmake_path(CONVERT "//?/UNC/host/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "//host/x/y/z/../../a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '//host/x/y/z/../../a/d'") + endif() + cmake_path(CONVERT "//?/UNC/host/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "//host/x/a/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '//host/x/a/d'") + endif() +endif() + +if (WIN32) + cmake_path(CONVERT "/x\\y/z/..\\../a\\d;c:\\a/b\\c/..\\d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d;c:/a/b/c/../d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d;c:/a/b/c/../d'") + endif() + cmake_path(CONVERT "/x\\y/z/..\\../a\\d;c:\\a/b\\c/..\\d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d;c:/a/b/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d;c:/a/b/d'") + endif() +else() + cmake_path(CONVERT "/x/y/z/../../a/d:/a/b/c/../d" TO_CMAKE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d;/a/b/c/../d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${outputh}' instead of '/x/y/z/../../a/d;/a/b/c/../d'") + endif() + cmake_path(CONVERT "/x/y/z/../../a/d:/a/b/c/../d" TO_CMAKE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d;/a/b/d") + list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d;/a/b/d'") + endif() +endif() + + +if (WIN32) + cmake_path(CONVERT "c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "c:\\a\\\\b\\c\\..\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of 'c:\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(CONVERT "c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "c:\\a\\b\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of 'c:\\a\\b\\d'") + endif() + + cmake_path(CONVERT "//host/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(CONVERT "//host/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "\\\\host\\a\\b\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\b\\d'") + endif() + cmake_path(CONVERT "//host/a//b\\c/..\\d;c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d;c:\\a\\\\b\\c\\..\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d;c:\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(CONVERT "//host/a//b\\c/..\\d;c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "\\\\host\\a\\b\\d;c:\\a\\b\\d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\b\\d;c:\\a\\b\\d'") + endif() +else() + cmake_path(CONVERT "/a//b/c/../d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "/a//b/c/../d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/a//b/c/../d'") + endif() + cmake_path(CONVERT "/a//b/c/../d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/a/b/d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/a/b/d'") + endif() + cmake_path(CONVERT "/x/y/z/../../a/d;/a/b/c/../d" TO_NATIVE_PATH_LIST output) + if (NOT output STREQUAL "/x/y/z/../../a/d:/a/b/c/../d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d:/a/b/c/../d'") + endif() + cmake_path(CONVERT "/x/y/z/../../a/d;/a/b/c/../d" TO_NATIVE_PATH_LIST output NORMALIZE) + if (NOT output STREQUAL "/x/a/d:/a/b/d") + list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/x/a/d:/a/b/d'") + endif() +endif() + + +check_errors (CONVERT ${errors}) diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-EXTENSION-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-FILENAME-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-PARENT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-PARENT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-RELATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_DIRECTORY-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_NAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_NAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-ROOT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-ROOT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-invalid-output-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-missing-output-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-STEM-wrong-path-result.txt b/Tests/RunCMake/cmake_path/GET-STEM-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-STEM-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-wrong-operator-result.txt b/Tests/RunCMake/cmake_path/GET-wrong-operator-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-wrong-operator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/GET-wrong-operator-stderr.txt b/Tests/RunCMake/cmake_path/GET-wrong-operator-stderr.txt new file mode 100644 index 000000000..71afc9262 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-wrong-operator-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at GET-wrong-operator.cmake:[0-9]+ \(cmake_path\): + cmake_path GET called with an unknown action: FOO. diff --git a/Tests/RunCMake/cmake_path/GET-wrong-operator.cmake b/Tests/RunCMake/cmake_path/GET-wrong-operator.cmake new file mode 100644 index 000000000..e09d6d7d8 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET-wrong-operator.cmake @@ -0,0 +1,3 @@ + +set (path "/a/b") +cmake_path(GET path FOO output) diff --git a/Tests/RunCMake/cmake_path/GET.cmake b/Tests/RunCMake/cmake_path/GET.cmake new file mode 100644 index 000000000..e68e65403 --- /dev/null +++ b/Tests/RunCMake/cmake_path/GET.cmake @@ -0,0 +1,248 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +############################################### +## First test with a path defining all elements +############################################### +if (WIN32) + set (path "C:/aa/bb/cc.ext1.ext2") +else() + set (path "/aa/bb/cc.ext1.ext2") +endif() + +cmake_path(GET path ROOT_NAME output) +if (WIN32) + if (NOT output STREQUAL "C:") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") + endif() +else() + if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") + endif() +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (WIN32) + if (NOT output STREQUAL "C:/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") + endif() +else() + if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") + endif() +endif() + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL "cc.ext1.ext2") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL ".ext1.ext2") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() +cmake_path(GET path EXTENSION LAST_ONLY output) +if (NOT output STREQUAL ".ext2") + list (APPEND errors "EXTENSION LAST_ONLY returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL "cc") + list (APPEND errors "STEM returns bad data: ${output}") +endif() +cmake_path(GET path STEM LAST_ONLY output) +if (NOT output STREQUAL "cc.ext1") + list (APPEND errors "STEM LAST_ONLY returns bad data: ${output}") +endif() + +cmake_path(GET path RELATIVE_PATH output) +if (NOT output STREQUAL "aa/bb/cc.ext1.ext2") + list (APPEND errors "RELATIVE_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path PARENT_PATH output) +if (WIN32) + if (NOT output STREQUAL "C:/aa/bb") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") + endif() +else() + if (NOT output STREQUAL "/aa/bb") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") + endif() +endif() + +###################################### +## second, tests with missing elements +###################################### +set (path "aa/bb/") + +cmake_path(GET path ROOT_NAME output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL "") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL "") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL "") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +cmake_path(GET path RELATIVE_PATH output) +if (NOT output STREQUAL path) + list (APPEND errors "RELATIVE_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path PARENT_PATH output) +if (NOT output STREQUAL "aa/bb") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") +endif() + +################################## +set (path "/aa/bb/") + +cmake_path(GET path ROOT_NAME output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") +endif() + +################################### +set (path "/") + +cmake_path(GET path ROOT_NAME output) +if (NOT output STREQUAL "") + list (APPEND errors "ROOT_NAME returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_DIRECTORY output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}") +endif() + +cmake_path(GET path ROOT_PATH output) +if (NOT output STREQUAL "/") + list (APPEND errors "ROOT_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL "") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL "") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL "") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +cmake_path(GET path RELATIVE_PATH output) +if (NOT output STREQUAL "") + list (APPEND errors "RELATIVE_PATH returns bad data: ${output}") +endif() + +cmake_path(GET path PARENT_PATH output) +if (NOT output STREQUAL "/") + list (APPEND errors "PARENT_PATH returns bad data: ${output}") +endif() + +################################### +set (path ".file") + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL ".file") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL "") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL ".file") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +################################### +set (path ".file.ext") + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL ".file.ext") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL ".ext") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() +cmake_path(GET path EXTENSION LAST_ONLY output) +if (NOT output STREQUAL ".ext") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL ".file") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +################################### +set (path ".file.ext1.ext2") + +cmake_path(GET path FILENAME output) +if (NOT output STREQUAL ".file.ext1.ext2") + list (APPEND errors "FILENAME returns bad data: ${output}") +endif() + +cmake_path(GET path EXTENSION output) +if (NOT output STREQUAL ".ext1.ext2") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() +cmake_path(GET path EXTENSION LAST_ONLY output) +if (NOT output STREQUAL ".ext2") + list (APPEND errors "EXTENSION returns bad data: ${output}") +endif() + +cmake_path(GET path STEM output) +if (NOT output STREQUAL ".file") + list (APPEND errors "STEM returns bad data: ${output}") +endif() + +check_errors (GET ${errors}) diff --git a/Tests/RunCMake/cmake_path/HASH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HASH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HASH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HASH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HASH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HASH.cmake b/Tests/RunCMake/cmake_path/HASH.cmake new file mode 100644 index 000000000..dfcf2b2a1 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HASH.cmake @@ -0,0 +1,27 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path1 "a///b/c") +cmake_path(HASH path1 hash1) +set (path2 "a/b////c") +cmake_path(HASH path2 hash2) +if (NOT hash1 STREQUAL hash2) + list (APPEND errors "'hash values not equal for '${path1}' and '${path2}'") +endif() + +set (path1 "a///b/c/../d") +cmake_path(HASH path1 hash1) +set (path2 "a/b////d") +cmake_path(HASH path2 hash2) +if (hash1 STREQUAL hash2) + list (APPEND errors "'hash values equal for '${path1}' and '${path2}'") +endif() +cmake_path(HASH path1 hash1 NORMALIZE) +cmake_path(HASH path2 NORMALIZE hash2) +if (NOT hash1 STREQUAL hash2) + list (APPEND errors "'hash values not equal for '${path1}' and '${path2}'") +endif() + + +check_errors (HASH ${errors}) diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_EXTENSION-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_FILENAME-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ITEM.cmake b/Tests/RunCMake/cmake_path/HAS_ITEM.cmake new file mode 100644 index 000000000..eb73bd5df --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ITEM.cmake @@ -0,0 +1,232 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "/a/b") +cmake_path(HAS_ROOT_NAME path output) +if (output) + list (APPEND errors "ROOT_NAME: ${path} has root name") +endif() +cmake_path(HAS_ROOT_DIRECTORY path output) +if (NOT output) + list (APPEND errors "ROOT_DIRECTORY: ${path} does not have root directory") +endif() +cmake_path(HAS_ROOT_PATH path output) +if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") +endif() + +set (path "a/b") +cmake_path(HAS_ROOT_PATH path output) +if (output) + list (APPEND errors "ROOT_PATH: ${path} has root path") +endif() + +set (path "/a/b") +cmake_path(HAS_FILENAME path output) +if (NOT output) + list (APPEND errors "FILENAME: ${path} does not have filename") +endif() +set (path "a.b") +cmake_path(HAS_FILENAME path output) +if (NOT output) + list (APPEND errors "FILENAME: ${path} does not have filename") +endif() +set (path "/a/b/") +cmake_path(HAS_FILENAME path output) +if (output) + list (APPEND errors "FILENAME: ${path} has filename") +endif() +set (path "/") +cmake_path(HAS_FILENAME path output) +if (output) + list (APPEND errors "FILENAME: ${path} has filename") +endif() + +set (path "/a/b") +cmake_path(HAS_STEM path output) +if (NOT output) + list (APPEND errors "STEM: ${path} does not have stem") +endif() +set (path "a.b") +cmake_path(HAS_STEM path output) +if (NOT output) + list (APPEND errors "STEM: ${path} does not have stem") +endif() +set (path ".a") +cmake_path(HAS_STEM path output) +if (NOT output) + list (APPEND errors "STEM: ${path} does not have stem") +endif() +set (path "/a/") +cmake_path(HAS_STEM path output) +if (output) + list (APPEND errors "STEM: ${path} has stem") +endif() +set (path "/") +cmake_path(HAS_STEM path output) +if (output) + list (APPEND errors "STEM: ${path} has stem") +endif() + +set (path "/a/b.c") +cmake_path(HAS_EXTENSION path output) +if (NOT output) + list (APPEND errors "EXTENSION: ${path} does not have extension") +endif() +set (path "b.c") +cmake_path(HAS_EXTENSION path output) +if (NOT output) + list (APPEND errors "EXTENSION: ${path} does not have extension") +endif() +set (path "/.a") +cmake_path(HAS_EXTENSION path output) +if (output) + list (APPEND errors "EXTENSION: ${path} has extension") +endif() +set (path "/a/") +cmake_path(HAS_EXTENSION path output) +if (output) + list (APPEND errors "EXTENSION: ${path} has extension") +endif() +set (path "/") +cmake_path(HAS_EXTENSION path output) +if (output) + list (APPEND errors "EXTENSION: ${path} has extension") +endif() + +set (path "/a/b") +cmake_path(HAS_RELATIVE_PATH path output) +if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") +endif() +set (path "/") +cmake_path(HAS_RELATIVE_PATH path output) +if (output) + list (APPEND errors "RELATIVE_PATH: ${path} has relative path") +endif() + +set (path "/a/b") +cmake_path(HAS_PARENT_PATH path output) +if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") +endif() +set (path "/") +cmake_path(HAS_PARENT_PATH path output) +if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") +endif() +set (path "a") +cmake_path(HAS_PARENT_PATH path output) +if (output) + list (APPEND errors "PARENT_PATH: ${path} has parent path") +endif() + +if (WIN32) + set (path "c:/a/b") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (NOT output) + list (APPEND errors "ROOT_DIRECTORY: ${path} does not have root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "c:a/b") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (output) + list (APPEND errors "ROOT_DIRECTORY: ${path} has root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "//host/b") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (NOT output) + list (APPEND errors "ROOT_DIRECTORY: ${path} does not have root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "//host") + cmake_path(HAS_ROOT_NAME path output) + if (NOT output) + list (APPEND errors "ROOT_NAME: ${path} does not have root name") + endif() + cmake_path(HAS_ROOT_DIRECTORY path output) + if (output) + list (APPEND errors "ROOT_DIRECTORY: ${path} has root directory") + endif() + cmake_path(HAS_ROOT_PATH path output) + if (NOT output) + list (APPEND errors "ROOT_PATH: ${path} does not have root path") + endif() + + set (path "c:/a/b") + cmake_path(HAS_RELATIVE_PATH path output) + if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") + endif() + + set (path "c:a/b") + cmake_path(HAS_RELATIVE_PATH path output) + if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") + endif() + + set (path "//host/b") + cmake_path(HAS_RELATIVE_PATH path output) + if (NOT output) + list (APPEND errors "RELATIVE_PATH: ${path} does not have relative path") + endif() + + set (path "c:/a/b") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "c:/") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "c:") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "//host/") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() + + set (path "//host") + cmake_path(HAS_PARENT_PATH path output) + if (NOT output) + list (APPEND errors "PARENT_PATH: ${path} does not have parent path") + endif() +endif() + + +check_errors (HAS ${errors}) diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_PARENT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_RELATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_DIRECTORY-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_NAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_ROOT_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-invalid-output-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-missing-output-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/HAS_STEM-wrong-path-result.txt b/Tests/RunCMake/cmake_path/HAS_STEM-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/HAS_STEM-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-invalid-output-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-missing-output-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE-wrong-path-result.txt b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_ABSOLUTE.cmake b/Tests/RunCMake/cmake_path/IS_ABSOLUTE.cmake new file mode 100644 index 000000000..794e78637 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_ABSOLUTE.cmake @@ -0,0 +1,48 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a") +else() + set (path "/a") +endif() +cmake_path(IS_ABSOLUTE path output) +if (NOT output) + list (APPEND errors "'${path} is not absolute") +endif() + +set (path "a/b") +cmake_path(IS_ABSOLUTE path output) +if (output) + list (APPEND errors "'${path} is absolute") +endif() + +if (WIN32) + set (path "c:/a/b") + cmake_path(IS_ABSOLUTE path output) + if (NOT output) + list (APPEND errors "'${path} is not absolute") + endif() + + set (path "//host/b") + cmake_path(IS_ABSOLUTE path output) + if (NOT output) + list (APPEND errors "'${path} is not absolute") + endif() + + set (path "/a") + cmake_path(IS_ABSOLUTE path output) + if (output) + list (APPEND errors "'${path} is absolute") + endif() + + set (path "c:a") + cmake_path(IS_ABSOLUTE path output) + if (output) + list (APPEND errors "'${path} is absolute") + endif() +endif() + + +check_errors (IS_ABSOLUTE ${errors}) diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-invalid-output-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-missing-output-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX-wrong-path-result.txt b/Tests/RunCMake/cmake_path/IS_PREFIX-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_PREFIX.cmake b/Tests/RunCMake/cmake_path/IS_PREFIX.cmake new file mode 100644 index 000000000..53da93bc9 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_PREFIX.cmake @@ -0,0 +1,22 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a///b/c") +cmake_path(IS_PREFIX path "a/b/c/d" output) +if (NOT output) + list (APPEND errors "'${path} is not prefix of 'a/b/c/d'") +endif() + +set (path "a///b/c/../d") +cmake_path(IS_PREFIX path "a/b/d/e" output) +if (output) + list (APPEND errors "'${path} is prefix of 'a/b/d/e'") +endif() +cmake_path(IS_PREFIX path "a/b/d/e" NORMALIZE output) +if (NOT output) + list (APPEND errors "'${path} is not prefix of 'a/b/d/e'") +endif() + + +check_errors (IS_PREFIX ${errors}) diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-invalid-output-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-missing-output-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE-wrong-path-result.txt b/Tests/RunCMake/cmake_path/IS_RELATIVE-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/IS_RELATIVE.cmake b/Tests/RunCMake/cmake_path/IS_RELATIVE.cmake new file mode 100644 index 000000000..ad1225390 --- /dev/null +++ b/Tests/RunCMake/cmake_path/IS_RELATIVE.cmake @@ -0,0 +1,48 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a") +else() + set (path "/a") +endif() +cmake_path(IS_RELATIVE path output) +if (output) + list (APPEND errors "'${path} is relative") +endif() + +set (path "a/b") +cmake_path(IS_RELATIVE path output) +if (NOT output) + list (APPEND errors "'${path} is not relative") +endif() + +if (WIN32) + set (path "c:/a/b") + cmake_path(IS_RELATIVE path output) + if (output) + list (APPEND errors "'${path} is relative") + endif() + + set (path "//host/b") + cmake_path(IS_RELATIVE path output) + if (output) + list (APPEND errors "'${path} is relative") + endif() + + set (path "/a") + cmake_path(IS_RELATIVE path output) + if (NOT output) + list (APPEND errors "'${path} is not relative") + endif() + + set (path "c:a") + cmake_path(IS_RELATIVE path output) + if (NOT output) + list (APPEND errors "'${path} is not relative") + endif() +endif() + + +check_errors (IS_RELATIVE ${errors}) diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-invalid-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-invalid-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-missing-output-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-missing-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/NATIVE_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NATIVE_PATH.cmake b/Tests/RunCMake/cmake_path/NATIVE_PATH.cmake new file mode 100644 index 000000000..066c44dc5 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NATIVE_PATH.cmake @@ -0,0 +1,37 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a//b\\c/..\\d") + cmake_path(NATIVE_PATH path output) + if (NOT output STREQUAL "c:\\a\\\\b\\c\\..\\d") + list (APPEND errors "'${output}' instead of 'c:\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(NATIVE_PATH path output NORMALIZE) + if (NOT output STREQUAL "c:\\a\\b\\d") + list (APPEND errors "'${output}' instead of 'c:\\a\\b\\d'") + endif() + + set (path "//host/a//b\\c/..\\d") + cmake_path(NATIVE_PATH path output) + if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d") + list (APPEND errors "'${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d'") + endif() + cmake_path(NATIVE_PATH path output NORMALIZE) + if (NOT output STREQUAL "\\\\host\\a\\b\\d") + list (APPEND errors "'${output}' instead of '\\\\host\\a\\b\\d'") + endif() +else() + set (path "/a//b/c/../d") + cmake_path(NATIVE_PATH path output) + if (NOT output STREQUAL "/a//b/c/../d") + list (APPEND errors "'${output}' instead of '/a//b/c/../d'") + endif() + cmake_path(NATIVE_PATH path NORMALIZE output) + if (NOT output STREQUAL "/a/b/d") + list (APPEND errors "'${output}' instead of '/a/b/d'") + endif() +endif() + +check_errors (NATIVE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/NORMAL_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/NORMAL_PATH.cmake b/Tests/RunCMake/cmake_path/NORMAL_PATH.cmake new file mode 100644 index 000000000..88db76ae7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/NORMAL_PATH.cmake @@ -0,0 +1,46 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/./b/..") +cmake_path(NORMAL_PATH path) +if (NOT path STREQUAL "a/") + list (APPEND errors "'${path}' instead of 'a/'") +endif() + +set (path "a/.///b/../") +cmake_path(NORMAL_PATH path) +if (NOT path STREQUAL "a/") + list (APPEND errors "'${path}' instead of 'a/'") +endif() + +set (path "a/.///b/../") +cmake_path(NORMAL_PATH path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/.///b/../") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/") + list (APPEND errors "'${output}' instead of 'a/'") +endif() + +if (WIN32) + set (path "//host/./b/..") + cmake_path(NORMAL_PATH path) + if (NOT path STREQUAL "//host/") + list (APPEND errors "'${path}' instead of '//host/'") + endif() + + set (path "//host/./b/../") + cmake_path(NORMAL_PATH path) + if (NOT path STREQUAL "//host/") + list (APPEND errors "'${path}' instead of '//host/'") + endif() + + set (path "c://a/.///b/../") + cmake_path(NORMAL_PATH path) + if (NOT path STREQUAL "c:/a/") + list (APPEND errors "'${path}' instead of 'c:/a/'") + endif() +endif() + +check_errors (NORMAL_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/OUTPUT_VARIABLE-no-arg-stderr.txt b/Tests/RunCMake/cmake_path/OUTPUT_VARIABLE-no-arg-stderr.txt new file mode 100644 index 000000000..e1d6592cf --- /dev/null +++ b/Tests/RunCMake/cmake_path/OUTPUT_VARIABLE-no-arg-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path OUTPUT_VARIABLE requires an argument. diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake b/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake new file mode 100644 index 000000000..ad2337764 --- /dev/null +++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake @@ -0,0 +1,41 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +if (WIN32) + set (path "c:/a/d") + cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "c:/a/d") + list (APPEND errors "'${path}' instead of 'c:/a/d'") + endif() +else() + set (path "/a/d") + cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "/a/d") + list (APPEND errors "'${path}' instead of '/a/d'") + endif() +endif() + +set (path "/a/d") +cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "/a/b/c" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/d") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "../../d") + list (APPEND errors "'${output}' instead of '../../d'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/a/d") +cmake_path(PROXIMATE_PATH path) +if (NOT path STREQUAL "a/d") + list (APPEND errors "'${path}' instead of 'a/d'") +endif() + +set (path "a/b/c") +cmake_path(PROXIMATE_PATH path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + + +check_errors (PROXIMATE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/RELATIVE_PATH-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake b/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake new file mode 100644 index 000000000..522a8991b --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake @@ -0,0 +1,76 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "/a//d") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "/a/b/c") +if (NOT path STREQUAL "../../d") + list (APPEND errors "'${path}' instead of '../../d'") +endif() + +set (path "/a//b///c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "/a/d") +if (NOT path STREQUAL "../b/c") + list (APPEND errors "'${path}' instead of '../b/c'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a") +if (NOT path STREQUAL "b/c") + list (APPEND errors "'${path}' instead of 'b/c'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a/b/c/x/y") +if (NOT path STREQUAL "../..") + list (APPEND errors "'${path}' instead of '../..'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a/b/c") +if (NOT path STREQUAL ".") + list (APPEND errors "'${path}' instead of '.'") +endif() + +set (path "a/b") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "c/d") +if (NOT path STREQUAL "../../a/b") + list (APPEND errors "'${path}' instead of '../../a/b'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/../../b") +cmake_path(RELATIVE_PATH path) +if (NOT path STREQUAL "../../b") + list (APPEND errors "'${path}' instead of '../../b'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/../../b") +cmake_path(RELATIVE_PATH path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/../../b") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "../../b") + list (APPEND errors "'${output}' instead of '../../b'") +endif() + +if (WIN32) + set (path "/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "/a/d") + list (APPEND errors "'${path}' instead of '/a/d'") + endif() + + set (path "c:/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "") + list (APPEND errors "'${path}' instead of ''") + endif() +elseif() + set (path "/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "") + list (APPEND errors "'${path}' instead of ''") + endif() +endif() + +check_errors (RELATIVE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_EXTENSION.cmake b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION.cmake new file mode 100644 index 000000000..ac06fde64 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_EXTENSION.cmake @@ -0,0 +1,52 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REMOVE_EXTENSION path LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e") + list (APPEND errors "'${path}' instead of 'a/b/c.e'") +endif() +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REMOVE_EXTENSION path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/b/c.e.f") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/b/c") + list (APPEND errors "'${output}' instead of 'a/b/'") +endif() + +set (path "a/b/c") +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/.c") +cmake_path (REMOVE_EXTENSION path) +if (NOT path STREQUAL "a/b/.c") + list (APPEND errors "'${path}' instead of 'a/b/.c'") +endif() +cmake_path (REMOVE_EXTENSION path LAST_ONLY) +if (NOT path STREQUAL "a/b/.c") + list (APPEND errors "'${path}' instead of 'a/b/.c'") +endif() + +set (path "a/b/.") +cmake_path (REMOVE_EXTENSION path LAST_ONLY) +if (NOT path STREQUAL "a/b/.") + list (APPEND errors "'${path}' instead of 'a/b/.'") +endif() + +check_errors (REMOVE_EXTENSION ${errors}) diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REMOVE_FILENAME.cmake b/Tests/RunCMake/cmake_path/REMOVE_FILENAME.cmake new file mode 100644 index 000000000..385dcd0fd --- /dev/null +++ b/Tests/RunCMake/cmake_path/REMOVE_FILENAME.cmake @@ -0,0 +1,25 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REMOVE_FILENAME path) +if (NOT path STREQUAL "a/b/") + list (APPEND errors "'${path}' instead of 'a/b/'") +endif() + +cmake_path (REMOVE_FILENAME path) +if (NOT path STREQUAL "a/b/") + list (APPEND errors "'${path}' instead of 'a/b/'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REMOVE_FILENAME path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/b/c.e.f") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/b/") + list (APPEND errors "'${output}' instead of 'a/b/'") +endif() + +check_errors (REMOVE_FILENAME ${errors}) diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_EXTENSION.cmake b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION.cmake new file mode 100644 index 000000000..45c15750d --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_EXTENSION.cmake @@ -0,0 +1,58 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REPLACE_EXTENSION path ".x") +if (NOT path STREQUAL "a/b/c.x") + list (APPEND errors "'${path}' instead of 'a/b/c.x'") +endif() +cmake_path (REPLACE_EXTENSION path ".y") +if (NOT path STREQUAL "a/b/c.y") + list (APPEND errors "'${path}' instead of 'a/b/c.y'") +endif() +cmake_path (REPLACE_EXTENSION path "") +if (NOT path STREQUAL "a/b/c") + list (APPEND errors "'${path}' instead of 'a/b/c'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REPLACE_EXTENSION path ".x" LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e.x") + list (APPEND errors "'${path}' instead of 'a/b/c.e.x'") +endif() +cmake_path (REPLACE_EXTENSION path ".y" LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e.y") + list (APPEND errors "'${path}' instead of 'a/b/c.e.y'") +endif() +cmake_path (REPLACE_EXTENSION path "" LAST_ONLY) +if (NOT path STREQUAL "a/b/c.e") + list (APPEND errors "'${path}' instead of 'a/b/c.e'") +endif() + +set (path "/a/.b") +cmake_path (REPLACE_EXTENSION path ".x") +if (NOT path STREQUAL "/a/.b.x") + list (APPEND errors "'${path}' instead of '/a/.b.x'") +endif() +cmake_path (REPLACE_EXTENSION path ".x" LAST_ONLY) +if (NOT path STREQUAL "/a/.b.x") + list (APPEND errors "'${path}' instead of '/a/.b.x'") +endif() + +set (path "/a/b") +cmake_path (REPLACE_EXTENSION path ".x") +if (NOT path STREQUAL "/a/b.x") + list (APPEND errors "'${path}' instead of '/a/b.x'") +endif() + +set (path "/a/b/") +cmake_path (REPLACE_EXTENSION path ".x" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "/a/b/") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "/a/b/.x") + list (APPEND errors "'${output}' instead of '/a/b/.x'") +endif() + +check_errors (REPLACE_EXTENSION ${errors}) diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-invalid-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-OUTPUT_VARIABLE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME-wrong-path-result.txt b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-wrong-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME-wrong-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_path/REPLACE_FILENAME.cmake b/Tests/RunCMake/cmake_path/REPLACE_FILENAME.cmake new file mode 100644 index 000000000..f7a9600a0 --- /dev/null +++ b/Tests/RunCMake/cmake_path/REPLACE_FILENAME.cmake @@ -0,0 +1,26 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "a/b/c.e.f") +cmake_path (REPLACE_FILENAME path "x.y") +if (NOT path STREQUAL "a/b/x.y") + list (APPEND errors "'${path}' instead of 'a/b/x.y'") +endif() + +set (path "a/b/") +cmake_path (REPLACE_FILENAME path "x.y") +if (NOT path STREQUAL "a/b/") + list (APPEND errors "'${path}' instead of 'a/b/'") +endif() + +set (path "a/b/c.e.f") +cmake_path (REPLACE_FILENAME path "" OUTPUT_VARIABLE output) +if (NOT path STREQUAL "a/b/c.e.f") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "a/b/") + list (APPEND errors "'${output}' instead of 'a/b/'") +endif() + +check_errors (REPLACE_FILENAME ${errors}) diff --git a/Tests/RunCMake/cmake_path/RunCMakeTest.cmake b/Tests/RunCMake/cmake_path/RunCMakeTest.cmake new file mode 100644 index 000000000..ca9cba66a --- /dev/null +++ b/Tests/RunCMake/cmake_path/RunCMakeTest.cmake @@ -0,0 +1,191 @@ +include(RunCMake) + +# Validate parsing arguments + +## input path is not a variable +set (RunCMake-stderr-file "wrong-path-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + run_cmake_command (GET-${subcommand}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET wrong_path ${subcommand} output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### COMPARE sub-command +foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) + run_cmake_command (COMPARE-${subcommand}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE wrong_path ${subcommand} path2 output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CONCAT REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + run_cmake_command (${command}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} wrong_path" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args path2) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} wrong_path ${extra_args} output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## missing output parameter +set (RunCMake-stderr-file "missing-output-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + run_cmake_command (GET-${subcommand}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET path ${subcommand}" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### CONVERT sub-command +foreach (subcommand IN ITEMS TO_CMAKE_PATH_LIST TO_NATIVE_PATH_LIST) + run_cmake_command (CONVERT-${subcommand}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=CONVERT path ${subcommand}" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### COMPARE sub-command +foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) + run_cmake_command (COMPARE-${subcommand}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE path ${subcommand} path2" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args path2) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args}" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## OUTPUT_VARIABLE without argument +set (RunCMake-stderr-file "OUTPUT_VARIABLE-no-arg-stderr.txt") + +foreach (command IN ITEMS APPEND CONCAT REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + run_cmake_command (${command}-OUTPUT_VARIABLE-no-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path OUTPUT_VARIABLE" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## Invalid output variable +set (RunCMake-stderr-file "invalid-output-var-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + run_cmake_command (GET-${subcommand}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET path ${subcommand}" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### CONVERT sub-command +foreach (subcommand IN ITEMS TO_CMAKE_PATH_LIST TO_NATIVE_PATH_LIST) + run_cmake_command (CONVERT-${subcommand}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=CONVERT path ${subcommand}" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### COMPARE sub-command +foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) + run_cmake_command (COMPARE-${subcommand}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE path ${subcommand} path2" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args path2) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args}" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS APPEND CONCAT REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + run_cmake_command (${command}-OUTPUT_VARIABLE-invalid-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path OUTPUT_VARIABLE" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + + +## Unexpected arguments +set (RunCMake-stderr-file "unexpected-arg-stderr.txt") + +### GET sub-command +foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSION + STEM RELATIVE_PATH PARENT_PATH) + if (subcommand STREQUAL "EXTENSION" OR subcommand STREQUAL "STEM") + set (extra_args LAST_ONLY) + else() + unset (extra_args) + endif() + run_cmake_command (GET-${subcommand}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET path ${subcommand} ${extra_args} unexpected output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +### CONVERT sub-command +foreach (subcommand IN ITEMS TO_CMAKE_PATH_LIST TO_NATIVE_PATH_LIST) + run_cmake_command (CONVERT-${subcommand}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=CONVERT path ${subcommand} output unexpected" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS REMOVE_FILENAME REPLACE_FILENAME + REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH + RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + if (command STREQUAL "REPLACE_FILENAME" OR command STREQUAL "REPLACE_EXTENSION") + set (extra_args input) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args} unexpected" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() + +foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH + HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH + HAS_FILENAME HAS_EXTENSION HAS_STEM + HAS_RELATIVE_PATH HAS_PARENT_PATH + IS_ABSOLUTE IS_RELATIVE IS_PREFIX + HASH) + if (command STREQUAL "IS_PREFIX") + set (extra_args input) + else() + unset (extra_args) + endif() + run_cmake_command (${command}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args} unexpected output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") +endforeach() +unset (RunCMake-stderr-file) + +run_cmake(GET-wrong-operator) +run_cmake(CONVERT-wrong-operator) +run_cmake(COMPARE-wrong-operator) + +set (RunCMake_TEST_OPTIONS "-DRunCMake_SOURCE_DIR=${RunCMake_SOURCE_DIR}") + +run_cmake(GET) +run_cmake(APPEND) +run_cmake(CONCAT) +run_cmake(REMOVE_FILENAME) +run_cmake(REPLACE_FILENAME) +run_cmake(REMOVE_EXTENSION) +run_cmake(REPLACE_EXTENSION) +run_cmake(NORMAL_PATH) +run_cmake(RELATIVE_PATH) +run_cmake(PROXIMATE_PATH) +run_cmake(ABSOLUTE_PATH) +run_cmake(CMAKE_PATH) +run_cmake(NATIVE_PATH) +run_cmake(CONVERT) +run_cmake(COMPARE) +run_cmake(HAS_ITEM) +run_cmake(IS_ABSOLUTE) +run_cmake(IS_RELATIVE) +run_cmake(IS_PREFIX) +run_cmake(HASH) diff --git a/Tests/RunCMake/cmake_path/call-cmake_path.cmake b/Tests/RunCMake/cmake_path/call-cmake_path.cmake new file mode 100644 index 000000000..70fd6f53f --- /dev/null +++ b/Tests/RunCMake/cmake_path/call-cmake_path.cmake @@ -0,0 +1,19 @@ + +cmake_minimum_required(VERSION 3.18...3.19) + +# define input variable +set (path "") + +separate_arguments(CMAKE_PATH_ARGUMENTS UNIX_COMMAND "${CMAKE_PATH_ARGUMENTS}") + +if (CHECK_INVALID_OUTPUT) + # special handling for CMAKE_PATH + list(GET CMAKE_PATH_ARGUMENTS 0 command) + if (command STREQUAL "CMAKE_PATH") + cmake_path(CMAKE_PATH "" "input") + else() + cmake_path(${CMAKE_PATH_ARGUMENTS} "") + endif() +else() + cmake_path(${CMAKE_PATH_ARGUMENTS}) +endif() diff --git a/Tests/RunCMake/cmake_path/check_errors.cmake b/Tests/RunCMake/cmake_path/check_errors.cmake new file mode 100644 index 000000000..d1369710e --- /dev/null +++ b/Tests/RunCMake/cmake_path/check_errors.cmake @@ -0,0 +1,12 @@ + +function (CHECK_ERRORS command) + set (errors ${ARGN}) + if (errors) + string (LENGTH "${command}" length) + math (EXPR count "${length} + 2") + string (REPEAT " " ${count} shift) + list (TRANSFORM errors PREPEND "${shift}") + list (JOIN errors "\n" msg) + message (FATAL_ERROR "${command}: ${msg}") + endif() +endfunction() diff --git a/Tests/RunCMake/cmake_path/invalid-output-var-stderr.txt b/Tests/RunCMake/cmake_path/invalid-output-var-stderr.txt new file mode 100644 index 000000000..32a89481d --- /dev/null +++ b/Tests/RunCMake/cmake_path/invalid-output-var-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path Invalid name for output variable. diff --git a/Tests/RunCMake/cmake_path/missing-output-stderr.txt b/Tests/RunCMake/cmake_path/missing-output-stderr.txt new file mode 100644 index 000000000..8ac049bc6 --- /dev/null +++ b/Tests/RunCMake/cmake_path/missing-output-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path [A-Z_]+ must be called with ((at least )?(two|three|four)|two or three|three or four) arguments. diff --git a/Tests/RunCMake/cmake_path/unexpected-arg-stderr.txt b/Tests/RunCMake/cmake_path/unexpected-arg-stderr.txt new file mode 100644 index 000000000..8f0e2f25b --- /dev/null +++ b/Tests/RunCMake/cmake_path/unexpected-arg-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path [A-Z_]+ (called with unexpected|must be called with two) arguments. diff --git a/Tests/RunCMake/cmake_path/wrong-path-stderr.txt b/Tests/RunCMake/cmake_path/wrong-path-stderr.txt new file mode 100644 index 000000000..c42b5a2ee --- /dev/null +++ b/Tests/RunCMake/cmake_path/wrong-path-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/cmake_path/call-cmake_path.cmake:[0-9]+ \(cmake_path\): + cmake_path undefined variable for input path. diff --git a/Tests/RunCMake/configure_file/NoSourcePermissions.cmake b/Tests/RunCMake/configure_file/NoSourcePermissions.cmake new file mode 100644 index 000000000..c6ad1311e --- /dev/null +++ b/Tests/RunCMake/configure_file/NoSourcePermissions.cmake @@ -0,0 +1,10 @@ +configure_file(NoSourcePermissions.sh NoSourcePermissions.sh.out + NO_SOURCE_PERMISSIONS) + +if (UNIX) + execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/NoSourcePermissions.sh.out + RESULT_VARIABLE result) + if (result EQUAL "0") + message(FATAL_ERROR "Copied file has executable permissions") + endif() +endif() diff --git a/Tests/RunCMake/configure_file/NoSourcePermissions.sh b/Tests/RunCMake/configure_file/NoSourcePermissions.sh new file mode 100755 index 000000000..0aa8f412e --- /dev/null +++ b/Tests/RunCMake/configure_file/NoSourcePermissions.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +#Testing NO_SOURCE_PERMISSIONS option of configure_file. diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake index 32a0770b9..71694fb0b 100644 --- a/Tests/RunCMake/configure_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake @@ -15,6 +15,7 @@ run_cmake(NewLineStyle-NoArg) run_cmake(NewLineStyle-WrongArg) run_cmake(NewLineStyle-ValidArg) run_cmake(NewLineStyle-COPYONLY) +run_cmake(NoSourcePermissions) if(RunCMake_GENERATOR MATCHES "Make") # Use a single build tree for a few tests without cleaning. diff --git a/Tests/RunCMake/ctest_build/BuildCommandFailure-check.cmake b/Tests/RunCMake/ctest_build/BuildCommandFailure-check.cmake new file mode 100644 index 000000000..feac3ced2 --- /dev/null +++ b/Tests/RunCMake/ctest_build/BuildCommandFailure-check.cmake @@ -0,0 +1,12 @@ +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(READ "${build_xml_file}" build_xml LIMIT 4096) + if(NOT build_xml MATCHES [[this command failed]]) + string(REPLACE "\n" "\n " build_xml " ${build_xml}") + set(RunCMake_TEST_FAILED + "Build.xml does not have expected error message:\n${build_xml}" + ) + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_build/BuildCommandFailure-result.txt b/Tests/RunCMake/ctest_build/BuildCommandFailure-result.txt new file mode 100644 index 000000000..b57e2deb7 --- /dev/null +++ b/Tests/RunCMake/ctest_build/BuildCommandFailure-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_build/BuildCommandFailure-stderr.txt b/Tests/RunCMake/ctest_build/BuildCommandFailure-stderr.txt new file mode 100644 index 000000000..bbe9410a1 --- /dev/null +++ b/Tests/RunCMake/ctest_build/BuildCommandFailure-stderr.txt @@ -0,0 +1 @@ +^Error\(s\) when building project diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake index b2e562a93..072fbac22 100644 --- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake @@ -48,8 +48,12 @@ function(run_BuildChangeId) endfunction() run_BuildChangeId() -set(RunCMake_USE_LAUNCHERS FALSE) set(RunCMake_USE_CUSTOM_BUILD_COMMAND TRUE) +set(RunCMake_BUILD_COMMAND "${FAKE_BUILD_COMMAND_EXE}") +run_ctest(BuildCommandFailure) +unset(RunCMake_BUILD_COMMAND) + +set(RunCMake_USE_LAUNCHERS FALSE) set(RunCMake_BUILD_COMMAND "${COLOR_WARNING}") run_ctest(IgnoreColor) unset(RunCMake_BUILD_COMMAND) diff --git a/Tests/RunCMake/ctest_memcheck/CMakeLists.txt.in b/Tests/RunCMake/ctest_memcheck/CMakeLists.txt.in index 3b8edf4c9..68a0fcb8b 100644 --- a/Tests/RunCMake/ctest_memcheck/CMakeLists.txt.in +++ b/Tests/RunCMake/ctest_memcheck/CMakeLists.txt.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.9) +cmake_minimum_required(VERSION 3.3) project(CTestTestMemcheck@CASE_NAME@ NONE) include(CTest) diff --git a/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-result.txt b/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-result.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-stderr.txt b/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-stderr.txt new file mode 100644 index 000000000..d302b5cb6 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-stderr.txt @@ -0,0 +1 @@ +Defect count: 23 diff --git a/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-stdout.txt new file mode 100644 index 000000000..034ee1e54 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyCudaSanitizer-stdout.txt @@ -0,0 +1,13 @@ +Memory checking results: +Uninitialized __global__ memory read - 1 +Unused memory - 1 +Host API memory access error - 1 +Barrier error - 2 +Invalid __global__ read - 1 +cudaErrorLaunchFailure - 2 +Fatal UVM GPU fault - 1 +Fatal UVM CPU fault - 1 +Memory leak - 1 +Potential WAR hazard detected - 4 +Potential RAW hazard detected - 4 +Race reported - 4 diff --git a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake index ab4c5abe5..6e0a91c85 100644 --- a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake @@ -175,3 +175,15 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) unset(CTEST_MEMCHECK_ARGS) unset(CTEST_SUFFIX_CODE) + +#----------------------------------------------------------------------------- +set(CMAKELISTS_EXTRA_CODE +"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\" +-P \"${RunCMake_SOURCE_DIR}/testCudaSanitizer.cmake\") +") +set(CTEST_SUFFIX_CODE "message(\"Defect count: \${defect_count}\")") +set(CTEST_MEMCHECK_ARGS "DEFECT_COUNT defect_count") +run_mc_test(DummyCudaSanitizer "${PSEUDO_CUDA_SANITIZER}") +unset(CTEST_MEMCHECK_ARGS) +unset(CTEST_SUFFIX_CODE) +unset(CTEST_EXTRA_CODE) diff --git a/Tests/RunCMake/ctest_memcheck/test.cmake.in b/Tests/RunCMake/ctest_memcheck/test.cmake.in index 50b4b6ab6..eedf080b7 100644 --- a/Tests/RunCMake/ctest_memcheck/test.cmake.in +++ b/Tests/RunCMake/ctest_memcheck/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.9) +cmake_minimum_required(VERSION 3.3) # Settings: set(CTEST_SITE "@SITE@") diff --git a/Tests/RunCMake/ctest_memcheck/testCudaSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testCudaSanitizer.cmake new file mode 100644 index 000000000..adc7a1a36 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/testCudaSanitizer.cmake @@ -0,0 +1,279 @@ +# this file simulates an execution of cuda-memcheck + +set(LOG_FILE "$ENV{PSEUDO_LOGFILE}") +message("LOG_FILE=[${LOG_FILE}]") + +# clear the log file +file(REMOVE "${LOG_FILE}") + +# create an error of each type of sanitizer tool and failure + +# initcheck +file(APPEND "${LOG_FILE}" +"========= CUDA-MEMCHECK +========= Uninitialized __global__ memory read of size 4 +========= at 0x00000020 in test(int*, int*) +========= by thread (0,0,0) in block (0,0,0) +========= Address 0x1303d80000 +========= Saved host backtrace up to driver entry point +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./uninit-read [0x101d9] +========= Host Frame:./uninit-read [0x10267] +========= Host Frame:./uninit-read [0x465b5] +========= Host Frame:./uninit-read [0x3342] +========= Host Frame:./uninit-read [0x3143] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./uninit-read [0x31e2] +========= +========= Unused memory in allocation 0x1303d80000 of size 16 bytes +========= Not written any memory. +========= 100.00% of allocation were unused. +========= Saved host backtrace up to driver entry point +========= Host Frame:/lib64/libcuda.so.1 (cuMemAlloc_v2 + 0x1b7) [0x26ec97] +========= Host Frame:./uninit-read [0x2bbd3] +========= Host Frame:./uninit-read [0x71ab] +========= Host Frame:./uninit-read [0x3c84f] +========= Host Frame:./uninit-read [0x3111] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./uninit-read [0x31e2] +========= +========= Host API memory access error at host access to 0x1303fd1400 of size 25600 bytes +========= Uninitialized access at 0x1303fd4600 on access by cudaMemcopy source. +========= Saved host backtrace up to driver entry point at error +========= Host Frame:/usr/lib/x86_64-linux-gnu/libcuda.so.1 (cuMemcpyDtoH_v2 + 0x1ec) [0x29200c] +========= Host Frame:/usr/local/cuda/targets/x86_64-linux/lib/libcudart.so.10.1 [0x38aaa] +========= Host Frame:/usr/local/cuda/targets/x86_64-linux/lib/libcudart.so.10.1 [0x18946] +========= Host Frame:/usr/local/cuda/targets/x86_64-linux/lib/libcudart.so.10.1 (cudaMemcpy + 0x1a2) [0x3b8c2] +========= Host Frame:/something/somewhere [0xcafe] +========= +========= ERROR SUMMARY: 2 errors +") + + +# synccheck +file(APPEND "${LOG_FILE}" +"========= CUDA-MEMCHECK +========= Barrier error detected. Divergent thread(s) in warp +========= at 0x00000058 in test(int*, int*) +========= by thread (1,0,0) in block (0,0,0) +========= Device Frame:test(int*, int*) (test(int*, int*) : 0x60) +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./sync [0x101d9] +========= Host Frame:./sync [0x10267] +========= Host Frame:./sync [0x465b5] +========= Host Frame:./sync [0x3342] +========= Host Frame:./sync [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./sync [0x31e2] +========= +========= Barrier error detected. Divergent thread(s) in warp +========= at 0x00000058 in test(int*, int*) +========= by thread (0,0,0) in block (0,0,0) +========= Device Frame:test(int*, int*) (test(int*, int*) : 0x60) +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./sync [0x101d9] +========= Host Frame:./sync [0x10267] +========= Host Frame:./sync [0x465b5] +========= Host Frame:./sync [0x3342] +========= Host Frame:./sync [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./sync [0x31e2] +========= +========= ERROR SUMMARY: 2 errors +") + +# memcheck +file(APPEND "${LOG_FILE}" +"========= CUDA-MEMCHECK +========= Invalid __global__ read of size 4 +========= at 0x00000020 in test(int*, int*) +========= by thread (0,0,0) in block (0,0,0) +========= Address 0x00000000 is out of bounds +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./invalid-read [0x101d9] +========= Host Frame:./invalid-read [0x10267] +========= Host Frame:./invalid-read [0x465b5] +========= Host Frame:./invalid-read [0x3342] +========= Host Frame:./invalid-read [0x3142] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./invalid-read [0x31e2] +========= +========= Program hit cudaErrorLaunchFailure (error 719) due to \"unspecified launch failure\" on CUDA API call to cudaDeviceSynchronize. +========= Saved host backtrace up to driver entry point at error +========= Host Frame:/lib64/libcuda.so.1 [0x3ac5a3] +========= Host Frame:./invalid-read [0x2e576] +========= Host Frame:./invalid-read [0x3147] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./invalid-read [0x31e2] +========= +========= Program hit cudaErrorLaunchFailure (error 719) due to \"unspecified launch failure\" on CUDA API call to cudaFree. +========= Saved host backtrace up to driver entry point at error +========= Host Frame:/lib64/libcuda.so.1 [0x3ac5a3] +========= Host Frame:./invalid-read [0x3c106] +========= Host Frame:./invalid-read [0x3150] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./invalid-read [0x31e2] +========= +========= Fatal UVM GPU fault of type invalid pde due to invalid address +========= during atomic access to address 0x20be00000 +========= +========= Fatal UVM CPU fault due to invalid operation +========= during read access to address 0x1357c92000 +========= +========= LEAK SUMMARY: 0 bytes leaked in 0 allocations +========= ERROR SUMMARY: 3 errors +") + +# memcheck with leak-check full +file(APPEND "${LOG_FILE}" +"========= CUDA-MEMCHECK +========= Leaked 10 bytes at 0x1303d80000 +========= Saved host backtrace up to driver entry point at cudaMalloc time +========= Host Frame:/lib64/libcuda.so.1 (cuMemAlloc_v2 + 0x1b7) [0x26ec97] +========= Host Frame:./leak [0x2bab3] +========= Host Frame:./leak [0x708b] +========= Host Frame:./leak [0x3c72f] +========= Host Frame:./leak [0x3113] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./leak [0x3174] +========= +========= LEAK SUMMARY: 10 bytes leaked in 1 allocations +========= ERROR SUMMARY: 1 error +") + +# racecheck with racecheck-report all +file(APPEND "${LOG_FILE}" +"========= CUDA-MEMCHECK +========= WARN:(Warp Level Programming) Potential WAR hazard detected at __shared__ 0x3 in block (0, 0, 0) : +========= Read Thread (31, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Write Thread (0, 0, 0) at 0x000001a8 in ./race.cu:4:test(int*, int*) +========= Current Value : 0, Incoming Value : 0 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN:(Warp Level Programming) Potential WAR hazard detected at __shared__ 0x2 in block (0, 0, 0) : +========= Read Thread (31, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Write Thread (0, 0, 0) at 0x000001a8 in ./race.cu:4:test(int*, int*) +========= Current Value : 0, Incoming Value : 0 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN:(Warp Level Programming) Potential WAR hazard detected at __shared__ 0x1 in block (0, 0, 0) : +========= Read Thread (31, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Write Thread (0, 0, 0) at 0x000001a8 in ./race.cu:4:test(int*, int*) +========= Current Value : 0, Incoming Value : 0 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN:(Warp Level Programming) Potential WAR hazard detected at __shared__ 0x0 in block (0, 0, 0) : +========= Read Thread (31, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Write Thread (0, 0, 0) at 0x000001a8 in ./race.cu:4:test(int*, int*) +========= Current Value : 0, Incoming Value : 1 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN:(Warp Level Programming) Potential RAW hazard detected at __shared__ 0x3 in block (0, 0, 0) : +========= Write Thread (31, 0, 0) at 0x00000148 in ./race.cu:3:test(int*, int*) +========= Read Thread (0, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Current Value : 0 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN:(Warp Level Programming) Potential RAW hazard detected at __shared__ 0x2 in block (0, 0, 0) : +========= Write Thread (31, 0, 0) at 0x00000148 in ./race.cu:3:test(int*, int*) +========= Read Thread (0, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Current Value : 0 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN:(Warp Level Programming) Potential RAW hazard detected at __shared__ 0x1 in block (0, 0, 0) : +========= Write Thread (31, 0, 0) at 0x00000148 in ./race.cu:3:test(int*, int*) +========= Read Thread (0, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Current Value : 0 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN:(Warp Level Programming) Potential RAW hazard detected at __shared__ 0x0 in block (0, 0, 0) : +========= Write Thread (31, 0, 0) at 0x00000148 in ./race.cu:3:test(int*, int*) +========= Read Thread (0, 0, 0) at 0x00000170 in ./race.cu:4:test(int*, int*) +========= Current Value : 0 +========= Saved host backtrace up to driver entry point at kernel launch time +========= Host Frame:/lib64/libcuda.so.1 (cuLaunchKernel + 0x346) [0x297db6] +========= Host Frame:./race [0x101d9] +========= Host Frame:./race [0x10267] +========= Host Frame:./race [0x465b5] +========= Host Frame:./race [0x3342] +========= Host Frame:./race [0x314a] +========= Host Frame:/lib64/libc.so.6 (__libc_start_main + 0xf5) [0x22505] +========= Host Frame:./race [0x31e2] +========= +========= WARN: Race reported between Read access at 0x00000170 in ./race.cu:4:test(int*, int*) +========= and Write access at 0x00000148 in ./race.cu:3:test(int*, int*) [4 hazards] +========= and Write access at 0x000001a8 in ./race.cu:4:test(int*, int*) [4 hazards] +========= +========= WARN: Race reported between Write access at 0x00000148 in ./race.cu:3:test(int*, int*) +========= and Write access at 0x00000148 in ./race.cu:3:test(int*, int*) [124 hazards] +========= and Read access at 0x00000170 in ./race.cu:4:test(int*, int*) [4 hazards] +========= +========= WARN: Race reported between Write access at 0x000001a8 in ./race.cu:4:test(int*, int*) +========= and Write access at 0x000001a8 in ./race.cu:4:test(int*, int*) [124 hazards] +========= and Read access at 0x00000170 in ./race.cu:4:test(int*, int*) [4 hazards] +========= +========= WARN: Race reported between Write access at 0x00000148 in ./race.cu:3:test(int*, int*) +========= and Write access at 0x00000148 in ./race.cu:3:test(int*, int*) [124 hazards] +========= and Read access at 0x00000170 in ./race.cu:4:test(int*, int*) [4 hazards] +========= +========= RACECHECK SUMMARY: 12 hazards displayed (0 errors, 12 warnings) +") diff --git a/Tests/RunCMake/ctest_update/test.cmake.in b/Tests/RunCMake/ctest_update/test.cmake.in index 25b842324..01aab26bb 100644 --- a/Tests/RunCMake/ctest_update/test.cmake.in +++ b/Tests/RunCMake/ctest_update/test.cmake.in @@ -10,7 +10,7 @@ set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -# FIXME: update test to do someting meaningful with this. +# FIXME: update test to do something meaningful with this. set(CTEST_UPDATE_COMMAND "not-actually-used") set(ctest_test_args "@CASE_CTEST_UPDATE_ARGS@") diff --git a/Tests/RunCMake/execute_process/AnyCommandError-result.txt b/Tests/RunCMake/execute_process/AnyCommandError-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandError-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/AnyCommandError-stderr.txt b/Tests/RunCMake/execute_process/AnyCommandError-stderr.txt new file mode 100644 index 000000000..038056231 --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandError-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*AnyCommandError.cmake:1 \(execute_process\): + execute_process failed command indexes: 2, 3, 4 diff --git a/Tests/RunCMake/execute_process/AnyCommandError.cmake b/Tests/RunCMake/execute_process/AnyCommandError.cmake new file mode 100644 index 000000000..f8ec38513 --- /dev/null +++ b/Tests/RunCMake/execute_process/AnyCommandError.cmake @@ -0,0 +1,8 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E true + COMMAND_ERROR_IS_FATAL ANY +) diff --git a/Tests/RunCMake/execute_process/CommandError-result.txt b/Tests/RunCMake/execute_process/CommandError-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/execute_process/CommandError-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/CommandError-stderr.txt b/Tests/RunCMake/execute_process/CommandError-stderr.txt new file mode 100644 index 000000000..c28f3a311 --- /dev/null +++ b/Tests/RunCMake/execute_process/CommandError-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*CommandError.cmake:1 \(execute_process\): + execute_process COMMAND_ERROR_IS_FATAL option can be ANY or LAST diff --git a/Tests/RunCMake/execute_process/CommandError.cmake b/Tests/RunCMake/execute_process/CommandError.cmake new file mode 100644 index 000000000..da5892876 --- /dev/null +++ b/Tests/RunCMake/execute_process/CommandError.cmake @@ -0,0 +1,3 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND_ERROR_IS_FATAL ALL +) diff --git a/Tests/RunCMake/execute_process/LastCommandError-result.txt b/Tests/RunCMake/execute_process/LastCommandError-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandError-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/LastCommandError-stderr.txt b/Tests/RunCMake/execute_process/LastCommandError-stderr.txt new file mode 100644 index 000000000..ff191b3cd --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandError-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*LastCommandError.cmake:1 \(execute_process\): + execute_process last command failed diff --git a/Tests/RunCMake/execute_process/LastCommandError.cmake b/Tests/RunCMake/execute_process/LastCommandError.cmake new file mode 100644 index 000000000..6116a5c23 --- /dev/null +++ b/Tests/RunCMake/execute_process/LastCommandError.cmake @@ -0,0 +1,8 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E false + COMMAND ${CMAKE_COMMAND} -E true + COMMAND ${CMAKE_COMMAND} -E false + COMMAND_ERROR_IS_FATAL LAST +) diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index 89ad6b207..f4c3d1919 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -26,3 +26,7 @@ run_cmake_command(EchoCommand3 ${CMAKE_COMMAND} ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) run_cmake_command(EchoVariable ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/EchoVariable.cmake) + +run_cmake_command(AnyCommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/AnyCommandError.cmake) +run_cmake_command(LastCommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandError.cmake) +run_cmake_command(CommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/CommandError.cmake) diff --git a/Tests/RunCMake/export/CMakeLists.txt b/Tests/RunCMake/export/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/export/CMakeLists.txt +++ b/Tests/RunCMake/export/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/export/NamelinkOnlyExport.cmake b/Tests/RunCMake/export/NamelinkOnlyExport.cmake new file mode 100644 index 000000000..4bdd180ab --- /dev/null +++ b/Tests/RunCMake/export/NamelinkOnlyExport.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) +add_library(foo SHARED empty.cpp) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + NAMELINK_ONLY +) +export(EXPORT fooExport FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 1c747623a..95c8d5cf4 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -15,3 +15,5 @@ run_cmake(ForbiddenToExportPropertyWithGenExp) run_cmake(ExportPropertiesUndefined) run_cmake(DependOnNotExport) run_cmake(DependOnDoubleExport) +run_cmake(UnknownExport) +run_cmake(NamelinkOnlyExport) diff --git a/Tests/RunCMake/export/UnknownExport-result.txt b/Tests/RunCMake/export/UnknownExport-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/export/UnknownExport-stderr.txt b/Tests/RunCMake/export/UnknownExport-stderr.txt new file mode 100644 index 000000000..a8f8453ec --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at UnknownExport\.cmake:[0-9]+ \(export\): + export Export set "fooExport" not found\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/UnknownExport.cmake b/Tests/RunCMake/export/UnknownExport.cmake new file mode 100644 index 000000000..bf82d1f32 --- /dev/null +++ b/Tests/RunCMake/export/UnknownExport.cmake @@ -0,0 +1,2 @@ +enable_language(CXX) +export(EXPORT fooExport FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") diff --git a/Tests/RunCMake/fake_build_command.c b/Tests/RunCMake/fake_build_command.c new file mode 100644 index 000000000..d87335b98 --- /dev/null +++ b/Tests/RunCMake/fake_build_command.c @@ -0,0 +1,6 @@ +#include <stdio.h> +int main(void) +{ + printf("this command failed\n"); + return 1; +} diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-all-perms-result.txt b/Tests/RunCMake/file-CHMOD/CHMOD-all-perms-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-all-perms-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-all-perms-stderr.txt b/Tests/RunCMake/file-CHMOD/CHMOD-all-perms-stderr.txt new file mode 100644 index 000000000..b22387bbd --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-all-perms-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at CHMOD-all-perms\.cmake:[0-9]+ \(file\): + file Remove either PERMISSIONS or FILE_PERMISSIONS or DIRECTORY_PERMISSIONS + from the invocation +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-all-perms.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-all-perms.cmake new file mode 100644 index 000000000..b49583d5c --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-all-perms.cmake @@ -0,0 +1,6 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a) +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a PERMISSIONS OWNER_READ + FILE_PERMISSIONS OWNER_READ DIRECTORY_PERMISSIONS OWNER_READ) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path-result.txt b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path-stderr.txt b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path-stderr.txt new file mode 100644 index 000000000..8d09e3510 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at CHMOD-invalid-path\.cmake:[0-9]+ \(file\): + file does not exist: + + .*/chmod-tests/I_dont_exist +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path.cmake new file mode 100644 index 000000000..36915c15b --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-path.cmake @@ -0,0 +1,4 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/I_dont_exist PERMISSIONS OWNER_READ) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms-result.txt b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms-stderr.txt b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms-stderr.txt new file mode 100644 index 000000000..84ba2a299 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CHMOD-invalid-perms\.cmake:[0-9]+ \(file\): + file INVALID_PERMISSION is an invalid permission specifier +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms.cmake new file mode 100644 index 000000000..22cab0b14 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-invalid-perms.cmake @@ -0,0 +1,5 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a) +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a PERMISSIONS INVALID_PERMISSION) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword-result.txt b/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword-stderr.txt b/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword-stderr.txt new file mode 100644 index 000000000..2c248f8bf --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CHMOD-no-keyword\.cmake:[0-9]+ \(file\): + file No permissions given +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword.cmake new file mode 100644 index 000000000..8b6210651 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-no-keyword.cmake @@ -0,0 +1,5 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a) +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-no-perms-result.txt b/Tests/RunCMake/file-CHMOD/CHMOD-no-perms-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-no-perms-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-no-perms-stderr.txt b/Tests/RunCMake/file-CHMOD/CHMOD-no-perms-stderr.txt new file mode 100644 index 000000000..a18609f2c --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-no-perms-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CHMOD-no-perms\.cmake:[0-9]+ \(file\): + file No permissions given +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-no-perms.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-no-perms.cmake new file mode 100644 index 000000000..9fbd3599d --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-no-perms.cmake @@ -0,0 +1,5 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a) +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a PERMISSIONS) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-ok.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-ok.cmake new file mode 100644 index 000000000..87e3e5766 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-ok.cmake @@ -0,0 +1,5 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a) +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a PERMISSIONS OWNER_READ) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-override.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-override.cmake new file mode 100644 index 000000000..d9226b835 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-override.cmake @@ -0,0 +1,6 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a) +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a PERMISSIONS OWNER_READ + FILE_PERMISSIONS OWNER_READ OWNER_WRITE) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-write-only-result.txt b/Tests/RunCMake/file-CHMOD/CHMOD-write-only-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-write-only-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-write-only-stderr.txt b/Tests/RunCMake/file-CHMOD/CHMOD-write-only-stderr.txt new file mode 100644 index 000000000..1c87a593f --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-write-only-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at CHMOD-write-only\.cmake:[0-9]+ \(file\): + file failed to open for reading \(Permission denied\): + + .*/chmod-tests/a +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file-CHMOD/CHMOD-write-only.cmake b/Tests/RunCMake/file-CHMOD/CHMOD-write-only.cmake new file mode 100644 index 000000000..1289efc10 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CHMOD-write-only.cmake @@ -0,0 +1,6 @@ +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a "CONTENT") +file(CHMOD ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a PERMISSIONS OWNER_WRITE) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/chmod-tests/a content) diff --git a/Tests/RunCMake/file-CHMOD/CMakeLists.txt b/Tests/RunCMake/file-CHMOD/CMakeLists.txt new file mode 100644 index 000000000..289710955 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/file-CHMOD/RunCMakeTest.cmake b/Tests/RunCMake/file-CHMOD/RunCMakeTest.cmake new file mode 100644 index 000000000..c7bff15c2 --- /dev/null +++ b/Tests/RunCMake/file-CHMOD/RunCMakeTest.cmake @@ -0,0 +1,19 @@ +include(RunCMake) + +run_cmake(CHMOD-no-perms) +run_cmake(CHMOD-no-keyword) +run_cmake(CHMOD-all-perms) +run_cmake(CHMOD-invalid-perms) +run_cmake(CHMOD-invalid-path) +run_cmake(CHMOD-ok) +run_cmake(CHMOD-override) + +if(UNIX) + execute_process(COMMAND id -u $ENV{USER} + OUTPUT_VARIABLE uid + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +if(NOT WIN32 AND NOT "${uid}" STREQUAL "0") + run_cmake(CHMOD-write-only) +endif() diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt new file mode 100644 index 000000000..b0f0d1934 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at DOWNLOAD-no-save-hash\.cmake:[0-9]+ \(file\): + file DOWNLOAD cannot calculate hash if file is not saved\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake new file mode 100644 index 000000000..ce959a7fe --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.cmake @@ -0,0 +1,8 @@ +if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/") + set(slash /) +endif() +file(DOWNLOAD + "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-no-save-md5.txt" + EXPECTED_HASH MD5=55555555555555555555555555555555 + STATUS status + ) diff --git a/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-no-save-hash.txt diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake index fe87c7849..684c1960e 100644 --- a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake @@ -8,3 +8,9 @@ file(GLOB_RECURSE ) string(SHA1 CONTENT_LIST_HASH "${CONTENT_LIST}") add_custom_target(CONTENT_ECHO ALL ${CMAKE_COMMAND} -E echo ${CONTENT_LIST_HASH}) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + # Xcode's "new build system" does not reload the project file if it is updated + # during the build. Print the output we expect the build to print just to make + # the test pass. + message(STATUS "CONTENT_LIST_HASH: ${CONTENT_LIST_HASH}") +endif() diff --git a/Tests/RunCMake/file/REAL_PATH-no-base-dir-result.txt b/Tests/RunCMake/file/REAL_PATH-no-base-dir-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file/REAL_PATH-no-base-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/REAL_PATH-no-base-dir-stderr.txt b/Tests/RunCMake/file/REAL_PATH-no-base-dir-stderr.txt new file mode 100644 index 000000000..7c58aeb4a --- /dev/null +++ b/Tests/RunCMake/file/REAL_PATH-no-base-dir-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at REAL_PATH-no-base-dir.cmake:[0-9]+ \(file\): + file BASE_DIRECTORY requires a value diff --git a/Tests/RunCMake/file/REAL_PATH-no-base-dir.cmake b/Tests/RunCMake/file/REAL_PATH-no-base-dir.cmake new file mode 100644 index 000000000..132aee6f6 --- /dev/null +++ b/Tests/RunCMake/file/REAL_PATH-no-base-dir.cmake @@ -0,0 +1,2 @@ + +file(REAL_PATH "some-path" real_path BASE_DIRECTORY) diff --git a/Tests/RunCMake/file/REAL_PATH-unexpected-arg-result.txt b/Tests/RunCMake/file/REAL_PATH-unexpected-arg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/file/REAL_PATH-unexpected-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/REAL_PATH-unexpected-arg-stderr.txt b/Tests/RunCMake/file/REAL_PATH-unexpected-arg-stderr.txt new file mode 100644 index 000000000..301db75b5 --- /dev/null +++ b/Tests/RunCMake/file/REAL_PATH-unexpected-arg-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at REAL_PATH-unexpected-arg.cmake:[0-9]+ \(file\): + file REAL_PATH called with unexpected arguments diff --git a/Tests/RunCMake/file/REAL_PATH-unexpected-arg.cmake b/Tests/RunCMake/file/REAL_PATH-unexpected-arg.cmake new file mode 100644 index 000000000..144f30bb4 --- /dev/null +++ b/Tests/RunCMake/file/REAL_PATH-unexpected-arg.cmake @@ -0,0 +1,2 @@ + +file(REAL_PATH "some-path" real_path extra_arg) diff --git a/Tests/RunCMake/file/REAL_PATH.cmake b/Tests/RunCMake/file/REAL_PATH.cmake new file mode 100644 index 000000000..be25706b2 --- /dev/null +++ b/Tests/RunCMake/file/REAL_PATH.cmake @@ -0,0 +1,14 @@ + +file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/test.txt") +file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test.sym") +file(CREATE_LINK "test.txt" "${CMAKE_CURRENT_BINARY_DIR}/test.sym" SYMBOLIC) + +file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/test.sym" real_path) +if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") +endif() + +file(REAL_PATH "test.sym" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") +endif() diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index a4de1d3ee..22813eb16 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -11,6 +11,7 @@ run_cmake(DOWNLOAD-netrc-bad) run_cmake(DOWNLOAD-tls-cainfo-not-set) run_cmake(DOWNLOAD-tls-verify-not-set) run_cmake(DOWNLOAD-pass-not-set) +run_cmake(DOWNLOAD-no-save-hash) run_cmake(TOUCH) run_cmake(TOUCH-error-in-source-directory) run_cmake(TOUCH-error-missing-directory) @@ -71,6 +72,9 @@ if(NOT WIN32 OR CYGWIN) run_cmake(READ_SYMLINK-noexist) run_cmake(READ_SYMLINK-notsymlink) run_cmake(INSTALL-FOLLOW_SYMLINK_CHAIN) + run_cmake(REAL_PATH-unexpected-arg) + run_cmake(REAL_PATH-no-base-dir) + run_cmake(REAL_PATH) endif() if(RunCMake_GENERATOR MATCHES "Ninja") diff --git a/Tests/RunCMake/find_dependency/CMakeLists.txt b/Tests/RunCMake/find_dependency/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/find_dependency/CMakeLists.txt +++ b/Tests/RunCMake/find_dependency/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/find_package/CMakeLists.txt b/Tests/RunCMake/find_package/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/find_package/CMakeLists.txt +++ b/Tests/RunCMake/find_package/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/find_package/EmptyVersionRange-result.txt b/Tests/RunCMake/find_package/EmptyVersionRange-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/EmptyVersionRange-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/EmptyVersionRange-stderr.txt b/Tests/RunCMake/find_package/EmptyVersionRange-stderr.txt new file mode 100644 index 000000000..9c00b9687 --- /dev/null +++ b/Tests/RunCMake/find_package/EmptyVersionRange-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at EmptyVersionRange.cmake:[0-9]+ \(find_package\): + find_package specified version range is empty. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at EmptyVersionRange.cmake:[0-9]+ \(find_package\): + find_package specified version range is empty. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_package/EmptyVersionRange.cmake b/Tests/RunCMake/find_package/EmptyVersionRange.cmake new file mode 100644 index 000000000..553e297a8 --- /dev/null +++ b/Tests/RunCMake/find_package/EmptyVersionRange.cmake @@ -0,0 +1,3 @@ +find_package(VersionRange 2.3...1.2) + +find_package(VersionRange 2.3...<2.3) diff --git a/Tests/RunCMake/find_package/FindVersionRange.cmake b/Tests/RunCMake/find_package/FindVersionRange.cmake new file mode 100644 index 000000000..27e5b90b3 --- /dev/null +++ b/Tests/RunCMake/find_package/FindVersionRange.cmake @@ -0,0 +1,82 @@ + +if (NOT VersionRange_FIND_VERSION_COMPLETE STREQUAL VersionRange_SPECIFIED_VERSION_COMPLETE) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_COMPLETE: ${VersionRange_FIND_VERSION_COMPLETE}") +endif() + +if (NOT VersionRange_FIND_VERSION VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION: ${VersionRange_FIND_VERSION}") +endif() +if (NOT VersionRange_FIND_VERSION_MAJOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MAJOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAJOR: ${VersionRange_FIND_VERSION_MAJOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MINOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MINOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MINOR: ${VersionRange_FIND_VERSION_MINOR}") +endif() +if (NOT VersionRange_FIND_VERSION_PATCH VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_PATCH) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_PATCH: ${VersionRange_FIND_VERSION_PATCH}") +endif() +if (NOT VersionRange_FIND_VERSION_TWEAK VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_TWEAK) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_TWEAK: ${VersionRange_FIND_VERSION_TWEAK}") +endif() + +if (NOT VersionRange_FIND_VERSION_RANGE STREQUAL VersionRange_SPECIFIED_VERSION_RANGE) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE: ${VersionRange_FIND_VERSION_RANGE}") +endif() +if (NOT VersionRange_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE_MIN: ${VersionRange_FIND_VERSION_RANGE_MIN}") +endif() +if (VersionRange_FIND_VERSION_RANGE MATCHES "<[0-9.]+$") + if (NOT VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE_MAX: ${VersionRange_FIND_VERSION_RANGE_MAX}") + endif() +else() + if (NOT VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE_MAX: ${VersionRange_FIND_VERSION_RANGE_MAX}") + endif() +endif() + +if (NOT VersionRange_FIND_VERSION_MIN VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN: ${VersionRange_FIND_VERSION_MIN}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_MAJOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MAJOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_MAJOR: ${VersionRange_FIND_VERSION_MIN_MAJOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_MINOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MINOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_MINOR: ${VersionRange_FIND_VERSION_MIN_MINOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_PATCH VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_PATCH) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_PATCH: ${VersionRange_FIND_VERSION_MIN_PATCH}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_TWEAK VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_TWEAK) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_TWEAK: ${VersionRange_FIND_VERSION_MIN_TWEAK}") +endif() + +if (NOT VersionRange_FIND_VERSION_MAX VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAX: ${VersionRange_FIND_VERSION_MAX}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_MAJOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_MAJOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAX_MAJOR: ${VersionRange_FIND_VERSION_MAX_MAJOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_MINOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_MINOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAX_MINOR: ${VersionRange_FIND_VERSION_MAX_MINOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_PATCH VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_PATCH) + message (SEND_ERROR "Wrong value for VersionRange_VERSION_FIND_MAX_PATCH: ${VersionRange_FIND_VERSION_MAX_PATCH}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_TWEAK VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_TWEAK) + message (SEND_ERROR "Wrong value for VersionRange_VERSION_FIND_MAX_TWEAK: ${VersionRange_FIND_VERSION_MAX_TWEAK}") +endif() + +if ((VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" + AND "2.3.4.5" VERSION_LESS_EQUAL VersionRange_FIND_VERSION_MAX) + OR (VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" + AND "2.3.4.5" VERSION_LESS VersionRange_FIND_VERSION_MAX)) +set (VersionRange_FOUND TRUE) +set (VersionRange_VERSION 2.3.4.5) +set (VersionRange_VERSION_MAJOR 2) +set (VersionRange_VERSION_MINOR 3) +set (VersionRange_VERSION_PATCH 4) +set (VersionRange_VERSION_TWEAK 5) +else() + set (VersionRange_FOUND FALSE) +endif() diff --git a/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld-stderr.txt b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld-stderr.txt index b336b5621..ebfd7d030 100644 --- a/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld-stderr.txt +++ b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld-stderr.txt @@ -1,9 +1,10 @@ CMake Warning \(dev\) at MissingNormalWarnNoModuleOld.cmake:2 \(find_package\): - find_package called without NO_MODULE option and no FindNotHere.cmake - module is in CMAKE_MODULE_PATH. Add NO_MODULE to exclusively request - Config mode and search for a package configuration file provided by NotHere - \(NotHereConfig.cmake or nothere-config.cmake\). Otherwise make - FindNotHere.cmake available in CMAKE_MODULE_PATH. + find_package called without either MODULE or CONFIG option and no + FindNotHere.cmake module is in CMAKE_MODULE_PATH. Add MODULE to + exclusively request Module mode and fail if FindNotHere.cmake is missing. + Add CONFIG to exclusively request Config mode and search for a package + configuration file provided by NotHere \(NotHereConfig.cmake or + nothere-config.cmake\). \(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.\) Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 5186297df..a899f46ad 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -29,6 +29,17 @@ run_cmake(WrongVersionConfig) run_cmake(CMP0084-OLD) run_cmake(CMP0084-WARN) run_cmake(CMP0084-NEW) +run_cmake(WrongVersionRange) +run_cmake(EmptyVersionRange) +run_cmake(VersionRangeWithEXACT) +run_cmake(VersionRange) +run_cmake(VersionRange2) +run_cmake(VersionRange3) +run_cmake(VersionRange4) +run_cmake(VersionRangeConfig) +run_cmake(VersionRangeConfig2) +run_cmake(VersionRangeConfigStd) +run_cmake(VersionRangeConfigStd2) if(UNIX) run_cmake(SetFoundResolved) endif() diff --git a/Tests/RunCMake/find_package/VersionRange.cmake b/Tests/RunCMake/find_package/VersionRange.cmake new file mode 100644 index 000000000..30b88a80a --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange.cmake @@ -0,0 +1,37 @@ + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MIN 1.2.3.4) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 1) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 3) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 4) +set (VersionRange_SPECIFIED_VERSION_MAX 5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 5) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 6) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 7) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 8) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRange2.cmake b/Tests/RunCMake/find_package/VersionRange2.cmake new file mode 100644 index 000000000..9adcc6400 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange2.cmake @@ -0,0 +1,37 @@ + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...<5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...<5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MIN 1.2.3.4) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 1) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 3) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 4) +set (VersionRange_SPECIFIED_VERSION_MAX 5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 5) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 6) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 7) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 8) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRange3.cmake b/Tests/RunCMake/find_package/VersionRange3.cmake new file mode 100644 index 000000000..41efac461 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange3.cmake @@ -0,0 +1,49 @@ + +# show the effect of the exclusion or inclusion of the upper endpoint + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...<2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...<2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MIN 1.2.3.4) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 1) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 3) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 4) +set (VersionRange_SPECIFIED_VERSION_MAX 2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 2) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 3) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 4) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 5) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange found unexpectedly.") +endif() + + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...2.3.4.5) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRange4.cmake b/Tests/RunCMake/find_package/VersionRange4.cmake new file mode 100644 index 000000000..0953d0429 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange4.cmake @@ -0,0 +1,39 @@ + +# show the effect of the exclusion or inclusion of the upper endpoint + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 2.3.4.5...2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_RANGE 2.3.4.5...2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MIN 2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 3) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 4) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 5) +set (VersionRange_SPECIFIED_VERSION_MAX 2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 2) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 3) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 4) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 5) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfig.cmake b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfig.cmake new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfig.cmake diff --git a/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfigVersion.cmake b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfigVersion.cmake new file mode 100644 index 000000000..e9f607685 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfigVersion.cmake @@ -0,0 +1,74 @@ + +if (NOT PACKAGE_FIND_VERSION_COMPLETE STREQUAL "1.2.3.4...5.6.7.8" + AND NOT PACKAGE_FIND_VERSION_COMPLETE STREQUAL "1.2.3.4...<5.6.7.8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_COMPLETE: ${PACKAGE_FIND_VERSION_COMPLETE}") +endif() + +if (NOT PACKAGE_FIND_VERSION VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION: ${PACKAGE_FIND_VERSION}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAJOR: ${PACKAGE_FIND_VERSION_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MINOR: ${PACKAGE_FIND_VERSION_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_PATCH: ${PACKAGE_FIND_VERSION_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_TWEAK: ${PACKAGE_FIND_VERSION_TWEAK}") +endif() + +if (NOT PACKAGE_FIND_VERSION_RANGE STREQUAL "1.2.3.4...5.6.7.8" + AND NOT PACKAGE_FIND_VERSION_RANGE STREQUAL "1.2.3.4...<5.6.7.8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE: ${PACKAGE_FIND_VERSION_RANGE}") +endif() + +if (NOT PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE_MIN: ${PACKAGE_FIND_VERSION_RANGE_MIN}") +endif() +if (PACKAGE_FIND_VERSION_RANGE MATCHES "<[0-9.]+$") + if (NOT PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE_MAX: ${PACKAGE_FIND_VERSION_RANGE_MAX}") + endif() +else() + if (NOT PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE_MAX: ${PACKAGE_FIND_VERSION_RANGE_MAX}") + endif() +endif() + +if (NOT PACKAGE_FIND_VERSION_MIN VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN: ${PACKAGE_FIND_VERSION_MIN}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_MAJOR: ${PACKAGE_FIND_VERSION_MIN_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_MINOR: ${PACKAGE_FIND_VERSION_MIN_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_PATCH: ${PACKAGE_FIND_VERSION_MIN_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_TWEAK: ${PACKAGE_FIND_VERSION_MIN_TWEAK}") +endif() + +if (NOT PACKAGE_FIND_VERSION_MAX VERSION_EQUAL "5.6.7.8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX: ${PACKAGE_FIND_VERSION_MAX}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_MAJOR VERSION_EQUAL "5") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX_MAJOR: ${PACKAGE_FIND_VERSION_MAX_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_MINOR VERSION_EQUAL "6") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX_MINOR: ${PACKAGE_FIND_VERSION_MAX_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_PATCH VERSION_EQUAL "7") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAXPATCH: ${PACKAGE_FIND_VERSION_MAX_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_TWEAK VERSION_EQUAL "8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX_TWEAK: ${PACKAGE_FIND_VERSION_MAX_TWEAK}") +endif() + +set (PACKAGE_VERSION 2.3.4.5) +set (PACKAGE_VERSION_COMPATIBLE TRUE) diff --git a/Tests/RunCMake/find_package/VersionRangeConfig.cmake b/Tests/RunCMake/find_package/VersionRangeConfig.cmake new file mode 100644 index 000000000..b39a96698 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfig.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4...5.6.7.8 CONFIG NAMES VersionRangeCfg) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeConfig2.cmake b/Tests/RunCMake/find_package/VersionRangeConfig2.cmake new file mode 100644 index 000000000..04c570a99 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfig2.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4...<5.6.7.8 CONFIG NAMES VersionRangeCfg) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeConfigStd.cmake b/Tests/RunCMake/find_package/VersionRangeConfigStd.cmake new file mode 100644 index 000000000..3ffc72f56 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfigStd.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4 CONFIG NAMES VersionRangeStd) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeConfigStd2.cmake b/Tests/RunCMake/find_package/VersionRangeConfigStd2.cmake new file mode 100644 index 000000000..8b48828f0 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfigStd2.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4...5.6.7.8 CONFIG NAMES VersionRangeStd) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfig.cmake b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfig.cmake new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfig.cmake diff --git a/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfigVersion.cmake b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfigVersion.cmake new file mode 100644 index 000000000..6e9151ca3 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfigVersion.cmake @@ -0,0 +1,24 @@ + +if (NOT PACKAGE_FIND_VERSION VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION: ${PACKAGE_FIND_VERSION}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAJOR: ${PACKAGE_FIND_VERSION_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MINOR: ${PACKAGE_FIND_VERSION_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_PATCH: ${PACKAGE_FIND_VERSION_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_TWEAK: ${PACKAGE_FIND_VERSION_TWEAK}") +endif() + +set (PACKAGE_VERSION 2.3.4.5) + +if (PACKAGE_FIND_VERSION VERSION_LESS_EQUAL PACKAGE_VERSION) + set (PACKAGE_VERSION_COMPATIBLE TRUE) +else() + set (PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeWithEXACT-result.txt b/Tests/RunCMake/find_package/VersionRangeWithEXACT-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeWithEXACT-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/VersionRangeWithEXACT-stderr.txt b/Tests/RunCMake/find_package/VersionRangeWithEXACT-stderr.txt new file mode 100644 index 000000000..6319aeed5 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeWithEXACT-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at VersionRangeWithEXACT.cmake:[0-9]+ \(find_package\): + find_package EXACT cannot be specified with a version range. diff --git a/Tests/RunCMake/find_package/VersionRangeWithEXACT.cmake b/Tests/RunCMake/find_package/VersionRangeWithEXACT.cmake new file mode 100644 index 000000000..419c7c53f --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeWithEXACT.cmake @@ -0,0 +1 @@ +find_package(VersionRange 1.2...3.4 EXACT) diff --git a/Tests/RunCMake/find_package/WrongVersionRange-result.txt b/Tests/RunCMake/find_package/WrongVersionRange-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/WrongVersionRange-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/WrongVersionRange-stderr.txt b/Tests/RunCMake/find_package/WrongVersionRange-stderr.txt new file mode 100644 index 000000000..fe0b0887f --- /dev/null +++ b/Tests/RunCMake/find_package/WrongVersionRange-stderr.txt @@ -0,0 +1,28 @@ +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2\.\.\." +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "\.\.\.1\.2" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2\.\.\.\.2\.3" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2\.\.\.>2\.3" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2>\.\.\.2\.3" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_package/WrongVersionRange.cmake b/Tests/RunCMake/find_package/WrongVersionRange.cmake new file mode 100644 index 000000000..9851ade92 --- /dev/null +++ b/Tests/RunCMake/find_package/WrongVersionRange.cmake @@ -0,0 +1,9 @@ +find_package(VersionRange 1.2...) + +find_package(VersionRange ...1.2) + +find_package(VersionRange 1.2....2.3) + +find_package(VersionRange 1.2...>2.3) + +find_package(VersionRange 1.2>...2.3) diff --git a/Tests/RunCMake/find_program/BundleSpaceInName-stdout.txt b/Tests/RunCMake/find_program/BundleSpaceInName-stdout.txt new file mode 100644 index 000000000..331d46577 --- /dev/null +++ b/Tests/RunCMake/find_program/BundleSpaceInName-stdout.txt @@ -0,0 +1 @@ +-- FakeApp_EXECUTABLE='.*/Tests/RunCMake/find_program/BundleSpaceInName-build/Fake app.app/Contents/MacOS/Fake app' diff --git a/Tests/RunCMake/find_program/BundleSpaceInName.cmake b/Tests/RunCMake/find_program/BundleSpaceInName.cmake new file mode 100644 index 000000000..9152d5b2e --- /dev/null +++ b/Tests/RunCMake/find_program/BundleSpaceInName.cmake @@ -0,0 +1,8 @@ +set(fakeApp "${CMAKE_CURRENT_BINARY_DIR}/Fake app.app/Contents/MacOS/Fake app") +file(WRITE "${fakeApp}" "#!/bin/sh\n") +execute_process(COMMAND chmod a+rx "${fakeApp}") + +find_program(FakeApp_EXECUTABLE NAMES "Fake app" NO_DEFAULT_PATH + PATHS "${CMAKE_CURRENT_BINARY_DIR}" +) +message(STATUS "FakeApp_EXECUTABLE='${FakeApp_EXECUTABLE}'") diff --git a/Tests/RunCMake/find_program/ExeNoRead.cmake b/Tests/RunCMake/find_program/CMP0109-Common.cmake index 7e22dc5b3..525413a3d 100644 --- a/Tests/RunCMake/find_program/ExeNoRead.cmake +++ b/Tests/RunCMake/find_program/CMP0109-Common.cmake @@ -1,4 +1,7 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead" "#!/bin/sh\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ReadNoExe" "#ReadNoExe") execute_process(COMMAND chmod -r+x "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead") find_program(ExeNoRead_EXECUTABLE NAMES ExeNoRead NO_DEFAULT_PATH PATHS "${CMAKE_CURRENT_BINARY_DIR}") message(STATUS "ExeNoRead_EXECUTABLE='${ExeNoRead_EXECUTABLE}'") +find_program(ReadNoExe_EXECUTABLE NAMES ReadNoExe NO_DEFAULT_PATH PATHS "${CMAKE_CURRENT_BINARY_DIR}") +message(STATUS "ReadNoExe_EXECUTABLE='${ReadNoExe_EXECUTABLE}'") diff --git a/Tests/RunCMake/find_program/CMP0109-NEW-stdout.txt b/Tests/RunCMake/find_program/CMP0109-NEW-stdout.txt new file mode 100644 index 000000000..2744463a3 --- /dev/null +++ b/Tests/RunCMake/find_program/CMP0109-NEW-stdout.txt @@ -0,0 +1,2 @@ +-- ExeNoRead_EXECUTABLE='.*/Tests/RunCMake/find_program/CMP0109-NEW-build/ExeNoRead' +-- ReadNoExe_EXECUTABLE='ReadNoExe_EXECUTABLE-NOTFOUND' diff --git a/Tests/RunCMake/find_program/CMP0109-NEW.cmake b/Tests/RunCMake/find_program/CMP0109-NEW.cmake new file mode 100644 index 000000000..b4a4033ae --- /dev/null +++ b/Tests/RunCMake/find_program/CMP0109-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0109 NEW) +include(CMP0109-Common.cmake) diff --git a/Tests/RunCMake/find_program/CMP0109-OLD-stdout.txt b/Tests/RunCMake/find_program/CMP0109-OLD-stdout.txt new file mode 100644 index 000000000..1a0e2a8e2 --- /dev/null +++ b/Tests/RunCMake/find_program/CMP0109-OLD-stdout.txt @@ -0,0 +1,2 @@ +-- ExeNoRead_EXECUTABLE='ExeNoRead_EXECUTABLE-NOTFOUND' +-- ReadNoExe_EXECUTABLE='.*/Tests/RunCMake/find_program/CMP0109-OLD-build/ReadNoExe' diff --git a/Tests/RunCMake/find_program/CMP0109-OLD.cmake b/Tests/RunCMake/find_program/CMP0109-OLD.cmake new file mode 100644 index 000000000..826016115 --- /dev/null +++ b/Tests/RunCMake/find_program/CMP0109-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0109 OLD) +include(CMP0109-Common.cmake) diff --git a/Tests/RunCMake/find_program/CMP0109-WARN-stderr.txt b/Tests/RunCMake/find_program/CMP0109-WARN-stderr.txt new file mode 100644 index 000000000..202fc6def --- /dev/null +++ b/Tests/RunCMake/find_program/CMP0109-WARN-stderr.txt @@ -0,0 +1,29 @@ +^CMake Warning \(dev\) at CMP0109-Common.cmake:4 \(find_program\): + Policy CMP0109 is not set: find_program\(\) requires permission to execute + but not to read. Run "cmake --help-policy CMP0109" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + The file + + .*/Tests/RunCMake/find_program/CMP0109-WARN-build/ExeNoRead + + is executable but not readable. CMake is ignoring it for compatibility. +Call Stack \(most recent call first\): + CMP0109-WARN.cmake:1 \(include\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0109-Common.cmake:6 \(find_program\): + Policy CMP0109 is not set: find_program\(\) requires permission to execute + but not to read. Run "cmake --help-policy CMP0109" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + The file + + .*/Tests/RunCMake/find_program/CMP0109-WARN-build/ReadNoExe + + is readable but not executable. CMake is using it for compatibility. +Call Stack \(most recent call first\): + CMP0109-WARN.cmake:1 \(include\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/find_program/CMP0109-WARN-stdout.txt b/Tests/RunCMake/find_program/CMP0109-WARN-stdout.txt new file mode 100644 index 000000000..baf560f6f --- /dev/null +++ b/Tests/RunCMake/find_program/CMP0109-WARN-stdout.txt @@ -0,0 +1,2 @@ +-- ExeNoRead_EXECUTABLE='ExeNoRead_EXECUTABLE-NOTFOUND' +-- ReadNoExe_EXECUTABLE='.*/Tests/RunCMake/find_program/CMP0109-WARN-build/ReadNoExe' diff --git a/Tests/RunCMake/find_program/CMP0109-WARN.cmake b/Tests/RunCMake/find_program/CMP0109-WARN.cmake new file mode 100644 index 000000000..a3d59af49 --- /dev/null +++ b/Tests/RunCMake/find_program/CMP0109-WARN.cmake @@ -0,0 +1 @@ +include(CMP0109-Common.cmake) diff --git a/Tests/RunCMake/find_program/ExeNoRead-stdout.txt b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt deleted file mode 100644 index f2311782d..000000000 --- a/Tests/RunCMake/find_program/ExeNoRead-stdout.txt +++ /dev/null @@ -1 +0,0 @@ --- ExeNoRead_EXECUTABLE='ExeNoRead_EXECUTABLE-NOTFOUND' diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 2bb777bff..3e2392031 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -17,6 +17,12 @@ else() OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT "${uid}" STREQUAL "0") - run_cmake(ExeNoRead) + run_cmake(CMP0109-WARN) + run_cmake(CMP0109-OLD) + run_cmake(CMP0109-NEW) endif() endif() + +if(APPLE) + run_cmake(BundleSpaceInName) +endif() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake index 9647deabd..3b03ed7a9 100644 --- a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake @@ -8,13 +8,13 @@ function(foreachTest result list_var_1 list_var_2 list_var_3) list(APPEND CMAKE_MESSAGE_INDENT "| ") foreach(first second third IN ZIP_LISTS ${list_var_1} ${list_var_2} ${list_var_3}) if(NOT first) - set(first "[undefiend]") + set(first "[undefined]") endif() if(NOT second) - set(second "[undefiend]") + set(second "[undefined]") endif() if(NOT third) - set(third "[undefiend]") + set(third "[undefined]") endif() if(NOT _arg_MUTE) message(STATUS "${first}, ${second}, ${third}") diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt index 25433fdc3..4730a86ed 100644 --- a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt @@ -14,6 +14,6 @@ -- | one, satu, raz -- | two, dua, dva -- | three, tiga, tri --- | \[undefiend\], empat, \[undefiend\] +-- | \[undefined\], empat, \[undefined\] -- End output -- <<< test variable value restored -- PASSED >>> diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake index 56cfe6434..aa0ed0717 100644 --- a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake @@ -9,7 +9,7 @@ function(foreachTest result list_var_1 list_var_2 list_var_3) foreach(num IN ZIP_LISTS ${list_var_1} ${list_var_2} ${list_var_3}) foreach(i RANGE 2) if(NOT num_${i}) - set(num_${i} "[undefiend]") + set(num_${i} "[undefined]") endif() endforeach() if(NOT _arg_MUTE) diff --git a/Tests/RunCMake/get_filename_component/IncorrectArguments-result.txt b/Tests/RunCMake/get_filename_component/IncorrectArguments-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/get_filename_component/IncorrectArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/get_filename_component/IncorrectArguments-stderr.txt b/Tests/RunCMake/get_filename_component/IncorrectArguments-stderr.txt new file mode 100644 index 000000000..af08afae6 --- /dev/null +++ b/Tests/RunCMake/get_filename_component/IncorrectArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at IncorrectArguments.cmake:1 \(get_filename_component\): + get_filename_component called with incorrect number of arguments +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_filename_component/IncorrectArguments.cmake b/Tests/RunCMake/get_filename_component/IncorrectArguments.cmake new file mode 100644 index 000000000..e329e2925 --- /dev/null +++ b/Tests/RunCMake/get_filename_component/IncorrectArguments.cmake @@ -0,0 +1,2 @@ +get_filename_component(var) +message("The error is fatal, so this should not print") diff --git a/Tests/RunCMake/get_filename_component/RunCMakeTest.cmake b/Tests/RunCMake/get_filename_component/RunCMakeTest.cmake index 156fc8f3c..a7820a0de 100644 --- a/Tests/RunCMake/get_filename_component/RunCMakeTest.cmake +++ b/Tests/RunCMake/get_filename_component/RunCMakeTest.cmake @@ -1,4 +1,5 @@ include(RunCMake) +run_cmake(IncorrectArguments) run_cmake(KnownComponents) run_cmake(UnknownComponent) diff --git a/Tests/RunCMake/get_filename_component/UnknownComponent-stderr.txt b/Tests/RunCMake/get_filename_component/UnknownComponent-stderr.txt index b146e5b4b..f86a6889a 100644 --- a/Tests/RunCMake/get_filename_component/UnknownComponent-stderr.txt +++ b/Tests/RunCMake/get_filename_component/UnknownComponent-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at UnknownComponent.cmake:1 \(get_filename_component\): +^CMake Error at UnknownComponent.cmake:1 \(get_filename_component\): get_filename_component unknown component BOGUS Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_filename_component/UnknownComponent.cmake b/Tests/RunCMake/get_filename_component/UnknownComponent.cmake index 06abc51e6..19521ba46 100644 --- a/Tests/RunCMake/get_filename_component/UnknownComponent.cmake +++ b/Tests/RunCMake/get_filename_component/UnknownComponent.cmake @@ -1 +1,2 @@ get_filename_component(var "/path/to/filename.ext.in" BOGUS) +message("The error is fatal, so this should not print") diff --git a/Tests/RunCMake/get_property/CMakeLists.txt b/Tests/RunCMake/get_property/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/get_property/CMakeLists.txt +++ b/Tests/RunCMake/get_property/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/if/CMakeLists.txt b/Tests/RunCMake/if/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/if/CMakeLists.txt +++ b/Tests/RunCMake/if/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include/CMakeLists.txt b/Tests/RunCMake/include/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/include/CMakeLists.txt +++ b/Tests/RunCMake/include/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_external_msproject/CMakeLists.txt b/Tests/RunCMake/include_external_msproject/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/include_external_msproject/CMakeLists.txt +++ b/Tests/RunCMake/include_external_msproject/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_external_msproject/check_utils.cmake b/Tests/RunCMake/include_external_msproject/check_utils.cmake index 0a2ba63f5..016251936 100644 --- a/Tests/RunCMake/include_external_msproject/check_utils.cmake +++ b/Tests/RunCMake/include_external_msproject/check_utils.cmake @@ -63,7 +63,7 @@ function(check_custom_platform TARGET_FILE PROJECT_NAME PLATFORM_NAME RESULT) return() endif() - # probably whould be better to use configuration name + # probably would be better to use configuration name # extracted from CMAKE_CONFIGURATION_TYPES than just hardcoded "Debug" instead set(REG_EXP "^(\t)*\\{${FOUND_GUID}\\}\\.Debug[^ ]*\\.ActiveCfg = Debug\\|${PLATFORM_NAME}$") check_line_exists(${TARGET_FILE} REG_EXP) diff --git a/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake b/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake new file mode 100644 index 000000000..1c310d1f9 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-NamelinkOnly.cmake @@ -0,0 +1,12 @@ +enable_language(C) +add_library(foo SHARED empty.c) +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY + DESTINATION lib + NAMELINK_ONLY +) +install(EXPORT fooExport + DESTINATION "lib/cmake/" + FILE "foo.cmake" +) diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt b/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt b/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt new file mode 100644 index 000000000..bd49fa26e --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport-stderr.txt @@ -0,0 +1 @@ +CMake Error: INSTALL\(EXPORT\) given unknown export "fooExport" diff --git a/Tests/RunCMake/install/EXPORT-UnknownExport.cmake b/Tests/RunCMake/install/EXPORT-UnknownExport.cmake new file mode 100644 index 000000000..2dbba4e28 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-UnknownExport.cmake @@ -0,0 +1,5 @@ +enable_language(C) +install(EXPORT fooExport + DESTINATION "lib/cmake/" + FILE "foo.cmake" +) diff --git a/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake new file mode 100644 index 000000000..8750a7685 --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS-all-check.cmake @@ -0,0 +1,11 @@ + +set(objs obj1 obj2) +set(targets sse2 sse4 avx avx2) +foreach(o IN LISTS objs) + set(item "objs/${o}\\.ispc\\.(o|obj)") + check_installed("${item}") + foreach(t IN LISTS targets) + set(item "objs/${o}\\.ispc_${t}\\.(o|obj)") + check_installed("${item}") + endforeach() +endforeach() diff --git a/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake new file mode 100644 index 000000000..ad542ed82 --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXTRA_ISPC_TARGET_OBJECTS.cmake @@ -0,0 +1,4 @@ +enable_language(ISPC) +add_library(objs OBJECT obj1.ispc obj2.ispc) +set_target_properties(objs PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i16x8;avx1-i32x16;avx2-i32x4") +install(FILES $<TARGET_OBJECTS:objs> DESTINATION objs) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index d83a07cdb..5aab88ca8 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -76,6 +76,8 @@ run_cmake(DIRECTORY-DESTINATION-bad) run_cmake(FILES-DESTINATION-bad) run_cmake(TARGETS-DESTINATION-bad) run_cmake(EXPORT-OldIFace) +run_cmake(EXPORT-UnknownExport) +run_cmake(EXPORT-NamelinkOnly) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) @@ -96,6 +98,11 @@ if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES} run_install_test(FILES-TARGET_OBJECTS) endif() +if(CMake_TEST_ISPC) + run_install_test(FILES-EXTRA_ISPC_TARGET_OBJECTS) +endif() + + run_install_test(TARGETS-InstallFromSubDir) run_install_test(TARGETS-OPTIONAL) run_install_test(FILES-OPTIONAL) diff --git a/Tests/RunCMake/install/obj1.ispc b/Tests/RunCMake/install/obj1.ispc new file mode 100644 index 000000000..0dc983c3f --- /dev/null +++ b/Tests/RunCMake/install/obj1.ispc @@ -0,0 +1,4 @@ + +float func1(float a, float b) { + return a + b / 2.; +} diff --git a/Tests/RunCMake/install/obj2.ispc b/Tests/RunCMake/install/obj2.ispc new file mode 100644 index 000000000..7b2aeb97f --- /dev/null +++ b/Tests/RunCMake/install/obj2.ispc @@ -0,0 +1,4 @@ + +float func2(float a, float b) { + return a + b / 2.; +} diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake deleted file mode 100644 index 5a6af1da6..000000000 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ /dev/null @@ -1,13 +0,0 @@ -include(RunCMake) - -run_cmake(invalid_name) -run_cmake(target_commands) -run_cmake(no_shared_libs) -run_cmake(whitelist) -run_cmake(invalid_signature) -run_cmake(global-interface) -run_cmake(genex_link) -run_cmake(add_custom_command-TARGET) -run_cmake(IMPORTED_LIBNAME-bad-value) -run_cmake(IMPORTED_LIBNAME-non-iface) -run_cmake(IMPORTED_LIBNAME-non-imported) diff --git a/Tests/RunCMake/interface_library/whitelist-stderr.txt b/Tests/RunCMake/interface_library/whitelist-stderr.txt deleted file mode 100644 index 577c0cc5d..000000000 --- a/Tests/RunCMake/interface_library/whitelist-stderr.txt +++ /dev/null @@ -1,19 +0,0 @@ -CMake Error at whitelist.cmake:4 \(set_property\): - INTERFACE_LIBRARY targets may only have whitelisted properties. The - property "OUTPUT_NAME" is not allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) - - -CMake Error at whitelist.cmake:5 \(set_property\): - INTERFACE_LIBRARY targets may only have whitelisted properties. The - property "OUTPUT_NAME" is not allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) - - -CMake Error at whitelist.cmake:6 \(get_target_property\): - INTERFACE_LIBRARY targets may only have whitelisted properties. The - property "OUTPUT_NAME" is not allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake deleted file mode 100644 index 0db637531..000000000 --- a/Tests/RunCMake/interface_library/whitelist.cmake +++ /dev/null @@ -1,25 +0,0 @@ - -add_library(iface INTERFACE) - -set_property(TARGET iface PROPERTY OUTPUT_NAME output) -set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append) -get_target_property(outname iface OUTPUT_NAME) - -# Properties starting with `_` are allowed. -set_property(TARGET iface PROPERTY "_custom_property" output) -set_property(TARGET iface APPEND PROPERTY "_custom_property" append) -get_target_property(outname iface "_custom_property") - -# Properties starting with a lowercase letter are allowed. -set_property(TARGET iface PROPERTY "custom_property" output) -set_property(TARGET iface APPEND PROPERTY "custom_property" append) -get_target_property(outname iface "custom_property") - -# PUBLIC_HEADER / PRIVATE_HEADER properties are allowed -set_property(TARGET iface PROPERTY PUBLIC_HEADER foo.h) -set_property(TARGET iface APPEND PROPERTY PUBLIC_HEADER bar.h) -get_target_property(outname iface PUBLIC_HEADER) - -set_property(TARGET iface PROPERTY PRIVATE_HEADER foo.h) -set_property(TARGET iface APPEND PROPERTY PRIVATE_HEADER bar.h) -get_target_property(outname iface PRIVATE_HEADER) diff --git a/Tests/RunCMake/list/CMakeLists.txt b/Tests/RunCMake/list/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/list/CMakeLists.txt +++ b/Tests/RunCMake/list/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt b/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt index a0f883780..9103bd2d4 100644 --- a/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt +++ b/Tests/RunCMake/list/GET-CMP0007-WARN-stderr.txt @@ -1,4 +1,13 @@ -^CMake Warning \(dev\) at GET-CMP0007-WARN.cmake:4 \(list\): +^CMake Deprecation Warning at GET-CMP0007-WARN.cmake:1 \(cmake_policy\): + Compatibility with CMake < 2.8.12 will be removed from a future version of + CMake. + + Update the VERSION argument <min> value or use a ...<max> suffix to tell + CMake that the project does not need compatibility with older versions. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Warning \(dev\) at GET-CMP0007-WARN.cmake:4 \(list\): Policy CMP0007 is not set: list command no longer ignores empty elements. Run "cmake --help-policy CMP0007" for policy details. Use the cmake_policy command to set the policy and suppress this warning. List has value = diff --git a/Tests/RunCMake/math/CMakeLists.txt b/Tests/RunCMake/math/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/math/CMakeLists.txt +++ b/Tests/RunCMake/math/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/message/CMakeLists.txt b/Tests/RunCMake/message/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/message/CMakeLists.txt +++ b/Tests/RunCMake/message/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/no_install_prefix/CMakeLists.txt b/Tests/RunCMake/no_install_prefix/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/no_install_prefix/CMakeLists.txt +++ b/Tests/RunCMake/no_install_prefix/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/project/CMakeLists.txt b/Tests/RunCMake/project/CMakeLists.txt index 12cd3c775..4b3de84d9 100644 --- a/Tests/RunCMake/project/CMakeLists.txt +++ b/Tests/RunCMake/project/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/separate_arguments/MultipleArguments-result.txt b/Tests/RunCMake/separate_arguments/MultipleArguments-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/MultipleArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/separate_arguments/MultipleArguments-stderr.txt b/Tests/RunCMake/separate_arguments/MultipleArguments-stderr.txt new file mode 100644 index 000000000..bbf1cf243 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/MultipleArguments-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at MultipleArguments.cmake:[0-9]+ \(separate_arguments\): + separate_arguments given unexpected argument\(s\) +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/separate_arguments/MultipleArguments.cmake b/Tests/RunCMake/separate_arguments/MultipleArguments.cmake new file mode 100644 index 000000000..d38a03b04 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/MultipleArguments.cmake @@ -0,0 +1,2 @@ + +separate_arguments (var UNIX_COMMAND arg1 arg2) diff --git a/Tests/RunCMake/separate_arguments/MultipleCommands-result.txt b/Tests/RunCMake/separate_arguments/MultipleCommands-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/MultipleCommands-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/separate_arguments/MultipleCommands-stderr.txt b/Tests/RunCMake/separate_arguments/MultipleCommands-stderr.txt new file mode 100644 index 000000000..9dca8f675 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/MultipleCommands-stderr.txt @@ -0,0 +1,19 @@ +CMake Error at MultipleCommands.cmake:[0-9]+ \(separate_arguments\): + separate_arguments 'UNIX_COMMAND', 'WINDOWS_COMMAND' and 'NATIVE_COMMAND' + are mutually exclusive +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at MultipleCommands.cmake:[0-9]+ \(separate_arguments\): + separate_arguments 'UNIX_COMMAND', 'WINDOWS_COMMAND' and 'NATIVE_COMMAND' + are mutually exclusive +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at MultipleCommands.cmake:[0-9]+ \(separate_arguments\): + separate_arguments 'UNIX_COMMAND', 'WINDOWS_COMMAND' and 'NATIVE_COMMAND' + are mutually exclusive +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/separate_arguments/MultipleCommands.cmake b/Tests/RunCMake/separate_arguments/MultipleCommands.cmake new file mode 100644 index 000000000..cb71fcbda --- /dev/null +++ b/Tests/RunCMake/separate_arguments/MultipleCommands.cmake @@ -0,0 +1,6 @@ + +separate_arguments(var UNIX_COMMAND WINDOWS_COMMAND) + +separate_arguments(var UNIX_COMMAND NATIVE_COMMAND) + +separate_arguments(var WINDOWS_COMMAND NATIVE_COMMAND) diff --git a/Tests/RunCMake/separate_arguments/NativeCommand.cmake b/Tests/RunCMake/separate_arguments/NativeCommand.cmake index 1cb009e9f..0051a7938 100644 --- a/Tests/RunCMake/separate_arguments/NativeCommand.cmake +++ b/Tests/RunCMake/separate_arguments/NativeCommand.cmake @@ -17,3 +17,8 @@ if(NOT "${native_out}" STREQUAL "${native_exp}") message(FATAL_ERROR "separate_arguments native-style failed. " "Expected\n [${native_exp}]\nbut got\n [${native_out}]\n") endif() + +separate_arguments(empty_out NATIVE_COMMAND) +if(NOT empty_out STREQUAL "") + message(FATAL_ERROR "separate_arguments native-style failed on no arguments") +endif() diff --git a/Tests/RunCMake/separate_arguments/ProgramCommand.cmake b/Tests/RunCMake/separate_arguments/ProgramCommand.cmake new file mode 100644 index 000000000..8325def1b --- /dev/null +++ b/Tests/RunCMake/separate_arguments/ProgramCommand.cmake @@ -0,0 +1,48 @@ + +separate_arguments (out UNIX_COMMAND PROGRAM "xx a b c") +if (out) + message (SEND_ERROR "unexpected result with nonexistent program") +endif() + +set (TEST_EXE_DIR "${CMAKE_CURRENT_BINARY_DIR}/TestExe") +file(MAKE_DIRECTORY "${TEST_EXE_DIR}") +file(COPY "${CMAKE_COMMAND}" DESTINATION "${TEST_EXE_DIR}") +get_filename_component (cmake_exe "${CMAKE_COMMAND}" NAME) + +set (ENV{PATH} "${TEST_EXE_DIR}") + + +separate_arguments (out UNIX_COMMAND PROGRAM "${cmake_exe}") +list (LENGTH out length) +if (length EQUAL 0) + message(FATAL_ERROR "existent program not found") +endif() +if (NOT length EQUAL 2) + message(FATAL_ERROR "unexpected arguments") +endif() +list(GET out 0 cmake) +list(GET out 1 args) +if (NOT cmake STREQUAL "${TEST_EXE_DIR}/${cmake_exe}") + message (SEND_ERROR "bad path for program: '${cmake}' instead of '${TEST_EXE_DIR}/${cmake_exe}'") +endif() +if (NOT args STREQUAL "") + message (SEND_ERROR "bad value for args: '${args}' instead of ''") +endif() + + +separate_arguments (out UNIX_COMMAND PROGRAM "${cmake_exe} a b c") +list (LENGTH out length) +if (length EQUAL 0) + message(FATAL_ERROR "existent program not found") +endif() +if (NOT length EQUAL 2) + message(FATAL_ERROR "unexpected arguments") +endif() +list(GET out 0 cmake) +list(GET out 1 args) +if (NOT cmake STREQUAL "${TEST_EXE_DIR}/${cmake_exe}") + message (SEND_ERROR "bad path for program: '${cmake}' instead of '${TEST_EXE_DIR}/${cmake_exe}'") +endif() +if (NOT args STREQUAL " a b c") + message (SEND_ERROR "bad value for args: '${args}' instead of ' a b c'") +endif() diff --git a/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake b/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake new file mode 100644 index 000000000..07572ba60 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake @@ -0,0 +1,28 @@ + +separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "xx a b c") +if (out) + message (SEND_ERROR "unexpected result with nonexistent program") +endif() + +set (TEST_EXE_DIR "${CMAKE_CURRENT_BINARY_DIR}/TestExe") +file(MAKE_DIRECTORY "${TEST_EXE_DIR}") +file(COPY "${CMAKE_COMMAND}" DESTINATION "${TEST_EXE_DIR}") +get_filename_component (cmake_exe "${CMAKE_COMMAND}" NAME) + +set (ENV{PATH} "${TEST_EXE_DIR}") + +separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "${cmake_exe} a b c") +list (LENGTH out length) +if (length EQUAL 0) + message(FATAL_ERROR "existent program not found") +endif() +if (NOT length EQUAL 4) + message(FATAL_ERROR "unexpected arguments") +endif() +list(POP_FRONT out cmake) +if (NOT cmake STREQUAL "${TEST_EXE_DIR}/${cmake_exe}") + message (SEND_ERROR "bad path for program: '${cmake}' instead of '${TEST_EXE_DIR}/${cmake_exe}'") +endif() +if (NOT out STREQUAL "a;b;c") + message (SEND_ERROR "bad path for args: '${out}' instead of 'a;b;c'") +endif() diff --git a/Tests/RunCMake/separate_arguments/ProgramOnly-result.txt b/Tests/RunCMake/separate_arguments/ProgramOnly-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/ProgramOnly-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/separate_arguments/ProgramOnly-stderr.txt b/Tests/RunCMake/separate_arguments/ProgramOnly-stderr.txt new file mode 100644 index 000000000..e34ca4c85 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/ProgramOnly-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at ProgramOnly.cmake:[0-9]+ \(separate_arguments\): + separate_arguments missing required option: 'UNIX_COMMAND' or + 'WINDOWS_COMMAND' or 'NATIVE_COMMAND' +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/separate_arguments/ProgramOnly.cmake b/Tests/RunCMake/separate_arguments/ProgramOnly.cmake new file mode 100644 index 000000000..cc21d2ba1 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/ProgramOnly.cmake @@ -0,0 +1,2 @@ + +separate_arguments (var PROGRAM arg) diff --git a/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake b/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake index 07951bb59..3c02c49fa 100644 --- a/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake +++ b/Tests/RunCMake/separate_arguments/RunCMakeTest.cmake @@ -1,7 +1,15 @@ include(RunCMake) +run_cmake(MultipleCommands) +run_cmake(MultipleArguments) +run_cmake(ProgramOnly) +run_cmake(SeparateArgsOnly) + run_cmake(EmptyCommand) run_cmake(PlainCommand) run_cmake(UnixCommand) run_cmake(WindowsCommand) run_cmake(NativeCommand) + +run_cmake(ProgramCommand) +run_cmake(ProgramCommandWithSeparateArgs) diff --git a/Tests/RunCMake/separate_arguments/SeparateArgsOnly-result.txt b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/separate_arguments/SeparateArgsOnly-stderr.txt b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-stderr.txt new file mode 100644 index 000000000..e87b1cb2b --- /dev/null +++ b/Tests/RunCMake/separate_arguments/SeparateArgsOnly-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at SeparateArgsOnly.cmake:[0-9]+ \(separate_arguments\): + separate_arguments `SEPARATE_ARGS` option requires `PROGRAM' option +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/separate_arguments/SeparateArgsOnly.cmake b/Tests/RunCMake/separate_arguments/SeparateArgsOnly.cmake new file mode 100644 index 000000000..876fd7cfc --- /dev/null +++ b/Tests/RunCMake/separate_arguments/SeparateArgsOnly.cmake @@ -0,0 +1,2 @@ + +separate_arguments (var UNIX_COMMAND SEPARATE_ARGS arg) diff --git a/Tests/RunCMake/separate_arguments/UnixCommand.cmake b/Tests/RunCMake/separate_arguments/UnixCommand.cmake index 0b5767ac5..c56cd632d 100644 --- a/Tests/RunCMake/separate_arguments/UnixCommand.cmake +++ b/Tests/RunCMake/separate_arguments/UnixCommand.cmake @@ -6,3 +6,8 @@ if(NOT "${unix_out}" STREQUAL "${unix_exp}") message(FATAL_ERROR "separate_arguments unix-style failed. " "Expected\n [${unix_exp}]\nbut got\n [${unix_out}]\n") endif() + +separate_arguments(empty_out UNIX_COMMAND) +if(NOT empty_out STREQUAL "") + message(FATAL_ERROR "separate_arguments unix-style failed on no arguments") +endif() diff --git a/Tests/RunCMake/separate_arguments/WindowsCommand.cmake b/Tests/RunCMake/separate_arguments/WindowsCommand.cmake index 86aa14ad0..cd0749487 100644 --- a/Tests/RunCMake/separate_arguments/WindowsCommand.cmake +++ b/Tests/RunCMake/separate_arguments/WindowsCommand.cmake @@ -6,3 +6,8 @@ if(NOT "${windows_out}" STREQUAL "${windows_exp}") message(FATAL_ERROR "separate_arguments windows-style failed. " "Expected\n [${windows_exp}]\nbut got\n [${windows_out}]\n") endif() + +separate_arguments(empty_out WINDOWS_COMMAND) +if(NOT empty_out STREQUAL "") + message(FATAL_ERROR "separate_arguments windows-style failed on no arguments") +endif() diff --git a/Tests/RunCMake/string/CMakeLists.txt b/Tests/RunCMake/string/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/string/CMakeLists.txt +++ b/Tests/RunCMake/string/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/string/JSON.cmake b/Tests/RunCMake/string/JSON.cmake new file mode 100644 index 000000000..ab4194d26 --- /dev/null +++ b/Tests/RunCMake/string/JSON.cmake @@ -0,0 +1,342 @@ +function(assert_strequal actual expected) + if(NOT expected STREQUAL actual) + message(SEND_ERROR "Output:\n${actual}\nDid not match expected:\n${expected}\n") + endif() +endfunction() + +function(assert_strequal_error actual expected error) + if(error) + message(SEND_ERROR "Unexpected error: ${error}") + endif() + assert_strequal("${actual}" "${expected}") +endfunction() + +function(assert_json_equal error actual expected) + if(error) + message(SEND_ERROR "Unexpected error: ${error}") + endif() + string(JSON eql EQUAL "${actual}" "${expected}") + if(NOT eql) + message(SEND_ERROR "Expected equality got\n ${actual}\n expected\n${expected}") + endif() +endfunction() + +# test EQUAL +string(JSON result EQUAL +[=[ {"foo":"bar"} ]=] +[=[ +{ +"foo": "bar" +} +]=]) +if(NOT result) + message(SEND_ERROR "Expected ON got ${result}") +endif() + +string(JSON result EQUAL +[=[ {"foo":"bar"} ]=] +[=[ +{ +"foo1": "bar" +} +]=]) +if(result) + message(SEND_ERROR "Expected OFF got ${result}") +endif() + + + +set(json1 [=[ +{ + "foo" : "bar", + "array" : [5, "val", {"some": "other"}, null], + "types" : { + "null" : null, + "number" : 5, + "string" : "foo", + "boolean" : false, + "array" : [1,2,3], + "object" : {} + }, + "values" : { + "null" : null, + "number" : 5, + "string" : "foo", + "false" : false, + "true" : true + }, + "special" : { + "foo;bar" : "value1", + ";" : "value2", + "semicolon" : ";", + "list" : ["one", "two;three", "four"], + "quote" : "\"", + "\"" : "quote", + "backslash" : "\\", + "\\" : "backslash", + "slash" : "\/", + "\/" : "slash", + "newline" : "\n", + "\n" : "newline", + "return" : "\r", + "\r" : "return", + "tab" : "\t", + "\t" : "tab", + "backspace" : "\b", + "\b" : "backspace", + "formfeed" : "\f", + "\f" : "formfeed" + } +} +]=]) + +string(JSON result GET "${json1}" foo) +assert_strequal("${result}" bar) +string(JSON result GET "${json1}" array 0) +assert_strequal("${result}" 5) +string(JSON result GET "${json1}" array 1) +assert_strequal("${result}" val) +string(JSON result GET "${json1}" array 2 some) +assert_strequal("${result}" other) + +string(JSON result GET "${json1}" values null) +assert_strequal("${result}" "") +string(JSON result GET "${json1}" values number) +assert_strequal("${result}" 5) +string(JSON result GET "${json1}" values string) +assert_strequal("${result}" "foo") +string(JSON result GET "${json1}" values true) +assert_strequal("${result}" "ON") +if(NOT result) + message(SEND_ERROR "Output did not match expected: TRUE actual: ${result}") +endif() +string(JSON result GET "${json1}" values false) +assert_strequal("${result}" "OFF") +if(result) + message(SEND_ERROR "Output did not match expected: FALSE actual: ${result}") +endif() + +string(JSON result ERROR_VARIABLE error GET "${json1}" foo) +assert_strequal_error("${result}" "bar" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" notThere) +assert_strequal("${result}" "notThere-NOTFOUND") +assert_strequal("${error}" "member 'notThere' not found") + +string(JSON result ERROR_VARIABLE error GET "${json1}" 0) +assert_strequal("${result}" "0-NOTFOUND") +assert_strequal("${error}" "member '0' not found") + +string(JSON result ERROR_VARIABLE error GET "${json1}" array 10) +assert_strequal("${result}" "array-10-NOTFOUND") +assert_strequal("${error}" "expected an index less then 4 got '10'") + +string(JSON result ERROR_VARIABLE error GET "${json1}" array 2 some notThere) +assert_strequal("${result}" "array-2-some-notThere-NOTFOUND") +assert_strequal("${error}" "invalid path 'array 2 some notThere', need element of OBJECT or ARRAY type to lookup 'notThere' got STRING") + +# special chars +string(JSON result ERROR_VARIABLE error GET "${json1}" special "foo;bar") +assert_strequal_error("${result}" "value1" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special ";") +assert_strequal_error("${result}" "value2" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special semicolon) +assert_strequal_error("${result}" ";" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" special list 1) +assert_strequal_error("${result}" "two;three" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}") +assert_json_equal("${error}" "${result}" "${json1}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" array) +assert_json_equal("${error}" "${result}" [=[ [5, "val", {"some": "other"}, null] ]=]) + +string(JSON result ERROR_VARIABLE error GET "${json1}" special quote) +assert_strequal_error("${result}" "\"" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special "\"") +assert_strequal_error("${result}" "quote" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" special backslash) +assert_strequal_error("${result}" "\\" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special "\\") +assert_strequal_error("${result}" "backslash" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" special slash) +assert_strequal_error("${result}" "/" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special "/") +assert_strequal_error("${result}" "slash" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" special newline) +assert_strequal_error("${result}" "\n" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special "\n") +assert_strequal_error("${result}" "newline" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" special return) +assert_strequal_error("${result}" "\r" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special "\r") +assert_strequal_error("${result}" "return" "${error}") + +string(JSON result ERROR_VARIABLE error GET "${json1}" special tab) +assert_strequal_error("${result}" "\t" "${error}") +string(JSON result ERROR_VARIABLE error GET "${json1}" special "\t") +assert_strequal_error("${result}" "tab" "${error}") + +file(READ ${CMAKE_CURRENT_LIST_DIR}/json/unicode.json unicode) +string(JSON char ERROR_VARIABLE error GET "${unicode}" backspace) +string(JSON result ERROR_VARIABLE error GET "${unicode}" "${char}") +assert_strequal_error("${result}" "backspace" "${error}") + +file(READ ${CMAKE_CURRENT_LIST_DIR}/json/unicode.json unicode) +string(JSON char ERROR_VARIABLE error GET "${unicode}" backspace) +string(JSON result ERROR_VARIABLE error GET "${unicode}" "${char}") +assert_strequal_error("${result}" "backspace" "${error}") + +string(JSON char ERROR_VARIABLE error GET "${unicode}" formfeed) +string(JSON result ERROR_VARIABLE error GET "${unicode}" "${char}") +assert_strequal_error("${result}" "formfeed" "${error}") + +string(JSON char ERROR_VARIABLE error GET "${unicode}" datalinkescape) +string(JSON result ERROR_VARIABLE error GET "${unicode}" "${char}") +assert_strequal_error("${result}" "datalinkescape" "${error}") + +# Test TYPE +string(JSON result TYPE "${json1}" types null) +assert_strequal("${result}" NULL) +string(JSON result TYPE "${json1}" types number) +assert_strequal("${result}" NUMBER) +string(JSON result TYPE "${json1}" types string) +assert_strequal("${result}" STRING) +string(JSON result TYPE "${json1}" types boolean) +assert_strequal("${result}" BOOLEAN) +string(JSON result TYPE "${json1}" types array) +assert_strequal("${result}" ARRAY) +string(JSON result TYPE "${json1}" types object) +assert_strequal("${result}" OBJECT) + +# Test LENGTH +string(JSON result ERROR_VARIABLE error LENGTH "${json1}") +assert_strequal("${result}" 5) +if(error) + message(SEND_ERROR "Unexpected error: ${error}") +endif() + +string(JSON result ERROR_VARIABLE error LENGTH "${json1}" array) +assert_strequal("${result}" 4) +if(error) + message(SEND_ERROR "Unexpected error: ${error}") +endif() + +string(JSON result ERROR_VARIABLE error LENGTH "${json1}" foo) +assert_strequal("${result}" "foo-NOTFOUND") +assert_strequal("${error}" "LENGTH needs to be called with an element of type ARRAY or OBJECT, got STRING") + +# Test MEMBER +string(JSON result ERROR_VARIABLE error MEMBER "${json1}" values 2) +assert_strequal("${result}" "number") +if(error) + message(SEND_ERROR "Unexpected error: ${error}") +endif() + +string(JSON result ERROR_VARIABLE error MEMBER "${json1}" values 100) +assert_strequal("${result}" "values-100-NOTFOUND") +assert_strequal("${error}" "expected an index less then 5 got '100'") + +# Test length loops +string(JSON arrayLength ERROR_VARIABLE error LENGTH "${json1}" types array) +if(error) + message(SEND_ERROR "Unexpected error: ${error}") +endif() +set(values "") +math(EXPR arrayLength "${arrayLength}-1") +foreach(index RANGE ${arrayLength}) + string(JSON value ERROR_VARIABLE error GET "${json1}" types array ${index}) + if(error) + message(SEND_ERROR "Unexpected error: ${error}") + endif() + list(APPEND values "${value}") +endforeach() +assert_strequal("${values}" "1;2;3") + +string(JSON valuesLength ERROR_VARIABLE error LENGTH "${json1}" values) +if(error) + message(SEND_ERROR "Unexpected error: ${error}") +endif() +set(values "") +set(members "") +math(EXPR valuesLength "${valuesLength}-1") +foreach(index RANGE ${valuesLength}) + string(JSON member ERROR_VARIABLE error MEMBER "${json1}" values ${index}) + if(error) + message(SEND_ERROR "Unexpected error: ${error}") + endif() + string(JSON value ERROR_VARIABLE error GET "${json1}" values ${member}) + if(error) + message(SEND_ERROR "Unexpected error: ${error}") + endif() + + list(APPEND members "${member}") + list(APPEND values "${value}") +endforeach() +assert_strequal("${members}" "false;null;number;string;true") +assert_strequal("${values}" "OFF;;5;foo;ON") + +# Test REMOVE +set(json2 [=[{ + "foo" : "bar", + "array" : [5, "val", {"some": "other"}, null] +}]=]) +string(JSON result ERROR_VARIABLE error REMOVE ${json2} foo) +assert_json_equal("${error}" "${result}" +[=[{ + "array" : [5, "val", {"some": "other"}, null] +}]=]) + +string(JSON result ERROR_VARIABLE error REMOVE ${json2} array 1) +assert_json_equal("${error}" "${result}" +[=[{ + "foo" : "bar", + "array" : [5, {"some": "other"}, null] +}]=]) + +string(JSON result ERROR_VARIABLE error REMOVE ${json2} array 100) +assert_strequal("${result}" "array-100-NOTFOUND") +assert_strequal("${error}" "expected an index less then 4 got '100'") + +# Test SET +string(JSON result ERROR_VARIABLE error SET ${json2} new 5) +assert_json_equal("${error}" "${result}" +[=[{ + "foo" : "bar", + "array" : [5, "val", {"some": "other"}, null], + "new" : 5 +}]=]) + +string(JSON result ERROR_VARIABLE error SET ${json2} new [=[ {"obj" : false} ]=]) +assert_json_equal("${error}" "${result}" +[=[{ + "foo" : "bar", + "array" : [5, "val", {"some": "other"}, null], + "new" : {"obj" : false} +}]=]) + +string(JSON result ERROR_VARIABLE error SET ${json2} array 0 6) +assert_json_equal("${error}" "${result}" +[=[{ + "foo" : "bar", + "array" : [6, "val", {"some": "other"}, null] +}]=]) + +string(JSON result ERROR_VARIABLE error SET ${json2} array 5 [["append"]]) +assert_json_equal("${error}" "${result}" +[=[{ + "foo" : "bar", + "array" : [5, "val", {"some": "other"}, null, "append"] +}]=]) + +string(JSON result ERROR_VARIABLE error SET ${json2} array 100 [["append"]]) +assert_json_equal("${error}" "${result}" +[=[{ + "foo" : "bar", + "array" : [5, "val", {"some": "other"}, null, "append"] +}]=]) diff --git a/Tests/RunCMake/string/JSONNoArgs-result.txt b/Tests/RunCMake/string/JSONNoArgs-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/string/JSONNoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/JSONNoArgs-stderr.txt b/Tests/RunCMake/string/JSONNoArgs-stderr.txt new file mode 100644 index 000000000..426735ac4 --- /dev/null +++ b/Tests/RunCMake/string/JSONNoArgs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at JSONNoArgs.cmake:1 \(string\): + string sub-command JSON missing out-var argument. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/JSONNoArgs.cmake b/Tests/RunCMake/string/JSONNoArgs.cmake new file mode 100644 index 000000000..4463fe4a2 --- /dev/null +++ b/Tests/RunCMake/string/JSONNoArgs.cmake @@ -0,0 +1 @@ +string(JSON) diff --git a/Tests/RunCMake/string/JSONNoJson-result.txt b/Tests/RunCMake/string/JSONNoJson-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/string/JSONNoJson-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/JSONNoJson-stderr.txt b/Tests/RunCMake/string/JSONNoJson-stderr.txt new file mode 100644 index 000000000..26804dfeb --- /dev/null +++ b/Tests/RunCMake/string/JSONNoJson-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at JSONNoJson.cmake:1 \(string\): + string sub-command JSON missing json string argument. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/JSONNoJson.cmake b/Tests/RunCMake/string/JSONNoJson.cmake new file mode 100644 index 000000000..4f819f16e --- /dev/null +++ b/Tests/RunCMake/string/JSONNoJson.cmake @@ -0,0 +1 @@ +string(JSON var GET) diff --git a/Tests/RunCMake/string/JSONOneArg-result.txt b/Tests/RunCMake/string/JSONOneArg-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/string/JSONOneArg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/JSONOneArg-stderr.txt b/Tests/RunCMake/string/JSONOneArg-stderr.txt new file mode 100644 index 000000000..282139cf1 --- /dev/null +++ b/Tests/RunCMake/string/JSONOneArg-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at JSONOneArg.cmake:1 \(string\): + string sub-command JSON missing mode argument. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/JSONOneArg.cmake b/Tests/RunCMake/string/JSONOneArg.cmake new file mode 100644 index 000000000..143f9ca1a --- /dev/null +++ b/Tests/RunCMake/string/JSONOneArg.cmake @@ -0,0 +1 @@ +string(JSON var) diff --git a/Tests/RunCMake/string/JSONWrongMode-result.txt b/Tests/RunCMake/string/JSONWrongMode-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/string/JSONWrongMode-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/JSONWrongMode-stderr.txt b/Tests/RunCMake/string/JSONWrongMode-stderr.txt new file mode 100644 index 000000000..c70991b27 --- /dev/null +++ b/Tests/RunCMake/string/JSONWrongMode-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at JSONWrongMode.cmake:1 \(string\): + string sub-command JSON got an invalid mode 'FOO', expected one of GET, + GET_ARRAY, TYPE, MEMBER, MEMBERS, LENGTH, REMOVE, SET, EQUAL. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/JSONWrongMode.cmake b/Tests/RunCMake/string/JSONWrongMode.cmake new file mode 100644 index 000000000..7301f7a88 --- /dev/null +++ b/Tests/RunCMake/string/JSONWrongMode.cmake @@ -0,0 +1 @@ +string(JSON var FOO) diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index bb7cb174e..ff0bb51a3 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -1,5 +1,12 @@ include(RunCMake) +run_cmake(JSON) + +run_cmake(JSONNoJson) +run_cmake(JSONWrongMode) +run_cmake(JSONOneArg) +run_cmake(JSONNoArgs) + run_cmake(Append) run_cmake(AppendNoArgs) diff --git a/Tests/RunCMake/string/json/unicode.json b/Tests/RunCMake/string/json/unicode.json new file mode 100644 index 000000000..86fd232c4 --- /dev/null +++ b/Tests/RunCMake/string/json/unicode.json @@ -0,0 +1,8 @@ +{ + "backspace" : "\b", + "\b" : "backspace", + "formfeed" : "\f", + "\f" : "formfeed" , + "datalinkescape" : "\u0010", + "\u0010" : "datalinkescape" +} diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake index 2e9cba82c..6c7254641 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake @@ -1,4 +1,4 @@ - +cmake_minimum_required(VERSION 2.8.11) project(CMP0022-WARN) add_library(foo SHARED empty_vs6_1.cpp) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake index fcc8da03e..dfdf70b27 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake @@ -1,4 +1,4 @@ - +cmake_minimum_required(VERSION 2.8.11) project(CMP0022-WARN) add_library(foo SHARED empty_vs6_1.cpp) diff --git a/Tests/RunCMake/target_link_libraries/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMakeLists.txt index 8f85fbf54..667561ea7 100644 --- a/Tests/RunCMake/target_link_libraries/CMakeLists.txt +++ b/Tests/RunCMake/target_link_libraries/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake index bab537edb..d6ddfaefb 100644 --- a/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake +++ b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake @@ -3,7 +3,8 @@ set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") add_library(imported SHARED IMPORTED) set_target_properties(imported PROPERTIES - IMPORTED_LOCATION "imported" + IMPORTED_LOCATION "imported${CMAKE_SHARED_LIBRARY_SUFFIX}" + IMPORTED_IMPLIB "imported${CMAKE_IMPORT_LIBRARY_SUFFIX}" IMPORTED_LINK_DEPENDENT_LIBRARIES "/path/to/libSharedDep.so" ) add_executable(empty empty.c) diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake index 9b97918a5..9f86b1850 100644 --- a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake +++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0022 NEW) enable_language(C) add_library(foo STATIC empty.c) add_library(not_exported STATIC empty.c) diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake index 7122ae91e..20ec43825 100644 --- a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake +++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0022 NEW) enable_language(C) add_library(foo STATIC empty.c) target_link_libraries(foo PRIVATE not_a_target) diff --git a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake index f52fa30bc..608f47b6f 100644 --- a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake +++ b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake @@ -1,4 +1,5 @@ enable_language(C) add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) +set_target_properties(UnknownImportedGlobal PROPERTIES IMPORTED_LOCATION "unknown.${CMAKE_SHARED_LIBRARY_SUFFIX}") add_library(mylib empty.c) target_link_libraries(mylib UnknownImportedGlobal) diff --git a/Tests/RunCMake/try_compile/CMP0056.cmake b/Tests/RunCMake/try_compile/CMP0056.cmake index e8d3d4a3b..2ab79d5dd 100644 --- a/Tests/RunCMake/try_compile/CMP0056.cmake +++ b/Tests/RunCMake/try_compile/CMP0056.cmake @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.1) enable_language(C) set(obj "${CMAKE_C_OUTPUT_EXTENSION}") if(BORLAND) diff --git a/Tests/RunCMake/try_compile/CMakeLists.txt b/Tests/RunCMake/try_compile/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/try_compile/CMakeLists.txt +++ b/Tests/RunCMake/try_compile/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/try_compile/CudaStandard-stderr.txt b/Tests/RunCMake/try_compile/CudaStandard-stderr.txt index 3c6bdf6b7..bcf95d546 100644 --- a/Tests/RunCMake/try_compile/CudaStandard-stderr.txt +++ b/Tests/RunCMake/try_compile/CudaStandard-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at .*/Tests/RunCMake/try_compile/CudaStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\): - CUDA_STANDARD is set to invalid value '3' + CUDA_STANDARD is set to invalid value '4' + CMake Error at CudaStandard.cmake:[0-9]+ \(try_compile\): Failed to generate test project build system. diff --git a/Tests/RunCMake/try_compile/CudaStandard.cmake b/Tests/RunCMake/try_compile/CudaStandard.cmake index 96da422c6..a230424bf 100644 --- a/Tests/RunCMake/try_compile/CudaStandard.cmake +++ b/Tests/RunCMake/try_compile/CudaStandard.cmake @@ -1,7 +1,7 @@ enable_language(CUDA) try_compile(result ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.cu - CUDA_STANDARD 3 + CUDA_STANDARD 4 OUTPUT_VARIABLE out ) message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/ISPCDuplicateTarget-stderr.txt b/Tests/RunCMake/try_compile/ISPCDuplicateTarget-stderr.txt new file mode 100644 index 000000000..7dcb1de78 --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCDuplicateTarget-stderr.txt @@ -0,0 +1 @@ +.*Error: Can't compile to multiple variants of avx512skx target!.* diff --git a/Tests/RunCMake/try_compile/ISPCDuplicateTarget.cmake b/Tests/RunCMake/try_compile/ISPCDuplicateTarget.cmake new file mode 100644 index 000000000..6d29069cd --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCDuplicateTarget.cmake @@ -0,0 +1,8 @@ +enable_language(ISPC) +set(CMAKE_ISPC_INSTRUCTION_SETS avx512skx-i32x16 + avx512skx-i32x16) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.ispc + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja-result.txt b/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja-stderr.txt b/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja-stderr.txt new file mode 100644 index 000000000..99248bfea --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja-stderr.txt @@ -0,0 +1 @@ +.*ninja: error: .* multiple rules generate.*src.ispc_avx512skx.o.* diff --git a/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja.cmake b/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja.cmake new file mode 100644 index 000000000..7f59c1451 --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCDuplicateTargetNinja.cmake @@ -0,0 +1,11 @@ +enable_language(ISPC) +set(CMAKE_ISPC_INSTRUCTION_SETS avx512skx-i32x16 + avx512skx-i32x16) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.ispc + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") +if(NOT result) + message(FATAL_ERROR "making Ninja and Ninja Multi-Config behave the same") +endif() diff --git a/Tests/RunCMake/try_compile/ISPCInvalidTarget-stderr.txt b/Tests/RunCMake/try_compile/ISPCInvalidTarget-stderr.txt new file mode 100644 index 000000000..44543addd --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCInvalidTarget-stderr.txt @@ -0,0 +1 @@ +.*Error: Incorrect targets: avxknl-i32x16.* diff --git a/Tests/RunCMake/try_compile/ISPCInvalidTarget.cmake b/Tests/RunCMake/try_compile/ISPCInvalidTarget.cmake new file mode 100644 index 000000000..c1ab6f24e --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCInvalidTarget.cmake @@ -0,0 +1,7 @@ +enable_language(ISPC) +set(CMAKE_ISPC_INSTRUCTION_SETS "avxknl-i32x16") +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.ispc + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/ISPCTargets-stderr.txt b/Tests/RunCMake/try_compile/ISPCTargets-stderr.txt new file mode 100644 index 000000000..72e0a018a --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCTargets-stderr.txt @@ -0,0 +1 @@ +.*Linking ISPC static library* diff --git a/Tests/RunCMake/try_compile/ISPCTargets-stdout.txt b/Tests/RunCMake/try_compile/ISPCTargets-stdout.txt new file mode 100644 index 000000000..a731d52b8 --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCTargets-stdout.txt @@ -0,0 +1 @@ +.*Detecting ISPC compiler ABI info - done.* diff --git a/Tests/RunCMake/try_compile/ISPCTargets.cmake b/Tests/RunCMake/try_compile/ISPCTargets.cmake new file mode 100644 index 000000000..0d3bd4369 --- /dev/null +++ b/Tests/RunCMake/try_compile/ISPCTargets.cmake @@ -0,0 +1,7 @@ +enable_language(ISPC) +set(CMAKE_ISPC_INSTRUCTION_SETS avx512knl-i32x16 avx512skx-i32x16) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.ispc + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 82c55ccb6..5b849bf8a 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -51,6 +51,15 @@ endif() if(CMake_TEST_CUDA) run_cmake(CudaStandard) endif() +if(CMake_TEST_ISPC) + run_cmake(ISPCTargets) + run_cmake(ISPCInvalidTarget) + set(ninja "") + if(RunCMake_GENERATOR MATCHES "Ninja") + set(ninja "Ninja") + endif() + run_cmake(ISPCDuplicateTarget${ninja}) +endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) run_cmake(CStandardGNU) endif() diff --git a/Tests/RunCMake/try_compile/proj/CMakeLists.txt b/Tests/RunCMake/try_compile/proj/CMakeLists.txt index 78a87c016..652f5b6be 100644 --- a/Tests/RunCMake/try_compile/proj/CMakeLists.txt +++ b/Tests/RunCMake/try_compile/proj/CMakeLists.txt @@ -1,2 +1,2 @@ -cmake_minimum_required(VERSION 2.8.10) +cmake_minimum_required(VERSION 3.3) project(TestProject NONE) diff --git a/Tests/RunCMake/try_compile/src.ispc b/Tests/RunCMake/try_compile/src.ispc new file mode 100644 index 000000000..b061f40a5 --- /dev/null +++ b/Tests/RunCMake/try_compile/src.ispc @@ -0,0 +1,4 @@ + +float func(float a, float b) { + return a + b / 2.; +} diff --git a/Tests/RunCMake/try_run/CMakeLists.txt b/Tests/RunCMake/try_run/CMakeLists.txt index e03478039..e93f0b69e 100644 --- a/Tests/RunCMake/try_run/CMakeLists.txt +++ b/Tests/RunCMake/try_run/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.0) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} C) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/variable_watch/CMakeLists.txt b/Tests/RunCMake/variable_watch/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/variable_watch/CMakeLists.txt +++ b/Tests/RunCMake/variable_watch/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/while/CMakeLists.txt b/Tests/RunCMake/while/CMakeLists.txt index 12cd3c775..74b3ff8de 100644 --- a/Tests/RunCMake/while/CMakeLists.txt +++ b/Tests/RunCMake/while/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/SetLang/CMakeLists.txt b/Tests/SetLang/CMakeLists.txt index 9de4fc61d..616421ed5 100644 --- a/Tests/SetLang/CMakeLists.txt +++ b/Tests/SetLang/CMakeLists.txt @@ -15,3 +15,10 @@ if(CMAKE_GENERATOR MATCHES "^Visual Studio" AND "x${CMAKE_C_COMPILER_ID}" STREQU add_library(stay stay_c.c stay_cxx.cxx) set_property(TARGET stay PROPERTY COMPILE_OPTIONS "-TP") endif() + +if((CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang|MSVC|Borland|Embarcadero|Intel|TI|XL)")) + add_library(zoom zoom.zzz) + set_source_files_properties(zoom.zzz PROPERTIES LANGUAGE CXX) + target_link_libraries(SetLang zoom) + target_compile_definitions(SetLang PRIVATE WITH_ZOOM) +endif() diff --git a/Tests/SetLang/bar.c b/Tests/SetLang/bar.c index b934356fa..515e8c233 100644 --- a/Tests/SetLang/bar.c +++ b/Tests/SetLang/bar.c @@ -1,10 +1,22 @@ #include <stdio.h> int foo(); + +#ifdef WITH_ZOOM +int zoom(); +#endif + class A { public: - A() { this->i = foo(); } + A() + { + this->i = foo(); +#ifdef WITH_ZOOM + i += zoom(); + i -= zoom(); +#endif + } int i; }; diff --git a/Tests/SetLang/zoom.zzz b/Tests/SetLang/zoom.zzz new file mode 100644 index 000000000..a0c8899b6 --- /dev/null +++ b/Tests/SetLang/zoom.zzz @@ -0,0 +1,7 @@ +int zoom() +{ + int r = 10; + r++; + int ret = r + 10; + return ret; +} diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index df921d814..0c6b9382c 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -283,11 +283,15 @@ TEST_ASSERT(C_RUN_SHOULD_WORK "CHECK_C_SOURCE_RUNS() failed") CHECK_CXX_SOURCE_COMPILES("I don't build" CXX_BUILD_SHOULD_FAIL) CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" CXX_BUILD_SHOULD_WORK) +CHECK_CXX_SOURCE_COMPILES("void l(char const (&x)[2]){}; int main() { l(\"\\\\n\"); return 0;}" + CXX_BUILD_SHOULD_WORK_COMPLEX) + CHECK_CXX_SOURCE_RUNS("int main() {return 2;}" CXX_RUN_SHOULD_FAIL) CHECK_CXX_SOURCE_RUNS("int main() {return 0;}" CXX_RUN_SHOULD_WORK) TEST_FAIL(CXX_BUILD_SHOULD_FAIL "CHECK_CXX_SOURCE_COMPILES() succeeded, but should have failed") TEST_ASSERT(CXX_BUILD_SHOULD_WORK "CHECK_CXX_SOURCE_COMPILES() failed") +TEST_ASSERT(CXX_BUILD_SHOULD_WORK_COMPLEX "CHECK_CXX_SOURCE_COMPILES() failed") TEST_FAIL(CXX_RUN_SHOULD_FAIL "CHECK_CXX_SOURCE_RUNS() succeeded, but should have failed") TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed") diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index cd04a4a7c..e1502239a 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -33,6 +33,16 @@ if (CMAKE_CSharp_COMPILER) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) endif() +add_test(NAME UseSWIG.NamespaceCsharp COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/NamespaceCsharp" + "${CMake_BINARY_DIR}/Tests/UseSWIG/NamespaceCsharp" + ${build_generator_args} + --build-project TestNamespaceCsharp + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) add_test(NAME UseSWIG.BasicPython COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> @@ -159,3 +169,15 @@ add_test(NAME UseSWIG.AlternateLibraryName COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + +add_test(NAME UseSWIG.SwigSrcOUTPUT_DIR COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/SwigSrcOUTPUT_DIR" + "${CMake_BINARY_DIR}/Tests/UseSWIG/SwigSrcOUTPUT_DIR" + ${build_generator_args} + --build-project TestSwigSrcOUTPUT_DIR + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt new file mode 100644 index 000000000..51ec1b291 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.12...3.13) + +project(TestNamespaceCsharp CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +set(UseSWIG_MODULE_VERSION 2) + + +add_library(ns_example STATIC ns_example.cpp) +target_include_directories(ns_example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +set_property(SOURCE ns_example.i PROPERTY CPLUSPLUS ON) + +swig_add_library(ns_csharp TYPE SHARED LANGUAGE csharp SOURCES ns_example.i) +set_target_properties(ns_csharp PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE) + +target_link_libraries(ns_csharp PRIVATE ns_example) + +get_target_property(NS_CSHARP_SUPPORT_FILES_DIR ns_csharp SWIG_SUPPORT_FILES_DIRECTORY) + +add_test(NAME NamespaceCsharp COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_DIRECTORY=${NS_CSHARP_SUPPORT_FILES_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake") diff --git a/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake b/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake new file mode 100644 index 000000000..828d54c72 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake @@ -0,0 +1,8 @@ + +file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_DIRECTORY}" "${SUPPORT_FILES_DIRECTORY}/*") + +list(SORT files) + +if (NOT files STREQUAL "NSExample.cs;NSExamplePINVOKE.cs;ns;ns/my_class_in_namespace.cs") + message (FATAL_ERROR "Support files not correctly collected.") +endif() diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp b/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp new file mode 100644 index 000000000..a03dbad12 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.cpp @@ -0,0 +1,14 @@ +#include "ns_example.hpp" + +namespace ns { + +void my_class_in_namespace::add(int value) +{ + Sum += value; +} + +int my_class_in_namespace::get_sum() const +{ + return Sum; +} +} diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp b/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp new file mode 100644 index 000000000..65b9ab5e5 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.hpp @@ -0,0 +1,19 @@ +#pragma once + +namespace ns { + +class my_class_in_namespace +{ +public: + my_class_in_namespace() + : Sum(0) + { + } + + void add(int value); + int get_sum() const; + +private: + int Sum; +}; +} diff --git a/Tests/UseSWIG/NamespaceCsharp/ns_example.i b/Tests/UseSWIG/NamespaceCsharp/ns_example.i new file mode 100644 index 000000000..036f7cae1 --- /dev/null +++ b/Tests/UseSWIG/NamespaceCsharp/ns_example.i @@ -0,0 +1,8 @@ +%module NSExample + +%{ +#include "ns_example.hpp" +%} + +%nspace ns::my_class_in_namespace; +%include "ns_example.hpp" diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt new file mode 100644 index 000000000..fc0cf8db7 --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required(VERSION 3.12...3.19) + +project(TestSwigSrcOUTPUT_DIR CXX) + +include(CTest) + + +set(CMAKE_CXX_STANDARD 11) + + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +set(UseSWIG_MODULE_VERSION 2) + + +file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/Foo" + "${CMAKE_CURRENT_BINARY_DIR}/FooSupport" + "${CMAKE_CURRENT_BINARY_DIR}/FooFile" + "${CMAKE_CURRENT_BINARY_DIR}/Bar" + "${CMAKE_CURRENT_BINARY_DIR}/BarSupport" + "${CMAKE_CURRENT_BINARY_DIR}/BarFile") + + +set_property (SOURCE foo.i PROPERTY COMPILE_OPTIONS -namespace Foo) +set_property (SOURCE foo.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Foo") +set_property (SOURCE foo.i PROPERTY CPLUSPLUS ON) + +set_property (SOURCE bar.i PROPERTY COMPILE_OPTIONS -namespace Bar) +set_property (SOURCE bar.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Bar") +set_property (SOURCE bar.i PROPERTY CPLUSPLUS ON) + +swig_add_library(outdir_test LANGUAGE csharp SOURCES foo.i bar.i cs.cpp + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed1" + OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed2") +target_include_directories(outdir_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") +set_property(TARGET outdir_test PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON) + + +get_target_property(SUPPORT_FILES_DIRS outdir_test SWIG_SUPPORT_FILES_DIRECTORY) + +add_test(NAME SwigSrcOUTPUT_DIR COMMAND "${CMAKE_COMMAND}" "-DBASE_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}" "-DSUPPORT_FILES_DIRECTORY=${SUPPORT_FILES_DIRS}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake") + + + +set_property (SOURCE foo.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/FooSupport") +set_property (SOURCE foo.i PROPERTY OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/FooFile") + +set_property (SOURCE bar.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/BarSupport") +set_property (SOURCE bar.i PROPERTY OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/BarFile") + +swig_add_library(outfiledir_test LANGUAGE csharp SOURCES foo.i bar.i cs.cpp + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed1" + OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed2") +target_include_directories(outfiledir_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") +set_property(TARGET outfiledir_test PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON) + + +get_target_property(SUPPORT_FILES_DIRS outfiledir_test SWIG_SUPPORT_FILES_DIRECTORY) + +add_test(NAME SwigSrcOUTFILE_DIR COMMAND "${CMAKE_COMMAND}" "-DBASE_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}" "-DSUPPORT_FILES_DIRECTORY=${SUPPORT_FILES_DIRS}" -DOUTFILE_DIR=ON -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake") diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/ValidateSupportFiles.cmake b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/ValidateSupportFiles.cmake new file mode 100644 index 000000000..20240ed52 --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/ValidateSupportFiles.cmake @@ -0,0 +1,17 @@ + +foreach (support_dir IN LISTS SUPPORT_FILES_DIRECTORY) + file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${BASE_DIRECTORY}" "${support_dir}/*") + list (APPEND support_files ${files}) +endforeach() + +list(SORT support_files) + +if (OUTFILE_DIR) + set (expected_files "BarSupport/Bar.cs;BarSupport/BarPINVOKE.cs;BarSupport/Math.cs;FooSupport/Foo.cs;FooSupport/FooPINVOKE.cs;FooSupport/Math.cs") +else() + set (expected_files "Bar/Bar.cs;Bar/BarPINVOKE.cs;Bar/Math.cs;Bar/barCSHARP_wrap.cxx;Foo/Foo.cs;Foo/FooPINVOKE.cs;Foo/Math.cs;Foo/fooCSHARP_wrap.cxx") +endif() + +if (NOT support_files STREQUAL expected_files) + message (FATAL_ERROR "Support files not correctly collected.") +endif() diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.hpp b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.hpp new file mode 100644 index 000000000..26b707fce --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.hpp @@ -0,0 +1,15 @@ +#pragma once + +namespace Bar { + +class Math +{ +public: + void add(int value); + int get_sum() const; + +private: + int sum_ = 0; +}; + +} // namespace cs diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.i b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.i new file mode 100644 index 000000000..539f32a2c --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.i @@ -0,0 +1,8 @@ +%module Bar + +%{ +#include <bar.hpp> +%} + +// %nspace cs::my_class_in_namespace; +%include <bar.hpp> diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/cs.cpp b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/cs.cpp new file mode 100644 index 000000000..e4aa56261 --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/cs.cpp @@ -0,0 +1,29 @@ +#include <bar.hpp> +#include <foo.hpp> + +namespace Foo { + +void Math::add(int value) +{ + sum_ += value; +} + +int Math::get_sum() const +{ + return sum_; +} +} + +namespace Bar { + +void Math::add(int value) +{ + sum_ += value; +} + +int Math::get_sum() const +{ + return sum_; +} + +} // namespace cs diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.hpp b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.hpp new file mode 100644 index 000000000..b227463c0 --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.hpp @@ -0,0 +1,15 @@ +#pragma once + +namespace Foo { + +class Math +{ +public: + void add(int value); + int get_sum() const; + +private: + int sum_ = 0; +}; + +} // namespace cs diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.i b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.i new file mode 100644 index 000000000..5e14b04b2 --- /dev/null +++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.i @@ -0,0 +1,8 @@ +%module Foo + +%{ +#include <foo.hpp> +%} + +// %nspace cs::my_class_in_namespace; +%include <foo.hpp> diff --git a/Tests/VSNsightTegra/AndroidManifest.xml b/Tests/VSAndroid/AndroidManifest.xml index 951e8f308..951e8f308 100644 --- a/Tests/VSNsightTegra/AndroidManifest.xml +++ b/Tests/VSAndroid/AndroidManifest.xml diff --git a/Tests/VSNsightTegra/CMakeLists.txt b/Tests/VSAndroid/CMakeLists.txt index 6d74f2f85..73b1e079c 100644 --- a/Tests/VSNsightTegra/CMakeLists.txt +++ b/Tests/VSAndroid/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.3) -project(VSNsightTegra C CXX) +project(VSAndroid C CXX) set(CMAKE_ANDROID_ARCH armv7-a) set(CMAKE_ANDROID_STL_TYPE stlport_shared) diff --git a/Tests/VSNsightTegra/build.xml b/Tests/VSAndroid/build.xml index 17a2cc07b..17a2cc07b 100644 --- a/Tests/VSNsightTegra/build.xml +++ b/Tests/VSAndroid/build.xml diff --git a/Tests/VSNsightTegra/jni/first.c b/Tests/VSAndroid/jni/first.c index b9dee2754..b9dee2754 100644 --- a/Tests/VSNsightTegra/jni/first.c +++ b/Tests/VSAndroid/jni/first.c diff --git a/Tests/VSNsightTegra/jni/first.h b/Tests/VSAndroid/jni/first.h index 9dfd8b886..9dfd8b886 100644 --- a/Tests/VSNsightTegra/jni/first.h +++ b/Tests/VSAndroid/jni/first.h diff --git a/Tests/VSNsightTegra/jni/second.c b/Tests/VSAndroid/jni/second.c index 30bdc17b0..30bdc17b0 100644 --- a/Tests/VSNsightTegra/jni/second.c +++ b/Tests/VSAndroid/jni/second.c diff --git a/Tests/VSNsightTegra/proguard-android.txt b/Tests/VSAndroid/proguard-android.txt index fe73baeb5..fe73baeb5 100644 --- a/Tests/VSNsightTegra/proguard-android.txt +++ b/Tests/VSAndroid/proguard-android.txt diff --git a/Tests/VSNsightTegra/res/values/strings.xml b/Tests/VSAndroid/res/values/strings.xml index 858cdb40e..858cdb40e 100644 --- a/Tests/VSNsightTegra/res/values/strings.xml +++ b/Tests/VSAndroid/res/values/strings.xml diff --git a/Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java b/Tests/VSAndroid/src/com/example/twolibs/TwoLibs.java index ef9da01cf..ef9da01cf 100644 --- a/Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java +++ b/Tests/VSAndroid/src/com/example/twolibs/TwoLibs.java diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index 558d5de95..56e4c1d4e 100644 --- a/Tests/VSWinStorePhone/CMakeLists.txt +++ b/Tests/VSWinStorePhone/CMakeLists.txt @@ -114,7 +114,7 @@ set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets") set_property(SOURCE ${STRING_FILES} PROPERTY VS_TOOL_OVERRIDE "PRIResource") set_property(SOURCE ${DEBUG_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $<CONFIG:Debug>) set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY - VS_DEPLOYMENT_CONTENT $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>) + VS_DEPLOYMENT_CONTENT $<CONFIG:Release,RelWithDebInfo,MinSizeRel>) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS) diff --git a/Tests/VariableUnusedViaSet/CMakeLists.txt b/Tests/VariableUnusedViaSet/CMakeLists.txt deleted file mode 100644 index 0123ab221..000000000 --- a/Tests/VariableUnusedViaSet/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -set(UNUSED_VARIABLE) -# Warning should occur here -set(UNUSED_VARIABLE "Usage") -message(STATUS "${UNUSED_VARIABLE}") diff --git a/Tests/VariableUnusedViaUnset/CMakeLists.txt b/Tests/VariableUnusedViaUnset/CMakeLists.txt deleted file mode 100644 index 4b4031da3..000000000 --- a/Tests/VariableUnusedViaUnset/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# NOTE: Changing lines in here changes the test results since the first -# instance shouldn't warn, but the second should and they have the same message - -# A warning should NOT be issued for this line: -set(UNUSED_VARIABLE) -# Warning should occur here: -set(UNUSED_VARIABLE) -message(STATUS "${UNUSED_VARIABLE}") diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt index d0b07ea1c..a07065123 100644 --- a/Tests/XCTest/CMakeLists.txt +++ b/Tests/XCTest/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.1) project(XCTest C) enable_testing() +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + find_package(XCTest REQUIRED) # Framework diff --git a/Tests/XCTest/StaticLibExample/StaticLibExample.c b/Tests/XCTest/StaticLibExample/StaticLibExample.c index b198f80f3..8d16eb596 100644 --- a/Tests/XCTest/StaticLibExample/StaticLibExample.c +++ b/Tests/XCTest/StaticLibExample/StaticLibExample.c @@ -1,6 +1,6 @@ #include "StaticLibExample.h" -int FourtyFour() +int FourtyFour(void) { return 44; } diff --git a/Tests/XCTest/StaticLibExample/StaticLibExample.h b/Tests/XCTest/StaticLibExample/StaticLibExample.h index 147a909aa..88695b1c8 100644 --- a/Tests/XCTest/StaticLibExample/StaticLibExample.h +++ b/Tests/XCTest/StaticLibExample/StaticLibExample.h @@ -1 +1 @@ -int FourtyFour(); +int FourtyFour(void); |