diff options
Diffstat (limited to 'Tests')
112 files changed, 2370 insertions, 598 deletions
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 5c14de2..4454f49 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -31,6 +31,7 @@ set(CMakeLib_TESTS testCMExtAlgorithm.cxx testCMExtEnumSet.cxx testList.cxx + testCMakePath.cxx ) if(CMake_ENABLE_DEBUGGER) list(APPEND CMakeLib_TESTS @@ -63,10 +64,15 @@ if(WIN32) endif() configure_file(testXMLParser.h.in testXMLParser.h @ONLY) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testUVProcessChainInput.txt" "HELLO WORLD!") create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) -target_link_libraries(CMakeLibTests CMakeLib CTestLib) +target_link_libraries(CMakeLibTests PRIVATE CTestLib CMakeLib) +if(CMake_BUILD_PCH) + target_precompile_headers(CMakeLibTests PRIVATE "<iostream>" "<cm3p/uv.h>") + target_compile_definitions(CMakeLibTests PRIVATE "NOMINMAX") +endif() set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "") set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "") diff --git a/Tests/CMakeLib/testCMakePath.cxx b/Tests/CMakeLib/testCMakePath.cxx new file mode 100644 index 0000000..aa17e50 --- /dev/null +++ b/Tests/CMakeLib/testCMakePath.cxx @@ -0,0 +1,441 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <iostream> +#include <string> +#include <utility> + +#include <cm/string_view> +#include <cmext/string_view> + +#include "cmCMakePath.h" + +namespace { + +void checkResult(bool success) +{ + if (!success) { + std::cout << " => failed"; + } + std::cout << std::endl; +} + +bool testConstructors() +{ + std::cout << "testConstructors()"; + + bool result = true; + + { + cmCMakePath path; + if (!path.String().empty() || path != cmCMakePath{}) { + result = false; + } + } + { + cmCMakePath path{ "aa/bb" }; + if (path.String() != "aa/bb") { + result = false; + } + } + { + std::string s{ "aa/bb" }; + cmCMakePath path{ s }; + if (path.String() != "aa/bb") { + result = false; + } + } + { + cmCMakePath path{ "aa/bb"_s }; + if (path.String() != "aa/bb") { + result = false; + } + } + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2("aa/bb"_s); + + if (path1 != path2) { + result = false; + } + if (path1.String() != "aa/bb") { + result = false; + } + if (path1.String() != path2.String()) { + result = false; + } + } + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ path1 }; + + if (path1 != path2) { + result = false; + } + if (path1.String() != "aa/bb") { + result = false; + } + if (path1.String() != path2.String()) { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testAssign() +{ + std::cout << "testAssign()"; + + bool result = true; + + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 = path1; + if (path1 != path2) { + result = false; + } + if (path1.String() != "aa/bb") { + result = false; + } + if (path1.String() != path2.String()) { + result = false; + } + } + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 = std::move(path1); + if (path2.String() != "aa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 = path1; + if (path2.String() != "aa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 = std::move(path1); + if (path2.String() != "aa/bb") { + result = false; + } + } + { + cm::string_view path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 = path1; + if (path2.String() != "aa/bb") { + result = false; + } + } + { + char path1[] = "aa/bb"; + cmCMakePath path2{ "cc/dd" }; + + path2 = path1; + if (path2.String() != "aa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Assign(path1); + if (path2.String() != path1) { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Assign(std::move(path1)); + if (path2.String() != "aa/bb") { + result = false; + } + } + { + cm::string_view path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Assign(path1); + if (path2.String() != path1) { + result = false; + } + } + { + char path1[] = "aa/bb"; + cmCMakePath path2{ "cc/dd" }; + + path2.Assign(path1); + if (path2.String() != path1) { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testConcat() +{ + std::cout << "testConcat()"; + + bool result = true; + + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 += path1; + + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 += std::move(path1); + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 += path1; + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 += std::move(path1); + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + cm::string_view path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 += path1; + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + char path1[] = "aa/bb"; + cmCMakePath path2{ "cc/dd" }; + + path2 += path1; + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Concat(path1); + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Concat(path1); + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Concat(std::move(path1)); + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + cm::string_view path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Concat(path1); + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + { + char path1[] = "aa/bb"; + cmCMakePath path2{ "cc/dd" }; + + path2.Concat(path1); + if (path2.String() != "cc/ddaa/bb") { + result = false; + } + } + + checkResult(result); + + return result; +} + +bool testAppend() +{ + std::cout << "testAppend()"; + + bool result = true; + + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 /= path1; + + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 /= std::move(path1); + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 /= path1; + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 /= std::move(path1); + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + cm::string_view path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2 /= path1; + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + char path1[] = "aa/bb"; + cmCMakePath path2{ "cc/dd" }; + + path2 /= path1; + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + cmCMakePath path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Append(path1); + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Append(path1); + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + std::string path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Append(std::move(path1)); + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + cm::string_view path1{ "aa/bb" }; + cmCMakePath path2{ "cc/dd" }; + + path2.Append(path1); + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + { + char path1[] = "aa/bb"; + cmCMakePath path2{ "cc/dd" }; + + path2.Append(path1); + if (path2.String() != "cc/dd/aa/bb") { + result = false; + } + } + + checkResult(result); + + return result; +} +} + +int testCMakePath(int /*unused*/, char* /*unused*/[]) +{ + int result = 0; + + if (!testConstructors()) { + result = 1; + } + if (!testAssign()) { + result = 1; + } + if (!testConcat()) { + result = 1; + } + if (!testAppend()) { + result = 1; + } + + return result; +} diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx index 7027689..7630aa0 100644 --- a/Tests/CMakeLib/testUVProcessChain.cxx +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -1,5 +1,6 @@ #include <algorithm> #include <csignal> +#include <cstdio> #include <functional> #include <iostream> #include <sstream> @@ -16,11 +17,11 @@ #include "cmStringAlgorithms.h" #include "cmUVHandlePtr.h" #include "cmUVProcessChain.h" +#include "cmUVStream.h" #include "cmUVStreambuf.h" struct ExpectedStatus { - bool Finished; bool MatchExitStatus; bool MatchTermSignal; cmUVProcessChain::Status Status; @@ -28,38 +29,6 @@ struct ExpectedStatus std::string ExceptionString; }; -static const std::vector<ExpectedStatus> status1 = { - { false, false, false, { 0, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, - { false, false, false, { 0, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, - { false, false, false, { 0, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, -}; - -static const std::vector<ExpectedStatus> status2 = { - { true, true, true, { 0, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, - { false, false, false, { 0, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, - { false, false, false, { 0, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, -}; - -static const std::vector<ExpectedStatus> status3 = { - { true, true, true, { 0, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, - { true, true, true, { 1, 0 }, cmUVProcessChain::ExceptionCode::None, "" }, -#ifdef _WIN32 - { true, - true, - true, - { STATUS_ACCESS_VIOLATION, 0 }, - cmUVProcessChain::ExceptionCode::Fault, - "Access violation" }, -#else - { true, - false, - true, - { 0, SIGABRT }, - cmUVProcessChain::ExceptionCode::Other, - "Subprocess aborted" }, -#endif -}; - static const char* ExceptionCodeToString(cmUVProcessChain::ExceptionCode code) { switch (code) { @@ -73,6 +42,8 @@ static const char* ExceptionCodeToString(cmUVProcessChain::ExceptionCode code) return "Interrupt"; case cmUVProcessChain::ExceptionCode::Numerical: return "Numerical"; + case cmUVProcessChain::ExceptionCode::Spawn: + return "Spawn"; case cmUVProcessChain::ExceptionCode::Other: return "Other"; default: @@ -83,9 +54,10 @@ static const char* ExceptionCodeToString(cmUVProcessChain::ExceptionCode code) bool operator==(const cmUVProcessChain::Status* actual, const ExpectedStatus& expected) { - if (!expected.Finished) { - return !actual; - } else if (!actual) { + if (expected.Status.SpawnResult != actual->SpawnResult) { + return false; + } + if (expected.Status.Finished != actual->Finished) { return false; } if (expected.MatchExitStatus && @@ -96,7 +68,7 @@ bool operator==(const cmUVProcessChain::Status* actual, expected.Status.TermSignal != actual->TermSignal) { return false; } - if (expected.Finished && + if (expected.Status.Finished && std::make_pair(expected.ExceptionCode, expected.ExceptionString) != actual->GetException()) { return false; @@ -150,39 +122,96 @@ static void printResults( { std::cout << "Expected: " << std::endl; for (auto const& e : expected) { - if (e.Finished) { - std::cout << " ExitStatus: " - << printExpected(e.MatchExitStatus, e.Status.ExitStatus) - << ", TermSignal: " - << printExpected(e.MatchTermSignal, e.Status.TermSignal) - << ", ExceptionCode: " - << printExpected(e.Finished, - ExceptionCodeToString(e.ExceptionCode)) - << ", ExceptionString: \"" - << printExpected(e.Finished, e.ExceptionString) << '"' - << std::endl; - } else { - std::cout << " null" << std::endl; - } + std::cout << " SpawnResult: " << e.Status.SpawnResult + << ", Finished: " << e.Status.Finished << ", ExitStatus: " + << printExpected(e.MatchExitStatus, e.Status.ExitStatus) + << ", TermSignal: " + << printExpected(e.MatchTermSignal, e.Status.TermSignal) + << ", ExceptionCode: " + << printExpected(e.Status.Finished, + ExceptionCodeToString(e.ExceptionCode)) + << ", ExceptionString: \"" + << printExpected(e.Status.Finished, e.ExceptionString) << '"' + << std::endl; } std::cout << "Actual:" << std::endl; for (auto const& a : actual) { - if (a) { - auto exception = a->GetException(); - std::cout << " ExitStatus: " << a->ExitStatus - << ", TermSignal: " << a->TermSignal << ", ExceptionCode: " - << ExceptionCodeToString(exception.first) - << ", ExceptionString: \"" << exception.second << '"' - << std::endl; - } else { - std::cout << " null" << std::endl; - } + auto exception = a->GetException(); + std::cout << " SpawnResult: " << a->SpawnResult + << ", Finished: " << a->Finished + << ", ExitStatus: " << a->ExitStatus + << ", TermSignal: " << a->TermSignal + << ", ExceptionCode: " << ExceptionCodeToString(exception.first) + << ", ExceptionString: \"" << exception.second << '"' + << std::endl; } } static bool checkExecution(cmUVProcessChainBuilder& builder, std::unique_ptr<cmUVProcessChain>& chain) { + static const std::vector<ExpectedStatus> status1 = { + { false, + false, + { 0, false, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + { false, + false, + { 0, false, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + { false, + false, + { 0, false, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + }; + + static const std::vector<ExpectedStatus> status2 = { + { true, + true, + { 0, true, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + { false, + false, + { 0, false, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + { false, + false, + { 0, false, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + }; + + static const std::vector<ExpectedStatus> status3 = { + { true, + true, + { 0, true, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + { true, + true, + { 0, true, 1, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, +#ifdef _WIN32 + { true, + true, + { 0, true, STATUS_ACCESS_VIOLATION, 0 }, + cmUVProcessChain::ExceptionCode::Fault, + "Access violation" }, +#else + { false, + true, + { 0, true, 0, SIGABRT }, + cmUVProcessChain::ExceptionCode::Other, + "Subprocess aborted" }, +#endif + }; + std::vector<const cmUVProcessChain::Status*> status; chain = cm::make_unique<cmUVProcessChain>(builder.Start()); @@ -201,7 +230,7 @@ static bool checkExecution(cmUVProcessChainBuilder& builder, return false; } - if (chain->Wait(6000)) { + if (chain->Wait(9000)) { std::cout << "Wait() returned true, should be false" << std::endl; return false; } @@ -273,16 +302,19 @@ bool testUVProcessChainBuiltin(const char* helperCommand) return false; } - if (!chain->OutputStream()) { - std::cout << "OutputStream() was null, expecting not null" << std::endl; + if (chain->OutputStream() < 0) { + std::cout << "OutputStream() was invalid, expecting valid" << std::endl; return false; } - if (!chain->ErrorStream()) { - std::cout << "ErrorStream() was null, expecting not null" << std::endl; + if (chain->ErrorStream() < 0) { + std::cout << "ErrorStream() was invalid, expecting valid" << std::endl; return false; } - if (!checkOutput(*chain->OutputStream(), *chain->ErrorStream())) { + cmUVPipeIStream output(chain->GetLoop(), chain->OutputStream()); + cmUVPipeIStream error(chain->GetLoop(), chain->ErrorStream()); + + if (!checkOutput(output, error)) { return false; } @@ -302,12 +334,12 @@ bool testUVProcessChainBuiltinMerged(const char* helperCommand) return false; } - if (!chain->OutputStream()) { - std::cout << "OutputStream() was null, expecting not null" << std::endl; + if (chain->OutputStream() < 0) { + std::cout << "OutputStream() was invalid, expecting valid" << std::endl; return false; } - if (!chain->ErrorStream()) { - std::cout << "ErrorStream() was null, expecting not null" << std::endl; + if (chain->ErrorStream() < 0) { + std::cout << "ErrorStream() was invalid, expecting valid" << std::endl; return false; } if (chain->OutputStream() != chain->ErrorStream()) { @@ -316,7 +348,9 @@ bool testUVProcessChainBuiltinMerged(const char* helperCommand) return false; } - std::string merged = getInput(*chain->OutputStream()); + cmUVPipeIStream mergedStream(chain->GetLoop(), chain->OutputStream()); + + std::string merged = getInput(mergedStream); auto qemuErrorPos = merged.find("qemu:"); if (qemuErrorPos != std::string::npos) { merged.resize(qemuErrorPos); @@ -370,12 +404,12 @@ bool testUVProcessChainExternal(const char* helperCommand) return false; } - if (chain->OutputStream()) { - std::cout << "OutputStream() was not null, expecting null" << std::endl; + if (chain->OutputStream() >= 0) { + std::cout << "OutputStream() was valid, expecting invalid" << std::endl; return false; } - if (chain->ErrorStream()) { - std::cout << "ErrorStream() was not null, expecting null" << std::endl; + if (chain->ErrorStream() >= 0) { + std::cout << "ErrorStream() was valid, expecting invalid" << std::endl; return false; } @@ -418,12 +452,12 @@ bool testUVProcessChainNone(const char* helperCommand) return false; } - if (chain->OutputStream()) { - std::cout << "OutputStream() was not null, expecting null" << std::endl; + if (chain->OutputStream() >= 0) { + std::cout << "OutputStream() was valid, expecting invalid" << std::endl; return false; } - if (chain->ErrorStream()) { - std::cout << "ErrorStream() was not null, expecting null" << std::endl; + if (chain->ErrorStream() >= 0) { + std::cout << "ErrorStream() was valid, expecting invalid" << std::endl; return false; } @@ -445,7 +479,8 @@ bool testUVProcessChainCwdUnchanged(const char* helperCommand) return false; } - auto cwd = getInput(*chain.OutputStream()); + cmUVPipeIStream output(chain.GetLoop(), chain.OutputStream()); + auto cwd = getInput(output); if (!cmHasLiteralSuffix(cwd, "/Tests/CMakeLib")) { std::cout << "Working directory was \"" << cwd << "\", expected to end in \"/Tests/CMakeLib\"" << std::endl; @@ -471,7 +506,8 @@ bool testUVProcessChainCwdChanged(const char* helperCommand) return false; } - auto cwd = getInput(*chain.OutputStream()); + cmUVPipeIStream output(chain.GetLoop(), chain.OutputStream()); + auto cwd = getInput(output); if (!cmHasLiteralSuffix(cwd, "/Tests")) { std::cout << "Working directory was \"" << cwd << "\", expected to end in \"/Tests\"" << std::endl; @@ -481,6 +517,141 @@ bool testUVProcessChainCwdChanged(const char* helperCommand) return true; } +bool testUVProcessChainSpawnFail(const char* helperCommand) +{ + static const std::vector<ExpectedStatus> status1 = { + { false, + false, + { 0, false, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, + { false, + false, + { UV_ENOENT, true, 0, 0 }, + cmUVProcessChain::ExceptionCode::Spawn, + uv_strerror(UV_ENOENT) }, +#ifdef _WIN32 + { true, + true, + { 0, true, STATUS_ACCESS_VIOLATION, 0 }, + cmUVProcessChain::ExceptionCode::Fault, + "Access violation" }, +#else + { false, + true, + { 0, true, 0, SIGABRT }, + cmUVProcessChain::ExceptionCode::Other, + "Subprocess aborted" }, +#endif + }; + + static const std::vector<ExpectedStatus> status2 = { +#ifdef _WIN32 + { true, + true, + { 0, true, 0, 0 }, + cmUVProcessChain::ExceptionCode::None, + "" }, +#else + { false, + true, + { 0, true, 0, SIGPIPE }, + cmUVProcessChain::ExceptionCode::Other, + "SIGPIPE" }, +#endif + { false, + false, + { UV_ENOENT, true, 0, 0 }, + cmUVProcessChain::ExceptionCode::Spawn, + uv_strerror(UV_ENOENT) }, +#ifdef _WIN32 + { true, + true, + { 0, true, STATUS_ACCESS_VIOLATION, 0 }, + cmUVProcessChain::ExceptionCode::Fault, + "Access violation" }, +#else + { false, + true, + { 0, true, 0, SIGABRT }, + cmUVProcessChain::ExceptionCode::Other, + "Subprocess aborted" }, +#endif + }; + + std::vector<const cmUVProcessChain::Status*> status; + + cmUVProcessChainBuilder builder; + builder.AddCommand({ helperCommand, "echo" }) + .AddCommand({ "this_command_is_for_cmake_and_should_never_exist" }) + .AddCommand({ helperCommand, "dedup" }) + .SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT) + .SetBuiltinStream(cmUVProcessChainBuilder::Stream_ERROR); + + auto chain = builder.Start(); + if (!chain.Valid()) { + std::cout << "Valid() returned false, should be true" << std::endl; + return false; + } + + // Some platforms, like Solaris 10, take a long time to report a trapped + // subprocess to the parent process (about 1.7 seconds in the case of + // Solaris 10.) Wait 3 seconds to give it enough time. + if (chain.Wait(3000)) { + std::cout << "Wait() did not time out" << std::endl; + return false; + } + + status = chain.GetStatus(); + if (!resultsMatch(status, status1)) { + std::cout << "GetStatus() did not produce expected output" << std::endl; + printResults(status, status1); + return false; + } + + if (!chain.Wait()) { + std::cout << "Wait() timed out" << std::endl; + return false; + } + + status = chain.GetStatus(); + if (!resultsMatch(status, status2)) { + std::cout << "GetStatus() did not produce expected output" << std::endl; + printResults(status, status2); + return false; + } + + return true; +} + +bool testUVProcessChainInputFile(const char* helperCommand) +{ + std::unique_ptr<FILE, int (*)(FILE*)> f( + fopen("testUVProcessChainInput.txt", "rb"), fclose); + + cmUVProcessChainBuilder builder; + builder.AddCommand({ helperCommand, "dedup" }) + .SetExternalStream(cmUVProcessChainBuilder::Stream_INPUT, fileno(f.get())) + .SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT); + + auto chain = builder.Start(); + + if (!chain.Wait()) { + std::cout << "Wait() timed out" << std::endl; + return false; + } + + cmUVPipeIStream stream(chain.GetLoop(), chain.OutputStream()); + std::string output = getInput(stream); + if (output != "HELO WRD!") { + std::cout << "Output was \"" << output << "\", expected \"HELO WRD!\"" + << std::endl; + return false; + } + + return true; +} + int testUVProcessChain(int argc, char** const argv) { if (argc < 2) { @@ -518,5 +689,15 @@ int testUVProcessChain(int argc, char** const argv) return -1; } + if (!testUVProcessChainSpawnFail(argv[1])) { + std::cout << "While executing testUVProcessChainSpawnFail().\n"; + return -1; + } + + if (!testUVProcessChainInputFile(argv[1])) { + std::cout << "While executing testUVProcessChainInputFile().\n"; + return -1; + } + return 0; } diff --git a/Tests/CMakeLib/testUVProcessChainHelper.cxx b/Tests/CMakeLib/testUVProcessChainHelper.cxx index 99743e7..fcc45b0 100644 --- a/Tests/CMakeLib/testUVProcessChainHelper.cxx +++ b/Tests/CMakeLib/testUVProcessChainHelper.cxx @@ -32,13 +32,13 @@ int main(int argc, char** argv) std::string command = argv[1]; if (command == "echo") { - std::this_thread::sleep_for(std::chrono::milliseconds(3000)); + std::this_thread::sleep_for(std::chrono::milliseconds(6000)); std::cout << "HELLO world!" << std::flush; std::cerr << "1" << std::flush; return 0; } if (command == "capitalize") { - std::this_thread::sleep_for(std::chrono::milliseconds(9000)); + std::this_thread::sleep_for(std::chrono::milliseconds(12000)); std::string input = getStdin(); for (auto& c : input) { c = static_cast<char>(std::toupper(c)); diff --git a/Tests/CMakeLib/testUVStreambuf.cxx b/Tests/CMakeLib/testUVStreambuf.cxx index f9ed6af..f3977d4 100644 --- a/Tests/CMakeLib/testUVStreambuf.cxx +++ b/Tests/CMakeLib/testUVStreambuf.cxx @@ -3,11 +3,14 @@ #include <string> #include <vector> +#include <cmext/algorithm> + #include <cm3p/uv.h> #include <stdint.h> #include "cmGetPipes.h" #include "cmUVHandlePtr.h" +#include "cmUVStream.h" #include "cmUVStreambuf.h" #define TEST_STR_LINE_1 "This string must be exactly 128 characters long so" @@ -437,6 +440,90 @@ end: return success; } +bool testUVPipeIStream() +{ + int pipe[] = { -1, -1 }; + if (cmGetPipes(pipe) < 0) { + std::cout << "cmGetPipes() returned an error" << std::endl; + return false; + } + + cm::uv_loop_ptr loop; + loop.init(); + cm::uv_pipe_ptr pipeSink; + pipeSink.init(*loop, 0); + uv_pipe_open(pipeSink, pipe[1]); + + std::string str = "Hello world!\n"; + uv_write_t writeReq; + uv_buf_t buf; + buf.base = &str.front(); + buf.len = str.length(); + uv_write(&writeReq, pipeSink, &buf, 1, nullptr); + uv_run(loop, UV_RUN_DEFAULT); + + cmUVPipeIStream pin(*loop, pipe[0]); + std::string line; + std::getline(pin, line); + if (line != "Hello world!") { + std::cout << "Line was \"" << line << "\", should be \"Hello world!\"" + << std::endl; + return false; + } + + return true; +} + +bool testUVStreamRead() +{ + int pipe[] = { -1, -1 }; + if (cmGetPipes(pipe) < 0) { + std::cout << "cmGetPipes() returned an error" << std::endl; + return false; + } + + cm::uv_loop_ptr loop; + loop.init(); + cm::uv_pipe_ptr pipeSink; + pipeSink.init(*loop, 0); + uv_pipe_open(pipeSink, pipe[1]); + + std::string str = "Hello world!"; + uv_write_t writeReq; + uv_buf_t buf; + buf.base = &str.front(); + buf.len = str.length(); + uv_write(&writeReq, pipeSink, &buf, 1, nullptr); + uv_run(loop, UV_RUN_DEFAULT); + pipeSink.reset(); + + cm::uv_pipe_ptr pipeSource; + pipeSource.init(*loop, 0); + uv_pipe_open(pipeSource, pipe[0]); + + std::string output; + bool finished = false; + cmUVStreamRead( + pipeSource, + [&output](std::vector<char> data) { cm::append(output, data); }, + [&output, &finished]() { + if (output != "Hello world!") { + std::cout << "Output was \"" << output + << "\", should be \"Hello world!\"" << std::endl; + return; + } + finished = true; + }); + uv_run(loop, UV_RUN_DEFAULT); + + if (!finished) { + std::cout << "finished was not set" << std::endl; + return false; + } + + return true; +} + int testUVStreambuf(int argc, char** const argv) { if (argc < 2) { @@ -454,5 +541,15 @@ int testUVStreambuf(int argc, char** const argv) return -1; } + if (!testUVPipeIStream()) { + std::cout << "While executing testUVPipeIStream().\n"; + return -1; + } + + if (!testUVStreamRead()) { + std::cout << "While executing testUVPipeIStream().\n"; + return -1; + } + return 0; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 53bb1e6..2a7c839 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -42,8 +42,8 @@ endif() # Suppress generator deprecation warnings in test suite. if(CMAKE_GENERATOR MATCHES "^Visual Studio 9 2008") set(TEST_WARN_VS_CODE "set(ENV{CMAKE_WARN_VS9} OFF)") -elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 11 2012") - set(TEST_WARN_VS_CODE "set(ENV{CMAKE_WARN_VS11} OFF)") +elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 12 2013") + set(TEST_WARN_VS_CODE "set(ENV{CMAKE_WARN_VS12} OFF)") else() set(TEST_WARN_VS_CODE "") endif() @@ -1540,10 +1540,40 @@ if(BUILD_TESTING) add_subdirectory(GoogleTest) endif() - if(CMake_TEST_FindPython OR CMake_TEST_FindPython_SABIModule OR CMake_TEST_FindPython_NumPy - OR CMake_TEST_FindPython_Conda OR CMake_TEST_FindPython_IronPython OR CMake_TEST_FindPython_PyPy) - if (CMake_TEST_FindPython AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") - set(CMake_TEST_FindPython_SABIModule TRUE) + if(CMake_TEST_FindPython) + set(CMake_TEST_FindPython2 TRUE) + set(CMake_TEST_FindPython3 TRUE) + endif() + if(CMake_TEST_FindPython_SABIMOdule) + set(CMake_TEST_FindPython2_SABIModule TRUE) + set(CMake_TEST_FindPython3_SABIModule TRUE) + endif() + if(CMake_TEST_FindPython_NumPy) + set(CMake_TEST_FindPython2_NumPyy TRUE) + set(CMake_TEST_FindPython3_NumPy TRUE) + endif() + if(CMake_TEST_FindPython_Conda) + set(CMake_TEST_FindPython3_Conda TRUE) + endif() + if(CMake_TEST_FindPython_IronPython) + set(CMake_TEST_FindPython2_IronPython TRUE) + set(CMake_TEST_FindPython3_IronPython TRUE) + endif() + if(CMake_TEST_FindPython_PyPy) + set(CMake_TEST_FindPython2_PyPy TRUE) + set(CMake_TEST_FindPython3_PyPy TRUE) + endif() + if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython3 + OR CMake_TEST_FindPython2_SABIModule OR CMake_TEST_FindPython3_SABIModule + OR CMake_TEST_FindPython2_NumPy OR CMake_TEST_FindPython3_NumPy + OR CMake_TEST_FindPython3_Conda + OR CMake_TEST_FindPython2_IronPython OR CMake_TEST_FindPython3_IronPython + OR CMake_TEST_FindPython2_PyPy OR CMake_TEST_FindPython3_PyPy) + if (CMake_TEST_FindPython2 AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") + set(CMake_TEST_FindPython2_SABIModule TRUE) + endif() + if (CMake_TEST_FindPython3 AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") + set(CMake_TEST_FindPython3_SABIModule TRUE) endif() add_subdirectory(FindPython) endif() @@ -2279,11 +2309,6 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}") endmacro() - if(vs11 AND ws80) - add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0 Win32) - add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012" WindowsStore 8.0 ARM) - add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012" WindowsStore 8.0 x64) - endif() if(vs12 AND ws81) add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1 Win32) add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013" WindowsStore 8.1 ARM) @@ -2311,10 +2336,6 @@ if(BUILD_TESTING) add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015" WindowsStore 10.0 ARM) add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015" WindowsStore 10.0 x64) endif() - if(vs11 AND wp80) - add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0 Win32) - add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012" WindowsPhone 8.0 ARM) - endif() if(vs12 AND wp81) add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1 Win32) add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013" WindowsPhone 8.1 ARM) @@ -2341,10 +2362,6 @@ if(BUILD_TESTING) endforeach() endmacro() - if(vs11) - add_test_VSWinCE(vs11-ce80-ARM "Visual Studio 11 2012" WindowsCE 8.0 ${wince_sdk}) - endif() - if(vs12) add_test_VSWinCE(vs12-ce80-ARM "Visual Studio 12 2013" WindowsCE 8.0 ${wince_sdk}) endif() @@ -2471,9 +2488,6 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSAndroid/${name}") endmacro() if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ") - if(vs11) - add_test_VSAndroid(vs11 "Visual Studio 11 2012" "Tegra-Android") - endif() if(vs12) add_test_VSAndroid(vs12 "Visual Studio 12 2013" "Tegra-Android") endif() diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 0041b07..c737bcc 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -13,6 +13,7 @@ add_cuda_test_macro(Cuda.MixedStandardLevels4 MixedStandardLevels4) add_cuda_test_macro(Cuda.MixedStandardLevels5 MixedStandardLevels5) add_cuda_test_macro(Cuda.NotEnabled CudaNotEnabled) add_cuda_test_macro(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly) +add_cuda_test_macro(Cuda.StubRPATH StubRPATH) add_cuda_test_macro(Cuda.Toolkit Toolkit) add_cuda_test_macro(Cuda.IncludePathNoToolkit IncludePathNoToolkit) add_cuda_test_macro(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) diff --git a/Tests/Cuda/StubRPATH/CMakeLists.txt b/Tests/Cuda/StubRPATH/CMakeLists.txt new file mode 100644 index 0000000..93643c5 --- /dev/null +++ b/Tests/Cuda/StubRPATH/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.18) +project(StubRPATH CXX) + +#Verify that linking to a stub library doesn't cause an `-rpath` entry + +# Needed for `CUDAToolkit_LIBRARY_SEARCH_DIRS` +find_package(CUDAToolkit REQUIRED) + +find_library(CUDA_DRIVER_STUB_LIBRARY + NAMES cuda + HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS} + ENV CUDA_PATH + PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs +) +add_library(imported_stub IMPORTED SHARED) +set_target_properties(imported_stub PROPERTIES IMPORTED_IMPLIB "${CUDA_DRIVER_STUB_LIBRARY}") +set_target_properties(imported_stub PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CUDAToolkit_INCLUDE_DIRS}") + +set(CMAKE_CXX_STANDARD 11) +add_executable(StubRPATH main.cxx) +target_link_libraries(StubRPATH PRIVATE imported_stub) diff --git a/Tests/Cuda/StubRPATH/main.cxx b/Tests/Cuda/StubRPATH/main.cxx new file mode 100644 index 0000000..877856e --- /dev/null +++ b/Tests/Cuda/StubRPATH/main.cxx @@ -0,0 +1,17 @@ + +#include <iostream> + +#include <cuda.h> + +int main(int argc, char** argv) +{ + int nDevices = 0; + cuInit(0); + auto err = cuDeviceGetCount(&nDevices); + if (err != CUDA_SUCCESS) { + std::cerr << "Failed to retrieve the number of CUDA enabled devices " + << err << std::endl; + return 1; + } + return 0; +} diff --git a/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt b/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt index 99823a6..18f8fda 100644 --- a/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt +++ b/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5) project(TestArtifactsInteractive LANGUAGES C) set (components Interpreter Development) -if (CMake_TEST_FindPython_NumPy) +if (CMake_TEST_FindPython3_NumPy) list (APPEND components NumPy) endif() @@ -12,13 +12,13 @@ find_package(Python3 REQUIRED COMPONENTS ${components}) if (Python3_ARTIFACTS_INTERACTIVE) if (NOT DEFINED CACHE{Python3_EXECUTABLE} OR NOT DEFINED CACHE{Python3_LIBRARY} OR NOT DEFINED CACHE{Python3_INCLUDE_DIR} - OR (CMake_TEST_FindPython_NumPy AND NOT DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) + OR (CMake_TEST_FindPython3_NumPy AND NOT DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=ON Failed.") endif() else() if (DEFINED CACHE{Python3_EXECUTABLE} OR DEFINED CACHE{Python3_LIBRARY} OR DEFINED CACHE{Python3_INCLUDE_DIR} - OR (CMake_TEST_FindPython_NumPy AND DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) + OR (CMake_TEST_FindPython3_NumPy AND DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=OFF Failed.") endif() endif() diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index b6942c9..636a7b0 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -1,4 +1,4 @@ -if(CMake_TEST_FindPython) +if(CMake_TEST_FindPython2) add_test(NAME FindPython.Python2.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -44,6 +44,139 @@ if(CMake_TEST_FindPython) set_tests_properties(FindPython.Python2Fail PROPERTIES PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") + add_test(NAME FindPython.Python.V2.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.LOCATION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V2.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VERSION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + add_test(NAME FindPython.Python2.ExactVersion.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.LOCATION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_MAJOR_VERSION=2 + -DPython_REQUESTED_VERSION=2.1.2 + -DPython2_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python2.ExactVersion.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.VERSION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_MAJOR_VERSION=2 + -DPython_REQUESTED_VERSION=2.1.2 + -DPython2_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + add_test(NAME FindPython.Python.V2.ExactVersion.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.LOCATION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 + -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V2.ExactVersion.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.VERSION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 + -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + 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.Python2Embedded COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Embedded" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2Embedded" + ${build_generator_args} + --build-project TestPython2Embedded + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + set_property(TEST FindPython.Python2.LOCATION FindPython.Python2.VERSION + FindPython.Python2.Development.Module FindPython.Python2Fail + FindPython.Python.V2.LOCATION FindPython.Python.V2.VERSION + FindPython.Python2.ExactVersion.LOCATION FindPython.Python2.ExactVersion.VERSION + FindPython.Python.V2.ExactVersion.LOCATION FindPython.Python.V2.ExactVersion.VERSION + FindPython.Python2.VersionRange.LOCATION FindPython.Python2.VersionRange.VERSION + FindPython.Python.V2.VersionRange.LOCATION FindPython.Python.V2.VersionRange.VERSION + FindPython.Python2Embedded + APPEND PROPERTY LABELS Python2) +endif() + +if(CMake_TEST_FindPython3) add_test(NAME FindPython.Python3.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -89,46 +222,6 @@ if(CMake_TEST_FindPython) set_tests_properties(FindPython.Python3Fail PROPERTIES PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") - add_test(NAME FindPython.Python.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.LOCATION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) - add_test(NAME FindPython.Python.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.VERSION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) - add_test(NAME FindPython.Python.V2.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.LOCATION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) - add_test(NAME FindPython.Python.V2.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VERSION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) add_test(NAME FindPython.Python.V3.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -150,30 +243,6 @@ if(CMake_TEST_FindPython) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.Python2.ExactVersion.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.LOCATION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_MAJOR_VERSION=2 - -DPython_REQUESTED_VERSION=2.1.2 - -DPython2_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) - add_test(NAME FindPython.Python2.ExactVersion.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.VERSION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_MAJOR_VERSION=2 - -DPython_REQUESTED_VERSION=2.1.2 - -DPython2_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) add_test(NAME FindPython.Python3.ExactVersion.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -198,28 +267,6 @@ if(CMake_TEST_FindPython) -DPython3_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.Python.V2.ExactVersion.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.LOCATION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 - -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) - add_test(NAME FindPython.Python.V2.ExactVersion.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.VERSION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 - -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) add_test(NAME FindPython.Python.V3.ExactVersion.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -263,46 +310,6 @@ if(CMake_TEST_FindPython) --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 @@ -324,17 +331,6 @@ if(CMake_TEST_FindPython) -DPython_FIND_STRATEGY=VERSION ) - add_test(NAME FindPython.MultiplePackages COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" - "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" - ${build_generator_args} - --build-project TestMultiplePackages - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) - add_test(NAME FindPython.VirtualEnv COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -346,16 +342,6 @@ if(CMake_TEST_FindPython) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.Python2Embedded COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Embedded" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2Embedded" - ${build_generator_args} - --build-project TestPython2Embedded - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) add_test(NAME FindPython.Python3Embedded COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -377,7 +363,7 @@ if(CMake_TEST_FindPython) --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython_SABIModule=${CMake_TEST_FindPython_SABIModule}" + "-DCMake_TEST_FindPython3_SABIModule=${CMake_TEST_FindPython3_SABIModule}" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -391,7 +377,7 @@ if(CMake_TEST_FindPython) --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython_NumPy=${CMake_TEST_FindPython_NumPy}" + "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}" "-DPython3_ARTIFACTS_INTERACTIVE=ON" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -405,7 +391,7 @@ if(CMake_TEST_FindPython) --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython_NumPy=${CMake_TEST_FindPython_NumPy}" + "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}" "-DPython3_ARTIFACTS_INTERACTIVE=OFF" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -420,7 +406,7 @@ if(CMake_TEST_FindPython) --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython_NumPy=${CMake_TEST_FindPython_NumPy}" + "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -437,6 +423,54 @@ if(CMake_TEST_FindPython) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + set_property(TEST FindPython.Python3.LOCATION FindPython.Python3.VERSION + FindPython.Python3.Development.Module FindPython.Python3Fail + FindPython.Python.V3.LOCATION FindPython.Python.V3.VERSION + FindPython.Python3.ExactVersion.LOCATION FindPython.Python3.ExactVersion.VERSION + FindPython.Python.V3.ExactVersion.LOCATION FindPython.Python.V3.ExactVersion.VERSION + FindPython.Python3.VersionRange.LOCATION FindPython.Python3.VersionRange.VERSION + FindPython.Python.V3.VersionRange.LOCATION FindPython.Python.V3.VersionRange.VERSION + FindPython.VirtualEnv FindPython.Python3Embedded FindPython.RequiredArtifacts + FindPython.ArtifactsInteractive.ON FindPython.ArtifactsInteractive.OFF + FindPython.CustomFailureMessage FindPython.DifferentComponents + APPEND PROPERTY LABELS Python3) + + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + add_test(NAME FindPython.UnversionedNames COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/UnversionedNames" + "${CMake_BINARY_DIR}/Tests/FindPython/UnversionedNames" + ${build_generator_args} + --build-project UnversionedNames + --build-options ${build_options} + ) + set_property(TEST FindPython.UnversionedNames APPEND PROPERTY LABELS Python3) + endif() +endif() + +if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython3) + add_test(NAME FindPython.Python.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.LOCATION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.VERSION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + if (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") add_test(NAME FindPython.Interpreter.SOABI COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> @@ -464,22 +498,28 @@ if(CMake_TEST_FindPython) "-DCMake_TEST_FindPython_COMPONENT=Development" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + set_property(TEST FindPython.Interpreter.SOABI FindPython.Development.SOABI + APPEND PROPERTY LABELS Python2 Python3) endif() - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - add_test(NAME FindPython.UnversionedNames COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/UnversionedNames" - "${CMake_BINARY_DIR}/Tests/FindPython/UnversionedNames" - ${build_generator_args} - --build-project UnversionedNames - --build-options ${build_options} + add_test(NAME FindPython.MultiplePackages COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" + "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" + ${build_generator_args} + --build-project TestMultiplePackages + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - endif() + + set_property(TEST FindPython.Python.LOCATION FindPython.Python.VERSION FindPython.MultiplePackages + APPEND PROPERTY LABELS Python2 Python3) endif() -if(CMake_TEST_FindPython_SABIModule) + +if(CMake_TEST_FindPython2_SABIModule) add_test(NAME FindPython.Python2.Development.SABIModule COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -490,9 +530,12 @@ if(CMake_TEST_FindPython_SABIModule) --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - set_tests_properties(FindPython.Python2.Development.SABIModule PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: .*Development\\.SABIModule") + set_tests_properties(FindPython.Python2.Development.SABIModule PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: .*Development\\.SABIModule") + set_property(TEST FindPython.Python2.Development.SABIModule APPEND PROPERTY LABELS Python2) +endif() +if(CMake_TEST_FindPython3_SABIModule) # Use exclusively Release configuration because Debug is, on Windows with MSVC, # unusable with SABI: Python force link with debug version of full versioned library rather than # the stable ABI one. @@ -506,9 +549,10 @@ if(CMake_TEST_FindPython_SABIModule) --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C Release ) + set_property(TEST FindPython.Python3.Development.SABIModule APPEND PROPERTY LABELS Python3) endif() -if(CMake_TEST_FindPython_NumPy) +if(CMake_TEST_FindPython2_NumPy OR CMake_TEST_FindPython3_NumPy) add_test(NAME FindPython.NumPy COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -528,9 +572,11 @@ if(CMake_TEST_FindPython_NumPy) --build-project TestNumPyOnly --build-options ${build_options} ) + + set_property(TEST FindPython.NumPy FindPython.NumPyOnly APPEND PROPERTY LABELS Python2 Python3) endif() -if(CMake_TEST_FindPython_Conda) +if(CMake_TEST_FindPython3_Conda) add_test(NAME FindPython.VirtualEnvConda COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -541,73 +587,83 @@ if(CMake_TEST_FindPython_Conda) --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + set_property(TEST FindPython.VirtualEnvConda APPEND PROPERTY LABELS Python3) endif() -if (CMake_TEST_FindPython AND CMake_TEST_FindPython_IronPython) - add_test(NAME FindPython.Implementation.CPython COMMAND +if (CMake_TEST_FindPython2 AND CMake_TEST_FindPython2_IronPython) + add_test(NAME FindPython.Implementation.CPython2 COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" - "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython" + "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython2" ${build_generator_args} --build-project TestImplementationCPython --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_REQUESTED_IMPLEMENTATIONS=CPython --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.Implementation.IronPython COMMAND + add_test(NAME FindPython.Implementation.IronPython2 COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" - "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython2" ${build_generator_args} --build-project TestImplementationIronPython --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_REQUESTED_IMPLEMENTATION=IronPython --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + set_property(TEST FindPython.Implementation.CPython2 FindPython.Implementation.IronPython2 + APPEND PROPERTY LABELS Python2) endif() -if(CMake_TEST_FindPython_IronPython) - add_test(NAME FindPython.IronPython2.LOCATION COMMAND +if (CMake_TEST_FindPython3 AND CMake_TEST_FindPython3_IronPython) + add_test(NAME FindPython.Implementation.CPython3 COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.LOCATION" + "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" + "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython3" ${build_generator_args} - --build-project TestIronPython2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION + --build-project TestImplementationCPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_REQUESTED_IMPLEMENTATIONS=CPython --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.IronPython2.VERSION COMMAND + add_test(NAME FindPython.Implementation.IronPython3 COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VERSION" + "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" + "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython3" ${build_generator_args} - --build-project TestIronPython2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION + --build-project TestImplementationIronPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_REQUESTED_IMPLEMENTATION=IronPython --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.IronPython.LOCATION COMMAND + set_property(TEST FindPython.Implementation.CPython3 FindPython.Implementation.IronPython3 + APPEND PROPERTY LABELS Python3) +endif() + +if(CMake_TEST_FindPython2_IronPython) + add_test(NAME FindPython.IronPython2.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.LOCATION" + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.LOCATION" ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION + --build-project TestIronPython2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.IronPython.VERSION COMMAND + add_test(NAME FindPython.IronPython2.VERSION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.VERSION" + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VERSION" ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION + --build-project TestIronPython2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + add_test(NAME FindPython.IronPython.V2.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -651,71 +707,133 @@ if(CMake_TEST_FindPython_IronPython) -DPython2_FIND_IMPLEMENTATIONS=IronPython -DPython2_FIND_STRATEGY=VERSION ) + + set_property(TEST FindPython.IronPython2.LOCATION FindPython.IronPython2.VERSION + FindPython.IronPython.V2.LOCATION FindPython.IronPython.V2.VERSION + FindPython.IronPython2.VersionRange.LOCATION FindPython.IronPython2.VersionRange.VERSION + APPEND PROPERTY LABELS Python2) endif() -if(CMake_TEST_FindPython_PyPy) - add_test(NAME FindPython.PyPy2.LOCATION COMMAND +if(CMake_TEST_FindPython3_IronPython) + add_test(NAME FindPython.IronPython3.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy2" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy2.LOCATION" + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython3" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.LOCATION" ${build_generator_args} - --build-project TestPyPy2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION + --build-project TestIronPython3 + --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.PyPy2.VERSION COMMAND + add_test(NAME FindPython.IronPython3.VERSION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy2" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy2.VERSION" + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython3" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VERSION" ${build_generator_args} - --build-project TestPyPy2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION + --build-project TestIronPython3 + --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.PyPy3.LOCATION COMMAND + add_test(NAME FindPython.IronPython.V3.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.LOCATION" + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V3.LOCATION" ${build_generator_args} - --build-project TestPyPy3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION + --build-project TestIronPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=LOCATION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.PyPy3.VERSION COMMAND + add_test(NAME FindPython.IronPython.V3.VERSION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.VERSION" + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V3.VERSION" ${build_generator_args} - --build-project TestPyPy3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION + --build-project TestIronPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.PyPy.LOCATION COMMAND + add_test(NAME FindPython.IronPython3.VersionRange.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.LOCATION" + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VersionRange.LOCATION" ${build_generator_args} - --build-project TestPyPy + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 + -DPython3_FIND_IMPLEMENTATIONS=IronPython + -DPython3_FIND_STRATEGY=LOCATION + ) + add_test(NAME FindPython.IronPython3.VersionRange.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VersionRange.VERSION" + ${build_generator_args} + --build-project TestVersionRange + --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 + -DPython3_FIND_IMPLEMENTATIONS=IronPython + -DPython3_FIND_STRATEGY=VERSION + ) + + set_property(TEST FindPython.IronPython3.LOCATION FindPython.IronPython3.VERSION + FindPython.IronPython.V3.LOCATION FindPython.IronPython.V3.VERSION + FindPython.IronPython3.VersionRange.LOCATION FindPython.IronPython3.VersionRange.VERSION + APPEND PROPERTY LABELS Python3) +endif() + +if(CMake_TEST_FindPython2_IronPython OR CMake_TEST_FindPython3_IronPython) + add_test(NAME FindPython.IronPython.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.LOCATION" + ${build_generator_args} + --build-project TestIronPython --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - add_test(NAME FindPython.PyPy.VERSION COMMAND + add_test(NAME FindPython.IronPython.VERSION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.VERSION" + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.VERSION" ${build_generator_args} - --build-project TestPyPy + --build-project TestIronPython --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + set_property(TEST FindPython.IronPython.LOCATION FindPython.IronPython.VERSION + APPEND PROPERTY LABELS Python2 Python3) +endif() + +if(CMake_TEST_FindPython2_PyPy) + add_test(NAME FindPython.PyPy2.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy2" + "${CMake_BINARY_DIR}/Tests/FindPython/PyPy2.LOCATION" + ${build_generator_args} + --build-project TestPyPy2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.PyPy2.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy2" + "${CMake_BINARY_DIR}/Tests/FindPython/PyPy2.VERSION" + ${build_generator_args} + --build-project TestPyPy2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.PyPy.V2.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -736,6 +854,34 @@ if(CMake_TEST_FindPython_PyPy) --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + set_property(TEST FindPython.PyPy2.LOCATION FindPython.PyPy2.VERSION + FindPython.PyPy.V2.LOCATION FindPython.PyPy.V2.VERSION + APPEND PROPERTY LABELS Python2) +endif() + +if(CMake_TEST_FindPython3_PyPy) + add_test(NAME FindPython.PyPy3.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3" + "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.LOCATION" + ${build_generator_args} + --build-project TestPyPy3 + --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.PyPy3.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3" + "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.VERSION" + ${build_generator_args} + --build-project TestPyPy3 + --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.PyPy.V3.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -756,4 +902,34 @@ if(CMake_TEST_FindPython_PyPy) --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + set_property(TEST FindPython.PyPy3.LOCATION FindPython.PyPy3.VERSION + FindPython.PyPy.V3.LOCATION FindPython.PyPy.V3.VERSION + APPEND PROPERTY LABELS Python3) +endif() + +if(CMake_TEST_FindPython2_PyPy OR CMake_TEST_FindPython3_PyPy) + add_test(NAME FindPython.PyPy.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" + "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.LOCATION" + ${build_generator_args} + --build-project TestPyPy + --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.PyPy.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" + "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.VERSION" + ${build_generator_args} + --build-project TestPyPy + --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + set_property(TEST FindPython.PyPy.LOCATION FindPython.PyPy.VERSION + APPEND PROPERTY LABELS Python2 Python3) endif() diff --git a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt index 283aeec..e0148f3 100644 --- a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt +++ b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt @@ -62,7 +62,7 @@ set_tests_properties(FindPython.CustomFailureMessage.Multiple PROPERTIES PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter.+Development: Cannot find the library") -if (CMake_TEST_FindPython_NumPy) +if (CMake_TEST_FindPython3_NumPy) add_test(NAME FindPython.CustomFailureMessage.NumPy COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test diff --git a/Tests/FindPython/IronPython3/CMakeLists.txt b/Tests/FindPython/IronPython3/CMakeLists.txt new file mode 100644 index 0000000..b09097a --- /dev/null +++ b/Tests/FindPython/IronPython3/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.5) + +project(TestIronPython3 LANGUAGES NONE) + +set (Python3_FIND_IMPLEMENTATIONS "IronPython") + +find_package(Python3 COMPONENTS Interpreter Compiler) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") +endif() + +if (NOT Python3_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python 3 Interpreter") +endif() +if (NOT Python3_INTERPRETER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous interpreter ID (${Python3_INTERPRETER_ID})") +endif() + +if (NOT Python3_Compiler_FOUND) + message (FATAL_ERROR "Failed to find Python 3 Compiler") +endif() +if (NOT Python3_COMPILER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous compiler ID (${Python3_COMPILER_ID})") +endif() + +if(NOT TARGET Python3::Interpreter) + message(SEND_ERROR "Python3::Interpreter not found") +endif() +if(NOT TARGET Python3::Compiler) + message(SEND_ERROR "Python3::Compiler not found") +endif() diff --git a/Tests/FindPython/MultiplePackages/CMakeLists.txt b/Tests/FindPython/MultiplePackages/CMakeLists.txt index 4845035..352a2f6f 100644 --- a/Tests/FindPython/MultiplePackages/CMakeLists.txt +++ b/Tests/FindPython/MultiplePackages/CMakeLists.txt @@ -2,32 +2,44 @@ cmake_minimum_required(VERSION 3.5) project(TestMultiplePackages C) -find_package (Python2 REQUIRED COMPONENTS Interpreter Development) -find_package (Python3 REQUIRED COMPONENTS Interpreter Development) - -# Must find Python 3 find_package (Python REQUIRED) -if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE) - message (FATAL_ERROR - "Python interpreters do not match:\n" - " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" - " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n" +if (CMake_TEST_FindPython2) + find_package (Python2 REQUIRED COMPONENTS Interpreter Development) + + if (NOT CMake_TEST_FindPython3 AND NOT Python2_EXECUTABLE STREQUAL Python_EXECUTABLE) + message (FATAL_ERROR + "Python interpreters do not match:\n" + " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" + " Python2_EXECUTABLE='${Python3_EXECUTABLE}'\n" ) -endif() + endif() + + Python2_add_library (spam2 MODULE ../spam.c) + target_compile_definitions (spam2 PRIVATE PYTHON2) + add_test (NAME python2_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" + "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") -Python2_add_library (spam2 MODULE ../spam.c) -target_compile_definitions (spam2 PRIVATE PYTHON2) +endif() + +if (CMake_TEST_FindPython3) + find_package (Python3 REQUIRED COMPONENTS Interpreter Development) -Python3_add_library (spam3 MODULE ../spam.c) -target_compile_definitions (spam3 PRIVATE PYTHON3) + if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE) + message (FATAL_ERROR + "Python interpreters do not match:\n" + " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" + " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n" + ) + endif() + Python3_add_library (spam3 MODULE ../spam.c) + target_compile_definitions (spam3 PRIVATE PYTHON3) -add_test (NAME python2_spam2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" - "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") + add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" + "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") -add_test (NAME python3_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" - "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") +endif() diff --git a/Tests/FindPython/NumPy/CMakeLists.txt b/Tests/FindPython/NumPy/CMakeLists.txt index 9920336..336bb83 100644 --- a/Tests/FindPython/NumPy/CMakeLists.txt +++ b/Tests/FindPython/NumPy/CMakeLists.txt @@ -2,21 +2,30 @@ cmake_minimum_required(VERSION 3.5) project(TestNumPy LANGUAGES C) -find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy) -find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy) +if(CMake_TEST_FindPython2_NumPy) -Python2_add_library (arraytest2 MODULE arraytest.c) -target_compile_definitions (arraytest2 PRIVATE PYTHON2) -target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy) -Python3_add_library (arraytest3 MODULE arraytest.c) -target_compile_definitions (arraytest3 PRIVATE PYTHON3) -target_link_libraries (arraytest3 PRIVATE Python3::NumPy) + Python2_add_library (arraytest2 MODULE arraytest.c) + target_compile_definitions (arraytest2 PRIVATE PYTHON2) + target_link_libraries (arraytest2 PRIVATE Python2::NumPy) -add_test (NAME python2_arraytest - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>" - "${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));") + add_test (NAME python2_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>" + "${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));") -add_test (NAME python3_arraytest - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>" - "${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));") +endif() + +if(CMake_TEST_FindPython3_NumPy) + + find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy) + + Python3_add_library (arraytest3 MODULE arraytest.c) + target_compile_definitions (arraytest3 PRIVATE PYTHON3) + target_link_libraries (arraytest3 PRIVATE Python3::NumPy) + + add_test (NAME python3_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>" + "${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));") + +endif() diff --git a/Tests/FindPython/NumPyOnly/CMakeLists.txt b/Tests/FindPython/NumPyOnly/CMakeLists.txt index 9aa1bcf..115cf2b 100644 --- a/Tests/FindPython/NumPyOnly/CMakeLists.txt +++ b/Tests/FindPython/NumPyOnly/CMakeLists.txt @@ -2,13 +2,23 @@ cmake_minimum_required(VERSION 3.5) project(TestNumPyOnly LANGUAGES C) -find_package(Python2 REQUIRED COMPONENTS NumPy) -find_package(Python3 REQUIRED COMPONENTS NumPy) +if(CMake_TEST_FindPython2_NumPy) + + find_package(Python2 REQUIRED COMPONENTS NumPy) + + Python2_add_library (arraytest2 MODULE ../NumPy/arraytest.c) + target_compile_definitions (arraytest2 PRIVATE PYTHON2) + target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + +endif() -Python2_add_library (arraytest2 MODULE ../NumPy/arraytest.c) -target_compile_definitions (arraytest2 PRIVATE PYTHON2) -target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + +if(CMake_TEST_FindPython3_NumPy) + +find_package(Python3 REQUIRED COMPONENTS NumPy) Python3_add_library (arraytest3 MODULE ../NumPy/arraytest.c) target_compile_definitions (arraytest3 PRIVATE PYTHON3) target_link_libraries (arraytest3 PRIVATE Python3::NumPy) + +endif() diff --git a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt index cb9d4d3..eec28a5 100644 --- a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt +++ b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt @@ -4,13 +4,20 @@ project(TestRequiredArtifacts LANGUAGES C) include(CTest) -find_package(Python2 REQUIRED COMPONENTS Interpreter Development) -if (NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python 2") +if(CMake_TEST_FindPython2) + find_package(Python2 REQUIRED COMPONENTS Interpreter Development) + if (NOT Python2_FOUND) + message (FATAL_ERROR "Failed to find Python 2") + endif() + set(USER_LIBRARY "${Python2_LIBRARY_RELEASE}") + set(USER_INCLUDE_DIR "${Python2_INCLUDE_DIRS}") +else() + set(USER_LIBRARY "/path/to/invalid${CMAKE_C_LINK_LIBRARY_SUFFIX}") + set(USER_INCLUDE_DIR "/path/to/invalid/dir") endif() set(components Interpreter Development) -if (CMake_TEST_FindPython_SABIModule AND WIN32) +if (CMake_TEST_FindPython3_SABIModule AND WIN32) list (APPEND components Development.SABIModule) endif() find_package(Python3 REQUIRED COMPONENTS ${components}) @@ -61,7 +68,7 @@ add_test(NAME FindPython.RequiredArtifacts.Library.INVALID COMMAND ${build_generator_args} --build-project TestRequiredArtifacts.Check --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON - "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}" + "-DPython3_LIBRARY=${USER_LIBRARY}" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -84,7 +91,7 @@ add_test(NAME FindPython.RequiredArtifacts.Include.INVALID COMMAND ${build_generator_args} --build-project TestRequiredArtifacts.Check --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INCLUDE=ON - "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}" + "-DPython3_INCLUDE_DIR=${USER_INCLUDE_DIR}" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -97,7 +104,7 @@ add_test(NAME FindPython.RequiredArtifacts.Interpreter-Library.INVALID COMMAND --build-project TestRequiredArtifacts.Check --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON -DCHECK_LIBRARY=ON "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}" - "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}" + "-DPython3_LIBRARY=${USER_LIBRARY}" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -110,11 +117,11 @@ add_test(NAME FindPython.RequiredArtifacts.Library-Include.INVALID COMMAND --build-project TestRequiredArtifacts.Check --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON -DCHECK_INCLUDE=ON "-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}" - "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}" + "-DPython3_INCLUDE_DIR=${USER_INCLUDE_DIR}" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) -if (CMake_TEST_FindPython_SABIModule AND WIN32) +if (CMake_TEST_FindPython3_SABIModule AND WIN32) add_test(NAME FindPython.RequiredArtifacts.SABILibrary.VALID COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -134,7 +141,7 @@ if (CMake_TEST_FindPython_SABIModule AND WIN32) ${build_generator_args} --build-project TestRequiredArtifacts.Check --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_SABI_LIBRARY=ON - "-DPython3_SABI_LIBRARY=${Python2_LIBRARY_RELEASE}" + "-DPython3_SABI_LIBRARY=${USER_LIBRARY}" --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) endif() diff --git a/Tests/FindPython/SOABI/CMakeLists.txt b/Tests/FindPython/SOABI/CMakeLists.txt index 60399d3..6c0e9a9 100644 --- a/Tests/FindPython/SOABI/CMakeLists.txt +++ b/Tests/FindPython/SOABI/CMakeLists.txt @@ -2,37 +2,40 @@ cmake_minimum_required(VERSION 3.5) project(TestSOABI LANGUAGES C) -find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() +if(CMake_TEST_FindPython3) + find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) + if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") + endif() -if(NOT DEFINED Python3_SOABI) - message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") -endif() + if(NOT DEFINED Python3_SOABI) + message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") + endif() -if (Python3_Development_FOUND AND Python3_SOABI) - Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c) - target_compile_definitions (spam3 PRIVATE PYTHON3) + if (Python3_Development_FOUND AND Python3_SOABI) + Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c) + target_compile_definitions (spam3 PRIVATE PYTHON3) - get_property (suffix TARGET spam3 PROPERTY SUFFIX) - if (NOT suffix MATCHES "^.${Python3_SOABI}") - message(FATAL_ERROR "Module suffix do not include Python3_SOABI") + get_property (suffix TARGET spam3 PROPERTY SUFFIX) + if (NOT suffix MATCHES "^.${Python3_SOABI}") + message(FATAL_ERROR "Module suffix do not include Python3_SOABI") + endif() endif() endif() +if(CMake_TEST_FindPython2) + find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) + if(NOT DEFINED Python2_SOABI) + message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") + endif() -find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) -if(NOT DEFINED Python2_SOABI) - message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") -endif() - -if (Python2_Development_FOUND AND Python2_SOABI) - Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c) - target_compile_definitions (spam2 PRIVATE PYTHON2) + if (Python2_Development_FOUND AND Python2_SOABI) + Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c) + target_compile_definitions (spam2 PRIVATE PYTHON2) - get_property (suffix TARGET spam2 PROPERTY SUFFIX) - if (NOT suffix MATCHES "^.${Python2_SOABI}") - message(FATAL_ERROR "Module suffix do not include Python2_SOABI") + get_property (suffix TARGET spam2 PROPERTY SUFFIX) + if (NOT suffix MATCHES "^.${Python2_SOABI}") + message(FATAL_ERROR "Module suffix do not include Python2_SOABI") + endif() endif() endif() diff --git a/Tests/FindPython/VirtualEnv/CMakeLists.txt b/Tests/FindPython/VirtualEnv/CMakeLists.txt index e2e5bd2..ea742ea 100644 --- a/Tests/FindPython/VirtualEnv/CMakeLists.txt +++ b/Tests/FindPython/VirtualEnv/CMakeLists.txt @@ -27,21 +27,23 @@ add_test(NAME FindPython3.VirtualEnvDefault "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake") -add_test(NAME FindPython3.VirtualEnvOnly - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=CONDA_PREFIX - "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") -add_test(NAME FindPython3.UnsetVirtualEnvOnly - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=VIRTUAL_ENV - --unset=CONDA_PREFIX - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") - add_test(NAME FindPython3.VirtualEnvStandard COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME --unset=CONDA_PREFIX "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake") + +if(CMake_TEST_FindPython2) + add_test(NAME FindPython3.VirtualEnvOnly + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=CONDA_PREFIX + "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") + add_test(NAME FindPython3.UnsetVirtualEnvOnly + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=VIRTUAL_ENV + --unset=CONDA_PREFIX + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") +endif() diff --git a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt index 2f7c0db..3a64c31 100644 --- a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt +++ b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt @@ -26,21 +26,23 @@ add_test(NAME FindPython3.VirtualEnvDefaultConda "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake") -add_test(NAME FindPython3.VirtualEnvOnlyConda - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=VIRTUAL_ENV - "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") -add_test(NAME FindPython3.UnsetVirtualEnvOnlyConda - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=CONDA_PREFIX - --unset=VIRTUAL_ENV - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") - add_test(NAME FindPython3.VirtualEnvStandardConda COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME --unset=VIRTUAL_ENV "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake") + +if(Cmake_TEST_FindPython2) + add_test(NAME FindPython3.VirtualEnvOnlyConda + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=VIRTUAL_ENV + "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" + "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") + add_test(NAME FindPython3.UnsetVirtualEnvOnlyConda + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=CONDA_PREFIX + --unset=VIRTUAL_ENV + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") +endif() diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index ef115e6..df7cda0 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -214,6 +214,22 @@ set_property(TARGET importedFallback2 PROPERTY IMPORTED_IMPLIB_SPECIAL special_i set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_NOCONFIG SPECIAL "") set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_DEBUG SPECIAL "") set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_RELEASE SPECIAL "") +set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_RELWITHDEBINFO SPECIAL "") + +add_library(importedFallback3 SHARED IMPORTED) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_LOCATION fallback_loc) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_IMPLIB imp_loc) +set_property(TARGET importedFallback3 PROPERTY MAP_IMPORTED_CONFIG_DEBUG "" DEBUG) +set_property(TARGET importedFallback3 PROPERTY MAP_IMPORTED_CONFIG_RELEASE "") + +add_library(importedFallback4 SHARED IMPORTED) +set_property(TARGET importedFallback4 PROPERTY IMPORTED_LOCATION fallback_loc) +set_property(TARGET importedFallback4 PROPERTY IMPORTED_IMPLIB imp_loc) + +add_library(importedFallback5 SHARED IMPORTED) +set_property(TARGET importedFallback5 PROPERTY IMPORTED_IMPLIB imp_loc) add_library(importedFallback_genex STATIC IMPORTED) set_property(TARGET importedFallback_genex PROPERTY IMPORTED_CONFIGURATIONS RELEASE) @@ -232,7 +248,10 @@ add_custom_target(check-part3 ALL -Dconfig=$<CONFIGURATION> -Dtest_imported_includes=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> -Dtest_imported_fallback=$<STREQUAL:$<TARGET_FILE_NAME:importedFallback>,fallback_loc> - -Dtest_imported_fallback2=$<IF:$<OR:$<PLATFORM_ID:Windows,CYGWIN,MSYS>,$<AND:$<PLATFORM_ID:Darwin>,$<BOOL:${CMAKE_TAPI}>>>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback2>,special_imp>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback2>,fallback_loc>> + -Dtest_imported_fallback2=$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback2>,special_imp> + -Dtest_imported_fallback3=$<IF:$<PLATFORM_ID:Windows,CYGWIN,MSYS>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback3>,imp_loc>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback3>,fallback_loc>> + -Dtest_imported_fallback4=$<IF:$<PLATFORM_ID:Windows,CYGWIN,MSYS>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback4>,imp_loc>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback4>,fallback_loc>> + -Dtest_imported_fallback5=$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback5>,imp_loc> -Dtest_imported_fallback_genex=$<STREQUAL:$<TARGET_PROPERTY:importedFallback_genex,INTERFACE_COMPILE_DEFINITIONS>,FOOBAR=1> -Dtest_alias_file_exe=$<STREQUAL:$<TARGET_FILE:Alias::SomeExe>,$<TARGET_FILE:someexe>> -Dtest_alias_file_lib=$<STREQUAL:$<TARGET_FILE:Alias::SomeLib>,$<TARGET_FILE:empty1>> diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 7bb0d85..eda3bc1 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -20,6 +20,9 @@ endif() check(test_imported_fallback "1") check(test_imported_fallback2 "1") +check(test_imported_fallback3 "1") +check(test_imported_fallback4 "1") +check(test_imported_fallback5 "1") check(test_imported_fallback_genex "1") check(test_alias_file_exe "1") diff --git a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake index c31e4ba..ab9e405 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake +++ b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake @@ -1,6 +1,3 @@ -# 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) diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt index 91a90e5..c6439e2 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt @@ -1,17 +1,6 @@ -^CMake Error in CMakeLists.txt: - IMPORTED_LOCATION not set for imported target "unknown_lib"( configuration +^(CMake Error in CMakeLists.txt: + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. -+ -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 - "[^"]+")?.( -+ -CMake Error in CMakeLists.txt: - IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration - "[^"]+")?.)* -+ +)+ +.*(IMPORTED_LOCATION or )?IMPORTED_IMPLIB not set for imported target.*"shared_lib".* CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt index 27af911..7a46c41 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt @@ -1,39 +1,19 @@ -^CMake Warning \(dev\) in CMakeLists.txt: +^(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 + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. This warning is for project developers. Use -Wno-dev to suppress it. -+ -CMake Warning \(dev\) in CMakeLists.txt: ++)+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 + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|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.( -+ -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|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration - "[^"]+")?. -This warning is for project developers. Use -Wno-dev to suppress it.)*$ +.*(IMPORTED_LOCATION or )?IMPORTED_IMPLIB not set for imported target.*"shared_lib".* +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt b/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt index 67d00f7..3472f33 100644 --- a/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt @@ -1,4 +1,13 @@ -^CMake Error at CMP0115\.cmake:[0-9]+ \(add_executable\): +^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0115 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 Error at CMP0115\.cmake:[0-9]+ \(add_executable\): Cannot find source file: noexist diff --git a/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt index 10e83a9..930dd3c 100644 --- a/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt +++ b/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt @@ -1,4 +1,15 @@ -^CMake Warning \(dev\) at CMP0116-Mixed\.cmake:1 \(add_custom_command\): +^CMake Deprecation Warning at CMP0116-Mixed\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0116 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 Warning \(dev\) at CMP0116-Mixed\.cmake:1 \(add_custom_command\): Policy CMP0116 is not set: Ninja generators transform DEPFILEs from add_custom_command\(\)\. Run "cmake --help-policy CMP0116" for policy details\. Use the cmake_policy command to set the policy and suppress this diff --git a/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN-stderr.txt new file mode 100644 index 0000000..887601c --- /dev/null +++ b/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0116 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\.$ diff --git a/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN-stderr.txt new file mode 100644 index 0000000..887601c --- /dev/null +++ b/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0116 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\.$ diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt index 2af72a4..9285f9d 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt @@ -1,4 +1,15 @@ -^prop: `0` +^CMake Deprecation Warning at CMP0118-OLD-Test1\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +prop: `0` CMake Error at CMP0118-Common-Test1\.cmake:[0-9]+ \(target_sources\): Cannot find source file: diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt index 6109f65..9bd3d33 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test10\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt index e5e97de..4730caf 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test11\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt index e6c429c..69a07e1 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt @@ -1,4 +1,15 @@ -^CMake Error at subdir-Common-Test12/CMakeLists\.txt:[0-9]+ \(add_custom_command\): +^CMake Deprecation Warning at CMP0118-OLD-Test12\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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 subdir-Common-Test12/CMakeLists\.txt:[0-9]+ \(add_custom_command\): TARGET 'custom[4-6]' was not created in this directory\. + CMake Error at subdir-Common-Test12/CMakeLists\.txt:[0-9]+ \(add_custom_command\): diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt index 75dbf23..45c1dcb 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt @@ -1,4 +1,15 @@ -^CMake Error at subdir-Common-Test13/CMakeLists\.txt:[0-9]+ \(add_custom_command\): +^CMake Deprecation Warning at CMP0118-OLD-Test13\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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 subdir-Common-Test13/CMakeLists\.txt:[0-9]+ \(add_custom_command\): TARGET 'custom[4-6]' was not created in this directory\. + CMake Error at subdir-Common-Test13/CMakeLists\.txt:[0-9]+ \(add_custom_command\): diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt index f5b3d1a..7ade0cf 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test14\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt index a30bc84..5735539 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test15\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt index 403ce5a..74eb3e1 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt @@ -1 +1,12 @@ -^prop: `1`$ +^CMake Deprecation Warning at CMP0118-OLD-Test2\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +prop: `1`$ diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt index 4f4fea3..cce5b19 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test3\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `1` Generated_with_full_path1\.txt: # 1b # GENERATED = `1` Generated_with_full_path1\.txt: # 2a # GENERATED = `1` Generated_with_full_path1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt index 3c80531..47eee2e 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test3b\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `1` Generated_with_full_path1\.txt: # 1b # GENERATED = `1` Generated_with_full_path1\.txt: # 2a # GENERATED = `1` Generated_with_full_path1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt index 9600fee..f17c9be 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test4\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `0` Generated_with_full_path1\.txt: # 1b # GENERATED = `0` Generated_with_full_path1\.txt: # 2a # GENERATED = `0` Generated_with_full_path1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt index e638660..388e90e 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test4b\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `0` Generated_with_full_path1\.txt: # 1b # GENERATED = `0` Generated_with_full_path1\.txt: # 2a # GENERATED = `0` Generated_with_full_path1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt index 18e6a8c..4a67fa7 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test5\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `1` Generated_with_full_path1\.txt: # 1b # GENERATED = `1` Generated_with_full_path1\.txt: # 2a # GENERATED = `1` Generated_with_full_path1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt index a60545f..0cad373 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test6\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source1\.txt: # 1a # GENERATED = `1` Generated_source1\.txt: # 1b # GENERATED = `1` Generated_source1\.txt: # 2a # GENERATED = `1` Generated_source1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt index fd496cb..7f232d5 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test7\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source1\.txt: # 1a # GENERATED = `1` Generated_source1\.txt: # 1b # GENERATED = `1` Generated_source1\.txt: # 2a # GENERATED = `1` Generated_source1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt index 3505242..dd9d2ef 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test8\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source1\.txt: # 1a # GENERATED = `0` Generated_source1\.txt: # 1b # GENERATED = `0` Generated_source1\.txt: # 2a # GENERATED = `0` Generated_source1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt index 63a9341..e01f782 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test9\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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\) ++ +Generated_source1\.txt: # 1a # GENERATED = `0` Generated_source1\.txt: # 1b # GENERATED = `0` Generated_source1\.txt: # 2a # GENERATED = `0` Generated_source1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt b/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt index 5e9cf6c..2fc472b 100644 --- a/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt @@ -1,4 +1,15 @@ -^CMake Error at GenInSubdir/CMakeLists\.txt:[0-9]+ \(target_sources\): +^CMake Deprecation Warning at GenInSubdir-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 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 GenInSubdir/CMakeLists\.txt:[0-9]+ \(target_sources\): Cannot find source file: [^ diff --git a/Tests/RunCMake/CMP0119/CMP0119-OLD-stderr.txt b/Tests/RunCMake/CMP0119/CMP0119-OLD-stderr.txt new file mode 100644 index 0000000..86eac41 --- /dev/null +++ b/Tests/RunCMake/CMP0119/CMP0119-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0119-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0119 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/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 63b7568..b278cef 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -171,8 +171,9 @@ endif() if(NOT CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") add_RunCMake_test(CMP0065 -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) endif() +add_executable(detect_jobserver detect_jobserver.c) if(CMAKE_GENERATOR MATCHES "Make") - add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU}) + add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU} -DDETECT_JOBSERVER=$<TARGET_FILE:detect_jobserver>) endif() unset(ninja_test_with_qt_version) unset(ninja_qt_args) @@ -363,7 +364,8 @@ if(CMake_TEST_FindOpenSSL) endif() if(CMake_TEST_UseSWIG) add_RunCMake_test(FindSWIG) - add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython=${CMake_TEST_FindPython}) + add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython2=${CMake_TEST_FindPython2} + -DCMake_TEST_FindPython3=${CMake_TEST_FindPython3}) endif() if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom") add_RunCMake_test(GenerateExportHeader) diff --git a/Tests/RunCMake/CXXModules/CMakeLists.txt b/Tests/RunCMake/CXXModules/CMakeLists.txt index 88eb282..640d67b 100644 --- a/Tests/RunCMake/CXXModules/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.23) project(${RunCMake_TEST} NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake b/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake index ff7219a..c17b5a4 100644 --- a/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake +++ b/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake @@ -1,4 +1,4 @@ -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") if (NOT EXISTS "${CMake_TEST_MODULE_COMPILATION_RULES}") message(FATAL_ERROR diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt b/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt index 78bdf2b..659414d 100644 --- a/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:15 \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt index 515b240..78a1d0b 100644 --- a/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt @@ -3,6 +3,14 @@ project(cxx_modules_deep_chain CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + include(CheckCompilerFlag) + check_compiler_flag(CXX "-Wread-modules-implicitly" have_implicit_module_warning) + if (have_implicit_module_warning) + add_compile_options(-Werror=read-modules-implicitly) + endif () +endif () + add_library(a STATIC) target_sources(a PUBLIC diff --git a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt index d227e55..a3e55f6 100644 --- a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") find_package(export_bmi_and_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt index d46d28b..0144b70 100644 --- a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") find_package(export_bmi_and_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt index 3cd156a..bd2f2d4 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") find_package(export_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt index 71bf86c..87451fe 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") find_package(export_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt index 0c094ac..5b6abc6 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") find_package(export_interfaces_no_properties REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt index 0c094ac..5b6abc6 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") find_package(export_interfaces_no_properties REQUIRED) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt deleted file mode 100644 index 9080942..0000000 --- a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -^CMake Warning: - The "Visual Studio 11 2012" generator is deprecated and will be removed in - a future version of CMake. - - Add CMAKE_WARN_VS11=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON.cmake b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-OFF.cmake index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON.cmake +++ b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-OFF.cmake diff --git a/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON-stderr.txt new file mode 100644 index 0000000..b69408e --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning: + The "Visual Studio 12 2013" generator is deprecated and will be removed in + a future version of CMake. + + Add CMAKE_WARN_VS12=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-OFF.cmake b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON.cmake index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-OFF.cmake +++ b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON.cmake diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 45b4c0e..611dde2 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -1119,9 +1119,9 @@ if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 2008") run_cmake_with_options(DeprecateVS9-WARN-OFF -DCMAKE_WARN_VS9=OFF) endif() -if(RunCMake_GENERATOR MATCHES "^Visual Studio 11 2012") - run_cmake_with_options(DeprecateVS11-WARN-ON -DCMAKE_WARN_VS11=ON) - unset(ENV{CMAKE_WARN_VS11}) - run_cmake(DeprecateVS11-WARN-ON) - run_cmake_with_options(DeprecateVS11-WARN-OFF -DCMAKE_WARN_VS11=OFF) +if(RunCMake_GENERATOR MATCHES "^Visual Studio 12 2013") + run_cmake_with_options(DeprecateVS12-WARN-ON -DCMAKE_WARN_VS12=ON) + unset(ENV{CMAKE_WARN_VS12}) + run_cmake(DeprecateVS12-WARN-ON) + run_cmake_with_options(DeprecateVS12-WARN-OFF -DCMAKE_WARN_VS12=OFF) endif() diff --git a/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator-stdout.txt b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator-stdout.txt new file mode 100644 index 0000000..9a7d746 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator-stdout.txt @@ -0,0 +1,2 @@ +-- env_emulator='pseudo_emulator(\.exe)?' +-- emulator='pseudo_emulator(\.exe)?' diff --git a/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator.cmake b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator.cmake new file mode 100644 index 0000000..55fc483 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator.cmake @@ -0,0 +1,6 @@ +message(STATUS "ENV{CMAKE_CROSS_COMPILING_EMULATOR}='$ENV{CMAKE_CROSSCOMPILING_EMULATOR}'") +message(STATUS "CMAKE_CROSSCOMPLING_EMULATOR='${CMAKE_CROSSCOMPILING_EMULATOR}'") +get_filename_component(env_emulator "$ENV{CMAKE_CROSSCOMPILING_EMULATOR}" NAME) +message(STATUS "env_emulator='${env_emulator}'") +get_filename_component(emulator "${CMAKE_CROSSCOMPILING_EMULATOR}" NAME) +message(STATUS "emulator='${emulator}'") diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake index 97b7b5a..1ffd91c 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake @@ -26,3 +26,11 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND_ARG}\;custom_argument") CustomCommandGenerator_run_and_build(AddCustomCommandWithArg) CustomCommandGenerator_run_and_build(AddCustomTargetWithArg) +unset(RunCMake_TEST_OPTIONS) + +function(run_EnvCrossCompilingEmulator) + set(ENV{CMAKE_CROSSCOMPILING_EMULATOR} "${PSEUDO_EMULATOR}") + run_cmake(EnvCrossCompilingEmulator) + unset(ENV{CMAKE_CROSSCOMPILING_EMULATOR}) +endfunction() +run_EnvCrossCompilingEmulator() diff --git a/Tests/RunCMake/Framework/FrameworkConsumption.cmake b/Tests/RunCMake/Framework/FrameworkConsumption.cmake index 2180cf9..f831a94 100644 --- a/Tests/RunCMake/Framework/FrameworkConsumption.cmake +++ b/Tests/RunCMake/Framework/FrameworkConsumption.cmake @@ -1,5 +1,7 @@ enable_language(C) +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install") + # Create framework and ensure header is placed in Headers set(input_header "${CMAKE_SOURCE_DIR}/Gui.h") add_library(Gui SHARED Gui.c "${input_header}") @@ -8,6 +10,8 @@ set_target_properties(Gui PROPERTIES FRAMEWORK TRUE ) +install(TARGETS Gui DESTINATION .) + add_executable(app main.c) target_link_libraries(app PRIVATE Gui) diff --git a/Tests/RunCMake/Framework/ImportedFrameworkConsumption.cmake b/Tests/RunCMake/Framework/ImportedFrameworkConsumption.cmake new file mode 100644 index 0000000..c44a1bb --- /dev/null +++ b/Tests/RunCMake/Framework/ImportedFrameworkConsumption.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(Gui IMPORTED UNKNOWN) +set_property(TARGET Gui PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/../FrameworkConsumption-build/install/Gui.framework") + +add_executable(app main.c) +target_link_libraries(app PRIVATE Gui) diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index a767130..7319a59 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -113,7 +113,16 @@ function(framework_consumption) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(FrameworkConsumption) - run_cmake_command(FrameworkConsumption-build ${CMAKE_COMMAND} --build .) + run_cmake_command(FrameworkConsumption-build ${CMAKE_COMMAND} --build . --config Release) + run_cmake_command(FrameworkConsumption-install ${CMAKE_COMMAND} --install . --config Release) + + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ImportedFrameworkConsumption-build") + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(ImportedFrameworkConsumption) + run_cmake_command(ImportedFrameworkConsumption-build ${CMAKE_COMMAND} --build . --config Release) endfunction() framework_consumption() diff --git a/Tests/RunCMake/MSVCRuntimeTypeInfo/CMP0117-OLD-stderr.txt b/Tests/RunCMake/MSVCRuntimeTypeInfo/CMP0117-OLD-stderr.txt new file mode 100644 index 0000000..4499d97 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeTypeInfo/CMP0117-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0117-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0117 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/Make/DetectJobServer-absent-parallel-build-stderr.txt b/Tests/RunCMake/Make/DetectJobServer-absent-parallel-build-stderr.txt new file mode 100644 index 0000000..c63bde3 --- /dev/null +++ b/Tests/RunCMake/Make/DetectJobServer-absent-parallel-build-stderr.txt @@ -0,0 +1 @@ +^(Warning: (Borland's make|NMake|Watcom's WMake) does not support parallel builds\. Ignoring parallel build command line option\.)?$ diff --git a/Tests/RunCMake/Make/DetectJobServer-absent.cmake b/Tests/RunCMake/Make/DetectJobServer-absent.cmake new file mode 100644 index 0000000..e3dddc0 --- /dev/null +++ b/Tests/RunCMake/Make/DetectJobServer-absent.cmake @@ -0,0 +1,13 @@ +# Verifies that the jobserver connection is absent +add_custom_command(OUTPUT custom_command.txt + JOB_SERVER_AWARE OFF + COMMENT "Should not detect jobserver" + COMMAND ${DETECT_JOBSERVER} --absent "custom_command.txt" +) + +# trigger the custom command to run +add_custom_target(dummy ALL + JOB_SERVER_AWARE OFF + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/custom_command.txt + COMMAND ${DETECT_JOBSERVER} --absent "custom_target.txt" +) diff --git a/Tests/RunCMake/Make/DetectJobServer-present.cmake b/Tests/RunCMake/Make/DetectJobServer-present.cmake new file mode 100644 index 0000000..a33658f --- /dev/null +++ b/Tests/RunCMake/Make/DetectJobServer-present.cmake @@ -0,0 +1,13 @@ +# Verifies that the jobserver is present +add_custom_command(OUTPUT custom_command.txt + JOB_SERVER_AWARE ON + COMMENT "Should detect jobserver support" + COMMAND ${DETECT_JOBSERVER} --present "custom_command.txt" +) + +# trigger the custom command to run +add_custom_target(dummy ALL + JOB_SERVER_AWARE ON + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/custom_command.txt + COMMAND ${DETECT_JOBSERVER} --present "custom_target.txt" +) diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake new file mode 100644 index 0000000..7c5c296 --- /dev/null +++ b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake @@ -0,0 +1,12 @@ +# This test verifies that the commands in the generated Makefiles contain the +# `+` prefix +function(check_for_plus_prefix target) + set(file "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build/${target}") + file(READ "${file}" build_file) + if(NOT "${build_file}" MATCHES [[\+]]) + message(FATAL_ERROR "The file ${file} does not contain the expected prefix in the custom command.") + endif() +endfunction() + +check_for_plus_prefix("CMakeFiles/dummy.dir/build.make") +check_for_plus_prefix("CMakeFiles/dummy2.dir/build.make") diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake new file mode 100644 index 0000000..951c2d7 --- /dev/null +++ b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake @@ -0,0 +1,12 @@ +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/custom-command" + JOB_SERVER_AWARE ON + COMMAND $(CMAKE_COMMAND) -E touch "${CMAKE_CURRENT_BINARY_DIR}/custom-command" +) +add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/custom-command") + +add_custom_target( + dummy2 ALL + JOB_SERVER_AWARE ON + COMMAND ${CMAKE_COMMAND} -E true +) diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index c7717ec..12904c8 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -70,3 +70,43 @@ if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") run_CMP0113(OLD) run_CMP0113(NEW) endif() + +function(detect_jobserver_present is_parallel) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DetectJobServer-present-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DDETECT_JOBSERVER=${DETECT_JOBSERVER}") + run_cmake(DetectJobServer-present) + if (is_parallel) + run_cmake_command(DetectJobServer-present-parallel-build ${CMAKE_COMMAND} --build . -j4) + else() + run_cmake_command(DetectJobServer-present-build ${CMAKE_COMMAND} --build .) + endif() +endfunction() + +function(detect_jobserver_absent is_parallel) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DetectJobServer-absent-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DDETECT_JOBSERVER=${DETECT_JOBSERVER}") + run_cmake(DetectJobServer-absent) + if (is_parallel) + run_cmake_command(DetectJobServer-absent-parallel-build ${CMAKE_COMMAND} --build . -j4) + else() + run_cmake_command(DetectJobServer-absent-build ${CMAKE_COMMAND} --build .) + endif() +endfunction() + +# Jobservers are currently only supported by GNU makes, except MSYS2 make +if(MAKE_IS_GNU AND NOT RunCMake_GENERATOR MATCHES "MSYS Makefiles") + detect_jobserver_present(ON) +else() + detect_jobserver_absent(ON) +endif() +# No matter which generator is used, the jobserver should not be present if a +# parallel build is not requested +detect_jobserver_absent(OFF) + +if(MAKE_IS_GNU) + # In GNU makes, `JOB_SERVER_AWARE` support is implemented by prefixing + # commands with the '+' operator. + run_cmake(GNUMakeJobServerAware) +endif() diff --git a/Tests/RunCMake/Ninja/QtAutoMocDeps-stderr.txt b/Tests/RunCMake/Ninja/QtAutoMocDeps-stderr.txt new file mode 100644 index 0000000..6024984 --- /dev/null +++ b/Tests/RunCMake/Ninja/QtAutoMocDeps-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at QtSubDir1/CMakeLists\.txt:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0116 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\.$ diff --git a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake index c7a118f..537f67d 100644 --- a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake +++ b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake @@ -6,7 +6,7 @@ run_cmake(CMP0078-NEW) run_cmake(CMP0086-WARN) -if (CMake_TEST_FindPython) +if (CMake_TEST_FindPython2 OR CMake_TEST_FindPython3) macro(run_cmake_target test subtest target) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-Direct-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-Direct-stderr.txt new file mode 100644 index 0000000..53f603e --- /dev/null +++ b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-Direct-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0120-OLD-Direct\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0120 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/WriteCompilerDetectionHeader/CMP0120-OLD-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-stderr.txt new file mode 100644 index 0000000..fea708f --- /dev/null +++ b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0120-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0120 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/XcodeProject-Device/DeploymentTarget.c b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c index 5e0f40f..c00fce7 100644 --- a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c +++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c @@ -5,6 +5,10 @@ # if __MAC_OS_X_VERSION_MIN_REQUIRED != __MAC_10_11 # error macOS deployment version mismatch # endif +#elif TARGET_OS_XR +# if __XR_OS_VERSION_MIN_REQUIRED != __XROS_1_0 +# error visionOS deployment version mismatch +# endif #elif TARGET_OS_IOS # if __IPHONE_OS_VERSION_MIN_REQUIRED != __IPHONE_9_1 # error iOS deployment version mismatch diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake index 234ceef..80e3877 100644 --- a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake +++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake @@ -7,6 +7,12 @@ 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_ENABLE_BITCODE "NO") +elseif(CMAKE_SYSTEM_NAME STREQUAL "visionOS") + set(CMAKE_OSX_DEPLOYMENT_TARGET "1.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 "watchOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") diff --git a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake index e2ed045..b3ab624 100644 --- a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake @@ -93,6 +93,25 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1) unset(RunCMake_TEST_OPTIONS) endif() +if(NOT XCODE_VERSION VERSION_LESS 15) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesVisionOS-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=visionOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeBundles) + run_cmake_command(XcodeBundles-build-visionOS ${CMAKE_COMMAND} --build .) + run_cmake_command(XcodeBundles-install-visionOS ${CMAKE_COMMAND} --build . --target install) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() + if(NOT XCODE_VERSION VERSION_LESS 7) set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake") run_cmake(XcodeTbdStub) @@ -242,6 +261,10 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) deployment_target_test(tvOS appletvsimulator) deployment_target_test(watchOS watchos) deployment_target_test(watchOS watchsimulator) + if(XCODE_VERSION VERSION_GREATER_EQUAL 15) + deployment_target_test(visionOS xros) + deployment_target_test(visionOS xrsimulator) + endif() endif() if(XCODE_VERSION VERSION_GREATER_EQUAL 8) diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake index a9fafd2..376a7fc 100644 --- a/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake @@ -9,7 +9,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") endif() -if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS" 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 "") diff --git a/Tests/RunCMake/detect_jobserver.c b/Tests/RunCMake/detect_jobserver.c new file mode 100644 index 0000000..a6c1a7c --- /dev/null +++ b/Tests/RunCMake/detect_jobserver.c @@ -0,0 +1,204 @@ +#ifndef _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1928 +# pragma warning(disable : 5105) /* macro expansion warning in windows.h */ +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define MAX_MESSAGE_LENGTH 1023 +#define USAGE "Usage: %s [--present|--absent] <output_file>\n" + +// Extracts --jobserver-auth=<string> or --jobserver-fds=<string> from +// MAKEFLAGS. The returned pointer points to the start of <string> Returns NULL +// if MAKEFLAGS is not set or does not contain --jobserver-auth or +// --jobserver-fds +char* jobserver_auth(char* message) +{ + const char* jobserver_auth = "--jobserver-auth="; + const char* jobserver_fds = "--jobserver-fds="; + char* auth; + char* fds; + char* start; + char* end; + char* result; + size_t len; + + char* makeflags = getenv("MAKEFLAGS"); + if (makeflags == NULL) { + strncpy(message, "MAKEFLAGS not set", MAX_MESSAGE_LENGTH); + return NULL; + } + + // write MAKEFLAGS to stdout for debugging + fprintf(stdout, "MAKEFLAGS: %s\n", makeflags); + + auth = strstr(makeflags, jobserver_auth); + fds = strstr(makeflags, jobserver_fds); + if (auth == NULL && fds == NULL) { + strncpy(message, "No jobserver found", MAX_MESSAGE_LENGTH); + return NULL; + } else if (auth != NULL) { + start = auth + strlen(jobserver_auth); + } else { + start = fds + strlen(jobserver_fds); + } + + end = strchr(start, ' '); + if (end == NULL) { + end = start + strlen(start); + } + len = (size_t)(end - start); + result = (char*)malloc(len + 1); + strncpy(result, start, len); + result[len] = '\0'; + + return result; +} + +#if defined(_WIN32) +# include <windows.h> + +int windows_semaphore(const char* semaphore, char* message) +{ + // Open the semaphore + HANDLE hSemaphore = OpenSemaphoreA(SEMAPHORE_ALL_ACCESS, FALSE, semaphore); + + if (hSemaphore == NULL) { +# if defined(_MSC_VER) && _MSC_VER < 1900 + sprintf(message, "Error opening semaphore: %s (%ld)\n", semaphore, + GetLastError()); +# else + snprintf(message, MAX_MESSAGE_LENGTH, + "Error opening semaphore: %s (%ld)\n", semaphore, GetLastError()); +# endif + return 1; + } + + strncpy(message, "Success", MAX_MESSAGE_LENGTH); + return 0; +} +#else +# include <errno.h> +# include <fcntl.h> + +int test_fd(int read_fd, int write_fd, char* message) +{ + // Detect if the file descriptors are valid + int read_good = fcntl(read_fd, F_GETFD) != -1; + int read_error = errno; + + int write_good = fcntl(write_fd, F_GETFD) != -1; + int write_error = errno; + + if (!read_good || !write_good) { + snprintf(message, MAX_MESSAGE_LENGTH, + "Error opening file descriptors: %d (%s), %d (%s)\n", read_fd, + strerror(read_error), write_fd, strerror(write_error)); + return 1; + } + + snprintf(message, MAX_MESSAGE_LENGTH, "Success\n"); + return 0; +} + +int posix(const char* jobserver, char* message) +{ + int read_fd; + int write_fd; + const char* path; + + // First try to parse as "R,W" file descriptors + if (sscanf(jobserver, "%d,%d", &read_fd, &write_fd) == 2) { + return test_fd(read_fd, write_fd, message); + } + + // Then try to parse as "fifo:PATH" + if (strncmp(jobserver, "fifo:", 5) == 0) { + path = jobserver + 5; + read_fd = open(path, O_RDONLY); + write_fd = open(path, O_WRONLY); + return test_fd(read_fd, write_fd, message); + } + + // We don't understand the format + snprintf(message, MAX_MESSAGE_LENGTH, "Unrecognized jobserver format: %s\n", + jobserver); + return 1; +} +#endif + +// Takes 2 arguments: +// Either --present or --absent to indicate we expect the jobserver to be +// "present and valid", or "absent or invalid" +// +// if `--present` is passed, the exit code will be 0 if the jobserver is +// present, 1 if it is absent if `--absent` is passed, the exit code will be 0 +// if the jobserver is absent, 1 if it is present in either case, if there is +// some fatal error (e.g the output file cannot be opened), the exit code will +// be 2 +int main(int argc, char** argv) +{ + char message[MAX_MESSAGE_LENGTH + 1]; + char* output_file; + FILE* fp; + int expecting_present; + int expecting_absent; + char* jobserver; + int result; + + if (argc != 3) { + fprintf(stderr, USAGE, argv[0]); + return 2; + } + + expecting_present = strcmp(argv[1], "--present") == 0; + expecting_absent = strcmp(argv[1], "--absent") == 0; + if (!expecting_present && !expecting_absent) { + fprintf(stderr, USAGE, argv[0]); + return 2; + } + + output_file = argv[2]; + fp = fopen(output_file, "w"); + if (fp == NULL) { + fprintf(stderr, "Error opening output file: %s\n", output_file); + return 2; + } + + jobserver = jobserver_auth(message); + if (jobserver == NULL) { + if (expecting_absent) { + fprintf(stdout, "Success\n"); + return 0; + } + + fprintf(stderr, "%s\n", message); + return 1; + } + +#if defined(_WIN32) + result = windows_semaphore(jobserver, message); +#else + result = posix(jobserver, message); +#endif + free(jobserver); + message[MAX_MESSAGE_LENGTH] = 0; + + if (result == 0 && expecting_present) { + fprintf(stdout, "Success\n"); + return 0; + } + + if (result == 1 && expecting_absent) { + fprintf(stdout, "Success\n"); + return 0; + } + + fprintf(stderr, "%s\n", message); + return 1; +} diff --git a/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt b/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt index 185720b..b0bf460 100644 --- a/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt +++ b/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt @@ -1,4 +1,4 @@ .*find_library considered the following locations.* -.*\(lib\)library_no_exist\(\\.tbd\|\\.dylib\|\\.so\|\\.a\).* +.*liblibrary_no_exist\(\\.tbd\|\\.dylib\|\\.so\|\\.a\).* .*The item was found at.* .*lib/libcreated.a.* diff --git a/Tests/RunCMake/find_library/FromScriptMode-stderr.txt b/Tests/RunCMake/find_library/FromScriptMode-stderr.txt index 046f680..6f25184 100644 --- a/Tests/RunCMake/find_library/FromScriptMode-stderr.txt +++ b/Tests/RunCMake/find_library/FromScriptMode-stderr.txt @@ -1,4 +1,4 @@ .*find_library considered the following locations.* -.*\(lib\)library_no_exist\(\\.so\|\\.a\).* +.*liblibrary_no_exist\(\\.so\|\\.a\).* .*The item was found at.* .*lib/libcreated.a.* diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake index 4a0f068..65c708c 100644 --- a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake +++ b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake @@ -14,8 +14,14 @@ set_property(TARGET import-local PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMA set_property(TARGET import-local PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}") add_library(alias::local ALIAS import-local) +if(NOT DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX) + add_library(import-local-stub SHARED IMPORTED) + set_property(TARGET import-local-stub PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}") + add_library(alias::local-stub ALIAS import-local-stub) +endif() + add_library (lib-local SHARED lib.c) -target_link_libraries (lib-local PRIVATE alias::local) +target_link_libraries (lib-local PRIVATE alias::local $<TARGET_NAME_IF_EXISTS:alias::local-stub>) add_executable (main-local main.c) target_link_libraries (main-local PRIVATE alias::local) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake index 9b6581c..8e4745a 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake @@ -126,7 +126,7 @@ if ((CMAKE_SYSTEM_NAME STREQUAL "Windows" AND ((DEFINED MSVC_VERSION AND MSVC_VERSION GREATER "1900") OR (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC"))) OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION GREATER "5.9")) - OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS|Linux|BSD|MSYS|CYGWIN") + OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|visionOS|watchOS|Linux|BSD|MSYS|CYGWIN") run_cmake(feature-WHOLE_ARCHIVE) run_cmake_target(feature-WHOLE_ARCHIVE link-exe main) endif() diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake b/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake new file mode 100644 index 0000000..04f9cfb --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake @@ -0,0 +1,2 @@ +add_library(SharedStubImportedGlobal SHARED IMPORTED GLOBAL) +set_target_properties(SharedStubImportedGlobal PROPERTIES IMPORTED_IMPLIB z) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 7c5d77d..0e3877a 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -23,6 +23,7 @@ run_cmake(CMP0079-link-NEW-bogus) run_cmake(CMP0108-OLD-self-link) run_cmake(CMP0108-NEW-self-link) run_cmake(ImportedTarget) +run_cmake(ImportedTargetStub) run_cmake(ImportedTargetFailure) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake new file mode 100644 index 0000000..0f897fe --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_\\$dollar") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_$dollar'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake index bb04841..879151b 100644 --- a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake @@ -53,3 +53,7 @@ target_link_options(LinkOptions_mod PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RE # executable with generator expression add_executable(LinkOptions_exe LinkOptionsExe.c) target_link_options(LinkOptions_exe PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>) + +# executable with dollar character +add_executable(LinkOptions_dollar_exe LinkOptionsExe.c) +target_link_options(LinkOptions_dollar_exe PRIVATE "${pre}BADFLAG_$dollar${obj}") diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake index 1a29ecf..ff0c5a8 100644 --- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake @@ -30,7 +30,7 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release) run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release) run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release) - + run_cmake_target(LINK_OPTIONS dollar-option LinkOptions_dollar_exe --config Release) run_cmake(genex_LINK_LANGUAGE) diff --git a/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport.cmake b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport.cmake new file mode 100644 index 0000000..f049d91 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +# According to https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#module:GNUInstallDirs +# relative CMAKE_INSTALL_<dir> are encouraged, but absolute path's are also allowed. +# Construct an absolute CMAKE_INSTALL_INCLUDEDIR. +set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") + +add_library(lib1) +target_sources(lib1 + PRIVATE lib1.c + PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +# Expect install(TARGETS) to respect absolute CMAKE_INSTALL_INCLUDEDIR +# when installing the HEADERS. +# Must not prepend the CMAKE_INSTALL_PREFIX in the <pkg>-config.cmake. +install(TARGETS lib1 EXPORT lib1-config FILE_SET HEADERS) +install(EXPORT lib1-config NAMESPACE lib1:: DESTINATION share/lib1) diff --git a/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirImport.cmake b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirImport.cmake new file mode 100644 index 0000000..123d6ae --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirImport.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) + +get_filename_component(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}" DIRECTORY) +string(APPEND CMAKE_PREFIX_PATH "/FileSetAbsoluteInstallIncludeDirExport-build/install") + +find_package(lib1 REQUIRED) + +add_executable(exe main.cpp) +target_link_libraries(exe PRIVATE lib1::lib1) diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake b/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake index 44f1626..84e1802 100644 --- a/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake @@ -1,6 +1,6 @@ enable_language(C) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") add_library(lib1 STATIC empty.c) target_sources(lib1 PRIVATE FILE_SET UNKNOWN) diff --git a/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake b/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake index adf1185..78e782d 100644 --- a/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake +++ b/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake @@ -1,6 +1,6 @@ enable_language(C) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "bf70d4b0-9fb7-465c-9803-34014e70d112") add_library(lib1 STATIC empty.c) target_sources(lib1 PRIVATE FILE_SET a TYPE UNKNOWN) diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index 90915cd..8505f71 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -99,3 +99,4 @@ function(run_export_import name) endfunction() run_export_import(FileSet) +run_export_import(FileSetAbsoluteInstallIncludeDir) diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt index d726395..550fe9e 100644 --- a/Tests/SourceGroups/CMakeLists.txt +++ b/Tests/SourceGroups/CMakeLists.txt @@ -63,3 +63,5 @@ add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c ${tree_files_with_prefix} ${tree_files_without_prefix} ${tree_files_with_empty_prefix} README.txt nested.c) + +add_subdirectory(sub2) diff --git a/Tests/SourceGroups/sub2/CMakeLists.txt b/Tests/SourceGroups/sub2/CMakeLists.txt new file mode 100644 index 0000000..e457bc4 --- /dev/null +++ b/Tests/SourceGroups/sub2/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(SourceGroups2 main.c + qux.c subsub/qax.c) + +source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" ) #PREFIX TheSubDir2 ) diff --git a/Tests/SourceGroups/sub2/main.c b/Tests/SourceGroups/sub2/main.c new file mode 100644 index 0000000..4cd8ae0 --- /dev/null +++ b/Tests/SourceGroups/sub2/main.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +extern int qax(void); +extern int qux(void); + +int main() +{ + printf("qux: %d qax: %d\n", qux(), qax()); + + return 0; +} diff --git a/Tests/SourceGroups/sub2/qux.c b/Tests/SourceGroups/sub2/qux.c new file mode 100644 index 0000000..1a8b6f9 --- /dev/null +++ b/Tests/SourceGroups/sub2/qux.c @@ -0,0 +1,4 @@ +int qux(void) +{ + return 1234; +} diff --git a/Tests/SourceGroups/sub2/subsub/qax.c b/Tests/SourceGroups/sub2/subsub/qax.c new file mode 100644 index 0000000..c1b1042 --- /dev/null +++ b/Tests/SourceGroups/sub2/subsub/qax.c @@ -0,0 +1,4 @@ +int qax(void) +{ + return 123; +} diff --git a/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt index a2c239c..f20593c 100644 --- a/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt +++ b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt @@ -7,7 +7,7 @@ include(CTest) find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) -find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +find_package(Python REQUIRED COMPONENTS Interpreter Development) # Path separator if (WIN32) @@ -27,9 +27,9 @@ swig_add_library(example_python set_target_properties (example_python PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.." SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE) -target_link_libraries(example_python PRIVATE Python2::Python) +target_link_libraries(example_python PRIVATE Python::Python) add_test (NAME AlternateLibraryName.example1 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:example_python>" - "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") + "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index 7c4925e..3d80270 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -147,16 +147,18 @@ add_test(NAME UseSWIG.MultipleModules COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) -add_test(NAME UseSWIG.MultiplePython COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultiplePython" - "${CMake_BINARY_DIR}/Tests/UseSWIG/MultiplePython" - ${build_generator_args} - --build-project TestMultiplePython - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> +if(CMake_TEST_FindPython2 AND CMake_TEST_FindPython3) + add_test(NAME UseSWIG.MultiplePython COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultiplePython" + "${CMake_BINARY_DIR}/Tests/UseSWIG/MultiplePython" + ${build_generator_args} + --build-project TestMultiplePython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) +endif() add_test(NAME UseSWIG.MultipleFiles COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -165,20 +167,20 @@ add_test(NAME UseSWIG.MultipleFiles COMMAND ${build_generator_args} --build-project TestMultipleFiles --build-options ${build_options} - ) - +) -add_test(NAME UseSWIG.ModuleVersion2 COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleVersion2" - "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleVersion2" - ${build_generator_args} - --build-project TestModuleVersion2 - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> +if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython3) + add_test(NAME UseSWIG.ModuleVersion2 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleVersion2" + "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleVersion2" + ${build_generator_args} + --build-project TestModuleVersion2 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - +endif() add_test(NAME UseSWIG.UseTargetINCLUDE_DIRECTORIES COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> diff --git a/Tests/UseSWIG/ModuleName/CMakeLists.txt b/Tests/UseSWIG/ModuleName/CMakeLists.txt index 435b441..c62319f 100644 --- a/Tests/UseSWIG/ModuleName/CMakeLists.txt +++ b/Tests/UseSWIG/ModuleName/CMakeLists.txt @@ -8,14 +8,7 @@ find_package(SWIG REQUIRED) cmake_policy(SET CMP0086 NEW) include(${SWIG_USE_FILE}) -find_package(Python2 REQUIRED COMPONENTS Interpreter Development) - -# Path separator -if (WIN32) - set (PS "$<SEMICOLON>") -else() - set (PS ":") -endif() +find_package(Python REQUIRED COMPONENTS Interpreter Development) unset(CMAKE_SWIG_FLAGS) @@ -34,9 +27,9 @@ set_target_properties (example1 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1") -target_link_libraries(example1 PRIVATE Python2::Module) +target_link_libraries(example1 PRIVATE Python::Module) add_test (NAME ModuleName.example1 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>" - "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py") + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example1>" + "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py") diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt index 093e858..317ed47 100644 --- a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt +++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt @@ -7,9 +7,6 @@ include(CTest) find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) -find_package(Python2 REQUIRED COMPONENTS Interpreter Development) -find_package(Python3 REQUIRED COMPONENTS Interpreter Development) - if (WIN32) set (PS $<SEMICOLON>) else() @@ -25,32 +22,69 @@ set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall) set_property(SOURCE "../example.i" PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..") -swig_add_library(example1 - LANGUAGE python - SOURCES ../example.i ../example.cxx) -set_target_properties (example1 PROPERTIES - OUTPUT_NAME example - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2") -target_link_libraries(example1 PRIVATE Python2::Module) - -# re-use sample interface file for another plugin -swig_add_library(example2 - LANGUAGE python - SOURCES ../example.i ../example.cxx) -set_target_properties (example2 PROPERTIES - OUTPUT_NAME example - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3") -target_link_libraries(example2 PRIVATE Python3::Module) - - -add_test (NAME ModuleVersion2.example1 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example1,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example1>" - "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") - -add_test (NAME ModuleVersion2.example2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example2,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example2>" - "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") +if(CMake_TEST_FindPython2) + find_package(Python2 REQUIRED COMPONENTS Interpreter Development) + + swig_add_library(example1 + LANGUAGE python + SOURCES ../example.i ../example.cxx) + set_target_properties (example1 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2-1" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2-1" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2-1") + target_link_libraries(example1 PRIVATE Python2::Module) + + add_test (NAME ModuleVersion2.example1 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example1,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example1>" + "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") + + # re-use sample interface file for another plugin + swig_add_library(example2 + LANGUAGE python + SOURCES ../example.i ../example.cxx) + set_target_properties (example2 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2-2" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2-2" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2-2") + target_link_libraries(example2 PRIVATE Python2::Module) + + add_test (NAME ModuleVersion2.example2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example2,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example2>" + "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") +endif() + +if(CMake_TEST_FindPython3) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + + swig_add_library(example3 + LANGUAGE python + SOURCES ../example.i ../example.cxx) + set_target_properties (example3 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3-1" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3-1" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3-1") + target_link_libraries(example3 PRIVATE Python3::Module) + + add_test (NAME ModuleVersion2.example3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example3,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example3>" + "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") + + + # re-use sample interface file for another plugin + swig_add_library(example4 + LANGUAGE python + SOURCES ../example.i ../example.cxx) + set_target_properties (example2 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3-2" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3-2" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3-2") + target_link_libraries(example4 PRIVATE Python3::Module) + + add_test (NAME ModuleVersion2.example4 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example4,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example4>" + "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") +endif() diff --git a/Tests/UseSWIG/MultipleFiles/CMakeLists.txt b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt index bf3d946..36734f9 100644 --- a/Tests/UseSWIG/MultipleFiles/CMakeLists.txt +++ b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt @@ -11,7 +11,7 @@ unset(SWIG_LANG_DEFINITIONS) unset(SWIG_LANG_OPTIONS) unset(SWIG_LANG_LIBRARIES) -find_package(Python3 REQUIRED COMPONENTS Development) +find_package(Python REQUIRED COMPONENTS Development) set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/add.i" PROPERTY CPLUSPLUS ON) set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" PROPERTY CPLUSPLUS ON) @@ -27,4 +27,4 @@ swig_add_library(example "${CMAKE_CURRENT_SOURCE_DIR}/add.cxx" "${CMAKE_CURRENT_SOURCE_DIR}/sub.cxx") target_include_directories(example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(example PRIVATE Python3::Module) +target_link_libraries(example PRIVATE Python::Module) diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt index 80a2e16..6cdf987 100644 --- a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt +++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt @@ -7,7 +7,7 @@ include(CTest) find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) -find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +find_package(Python REQUIRED COMPONENTS Interpreter Development) unset(CMAKE_SWIG_FLAGS) @@ -25,7 +25,7 @@ set_target_properties (example1 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1") -target_link_libraries(example1 PRIVATE Python3::Module) +target_link_libraries(example1 PRIVATE Python::Module) # Check that source property override target property @@ -42,4 +42,4 @@ set_target_properties (example2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2" ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2") -target_link_libraries(example2 PRIVATE Python3::Module) +target_link_libraries(example2 PRIVATE Python::Module) |