diff options
Diffstat (limited to 'Tests')
588 files changed, 8040 insertions, 509 deletions
diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 7dc7995..a5bc1e1 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -34,6 +34,7 @@ target_compile_definitions(consumer CONSUMER_LANG_$<COMPILE_LANGUAGE> LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX> LANG_IS_C=$<COMPILE_LANGUAGE:C> + LANG_IS_C_OR_CXX=$<COMPILE_LANGUAGE:C,CXX> ) if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") target_compile_definitions(consumer diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.c b/Tests/CMakeCommands/target_compile_definitions/consumer.c index bacd4c4..bb65e01 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.c +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.c @@ -35,6 +35,10 @@ # endif #endif +#if !LANG_IS_C_OR_CXX +# error Expected LANG_IS_C_OR_CXX +#endif + void consumer_c() { } diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt index 1dedbae..a7055b1 100644 --- a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt @@ -7,9 +7,11 @@ add_executable(target_compile_options "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ) target_compile_options(target_compile_options - PRIVATE $<$<CXX_COMPILER_ID:GNU>:-DMY_PRIVATE_DEFINE> - PUBLIC $<$<CXX_COMPILER_ID:GNU>:-DMY_PUBLIC_DEFINE> + PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang,GNU>:-DMY_PRIVATE_DEFINE> + PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DMY_PUBLIC_DEFINE> + PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang,AppleClang>:-DMY_MUTLI_COMP_PUBLIC_DEFINE> INTERFACE $<$<CXX_COMPILER_ID:GNU>:-DMY_INTERFACE_DEFINE> + INTERFACE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-DMY_MULTI_COMP_INTERFACE_DEFINE> ) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -17,6 +19,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") PRIVATE "DO_GNU_TESTS" ) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_definitions(target_compile_options + PRIVATE + "DO_CLANG_TESTS" + ) endif() add_executable(consumer @@ -40,7 +47,7 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio") endif() target_compile_options(consumer - PRIVATE $<$<CXX_COMPILER_ID:GNU>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>> + PRIVATE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>> ) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -48,6 +55,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") PRIVATE "DO_GNU_TESTS" ) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_definitions(consumer + PRIVATE + "DO_CLANG_TESTS" + ) endif() # Test no items diff --git a/Tests/CMakeCommands/target_compile_options/consumer.cpp b/Tests/CMakeCommands/target_compile_options/consumer.cpp index fe79eb5..78928b4 100644 --- a/Tests/CMakeCommands/target_compile_options/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_options/consumer.cpp @@ -13,6 +13,30 @@ # error Expected MY_INTERFACE_DEFINE # endif +# ifndef MY_MULTI_COMP_INTERFACE_DEFINE +# error Expected MY_MULTI_COMP_INTERFACE_DEFINE +# endif + +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif + +#endif + +#ifdef DO_CLANG_TESTS + +# ifdef MY_PRIVATE_DEFINE +# error Unexpected MY_PRIVATE_DEFINE +# endif + +# ifndef MY_MULTI_COMP_INTERFACE_DEFINE +# error Expected MY_MULTI_COMP_INTERFACE_DEFINE +# endif + +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif + #endif #ifndef CONSUMER_LANG_CXX diff --git a/Tests/CMakeCommands/target_compile_options/main.cpp b/Tests/CMakeCommands/target_compile_options/main.cpp index 829a25e..7608400 100644 --- a/Tests/CMakeCommands/target_compile_options/main.cpp +++ b/Tests/CMakeCommands/target_compile_options/main.cpp @@ -9,12 +9,32 @@ # error Expected MY_PUBLIC_DEFINE # endif +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif + # ifdef MY_INTERFACE_DEFINE # error Unexpected MY_INTERFACE_DEFINE # endif #endif +#ifdef DO_CLANG_TESTS + +# ifndef MY_PRIVATE_DEFINE +# error Expected MY_PRIVATE_DEFINE +# endif + +# ifdef MY_PUBLIC_DEFINE +# error Unexpected MY_PUBLIC_DEFINE +# endif + +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif + +#endif + int main() { return 0; diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index f6a9153..a25f25a 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -5,18 +5,26 @@ include_directories( ) set(CMakeLib_TESTS + testArgumentParser.cxx testGeneratedFileStream.cxx testRST.cxx + testRange.cxx testString.cxx testSystemTools.cxx testUTF8.cxx testXMLParser.cxx testXMLSafe.cxx testFindPackageCommand.cxx + testUVProcessChain.cxx testUVRAII.cxx + testUVStreambuf.cxx ) +add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx) + set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}) +set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>) +set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>) if(WIN32) list(APPEND CMakeLib_TESTS @@ -41,7 +49,7 @@ target_link_libraries(testEncoding cmsys) foreach(testfile ${CMakeLib_TESTS}) get_filename_component(test "${testfile}" NAME_WE) - add_test(CMakeLib.${test} CMakeLibTests ${test} ${${test}_ARGS}) + add_test(NAME CMakeLib.${test} COMMAND CMakeLibTests ${test} ${${test}_ARGS}) endforeach() if(TEST_CompileCommandOutput) diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx new file mode 100644 index 0000000..788fece --- /dev/null +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -0,0 +1,148 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmArgumentParser.h" + +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" + +#include <initializer_list> +#include <iostream> +#include <string> +#include <vector> + +namespace { + +struct Result +{ + bool Option1 = false; + bool Option2 = false; + + std::string String1; + std::string String2; + + std::vector<std::string> List1; + std::vector<std::string> List2; + std::vector<std::string> List3; + + std::vector<std::vector<std::string>> Multi1; + std::vector<std::vector<std::string>> Multi2; + std::vector<std::vector<std::string>> Multi3; +}; + +std::initializer_list<cm::string_view> const args = { + /* clang-format off */ + "OPTION_1", // option + "STRING_1", // string arg missing value + "STRING_2", "foo", "bar", // string arg + unparsed value + "LIST_1", // list arg missing values + "LIST_2", "foo", "bar", // list arg with 2 elems + "LIST_3", "bar", // list arg ... + "LIST_3", "foo", // ... with continuation + "MULTI_2", // multi list with 0 lists + "MULTI_3", "foo", "bar", // multi list with first list with two elems + "MULTI_3", "bar", "foo", // multi list with second list with two elems + /* clang-format on */ +}; + +bool verifyResult(Result const& result, + std::vector<std::string> const& unparsedArguments, + std::vector<std::string> const& keywordsMissingValue) +{ + static std::vector<std::string> const foobar = { "foo", "bar" }; + static std::vector<std::string> const barfoo = { "bar", "foo" }; + static std::vector<std::string> const missing = { "STRING_1", "LIST_1" }; + +#define ASSERT_TRUE(x) \ + do { \ + if (!(x)) { \ + std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ + return false; \ + } \ + } while (false) + + ASSERT_TRUE(result.Option1); + ASSERT_TRUE(!result.Option2); + + ASSERT_TRUE(result.String1.empty()); + ASSERT_TRUE(result.String2 == "foo"); + + ASSERT_TRUE(result.List1.empty()); + ASSERT_TRUE(result.List2 == foobar); + ASSERT_TRUE(result.List3 == barfoo); + + ASSERT_TRUE(result.Multi1.empty()); + ASSERT_TRUE(result.Multi2.size() == 1); + ASSERT_TRUE(result.Multi2[0].empty()); + ASSERT_TRUE(result.Multi3.size() == 2); + ASSERT_TRUE(result.Multi3[0] == foobar); + ASSERT_TRUE(result.Multi3[1] == barfoo); + + ASSERT_TRUE(unparsedArguments.size() == 1); + ASSERT_TRUE(unparsedArguments[0] == "bar"); + ASSERT_TRUE(keywordsMissingValue == missing); + + return true; +} + +bool testArgumentParserDynamic() +{ + Result result; + std::vector<std::string> unparsedArguments; + std::vector<std::string> keywordsMissingValue; + + cmArgumentParser<void>{} + .Bind("OPTION_1"_s, result.Option1) + .Bind("OPTION_2"_s, result.Option2) + .Bind("STRING_1"_s, result.String1) + .Bind("STRING_2"_s, result.String2) + .Bind("LIST_1"_s, result.List1) + .Bind("LIST_2"_s, result.List2) + .Bind("LIST_3"_s, result.List3) + .Bind("MULTI_1"_s, result.Multi1) + .Bind("MULTI_2"_s, result.Multi2) + .Bind("MULTI_3"_s, result.Multi3) + .Parse(args, &unparsedArguments, &keywordsMissingValue); + + return verifyResult(result, unparsedArguments, keywordsMissingValue); +} + +bool testArgumentParserStatic() +{ + static auto const parser = // + cmArgumentParser<Result>{} + .Bind("OPTION_1"_s, &Result::Option1) + .Bind("OPTION_2"_s, &Result::Option2) + .Bind("STRING_1"_s, &Result::String1) + .Bind("STRING_2"_s, &Result::String2) + .Bind("LIST_1"_s, &Result::List1) + .Bind("LIST_2"_s, &Result::List2) + .Bind("LIST_3"_s, &Result::List3) + .Bind("MULTI_1"_s, &Result::Multi1) + .Bind("MULTI_2"_s, &Result::Multi2) + .Bind("MULTI_3"_s, &Result::Multi3); + + std::vector<std::string> unparsedArguments; + std::vector<std::string> keywordsMissingValue; + Result const result = + parser.Parse(args, &unparsedArguments, &keywordsMissingValue); + + return verifyResult(result, unparsedArguments, keywordsMissingValue); +} + +} // namespace + +int testArgumentParser(int /*unused*/, char* /*unused*/ []) +{ + if (!testArgumentParserDynamic()) { + std::cout << "While executing testArgumentParserDynamic().\n"; + return -1; + } + + if (!testArgumentParserStatic()) { + std::cout << "While executing testArgumentParserStatic().\n"; + return -1; + } + + return 0; +} diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect index d7b91d1..c19ee94 100644 --- a/Tests/CMakeLib/testRST.expect +++ b/Tests/CMakeLib/testRST.expect @@ -83,6 +83,10 @@ or after a paragraph ending in two colons:: but not after a line ending in two colons:: in the middle of a paragraph. +A literal block can be empty:: + + + .. productionlist:: grammar: `production` production: "content rendered" diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst index 633219f..d2d1140 100644 --- a/Tests/CMakeLib/testRST.rst +++ b/Tests/CMakeLib/testRST.rst @@ -90,6 +90,10 @@ or after a paragraph ending in two colons:: but not after a line ending in two colons:: in the middle of a paragraph. +A literal block can be empty:: + + + .. productionlist:: grammar: `production` production: "content rendered" diff --git a/Tests/CMakeLib/testRange.cxx b/Tests/CMakeLib/testRange.cxx new file mode 100644 index 0000000..b26b07b --- /dev/null +++ b/Tests/CMakeLib/testRange.cxx @@ -0,0 +1,45 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmRange.h" + +#include <iostream> +#include <string> +#include <vector> + +#define ASSERT_TRUE(x) \ + do { \ + if (!(x)) { \ + std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ + return -1; \ + } \ + } while (false) + +int testRange(int /*unused*/, char* /*unused*/ []) +{ + std::vector<int> const testData = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + + ASSERT_TRUE(!cmMakeRange(testData).empty()); + ASSERT_TRUE(cmMakeRange(testData).size() == 10); + + ASSERT_TRUE(!cmMakeRange(testData).advance(5).empty()); + ASSERT_TRUE(cmMakeRange(testData).advance(5).size() == 5); + + ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).empty()); + ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).size() == 0); + + ASSERT_TRUE(cmMakeRange(testData).any_of([](int n) { return n % 3 == 0; })); + ASSERT_TRUE(cmMakeRange(testData).all_of([](int n) { return n < 11; })); + ASSERT_TRUE(cmMakeRange(testData).none_of([](int n) { return n > 11; })); + + std::vector<int> const evenData = { 2, 4, 6, 8, 10 }; + ASSERT_TRUE(cmMakeRange(testData).filter([](int n) { return n % 2 == 0; }) == + cmMakeRange(evenData)); + + std::vector<std::string> const stringRange = { "1", "2", "3", "4", "5" }; + ASSERT_TRUE(cmMakeRange(testData) + .transform([](int n) { return std::to_string(n); }) + .retreat(5) == cmMakeRange(stringRange)); + + return 0; +} diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index 96a4819..121e639 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -93,5 +93,22 @@ int testSystemTools(int /*unused*/, char* /*unused*/ []) if (!failed) { cmPassed("cmSystemTools::strverscmp working"); } + + // ---------------------------------------------------------------------- + // Test cmSystemTools::StringToULong + { + unsigned long value; + cmAssert(cmSystemTools::StringToULong("1", &value) && value == 1, + "StringToULong parses a decimal integer."); + cmAssert(cmSystemTools::StringToULong(" 1", &value) && value == 1, + "StringToULong parses a decimal integer after whitespace."); + cmAssert(!cmSystemTools::StringToULong("-1", &value), + "StringToULong rejects a negative number."); + cmAssert(!cmSystemTools::StringToULong(" -1", &value), + "StringToULong rejects a negative number after whitespace."); + cmAssert(!cmSystemTools::StringToULong("1x", &value), + "StringToULong rejects trailing content."); + } + return failed; } diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx index c99c46d..a0bb5cd 100644 --- a/Tests/CMakeLib/testUTF8.cxx +++ b/Tests/CMakeLib/testUTF8.cxx @@ -13,6 +13,21 @@ static void test_utf8_char_print(test_utf8_char const c) static_cast<int>(d[3])); } +static void byte_array_print(char const* s) +{ + unsigned char const* d = reinterpret_cast<unsigned char const*>(s); + bool started = false; + printf("["); + for (; *d; ++d) { + if (started) { + printf(","); + } + started = true; + printf("0x%02X", static_cast<int>(*d)); + } + printf("]"); +} + struct test_utf8_entry { int n; @@ -21,17 +36,36 @@ struct test_utf8_entry }; static test_utf8_entry const good_entry[] = { - { 1, "\x20\x00\x00\x00", 0x0020 }, /* Space. */ - { 2, "\xC2\xA9\x00\x00", 0x00A9 }, /* Copyright. */ - { 3, "\xE2\x80\x98\x00", 0x2018 }, /* Open-single-quote. */ - { 3, "\xE2\x80\x99\x00", 0x2019 }, /* Close-single-quote. */ - { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629. */ + { 1, "\x20\x00\x00\x00", 0x0020 }, /* Space. */ + { 2, "\xC2\xA9\x00\x00", 0x00A9 }, /* Copyright. */ + { 3, "\xE2\x80\x98\x00", 0x2018 }, /* Open-single-quote. */ + { 3, "\xE2\x80\x99\x00", 0x2019 }, /* Close-single-quote. */ + { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629. */ + { 3, "\xED\x80\x80\x00", 0xD000 }, /* Valid 0xED prefixed codepoint. */ + { 4, "\xF4\x8F\xBF\xBF", 0x10FFFF }, /* Highest valid RFC codepoint. */ { 0, { 0, 0, 0, 0, 0 }, 0 } }; static test_utf8_char const bad_chars[] = { - "\x80\x00\x00\x00", "\xC0\x00\x00\x00", "\xE0\x00\x00\x00", - "\xE0\x80\x80\x00", "\xF0\x80\x80\x80", { 0, 0, 0, 0, 0 } + "\x80\x00\x00\x00", /* Leading continuation byte. */ + "\xC0\x80\x00\x00", /* Overlong encoding. */ + "\xC1\x80\x00\x00", /* Overlong encoding. */ + "\xC2\x00\x00\x00", /* Missing continuation byte. */ + "\xE0\x00\x00\x00", /* Missing continuation bytes. */ + "\xE0\x80\x80\x00", /* Overlong encoding. */ + "\xF0\x80\x80\x80", /* Overlong encoding. */ + "\xED\xA0\x80\x00", /* UTF-16 surrogate half. */ + "\xED\xBF\xBF\x00", /* UTF-16 surrogate half. */ + "\xF4\x90\x80\x80", /* Lowest out-of-range codepoint. */ + "\xF5\x80\x80\x80", /* Prefix forces out-of-range codepoints. */ + { 0, 0, 0, 0, 0 } +}; + +static char const* good_strings[] = { "", "ASCII", "\xC2\xA9 Kitware", 0 }; + +static char const* bad_strings[] = { + "\xC0\x80", /* Modified UTF-8 for embedded 0-byte. */ + 0 }; static void report_good(bool passed, test_utf8_char const c) @@ -87,6 +121,46 @@ static bool decode_bad(test_utf8_char const s) return true; } +static void report_valid(bool passed, char const* s) +{ + printf("%s: validity good ", passed ? "pass" : "FAIL"); + byte_array_print(s); + printf(" (%s) ", s); +} + +static void report_invalid(bool passed, char const* s) +{ + printf("%s: validity bad ", passed ? "pass" : "FAIL"); + byte_array_print(s); + printf(" "); +} + +static bool is_valid(const char* s) +{ + bool valid = cm_utf8_is_valid(s) != 0; + if (!valid) { + report_valid(false, s); + printf("expected valid, reported as invalid\n"); + return false; + } + report_valid(true, s); + printf("valid as expected\n"); + return true; +} + +static bool is_invalid(const char* s) +{ + bool valid = cm_utf8_is_valid(s) != 0; + if (valid) { + report_invalid(false, s); + printf("expected invalid, reported as valid\n"); + return false; + } + report_invalid(true, s); + printf("invalid as expected\n"); + return true; +} + int testUTF8(int /*unused*/, char* /*unused*/ []) { int result = 0; @@ -94,11 +168,27 @@ int testUTF8(int /*unused*/, char* /*unused*/ []) if (!decode_good(*e)) { result = 1; } + if (!is_valid(e->str)) { + result = 1; + } } for (test_utf8_char const* c = bad_chars; (*c)[0]; ++c) { if (!decode_bad(*c)) { result = 1; } + if (!is_invalid(*c)) { + result = 1; + } + } + for (char const** s = good_strings; *s; ++s) { + if (!is_valid(*s)) { + result = 1; + } + } + for (char const** s = bad_strings; *s; ++s) { + if (!is_invalid(*s)) { + result = 1; + } } return result; } diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx new file mode 100644 index 0000000..72ae602 --- /dev/null +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -0,0 +1,335 @@ +#include "cmUVProcessChain.h" + +#include "cmAlgorithms.h" +#include "cmGetPipes.h" +#include "cmUVHandlePtr.h" +#include "cmUVStreambuf.h" + +#include "cm_uv.h" + +#include <algorithm> +#include <functional> +#include <iostream> +#include <sstream> +#include <string> +#include <vector> + +#include <csignal> + +struct ExpectedStatus +{ + bool Finished; + bool MatchExitStatus; + bool MatchTermSignal; + cmUVProcessChain::Status Status; +}; + +static const std::vector<ExpectedStatus> status1 = { + { false, false, false, { 0, 0 } }, + { false, false, false, { 0, 0 } }, + { false, false, false, { 0, 0 } }, +}; + +static const std::vector<ExpectedStatus> status2 = { + { true, true, true, { 0, 0 } }, + { false, false, false, { 0, 0 } }, + { false, false, false, { 0, 0 } }, +}; + +static const std::vector<ExpectedStatus> status3 = { + { true, true, true, { 0, 0 } }, + { true, true, true, { 1, 0 } }, +#ifdef _WIN32 + { true, true, true, { 2, 0 } }, +#else + { true, false, true, { 0, SIGABRT } }, +#endif +}; + +bool operator==(const cmUVProcessChain::Status* actual, + const ExpectedStatus& expected) +{ + if (!expected.Finished) { + return !actual; + } else if (!actual) { + return false; + } + if (expected.MatchExitStatus && + expected.Status.ExitStatus != actual->ExitStatus) { + return false; + } + if (expected.MatchTermSignal && + expected.Status.TermSignal != actual->TermSignal) { + return false; + } + return true; +} + +bool resultsMatch(const std::vector<const cmUVProcessChain::Status*>& actual, + const std::vector<ExpectedStatus>& expected) +{ + return actual.size() == expected.size() && + std::equal(actual.begin(), actual.end(), expected.begin()); +} + +std::string getInput(std::istream& input) +{ + char buffer[1024]; + std::ostringstream str; + do { + input.read(buffer, 1024); + str.write(buffer, input.gcount()); + } while (input.gcount() > 0); + return str.str(); +} + +template <typename T> +std::function<std::ostream&(std::ostream&)> printExpected(bool match, + const T& value) +{ + return [match, value](std::ostream& stream) -> std::ostream& { + if (match) { + stream << value; + } else { + stream << "*"; + } + return stream; + }; +} + +std::ostream& operator<<( + std::ostream& stream, + const std::function<std::ostream&(std::ostream&)>& func) +{ + return func(stream); +} + +void printResults(const std::vector<const cmUVProcessChain::Status*>& actual, + const std::vector<ExpectedStatus>& expected) +{ + 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) + << std::endl; + } else { + std::cout << " null" << std::endl; + } + } + std::cout << "Actual:" << std::endl; + for (auto const& a : actual) { + if (a) { + std::cout << " ExitStatus: " << a->ExitStatus + << ", TermSignal: " << a->TermSignal << std::endl; + } else { + std::cout << " null" << std::endl; + } + } +} + +bool checkExecution(cmUVProcessChainBuilder& builder, + std::unique_ptr<cmUVProcessChain>& chain) +{ + std::vector<const cmUVProcessChain::Status*> status; + + chain = cm::make_unique<cmUVProcessChain>(builder.Start()); + if (!chain->Valid()) { + std::cout << "Valid() returned false, should be true" << 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(6000)) { + std::cout << "Wait() returned true, should be false" << 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; + } + + if (!chain->Wait()) { + std::cout << "Wait() returned false, should be true" << std::endl; + return false; + } + status = chain->GetStatus(); + if (!resultsMatch(status, status3)) { + std::cout << "GetStatus() did not produce expected output" << std::endl; + printResults(status, status3); + return false; + } + + return true; +} + +bool checkOutput(std::istream& outputStream, std::istream& errorStream) +{ + std::string output = getInput(outputStream); + if (output != "HELO WRD!") { + std::cout << "Output was \"" << output << "\", expected \"HELO WRD!\"" + << std::endl; + return false; + } + + std::string error = getInput(errorStream); + if (error.length() != 3 || error.find('1') == std::string::npos || + error.find('2') == std::string::npos || + error.find('3') == std::string::npos) { + std::cout << "Error was \"" << error << "\", expected \"123\"" + << std::endl; + return false; + } + + return true; +} + +bool testUVProcessChainBuiltin(const char* helperCommand) +{ + cmUVProcessChainBuilder builder; + std::unique_ptr<cmUVProcessChain> chain; + builder.AddCommand({ helperCommand, "echo" }) + .AddCommand({ helperCommand, "capitalize" }) + .AddCommand({ helperCommand, "dedup" }) + .SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT) + .SetBuiltinStream(cmUVProcessChainBuilder::Stream_ERROR); + + if (!checkExecution(builder, chain)) { + return false; + } + + if (!chain->OutputStream()) { + std::cout << "OutputStream() was null, expecting not null" << std::endl; + return false; + } + if (!chain->ErrorStream()) { + std::cout << "ErrorStream() was null, expecting not null" << std::endl; + return false; + } + + if (!checkOutput(*chain->OutputStream(), *chain->ErrorStream())) { + return false; + } + + return true; +} + +bool testUVProcessChainExternal(const char* helperCommand) +{ + cmUVProcessChainBuilder builder; + std::unique_ptr<cmUVProcessChain> chain; + int outputPipe[2], errorPipe[2]; + cm::uv_pipe_ptr outputInPipe, outputOutPipe, errorInPipe, errorOutPipe; + + if (cmGetPipes(outputPipe) < 0) { + std::cout << "Error creating pipes" << std::endl; + return false; + } + if (cmGetPipes(errorPipe) < 0) { + std::cout << "Error creating pipes" << std::endl; + return false; + } + + builder.AddCommand({ helperCommand, "echo" }) + .AddCommand({ helperCommand, "capitalize" }) + .AddCommand({ helperCommand, "dedup" }) + .SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, outputPipe[1]) + .SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, errorPipe[1]); + + if (!checkExecution(builder, chain)) { + return false; + } + + if (chain->OutputStream()) { + std::cout << "OutputStream() was not null, expecting null" << std::endl; + return false; + } + if (chain->ErrorStream()) { + std::cout << "ErrorStream() was not null, expecting null" << std::endl; + return false; + } + + outputOutPipe.init(chain->GetLoop(), 0); + uv_pipe_open(outputOutPipe, outputPipe[1]); + outputOutPipe.reset(); + + errorOutPipe.init(chain->GetLoop(), 0); + uv_pipe_open(errorOutPipe, errorPipe[1]); + errorOutPipe.reset(); + + outputInPipe.init(chain->GetLoop(), 0); + uv_pipe_open(outputInPipe, outputPipe[0]); + cmUVStreambuf outputBuf; + outputBuf.open(outputInPipe); + std::istream outputStream(&outputBuf); + + errorInPipe.init(chain->GetLoop(), 0); + uv_pipe_open(errorInPipe, errorPipe[0]); + cmUVStreambuf errorBuf; + errorBuf.open(errorInPipe); + std::istream errorStream(&errorBuf); + + if (!checkOutput(outputStream, errorStream)) { + return false; + } + + return true; +} + +bool testUVProcessChainNone(const char* helperCommand) +{ + cmUVProcessChainBuilder builder; + std::unique_ptr<cmUVProcessChain> chain; + builder.AddCommand({ helperCommand, "echo" }) + .AddCommand({ helperCommand, "capitalize" }) + .AddCommand({ helperCommand, "dedup" }); + + if (!checkExecution(builder, chain)) { + return false; + } + + if (chain->OutputStream()) { + std::cout << "OutputStream() was not null, expecting null" << std::endl; + return false; + } + if (chain->ErrorStream()) { + std::cout << "ErrorStream() was not null, expecting null" << std::endl; + return false; + } + + return true; +} + +int testUVProcessChain(int argc, char** const argv) +{ + if (argc < 2) { + std::cout << "Invalid arguments.\n"; + return -1; + } + + if (!testUVProcessChainBuiltin(argv[1])) { + std::cout << "While executing testUVProcessChainBuiltin().\n"; + return -1; + } + + if (!testUVProcessChainExternal(argv[1])) { + std::cout << "While executing testUVProcessChainExternal().\n"; + return -1; + } + + if (!testUVProcessChainNone(argv[1])) { + std::cout << "While executing testUVProcessChainNone().\n"; + return -1; + } + + return 0; +} diff --git a/Tests/CMakeLib/testUVProcessChainHelper.cxx b/Tests/CMakeLib/testUVProcessChainHelper.cxx new file mode 100644 index 0000000..263665d --- /dev/null +++ b/Tests/CMakeLib/testUVProcessChainHelper.cxx @@ -0,0 +1,72 @@ +#include <chrono> +#include <iostream> +#include <set> +#include <sstream> +#include <string> +#include <thread> + +#include <cctype> +#include <cstdlib> + +std::string getStdin() +{ + char buffer[1024]; + std::ostringstream str; + do { + std::cin.read(buffer, 1024); + str.write(buffer, std::cin.gcount()); + } while (std::cin.gcount() > 0); + return str.str(); +} + +int main(int argc, char** argv) +{ + if (argc < 2) { + return -1; + } + + std::string command = argv[1]; + if (command == "echo") { + std::this_thread::sleep_for(std::chrono::milliseconds(3000)); + 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::string input = getStdin(); + for (auto& c : input) { + c = static_cast<char>(std::toupper(c)); + } + std::cout << input << std::flush; + std::cerr << "2" << std::flush; + return 1; + } + if (command == "dedup") { + // Use a nested scope to free all resources before aborting below. + { + std::string input = getStdin(); + std::set<char> seen; + std::string output; + for (auto c : input) { + if (!seen.count(c)) { + seen.insert(c); + output += c; + } + } + std::cout << output << std::flush; + std::cerr << "3" << std::flush; + } + + // On Windows, the exit code of abort() is different between debug and + // release builds, and does not yield a term_signal in libuv in either + // case. For the sake of simplicity, we just return another non-zero code. +#ifdef _WIN32 + return 2; +#else + std::abort(); +#endif + } + + return -1; +} diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx index 1c1da76..2aeaf2c 100644 --- a/Tests/CMakeLib/testUVRAII.cxx +++ b/Tests/CMakeLib/testUVRAII.cxx @@ -171,11 +171,59 @@ static bool testAllMoves() return true; }; +static bool testLoopReset() +{ + bool closed = false; + cm::uv_loop_ptr loop; + loop.init(); + + uv_timer_t timer; + uv_timer_init(loop, &timer); + timer.data = &closed; + uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) { + auto closedPtr = static_cast<bool*>(handle->data); + *closedPtr = true; + }); + + loop.reset(); + if (!closed) { + std::cerr << "uv_loop_ptr did not finish" << std::endl; + return false; + } + + return true; +}; + +static bool testLoopDestructor() +{ + bool closed = false; + + uv_timer_t timer; + { + cm::uv_loop_ptr loop; + loop.init(); + + uv_timer_init(loop, &timer); + timer.data = &closed; + uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) { + auto closedPtr = static_cast<bool*>(handle->data); + *closedPtr = true; + }); + } + + if (!closed) { + std::cerr << "uv_loop_ptr did not finish" << std::endl; + return false; + } + + return true; +}; + int testUVRAII(int, char** const) { if ((testAsyncShutdown() && testAsyncDtor() & testAsyncMove() & testCrossAssignment() & - testAllMoves()) == 0) { + testAllMoves() & testLoopReset() & testLoopDestructor()) == 0) { return -1; } return 0; diff --git a/Tests/CMakeLib/testUVStreambuf.cxx b/Tests/CMakeLib/testUVStreambuf.cxx new file mode 100644 index 0000000..39655f3 --- /dev/null +++ b/Tests/CMakeLib/testUVStreambuf.cxx @@ -0,0 +1,457 @@ +#include "cmUVStreambuf.h" + +#include "cmGetPipes.h" +#include "cmUVHandlePtr.h" + +#include "cm_uv.h" + +#include <iostream> +#include <string> +#include <vector> + +#include <cstring> + +#include <stdint.h> + +#define TEST_STR_LINE_1 "This string must be exactly 128 characters long so" +#define TEST_STR_LINE_2 "that we can test CMake's std::streambuf integration" +#define TEST_STR_LINE_3 "with libuv's uv_stream_t." +#define TEST_STR TEST_STR_LINE_1 "\n" TEST_STR_LINE_2 "\n" TEST_STR_LINE_3 + +bool writeDataToStreamPipe(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe, + char* outputData, unsigned int outputDataLength, + const char* /* unused */) +{ + int err; + + // Create the pipe + int pipeHandles[2]; + if (cmGetPipes(pipeHandles) < 0) { + std::cout << "Could not open pipe" << std::endl; + return false; + } + + cm::uv_pipe_ptr outputPipe; + inputPipe.init(loop, 0); + outputPipe.init(loop, 0); + uv_pipe_open(inputPipe, pipeHandles[0]); + uv_pipe_open(outputPipe, pipeHandles[1]); + + // Write data for reading + uv_write_t writeReq; + struct WriteCallbackData + { + bool Finished = false; + int Status; + } writeData; + writeReq.data = &writeData; + uv_buf_t outputBuf; + outputBuf.base = outputData; + outputBuf.len = outputDataLength; + if ((err = uv_write(&writeReq, outputPipe, &outputBuf, 1, + [](uv_write_t* req, int status) { + auto data = static_cast<WriteCallbackData*>(req->data); + data->Finished = true; + data->Status = status; + })) < 0) { + std::cout << "Could not write to pipe: " << uv_strerror(err) << std::endl; + return false; + } + while (!writeData.Finished) { + uv_run(&loop, UV_RUN_ONCE); + } + if (writeData.Status < 0) { + std::cout << "Status is " << uv_strerror(writeData.Status) + << ", should be 0" << std::endl; + return false; + } + + return true; +} + +bool writeDataToStreamProcess(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe, + char* outputData, unsigned int /* unused */, + const char* cmakeCommand) +{ + int err; + + inputPipe.init(loop, 0); + std::vector<std::string> arguments = { cmakeCommand, "-E", "echo_append", + outputData }; + std::vector<const char*> processArgs; + for (auto const& arg : arguments) { + processArgs.push_back(arg.c_str()); + } + processArgs.push_back(nullptr); + std::vector<uv_stdio_container_t> stdio(3); + stdio[0].flags = UV_IGNORE; + stdio[0].data.stream = nullptr; + stdio[1].flags = + static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE); + stdio[1].data.stream = inputPipe; + stdio[2].flags = UV_IGNORE; + stdio[2].data.stream = nullptr; + + struct ProcessExitData + { + bool Finished = false; + int64_t ExitStatus; + int TermSignal; + } exitData; + cm::uv_process_ptr process; + auto options = uv_process_options_t(); + options.file = cmakeCommand; + options.args = const_cast<char**>(processArgs.data()); + options.flags = UV_PROCESS_WINDOWS_HIDE; + options.stdio = stdio.data(); + options.stdio_count = static_cast<int>(stdio.size()); + options.exit_cb = [](uv_process_t* handle, int64_t exitStatus, + int termSignal) { + auto data = static_cast<ProcessExitData*>(handle->data); + data->Finished = true; + data->ExitStatus = exitStatus; + data->TermSignal = termSignal; + }; + if ((err = process.spawn(loop, options, &exitData)) < 0) { + std::cout << "Could not spawn process: " << uv_strerror(err) << std::endl; + return false; + } + while (!exitData.Finished) { + uv_run(&loop, UV_RUN_ONCE); + } + if (exitData.ExitStatus != 0) { + std::cout << "Process exit status is " << exitData.ExitStatus + << ", should be 0" << std::endl; + return false; + } + if (exitData.TermSignal != 0) { + std::cout << "Process term signal is " << exitData.TermSignal + << ", should be 0" << std::endl; + return false; + } + + return true; +} + +bool testUVStreambufRead( + bool (*cb)(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe, char* outputData, + unsigned int outputDataLength, const char* cmakeCommand), + const char* cmakeCommand) +{ + char outputData[] = TEST_STR; + bool success = false; + cm::uv_loop_ptr loop; + loop.init(); + cm::uv_pipe_ptr inputPipe; + std::vector<char> inputData(128); + std::streamsize readLen; + std::string line; + cm::uv_timer_ptr timer; + + // Create the streambuf + cmUVStreambuf inputBuf(64); + std::istream inputStream(&inputBuf); + if (inputBuf.is_open()) { + std::cout << "is_open() is true, should be false" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + + // Perform first read test - read all the data + if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) { + goto end; + } + inputBuf.open(inputPipe); + if (!inputBuf.is_open()) { + std::cout << "is_open() is false, should be true" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 0) { + std::cout << "in_avail() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) { + std::cout << "sgetn() returned " << readLen << ", should be 128" + << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 0) { + std::cout << "in_avail() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + if (std::memcmp(inputData.data(), outputData, 128)) { + std::cout << "Read data does not match write data" << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + inputData.assign(128, char{}); + inputBuf.close(); + if (inputBuf.is_open()) { + std::cout << "is_open() is true, should be false" << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + + // Perform second read test - read some data and then close + if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) { + goto end; + } + inputBuf.open(inputPipe); + if (!inputBuf.is_open()) { + std::cout << "is_open() is false, should be true" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 0) { + std::cout << "in_avail() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 64)) != 64) { + std::cout << "sgetn() returned " << readLen << ", should be 64" + << std::endl; + goto end; + } + if (std::memcmp(inputData.data(), outputData, 64)) { + std::cout << "Read data does not match write data" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 8) { + std::cout << "in_avail() returned " << readLen << ", should be 8" + << std::endl; + goto end; + } + inputData.assign(128, char{}); + inputBuf.close(); + if (inputBuf.is_open()) { + std::cout << "is_open() is true, should be false" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + + // Perform third read test - read line by line + if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) { + goto end; + } + inputBuf.open(inputPipe); + if (!inputBuf.is_open()) { + std::cout << "is_open() is false, should be true" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 0) { + std::cout << "in_avail() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + + if (!std::getline(inputStream, line)) { + std::cout << "getline returned false, should be true" << std::endl; + goto end; + } + if (line != TEST_STR_LINE_1) { + std::cout << "Line 1 is \"" << line + << "\", should be \"" TEST_STR_LINE_1 "\"" << std::endl; + goto end; + } + + if (!std::getline(inputStream, line)) { + std::cout << "getline returned false, should be true" << std::endl; + goto end; + } + if (line != TEST_STR_LINE_2) { + std::cout << "Line 2 is \"" << line + << "\", should be \"" TEST_STR_LINE_2 "\"" << std::endl; + goto end; + } + + if (!std::getline(inputStream, line)) { + std::cout << "getline returned false, should be true" << std::endl; + goto end; + } + if (line != TEST_STR_LINE_3) { + std::cout << "Line 3 is \"" << line + << "\", should be \"" TEST_STR_LINE_3 "\"" << std::endl; + goto end; + } + + if (std::getline(inputStream, line)) { + std::cout << "getline returned true, should be false" << std::endl; + goto end; + } + + inputBuf.close(); + if (inputBuf.is_open()) { + std::cout << "is_open() is true, should be false" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + + // Perform fourth read test - run the event loop outside of underflow() + if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) { + goto end; + } + inputBuf.open(inputPipe); + if (!inputBuf.is_open()) { + std::cout << "is_open() is false, should be true" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 0) { + std::cout << "in_avail() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + uv_run(loop, UV_RUN_DEFAULT); + if ((readLen = inputBuf.in_avail()) != 72) { + std::cout << "in_avail() returned " << readLen << ", should be 72" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) { + std::cout << "sgetn() returned " << readLen << ", should be 128" + << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 0) { + std::cout << "in_avail() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 128" + << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + + inputBuf.close(); + if (inputBuf.is_open()) { + std::cout << "is_open() is true, should be false" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + + // Perform fifth read test - close the streambuf in the middle of a read + timer.init(*loop, &inputBuf); + if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) { + goto end; + } + inputBuf.open(inputPipe); + if (!inputBuf.is_open()) { + std::cout << "is_open() is false, should be true" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != 0) { + std::cout << "in_avail() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + uv_timer_start(timer, + [](uv_timer_t* handle) { + auto buf = static_cast<cmUVStreambuf*>(handle->data); + buf->close(); + }, + 0, 0); + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + if (inputBuf.is_open()) { + std::cout << "is_open() is true, should be false" << std::endl; + goto end; + } + if ((readLen = inputBuf.in_avail()) != -1) { + std::cout << "in_avail() returned " << readLen << ", should be -1" + << std::endl; + goto end; + } + if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { + std::cout << "sgetn() returned " << readLen << ", should be 0" + << std::endl; + goto end; + } + + success = true; + +end: + return success; +} + +int testUVStreambuf(int argc, char** const argv) +{ + if (argc < 2) { + std::cout << "Invalid arguments.\n"; + return -1; + } + + if (!testUVStreambufRead(writeDataToStreamPipe, argv[1])) { + std::cout << "While executing testUVStreambufRead() with pipe.\n"; + return -1; + } + + if (!testUVStreambufRead(writeDataToStreamProcess, argv[1])) { + std::cout << "While executing testUVStreambufRead() with process.\n"; + return -1; + } + + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 588c8e0..e73b277 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -22,6 +22,7 @@ macro(ADD_TEST_MACRO NAME) endmacro() include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake) # Fake a user home directory to avoid polluting the real one. if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) @@ -365,11 +366,16 @@ if(BUILD_TESTING) ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10))) if(CMAKE_GENERATOR STREQUAL "Xcode") - ADD_TEST_MACRO(SwiftMix SwiftMix) - ADD_TEST_MACRO(SwiftOnly SwiftOnly) + set(CMake_TEST_XCODE_SWIFT 1) endif() endif() endif() + if(CMAKE_Swift_COMPILER OR CMake_TEST_XCODE_SWIFT) + ADD_TEST_MACRO(SwiftOnly SwiftOnly) + if(CMake_TEST_XCODE_SWIFT) + ADD_TEST_MACRO(SwiftMix SwiftMix) + endif() + endif() if(CMAKE_Fortran_COMPILER) ADD_TEST_MACRO(FortranOnly FortranOnly) endif() @@ -459,7 +465,7 @@ if(BUILD_TESTING) set(runCxxDialectTest 1) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL Clang - AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4 AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if(NOT APPLE OR POLICY CMP0025) set(runCxxDialectTest 1) endif() @@ -764,14 +770,14 @@ if(BUILD_TESTING) file(WRITE "${_TEST_DIR}/nightly-cmake.sh" "cd ${_TEST_DIR} ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script} -${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake +${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGHTLY_RELEASES}' ") add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh) if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif() endmacro() - if(CMAKE_BUILD_NIGHTLY_RELEASES) + if(CMake_BUILD_NIGHTLY_RELEASES) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32 win32_release.cmake) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64 @@ -1413,10 +1419,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindCURL) endif() + if(CMake_TEST_FindCups) + add_subdirectory(FindCups) + endif() + if(CMake_TEST_FindDoxygen) add_subdirectory(FindDoxygen) endif() + if(CMake_TEST_FindEnvModules) + add_subdirectory(FindEnvModules) + endif() + if(CMake_TEST_FindEXPAT) add_subdirectory(FindEXPAT) endif() @@ -1441,6 +1455,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindGit) endif() + if(CMake_TEST_FindGLEW) + add_subdirectory(FindGLEW) + endif() + if(CMake_TEST_FindGSL) add_subdirectory(FindGSL) endif() @@ -1450,6 +1468,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(GoogleTest) endif() + if(CMake_TEST_FindGTK2) + add_subdirectory(FindGTK2) + endif() + if(CMake_TEST_FindIconv) add_subdirectory(FindIconv) endif() @@ -1593,11 +1615,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(FindMatlab.r2018a_check ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) endif() - find_package(GTK2 QUIET) - if(GTK2_FOUND) - add_subdirectory(FindGTK2) - endif() - add_test(ExternalProject ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalProject" @@ -1984,6 +2001,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") ADD_TEST_MACRO(PrecompiledHeader foo) endif() + set(MSVCRuntimeLibrary_BUILD_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + ADD_TEST_MACRO(MSVCRuntimeLibrary) + if(CMAKE_Fortran_COMPILER) + ADD_TEST_MACRO(MSVCRuntimeLibrary.Fortran) + endif() endif() if(MSVC OR "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") @@ -1992,7 +2014,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) - if("${CMAKE_GENERATOR}" MATCHES "Makefile") + if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR + "${CMAKE_GENERATOR}" MATCHES "Ninja") add_test(MakeClean ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MakeClean" @@ -2313,6 +2336,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-generator "Green Hills MULTI" --build-project test --build-config $<CONFIGURATION> + --force-new-ctest-process --build-options ${ghs_target_arch} ${ghs_toolset_name} ${ghs_toolset_root} ${ghs_target_platform} ${ghs_os_root} ${ghs_os_dir} ${ghs_bsp_name} ${_ghs_build_opts} ${_ghs_toolset_extra} ${_ghs_test_command} @@ -2324,7 +2348,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endmacro() macro(add_test_GhsMulti_rename_install test_name) add_test_GhsMulti( ${test_name} GhsMultiRenameInstall ${test_name} - "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} -P ./cmake_install.cmake) + "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target install) endmacro() #unset ghs config variables unset(ghs_config_name) @@ -2379,6 +2403,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_test_GhsMulti(compiler_options_kernel GhsMultiCompilerOptions Kernel "-DRUN_TEST=KERNEL_FLAGS -DRUN_TEST_BUILD_TYPE=DEBUG") add_test_GhsMulti(try_compile_copy GhsMultiCopyFile "" "") add_test_GhsMulti(ghs_platform GhsMultiPlatform "" "") + add_test_GhsMulti(custom_target GhsMultiCustomTarget "" "") + add_test_GhsMulti(dep_order GhsMultiDepOrder "" "") + add_test_GhsMulti(external_project GhsMultiExternalProject "" "") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}") #unset ghs config variables unset(ghs_config_name) @@ -2505,24 +2532,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) - # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails - # this test. (See #13371) - # Apparently Visual Studio does not support it either. As the MakeClean - # test above is only run with the Makefiles generator, only run this - # test with the Makefiles generator also. - add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused" - "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" - ${build_generator_args} - --build-project WarnUnusedCliUnused - --build-options ${build_options} - "-DUNUSED_CLI_VARIABLE=Unused") - set_tests_properties(WarnUnusedCliUnused PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") - endif() + add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused" + "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" + ${build_generator_args} + --build-project WarnUnusedCliUnused + --build-options ${build_options} + "-DUNUSED_CLI_VARIABLE=Unused") + set_tests_properties(WarnUnusedCliUnused PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND} --build-and-test @@ -3264,12 +3284,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log" ) - configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) - add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} - -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V - --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" - ) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) + add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" + ) + endif() if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja") configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in" @@ -3301,11 +3323,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif () - get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest2 - PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - endif () + if(NOT CMake_TEST_EXTERNAL_CMAKE) + get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties ( CTestTest2 + PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + endif() + endif() endif () if(CMake_TEST_EXTERNAL_CMAKE) @@ -3369,6 +3393,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} -DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES} + ${CMake_TEST_FortranModules_BUILD_OPTIONS} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules") endif() diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index f40524f..1aeab8b 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -56,6 +56,18 @@ add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake ) +add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectIncludeAny + -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) + +add_test(CMakeOnly.ProjectIncludeBefore ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectIncludeBefore + -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) + include(CMakeParseArguments) function(add_major_test module) diff --git a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt index 9be69f1..1f9d3ac 100644 --- a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt @@ -57,7 +57,7 @@ else() message("Unhandled Platform") endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") check_cxx_compiler_flag("-x c++" HAVE_X_CXX) if(NOT HAVE_X_CXX) message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed") diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt index f5336dc..ca4becb 100644 --- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -7,7 +7,8 @@ set(expect_C 1) set(expect_CXX 1) unset(expect_Fortran) set(expect_NoSuchLanguage 0) -foreach(lang C CXX Fortran NoSuchLanguage) + +foreach(lang C CXX Fortran CUDA NoSuchLanguage) check_language(${lang}) if(NOT DEFINED CMAKE_${lang}_COMPILER) message(FATAL_ERROR "check_language(${lang}) did not set result") diff --git a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt index a9abb4a..ffce488 100644 --- a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt +++ b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt @@ -1,4 +1,4 @@ -project(ProjectInclude) +project(ProjectInclude LANGUAGES NONE) if(NOT AUTO_INCLUDE) message(FATAL_ERROR "include file not found") endif() diff --git a/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt b/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt new file mode 100644 index 0000000..ffce488 --- /dev/null +++ b/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt @@ -0,0 +1,4 @@ +project(ProjectInclude LANGUAGES NONE) +if(NOT AUTO_INCLUDE) + message(FATAL_ERROR "include file not found") +endif() diff --git a/Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt b/Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt new file mode 100644 index 0000000..5cd9cba --- /dev/null +++ b/Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt @@ -0,0 +1,5 @@ +set(FOO TRUE) +project(ProjectInclude LANGUAGES NONE) +if(NOT AUTO_INCLUDE) + message(FATAL_ERROR "include file not found") +endif() diff --git a/Tests/CMakeOnly/ProjectIncludeBefore/include.cmake b/Tests/CMakeOnly/ProjectIncludeBefore/include.cmake new file mode 100644 index 0000000..0a4799d --- /dev/null +++ b/Tests/CMakeOnly/ProjectIncludeBefore/include.cmake @@ -0,0 +1,9 @@ +if(NOT FOO) + message(FATAL_ERROR "FOO is not set") +endif() + +if(NOT "${PROJECT_NAME}" STREQUAL "") + message(FATAL_ERROR "PROJECT_NAME should be empty") +endif() + +set(AUTO_INCLUDE TRUE) diff --git a/Tests/COnly/CMakeLists.txt b/Tests/COnly/CMakeLists.txt index b3cc438..3037f13 100644 --- a/Tests/COnly/CMakeLists.txt +++ b/Tests/COnly/CMakeLists.txt @@ -7,7 +7,7 @@ add_library(testc1 STATIC libc1.c) add_library(testc2 SHARED libc2.c) add_executable (COnly conly.c foo.c foo.h) target_link_libraries(COnly testc1 testc2) -if(MSVC_VERSION) +if(MSVC_VERSION AND NOT CMAKE_C_COMPILER_ID STREQUAL Clang OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set_target_properties(COnly PROPERTIES LINK_FLAGS " /NODEFAULTLIB:\"libcdg.lib\" /NODEFAULTLIB:\"libcmtg.lib\" /NODEFAULTLIB:\"foomsvcrt.lib\" /NODEFAULTLIB:\"libbar.lib\" /NODEFAULTLIB:\"libfooba.lib\"") endif() diff --git a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake index b0c3a9b..6df4292 100644 --- a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake +++ b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake @@ -1,14 +1,17 @@ +function(create_gcov_file gcda_full_path) + get_filename_component(gcda_name ${gcda_full_path} NAME) + string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}") + + file(STRINGS "${gcda_full_path}" source_file LIMIT_COUNT 1 ENCODING UTF-8) + + file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}" + " -: 0:Source:${source_file}" + ) +endfunction() + foreach(I RANGE 0 ${CMAKE_ARGC}) if("${CMAKE_ARGV${I}}" MATCHES ".*\\.gcda") set(gcda_file "${CMAKE_ARGV${I}}") + create_gcov_file(${gcda_file}) endif() endforeach() - -get_filename_component(gcda_name ${gcda_file} NAME) -string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}") - -file(STRINGS "${gcda_file}" source_file LIMIT_COUNT 1 ENCODING UTF-8) - -file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}" - " -: 0:Source:${source_file}" -) diff --git a/Tests/CheckSwift.cmake b/Tests/CheckSwift.cmake new file mode 100644 index 0000000..fcbae7e --- /dev/null +++ b/Tests/CheckSwift.cmake @@ -0,0 +1,61 @@ +if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja") + set(CMAKE_Swift_COMPILER "") + return() +endif() + +if(NOT DEFINED CMAKE_Swift_COMPILER) + set(_desc "Looking for a Swift compiler") + message(STATUS ${_desc}) + + file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift/CMakeLists.txt" + "cmake_minimum_required(VERSION 3.14) +project(CheckSwift Swift) +file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" + \"set(CMAKE_Swift_COMPILER \\\"\${CMAKE_Swift_COMPILER}\\\")\\n\" + \"set(CMAKE_Swift_FLAGS \\\"\${CMAKE_Swift_FLAGS}\\\")\\n\") +") + + if(CMAKE_GENERATOR_INSTANCE) + set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}") + else() + set(_D_CMAKE_GENERATOR_INSTANCE "") + endif() + + execute_process(WORKING_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift + COMMAND + ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} + -A "${CMAKE_GENERATOR_PLATFORM}" + -T "${CMAKE_GENERATOR_TOOLSET}" + ${_D_CMAKE_GENERATOR_INSTANCE} + TIMEOUT + 60 + OUTPUT_VARIABLE + output + ERROR_VARIABLE + output + RESULT_VARIABLE + result) + + include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift/result.cmake + OPTIONAL) + if(CMAKE_Swift_COMPILER AND "${result}" STREQUAL "0") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${_desc} passed with the following output:\n" + "${output}\n") + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${_desc} failed with the following output:\n" + "${output}\n") + endif() + + message(STATUS "${_desc} - ${CMAKE_Swift_COMPILER}") + + set(CMAKE_Swift_COMPILER "${CMAKE_Swift_COMPILER}" CACHE FILEPATH "Swift compiler") + set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS}" CACHE STRING "Swift flags") + + mark_as_advanced(CMAKE_Swift_COMPILER) + mark_as_advanced(CMAKE_Swift_FLAGS) +endif() diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index b0bc656..060fb49 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -15,17 +15,21 @@ macro(run_test feature lang) endif() endmacro() -get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) -list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") -foreach(feature ${c_features}) - run_test(${feature} C) -endforeach() +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) + list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") + foreach(feature ${c_features}) + run_test(${feature} C) + endforeach() +endif() -get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) -list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") -foreach(feature ${cxx_features}) - run_test(${feature} CXX) -endforeach() +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) + list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") + foreach(feature ${cxx_features}) + run_test(${feature} CXX) + endforeach() +endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) @@ -48,6 +52,16 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" endif() if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.15) + # SunPro 5.14 accepts -std=c++14 and compiles two features but does + # not define __cplusplus to a value different than with -std=c++11. + list(REMOVE_ITEM CXX_non_features + cxx_aggregate_default_initializers + cxx_digit_separators + ) + endif() + + # FIXME: Do any of these work correctly on SunPro 5.13 or above? list(REMOVE_ITEM CXX_non_features cxx_attribute_deprecated cxx_contextual_conversions @@ -338,11 +352,11 @@ else() add_executable(CompileFeaturesGenex2 genex_test.cpp) target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11) - target_compile_definitions(CompileFeaturesGenex2 PRIVATE ${genex_test_defs}) + target_compile_definitions(CompileFeaturesGenex2 PRIVATE ${genex_test_defs} ALLOW_LATER_STANDARDS=1) add_library(std_11_iface INTERFACE) target_compile_features(std_11_iface INTERFACE cxx_std_11) add_executable(CompileFeaturesGenex3 genex_test.cpp) target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface) - target_compile_definitions(CompileFeaturesGenex3 PRIVATE ${genex_test_defs}) + target_compile_definitions(CompileFeaturesGenex3 PRIVATE ${genex_test_defs} ALLOW_LATER_STANDARDS=1) endif() diff --git a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp index 7b3602c..953148d 100644 --- a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp +++ b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp @@ -22,6 +22,7 @@ constexpr int g(const int (&is)[4]) int someFunc() { - constexpr int k3 = g({ 4, 5, 6, 7 }); + constexpr int values[4] = { 4, 5, 6, 7 }; + constexpr int k3 = g(values); return k3 - 42; } diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index 59f9006..53dce62 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -15,10 +15,10 @@ # if !HAVE_CXX_STD_11 # error HAVE_CXX_STD_11 is false with CXX_STANDARD == 11 # endif -# if HAVE_CXX_STD_14 +# if HAVE_CXX_STD_14 && !defined(ALLOW_LATER_STANDARDS) # error HAVE_CXX_STD_14 is true with CXX_STANDARD == 11 # endif -# if HAVE_CXX_STD_17 +# if HAVE_CXX_STD_17 && !defined(ALLOW_LATER_STANDARDS) # error HAVE_CXX_STD_17 is true with CXX_STANDARD == 11 # endif #endif @@ -31,17 +31,6 @@ # if !EXPECT_OVERRIDE_CONTROL # error "Expect no override control feature" # endif - -struct A -{ - virtual int getA() { return 7; } -}; - -struct B final : A -{ - int getA() override { return 42; } -}; - #endif #if !HAVE_AUTO_TYPE diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index 15a993c..1433462 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -25,6 +25,7 @@ set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "-DTEST_DEFINE" "-DNEEDS_ESCAPE=\"E$CAPE\"" "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>" + "$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DTEST_DEFINE_CXX_AND_GNU>" "SHELL:" # produces no options ${c_tests} ${cxx_tests} @@ -42,7 +43,7 @@ else() ) endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS "-DTEST_OCTOTHORPE=\"#\"" ) diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp index d94a169..ebc1017 100644 --- a/Tests/CompileOptions/main.cpp +++ b/Tests/CompileOptions/main.cpp @@ -10,6 +10,9 @@ # ifndef TEST_DEFINE_GNU # error Expected definition TEST_DEFINE_GNU # endif +# ifndef TEST_DEFINE_CXX_AND_GNU +# error Expected definition TEST_DEFINE_CXX_AND_GNU +# endif #endif #ifndef NO_DEF_TESTS diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 1b3daa6..a30071f 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -3,6 +3,7 @@ ADD_TEST_MACRO(Cuda.Complex CudaComplex) ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures) ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary) ADD_TEST_MACRO(Cuda.MixedStandardLevels MixedStandardLevels) +ADD_TEST_MACRO(Cuda.NotEnabled CudaNotEnabled) ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude) ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries) ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) diff --git a/Tests/Cuda/NotEnabled/CMakeLists.txt b/Tests/Cuda/NotEnabled/CMakeLists.txt new file mode 100644 index 0000000..968751b --- /dev/null +++ b/Tests/Cuda/NotEnabled/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.7) +project(CudaNotEnabled CXX) + +add_library(HasCudaProps lib.cxx) + +target_compile_features(HasCudaProps PUBLIC cxx_std_11) +#Verify that setting this variables in a project that doesn't have CUDA +#enabled allow for the project to configure and build correctly. +#Tests the fix for #19432 +set_property(TARGET HasCudaProps PROPERTY CUDA_SEPARABLE_COMPILATION ON) +set_property(TARGET HasCudaProps PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON) + +add_executable(CudaNotEnabled main.cxx) +target_link_libraries(CudaNotEnabled PRIVATE HasCudaProps) diff --git a/Tests/Cuda/NotEnabled/lib.cxx b/Tests/Cuda/NotEnabled/lib.cxx new file mode 100644 index 0000000..5dae5a3 --- /dev/null +++ b/Tests/Cuda/NotEnabled/lib.cxx @@ -0,0 +1,5 @@ + +int cxx_function(int input) +{ + return input; +} diff --git a/Tests/Cuda/NotEnabled/main.cxx b/Tests/Cuda/NotEnabled/main.cxx new file mode 100644 index 0000000..a644207 --- /dev/null +++ b/Tests/Cuda/NotEnabled/main.cxx @@ -0,0 +1,9 @@ + +#include <type_traits> + +int main(int argc, char** argv) +{ + // make sure we have c++11 enabled + using returnv = std::integral_constant<int, 0>; + return returnv::value; +} diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index e58204d..00fd7d2 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -37,6 +37,8 @@ target_compile_definitions(CudaOnlyWithDefs $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>> -DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE> -DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> + -DDEF_CUDA_COMPILER=$<CUDA_COMPILER_ID> + -DDEF_CUDA_COMPILER_VERSION=$<CUDA_COMPILER_VERSION> ) target_include_directories(CudaOnlyWithDefs diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu index 98f73ce..68a296b 100644 --- a/Tests/CudaOnly/WithDefs/main.notcu +++ b/Tests/CudaOnly/WithDefs/main.notcu @@ -39,6 +39,14 @@ # error "Expected DEF_LANG_IS_CUDA" #endif +#ifndef DEF_CUDA_COMPILER +# error "DEF_CUDA_COMPILER not defined!" +#endif + +#ifndef DEF_CUDA_COMPILER_VERSION +# error "DEF_CUDA_COMPILER_VERSION not defined!" +#endif + static __global__ void DetermineIfValidCudaDevice() { } diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index 8c0817c..b7587aa 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -18,9 +18,20 @@ if(NOT CTEST_CONFIGURATION_TYPE) endif() endforeach() if(NOT CTEST_CONFIGURATION_TYPE) - set(CTEST_CONFIGURATION_TYPE NoConfig) + if("@CMAKE_C_COMPILER_ID@;@CMAKE_C_SIMULATE_ID@;@CMAKE_C_COMPILER_FRONTEND_VARIANT@" STREQUAL "Clang;MSVC;GNU") + # A valid configuration is required for this compiler in tests that do not set CMP0091 to NEW. + set(CTEST_CONFIGURATION_TYPE Debug) + else() + set(CTEST_CONFIGURATION_TYPE NoConfig) + endif() endif() message("Guessing configuration ${CTEST_CONFIGURATION_TYPE}") endif() +# Isolate tests from user configuration in the environment. +unset(ENV{CMAKE_GENERATOR}) +unset(ENV{CMAKE_GENERATOR_INSTANCE}) +unset(ENV{CMAKE_GENERATOR_PLATFORM}) +unset(ENV{CMAKE_GENERATOR_TOOLSET}) + @TEST_HOME_ENV_CODE@ diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index fd55c42..22a4ef6 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -41,6 +41,8 @@ install(FILES add_library(cmakeonly INTERFACE) set_property(TARGET cmakeonly PROPERTY INTERFACE_COMPILE_DEFINITIONS [[DEF="\"\$\B"]]) +set_property(TARGET cmakeonly PROPERTY custom_property CustomPropertyValue) +set_property(TARGET cmakeonly PROPERTY EXPORT_PROPERTIES custom_property) install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target cmakeonly diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 811fff3..b5df961 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -407,7 +407,7 @@ endforeach() unset(_configs) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR CMAKE_C_COMPILER_ID STREQUAL Clang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index c850508..a07a5b3 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -109,4 +109,12 @@ foreach(ns exp bld) "not\n" " " [[DEF="\"\$\B"]] "\n") endif() + get_property(custom TARGET ${ns}::cmakeonly PROPERTY custom_property) + if(NOT custom STREQUAL "CustomPropertyValue") + message(SEND_ERROR + "${ns}::cmakeonly property custom_property is:\n" + " ${custom}\n" + "not\n" + " CustomPropertyValue\n") + endif() endforeach() diff --git a/Tests/FindBoost/CMakeLists.txt b/Tests/FindBoost/CMakeLists.txt index 58d795b..8489d85 100644 --- a/Tests/FindBoost/CMakeLists.txt +++ b/Tests/FindBoost/CMakeLists.txt @@ -21,7 +21,8 @@ add_test(NAME FindBoost.TestFail COMMAND ) set_tests_properties(FindBoost.TestFail PROPERTIES - PASS_REGULAR_EXPRESSION "Could not find the following Boost libraries:[ \t\n]+boost_foobar") + WILL_FAIL ON + PASS_REGULAR_EXPRESSION "Could NOT find Boost (missing: foobar)") add_test(NAME FindBoost.TestHeaders COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> diff --git a/Tests/FindBoost/Test/CMakeLists.txt b/Tests/FindBoost/Test/CMakeLists.txt index 39e92c1..f60ccfa 100644 --- a/Tests/FindBoost/Test/CMakeLists.txt +++ b/Tests/FindBoost/Test/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(TestFindBoost CXX) include(CTest) +set(Boost_NO_BOOST_CMAKE ON) find_package(Boost REQUIRED COMPONENTS filesystem thread OPTIONAL_COMPONENTS program_options foobar) diff --git a/Tests/FindCups/CMakeLists.txt b/Tests/FindCups/CMakeLists.txt new file mode 100644 index 0000000..5be1ac1 --- /dev/null +++ b/Tests/FindCups/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindCups.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindCups/Test" + "${CMake_BINARY_DIR}/Tests/FindCups/Test" + ${build_generator_args} + --build-project FindCups + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindCups/Test/CMakeLists.txt b/Tests/FindCups/Test/CMakeLists.txt new file mode 100644 index 0000000..9e90553 --- /dev/null +++ b/Tests/FindCups/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) +project(TestFindCups C) +include(CTest) + +find_package(Cups REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_CUPS_VERSION="${CUPS_VERSION_STRING}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt Cups::Cups) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${CUPS_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${CUPS_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindCups/Test/main.c b/Tests/FindCups/Test/main.c new file mode 100644 index 0000000..b69d621 --- /dev/null +++ b/Tests/FindCups/Test/main.c @@ -0,0 +1,12 @@ +#include <cups/cups.h> + +int main() +{ + int num_options = 0; + cups_option_t* options = NULL; + + num_options = cupsAddOption(CUPS_COPIES, "1", num_options, &options); + cupsFreeOptions(num_options, options); + + return 0; +} diff --git a/Tests/FindEnvModules/CMakeLists.txt b/Tests/FindEnvModules/CMakeLists.txt new file mode 100644 index 0000000..95b7d1d --- /dev/null +++ b/Tests/FindEnvModules/CMakeLists.txt @@ -0,0 +1,3 @@ +add_test(FindEnvModules.Test ${CMAKE_CMAKE_COMMAND} + -P ${CMAKE_CURRENT_LIST_DIR}/EnvModules.cmake +) diff --git a/Tests/FindEnvModules/EnvModules.cmake b/Tests/FindEnvModules/EnvModules.cmake new file mode 100644 index 0000000..0c81bf2 --- /dev/null +++ b/Tests/FindEnvModules/EnvModules.cmake @@ -0,0 +1,35 @@ +find_package(EnvModules REQUIRED) +message("module purge") +env_module(COMMAND purge RESULT_VARIABLE ret_var) +if(NOT ret_var EQUAL 0) + message(FATAL_ERROR "module(purge) returned ${ret_var}") +endif() + +message("module avail") +env_module_avail(avail_mods) +foreach(mod IN LISTS avail_mods) + message(" ${mod}") +endforeach() + +if(avail_mods) + list(GET avail_mods 0 mod0) + message("module load ${mod0}") + env_module(load ${mod0}) + + message("module list") + env_module_list(loaded_mods) + foreach(mod IN LISTS loaded_mods) + message(" ${mod}") + endforeach() + + list(LENGTH loaded_mods num_loaded_mods) + message("Number of modules loaded: ${num_loaded_mods}") + if(NOT num_loaded_mods EQUAL 1) + message(FATAL_ERROR "Exactly 1 module should be loaded. Found ${num_loaded_mods}") + endif() + + list(GET loaded_mods 0 mod0_actual) + if(NOT (mod0_actual MATCHES "^${mod0}")) + message(FATAL_ERROR "Loaded module does not match ${mod0}. Actual: ${mod0_actual}") + endif() +endif() diff --git a/Tests/FindGLEW/CMakeLists.txt b/Tests/FindGLEW/CMakeLists.txt new file mode 100644 index 0000000..ff42bce --- /dev/null +++ b/Tests/FindGLEW/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindGLEW.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindGLEW/Test" + "${CMake_BINARY_DIR}/Tests/FindGLEW/Test" + ${build_generator_args} + --build-project TestFindGLEW + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindGLEW/Test/CMakeLists.txt b/Tests/FindGLEW/Test/CMakeLists.txt new file mode 100644 index 0000000..954ee10 --- /dev/null +++ b/Tests/FindGLEW/Test/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindGLEW LANGUAGES CXX) +include(CTest) + +find_package(GLEW REQUIRED) + +add_executable(test_glew_shared_tgt main.cpp) +target_link_libraries(test_glew_shared_tgt GLEW::GLEW) +add_test(NAME test_glew_shared_tgt COMMAND test_glew_shared_tgt) + +add_executable(test_glew_generic_tgt main.cpp) +target_link_libraries(test_glew_generic_tgt GLEW::glew) +add_test(NAME test_glew_generic_tgt COMMAND test_glew_generic_tgt) + +add_executable(test_glew_var main.cpp) +target_include_directories(test_glew_var PRIVATE ${GLEW_INCLUDE_DIRS}) +target_link_libraries(test_glew_var PRIVATE ${GLEW_LIBRARIES}) +add_test(NAME test_glew_var COMMAND test_glew_var) diff --git a/Tests/FindGLEW/Test/main.cpp b/Tests/FindGLEW/Test/main.cpp new file mode 100644 index 0000000..4a108ad --- /dev/null +++ b/Tests/FindGLEW/Test/main.cpp @@ -0,0 +1,8 @@ +#include <GL/glew.h> + +int main() +{ + GLenum init_return = glewInit(); + + return (init_return == GLEW_OK); +} diff --git a/Tests/FindIconv/Test/CMakeLists.txt b/Tests/FindIconv/Test/CMakeLists.txt index c59adb3..a6243f5 100644 --- a/Tests/FindIconv/Test/CMakeLists.txt +++ b/Tests/FindIconv/Test/CMakeLists.txt @@ -6,9 +6,11 @@ find_package(Iconv REQUIRED) add_executable(test_iconv_tgt main.cxx) target_link_libraries(test_iconv_tgt Iconv::Iconv) +target_compile_features(test_iconv_tgt PRIVATE cxx_std_11) add_test(NAME test_iconv_tgt COMMAND test_iconv_tgt) add_executable(test_iconv_var main.cxx) target_include_directories(test_iconv_var PRIVATE ${Iconv_INCLUDE_DIRS}) target_link_libraries(test_iconv_var PRIVATE ${Iconv_LIBRARIES}) +target_compile_features(test_iconv_var PRIVATE cxx_std_11) add_test(NAME test_iconv_var COMMAND test_iconv_var) diff --git a/Tests/FindPackageTest/.gitignore b/Tests/FindPackageTest/.gitignore new file mode 100644 index 0000000..3aaef13 --- /dev/null +++ b/Tests/FindPackageTest/.gitignore @@ -0,0 +1 @@ +/symlink diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index f8b36c5..1b9c973 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -205,15 +205,20 @@ if(UNIX) message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") endif() - # Resolve symlinks when finding the package. - set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) - set(SetFoundResolved_DIR "") - find_package(SetFoundResolved) - # ./symlink points back here so it should be gone when resolved. - set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") - message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + # This part of the test only works if there are no symlinks in our path. + get_filename_component(real_src_dir "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH) + if(real_src_dir STREQUAL CMAKE_CURRENT_SOURCE_DIR) + # Resolve symlinks when finding the package. + set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) + set(SetFoundResolved_DIR "") + find_package(SetFoundResolved) + # ./symlink points back here so it should be gone when resolved. + set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") + message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + endif() endif() + # Cleanup. unset(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS) file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/symlink") @@ -380,6 +385,7 @@ try_compile(EXPORTER_COMPILED ${FindPackageTest_SOURCE_DIR}/Exporter CMakeTestExportPackage dummy CMAKE_FLAGS "-UCMAKE_EXPORT_NO_PACKAGE_REGISTRY" + "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=OLD" -Dversion=${version} OUTPUT_VARIABLE output) message(STATUS "Searching for export(PACKAGE) test project") @@ -417,6 +423,25 @@ if(CMakeTestExportPackage_FOUND) message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!") endif() +message(STATUS "Remove export(PACKAGE) test project") +file(REMOVE_RECURSE ${FindPackageTest_BINARY_DIR}/Exporter-build) + +message(STATUS "Preparing export(PACKAGE) test project with POLICY CMP0090=NEW") +try_compile(EXPORTER_COMPILED + ${FindPackageTest_BINARY_DIR}/Exporter-build + ${FindPackageTest_SOURCE_DIR}/Exporter + CMakeTestExportPackage dummy + CMAKE_FLAGS + "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=NEW" + -Dversion=${version} + OUTPUT_VARIABLE output) +message(STATUS "Searching for export(PACKAGE) test project") +find_package(CMakeTestExportPackage 1.${version} EXACT QUIET) +if(CMakeTestExportPackage_FOUND) + message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!") +endif() + + #----------------------------------------------------------------------------- # Test configure_package_config_file(). @@ -516,7 +541,93 @@ endif() set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) unset(SortLib_VERSION) - unset(CMAKE_FIND_PACKAGE_SORT_ORDER) unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION) set(CMAKE_PREFIX_PATH ) + +############################################################################ +##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG + +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig) + +# prefer module mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +unset(ABC_FOUND) +unset(ABC_CONFIG) + +find_package(ABC) +if(NOT ABC_FOUND) + message(SEND_ERROR "Did not find ABC package") +endif() +if(ABC_CONFIG) + message(SEND_ERROR "Incorrectly found ABC in CONFIG mode, expected to find it with MODULE mode") +endif() + +# Now prefer config mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +unset(ABC_FOUND) +unset(ABC_CONFIG) + +find_package(ABC) +if(NOT ABC_FOUND) + message(SEND_ERROR "Did not find ABC package") +endif() +if(NOT ABC_CONFIG) + message(SEND_ERROR "Incorrectly found ABC in MODULE mode, expected to find it with CONFIG mode") +endif() + +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +set(CMAKE_PREFIX_PATH) +set(CMAKE_MODULE_PATH) + +############################################################################ +##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG - Do not recurse + +# No CMAKE_PREFIX_PATH +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigRecurse) + +# Now prefer config mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +unset(ACME_FOUND) +unset(ACME_CONFIG) + +find_package(ACME) +if(ACME_FOUND AND ACME_CONFIG) + message(SEND_ERROR "Incorrectly found ACME in CONFIG mode, from the MODULE package") +endif() + +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +set(CMAKE_MODULE_PATH) + +############################################################################ +##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with module fallback + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigOnlyModule) + +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) + +find_package(ACME REQUIRED) + +if(NOT ACME_FOUND) + message(SEND_ERROR "Did not find ACME package") +endif() + +############################################################################ +##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with NO_MODULE + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigOnlyModule) + +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) + +find_package(ACME NO_MODULE) + +if(ACME_FOUND) + message(SEND_ERROR "Should not find ACME package") +endif() + +############################################################################ +##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with unknown package + +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +find_package(DoesNotExist) diff --git a/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake b/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake new file mode 100644 index 0000000..281a5cd --- /dev/null +++ b/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake @@ -0,0 +1 @@ +set(ABC_FOUND TRUE) diff --git a/Tests/FindPackageTest/PreferConfig/FindABC.cmake b/Tests/FindPackageTest/PreferConfig/FindABC.cmake new file mode 100644 index 0000000..281a5cd --- /dev/null +++ b/Tests/FindPackageTest/PreferConfig/FindABC.cmake @@ -0,0 +1 @@ +set(ABC_FOUND TRUE) diff --git a/Tests/FindPackageTest/PreferConfigOnlyModule/FindACME.cmake b/Tests/FindPackageTest/PreferConfigOnlyModule/FindACME.cmake new file mode 100644 index 0000000..7a4e1b3 --- /dev/null +++ b/Tests/FindPackageTest/PreferConfigOnlyModule/FindACME.cmake @@ -0,0 +1 @@ +set(ACME_FOUND TRUE) diff --git a/Tests/FindPackageTest/PreferConfigRecurse/ACMEConfig.cmake b/Tests/FindPackageTest/PreferConfigRecurse/ACMEConfig.cmake new file mode 100644 index 0000000..7a4e1b3 --- /dev/null +++ b/Tests/FindPackageTest/PreferConfigRecurse/ACMEConfig.cmake @@ -0,0 +1 @@ +set(ACME_FOUND TRUE) diff --git a/Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake b/Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake new file mode 100644 index 0000000..9bdc7db --- /dev/null +++ b/Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake @@ -0,0 +1 @@ +find_package(ACME NO_MODULE) diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index 38211a4..4be2f22 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -1,12 +1,22 @@ if(CMake_TEST_FindPython) - add_test(NAME FindPython.Python2 COMMAND + add_test(NAME FindPython.Python2.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.LOCATION" ${build_generator_args} --build-project TestPython2 - --build-options ${build_options} + --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python2.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VERSION" + ${build_generator_args} + --build-project TestPython2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -23,14 +33,24 @@ if(CMake_TEST_FindPython) set_tests_properties(FindPython.Python2Fail PROPERTIES PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") - add_test(NAME FindPython.Python3 COMMAND + add_test(NAME FindPython.Python3.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.LOCATION" ${build_generator_args} --build-project TestPython3 - --build-options ${build_options} + --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python3.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VERSION" + ${build_generator_args} + --build-project TestPython3 + --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -68,6 +88,39 @@ if(CMake_TEST_FindPython) --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 + "${CMake_SOURCE_DIR}/Tests/FindPython/VirtualEnv" + "${CMake_BINARY_DIR}/Tests/FindPython/VirtualEnv" + ${build_generator_args} + --build-project TestVirtualEnv + --build-options ${build_options} + --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 + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Embedded" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3Embedded" + ${build_generator_args} + --build-project TestPython3Embedded + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + endif() if(CMake_TEST_FindPython_NumPy) diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt index f7fc243..62c805e 100644 --- a/Tests/FindPython/Python/CMakeLists.txt +++ b/Tests/FindPython/Python/CMakeLists.txt @@ -16,6 +16,9 @@ endif() if(NOT TARGET Python::Python) message(SEND_ERROR "Python::Python not found") endif() +if(NOT TARGET Python::Module) + message(SEND_ERROR "Python::Module not found") +endif() Python_add_library (spam3 MODULE ../spam.c) target_compile_definitions (spam3 PRIVATE PYTHON3) diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt index a0753f6..274745a 100644 --- a/Tests/FindPython/Python2/CMakeLists.txt +++ b/Tests/FindPython/Python2/CMakeLists.txt @@ -21,6 +21,9 @@ endif() if(NOT TARGET Python2::Python) message(SEND_ERROR "Python2::Python not found") endif() +if(NOT TARGET Python2::Module) + message(SEND_ERROR "Python2::Module not found") +endif() Python2_add_library (spam2 MODULE ../spam.c) target_compile_definitions (spam2 PRIVATE PYTHON2) diff --git a/Tests/FindPython/Python2Embedded/CMakeLists.txt b/Tests/FindPython/Python2Embedded/CMakeLists.txt new file mode 100644 index 0000000..0115dea --- /dev/null +++ b/Tests/FindPython/Python2Embedded/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestPython2Embedded C) + +include(CTest) + +find_package(Python2 REQUIRED COMPONENTS Development) +if (NOT Python2_FOUND) + message (FATAL_ERROR "Fail to found Python 2") +endif() + +if(NOT TARGET Python2::Python) + message(SEND_ERROR "Python2::Python not found") +endif() + +Python2_add_library (display_time2 SHARED ../display_time.c) +set_property (TARGET display_time2 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) +target_compile_definitions (display_time2 PRIVATE PYTHON2) + +add_executable (main2 ../main.c) +target_link_libraries (main2 PRIVATE display_time2) + +if (WIN32 OR CYGWIN OR MSYS OR MINGW) + list (JOIN Python2_RUNTIME_LIBRARY_DIRS "$<SEMICOLON>" RUNTIME_DIRS) + add_test (NAME Python2.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $<TARGET_FILE:main2>) +else() + add_test (NAME Python2.Embedded COMMAND main2) +endif() +set_property (TEST Python2.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is") diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt index 65eea4c..b21a15b 100644 --- a/Tests/FindPython/Python3/CMakeLists.txt +++ b/Tests/FindPython/Python3/CMakeLists.txt @@ -21,6 +21,9 @@ endif() if(NOT TARGET Python3::Python) message(SEND_ERROR "Python2::Python not found") endif() +if(NOT TARGET Python3::Module) + message(SEND_ERROR "Python2::Module not found") +endif() Python3_add_library (spam3 MODULE ../spam.c) target_compile_definitions (spam3 PRIVATE PYTHON3) diff --git a/Tests/FindPython/Python3Embedded/CMakeLists.txt b/Tests/FindPython/Python3Embedded/CMakeLists.txt new file mode 100644 index 0000000..4eb7ebc --- /dev/null +++ b/Tests/FindPython/Python3Embedded/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestPython3Embedded C) + +include(CTest) + +find_package(Python3 REQUIRED COMPONENTS Development) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Fail to found Python 3") +endif() + +if(NOT TARGET Python3::Python) + message(SEND_ERROR "Python3::Python not found") +endif() + +Python3_add_library (display_time3 SHARED ../display_time.c) +set_property (TARGET display_time3 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) +target_compile_definitions (display_time3 PRIVATE PYTHON3) + +add_executable (main3 ../main.c) +target_link_libraries (main3 PRIVATE display_time3) + +if (WIN32 OR CYGWIN OR MSYS OR MINGW) + list (JOIN Python3_RUNTIME_LIBRARY_DIRS "$<SEMICOLON>" RUNTIME_DIRS) + add_test (NAME Python3.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $<TARGET_FILE:main3>) +else() + add_test (NAME Python3.Embedded COMMAND main3) +endif() +set_property (TEST Python3.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is") diff --git a/Tests/FindPython/VirtualEnv/CMakeLists.txt b/Tests/FindPython/VirtualEnv/CMakeLists.txt new file mode 100644 index 0000000..64ba201 --- /dev/null +++ b/Tests/FindPython/VirtualEnv/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestVirtualEnv LANGUAGES NONE) + +include(CTest) + +find_package(Python3 REQUIRED COMPONENTS Interpreter) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Fail to found Python 3") +endif() + +set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/py3venv") + +execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv "${Python3_VIRTUAL_ENV}" + RESULT_VARIABLE result + OUTPUT_VARIABLE outputs + ERROR_VARIABLE outputs) +if (result) + message (FATAL_ERROR "Fail to create virtual environment: ${outputs}") +endif() + +add_test(NAME FindPython3.VirtualEnvDefault + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + "${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 + "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 + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") + +add_test(NAME FindPython3.VirtualEnvStandard + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake") diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake new file mode 100644 index 0000000..020ecac --- /dev/null +++ b/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake @@ -0,0 +1,6 @@ + +find_package (Python3 REQUIRED) + +if (NOT Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") + message (FATAL_ERROR "Fail to use virtual environment") +endif() diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake new file mode 100644 index 0000000..29a4924 --- /dev/null +++ b/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake @@ -0,0 +1,16 @@ + +# +# Virtual environment is defined for python3 +# Trying to find a python2 using only virtual environment +# It is expecting to fail if a virtual environment is active and to success otherwise. +# +set (Python2_FIND_VIRTUALENV ONLY) +find_package (Python2 QUIET) + +if (PYTHON3_VIRTUAL_ENV AND Python2_FOUND) + message (FATAL_ERROR "Python2 unexpectedly found.") +endif() + +if (NOT PYTHON3_VIRTUAL_ENV AND NOT Python2_FOUND) + message (FATAL_ERROR "Fail to find Python2.") +endif() diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake new file mode 100644 index 0000000..89f27d8 --- /dev/null +++ b/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake @@ -0,0 +1,7 @@ + +set (Python3_FIND_VIRTUALENV STANDARD) +find_package (Python3 REQUIRED) + +if (Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") + message (FATAL_ERROR "Python3 virtual env unexpectedly found.") +endif() diff --git a/Tests/FindPython/display_time.c b/Tests/FindPython/display_time.c new file mode 100644 index 0000000..0e78434 --- /dev/null +++ b/Tests/FindPython/display_time.c @@ -0,0 +1,36 @@ + +#include <stdio.h> + +#define PY_SSIZE_T_CLEAN +#include <Python.h> + +#include "display_time.h" + +void display_time() +{ +#if defined(PYTHON3) + wchar_t* program = Py_DecodeLocale("display_time", NULL); + if (program == NULL) { + fprintf(stderr, "Fatal error: cannot decode argv[0]\n"); + exit(1); + } + char* cmd = "from time import time,ctime\n" + "print('Today is', ctime(time()))\n"; +#else + char* program = "display_time"; + char* cmd = "from time import time,ctime\n" + "print 'Today is', ctime(time())\n"; +#endif + + Py_SetProgramName(program); /* optional but recommended */ + Py_Initialize(); + PyRun_SimpleString(cmd); +#if defined(PYTHON3) + if (Py_FinalizeEx() < 0) { + exit(120); + } + PyMem_RawFree(program); +#else + Py_Finalize(); +#endif +} diff --git a/Tests/FindPython/display_time.h b/Tests/FindPython/display_time.h new file mode 100644 index 0000000..d825e02 --- /dev/null +++ b/Tests/FindPython/display_time.h @@ -0,0 +1,2 @@ + +void display_time(); diff --git a/Tests/FindPython/main.c b/Tests/FindPython/main.c new file mode 100644 index 0000000..0acba29 --- /dev/null +++ b/Tests/FindPython/main.c @@ -0,0 +1,7 @@ + +#include "display_time.h" + +int main() +{ + display_time(); +} diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 7023615..929fa4d 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -46,7 +46,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale|Absoft") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 3d08704..3ff2b85 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -3,11 +3,26 @@ project(GeneratorExpression) include(CTest) +# Real projects normally want the MSYS shell path conversion, but for this test +# we need to verify that the command line is constructed with the proper string. +set(msys1_prefix "") +set(msys2_no_conv "") +if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") + execute_process(COMMAND "uname" OUTPUT_VARIABLE uname) + if("${uname}" MATCHES "^MINGW32") + # MinGW.org MSYS 1.0 does not support generic path conversion suppression + set(msys1_prefix MSYS1_PREFIX) + else() + # msys2 supports generic path conversion suppression + set(msys2_no_conv env MSYS2_ARG_CONV_EXCL=-D) + endif() +endif() + # This test is split into multiple parts as needed to avoid NMake command # length limits. add_custom_target(check-part1 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_0=$<0:nothing> -Dtest_0_with_comma=$<0:-Wl,--no-undefined> -Dtest_1=$<1:content> @@ -97,7 +112,7 @@ add_library(empty5 empty.cpp) target_include_directories(empty5 PRIVATE /empty5/private1 /empty5/private2) add_custom_target(check-part2 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_incomplete_1=$< -Dtest_incomplete_2=$<something -Dtest_incomplete_3=$<something: @@ -188,7 +203,7 @@ set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_DEBUG "" DEBUG set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_RELEASE "") add_custom_target(check-part3 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1> -Dtest_version_greater_2=$<VERSION_GREATER:1.1.1,1.0> -Dtest_version_less_1=$<VERSION_LESS:1.1.1,1.0> @@ -205,6 +220,7 @@ add_custom_target(check-part3 ALL -Dtest_early_termination_2=$<$<1:>:, -Dsystem_name=${CMAKE_HOST_SYSTEM_NAME} -Dtest_platform_id=$<PLATFORM_ID> + -Dtest_platform_id_supported=$<PLATFORM_ID:Linux,Windows,Darwin> -Dtest_platform_id_Linux=$<PLATFORM_ID:Linux> -Dtest_platform_id_Windows=$<PLATFORM_ID:Windows> -Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin> @@ -241,17 +257,19 @@ add_custom_target(check-part3 ALL if(WIN32) set(test_shell_path c:/shell/path) + set(test_shell_path2 c:/shell/path d:/another/path) else() set(test_shell_path /shell/path) + set(test_shell_path2 /shell/path /another/path) endif() -set(path_prefix BYPASS_FURTHER_CONVERSION) add_custom_target(check-part4 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} # Prefix path to bypass its further conversion when being processed by # CMake as command-line argument - -Dtest_shell_path=${path_prefix}$<SHELL_PATH:${test_shell_path}> - -Dpath_prefix=${path_prefix} + -Dmsys1_prefix=${msys1_prefix} + -Dtest_shell_path=${msys1_prefix}$<SHELL_PATH:${test_shell_path}> + "-Dtest_shell_path2=$<SHELL_PATH:${test_shell_path2}>" -Dif_1=$<IF:1,a,b> -Dif_2=$<IF:0,a,b> -Dif_3=$<IF:$<EQUAL:10,30>,a,b> @@ -357,4 +375,49 @@ if(NOT CMAKE_GENERATOR STREQUAL Xcode OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[; -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" DEPENDS objlib ) + + + add_library(sharedlib SHARED objlib1.c objlib2.c) + file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>" + CONTENT "$<JOIN:$<TARGET_OBJECTS:sharedlib>,\n>\n" + ) + + add_custom_target(check_sharedlib_objs ALL + COMMAND ${CMAKE_COMMAND} + "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>" + -DEXPECTED_NUM_OBJECTFILES=2 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS sharedlib + ) + + + add_library(staticlib STATIC objlib1.c objlib2.c) + file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>" + CONTENT "$<JOIN:$<TARGET_OBJECTS:staticlib>,\n>\n" + ) + + add_custom_target(check_staticlib_objs ALL + COMMAND ${CMAKE_COMMAND} + "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>" + -DEXPECTED_NUM_OBJECTFILES=2 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS staticlib + ) + + + add_executable(execobjs objlib1.c objlib2.c echo.c) + file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>" + CONTENT "$<JOIN:$<TARGET_OBJECTS:execobjs>,\n>\n" + ) + + add_custom_target(check_exec_objs ALL + COMMAND ${CMAKE_COMMAND} + "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>" + -DEXPECTED_NUM_OBJECTFILES=3 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS execobjs + ) endif() diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 9014406..4fb7308 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -28,11 +28,16 @@ check(test_early_termination_2 "$<:,") check(test_platform_id "${system_name}") foreach(system Linux Windows Darwin) if(system_name STREQUAL system) + check(test_platform_id_supported 1) check(test_platform_id_${system} 1) + set(platform_supported 1) else() check(test_platform_id_${system} 0) endif() endforeach() +if(NOT platform_supported) + check(test_platform_id_supported 0) +endif() check(lower_case "mi,xed") check(upper_case "MIX,ED") check(make_c_identifier "_4f_oo__bar__") diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake index f5d14dd..a7e0944 100644 --- a/Tests/GeneratorExpression/check-part4.cmake +++ b/Tests/GeneratorExpression/check-part4.cmake @@ -1,6 +1,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake) -string(REPLACE ${path_prefix} "" test_shell_path ${test_shell_path}) +if(msys1_prefix) + string(REPLACE "${msys1_prefix}" "" test_shell_path ${test_shell_path}) +endif() if(WIN32) if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") @@ -13,6 +15,17 @@ if(WIN32) else() check(test_shell_path [[/shell/path]]) endif() +if(WIN32) + if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles" AND NOT msys1_prefix) + check(test_shell_path2 [[/c/shell/path:/d/another/path]]) + elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + check(test_shell_path2 [[c:/shell/path;d:/another/path]]) + else() + check(test_shell_path2 [[c:\shell\path;d:\another\path]]) + endif() +else() + check(test_shell_path2 [[/shell/path:/another/path]]) +endif() check(if_1 "a") check(if_2 "b") diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt new file mode 100644 index 0000000..93d668b --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt @@ -0,0 +1,110 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +# Tests assume no previous builds in the build directory +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/build) + +macro (test_output) + if (BUILD_OUTPUT STREQUAL EXPECTED_LINES ) + message("Build OK") + else() + message("BUILD_OUTPUT") + foreach(Line IN LISTS BUILD_OUTPUT) + message("${Line}") + endforeach() + message("EXPECTED_LINES") + foreach(Line IN LISTS EXPECTED_LINES) + message("${Line}") + endforeach() + message(SEND_ERROR "Build KO") + endif() +endmacro() + +message("Copy project") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/exe1.c + ${CMAKE_CURRENT_SOURCE_DIR}/lib1.c + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src +) + +message("Building ALL target") +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/src + test + CMAKE_FLAGS + -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} + OUTPUT_VARIABLE BUILD_OUTPUT) + +message("Output from build:\n${BUILD_OUTPUT}") + +#filter outputs +string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}") +string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}") +list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:") + +unset(EXPECTED_LINES) +list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild") +list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild") +list(APPEND EXPECTED_LINES "CT: Processing target_cmd") +list(APPEND EXPECTED_LINES "CT: Processing target_cmd_prebuild") +list(APPEND EXPECTED_LINES "CT: Processing target_cmd_postbuild") + +test_output() + +message("Building target_update_files target") +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/src + test target_update_files + CMAKE_FLAGS + -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} + OUTPUT_VARIABLE BUILD_OUTPUT) + +message("Output from build:\n${BUILD_OUTPUT}") + +#filter outputs +string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}") +string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}") +list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:") + +unset(EXPECTED_LINES) +list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild") +list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild") +list(APPEND EXPECTED_LINES "CT: generate C file another_file") +list(APPEND EXPECTED_LINES "CT: generate text file dependsA") +list(APPEND EXPECTED_LINES "CT: generate text file out_of_order_dep") +list(APPEND EXPECTED_LINES "CT: generate text files A, B, and C") +list(APPEND EXPECTED_LINES "CT: Processing target_update_files") + +test_output() + +message("Rerun target_update_files target") +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/src + test target_update_files + CMAKE_FLAGS + -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} + OUTPUT_VARIABLE BUILD_OUTPUT) + +message("Output from build:\n${BUILD_OUTPUT}") + +#filter outputs +string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}") +string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}") +list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:") + +unset(EXPECTED_LINES) +list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild") +list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild") +list(APPEND EXPECTED_LINES "CT: generate text files A, B, and C") +list(APPEND EXPECTED_LINES "CT: Processing target_update_files") + +test_output() diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt.in new file mode 100644 index 0000000..fed946c --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt.in @@ -0,0 +1,108 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +add_library(lib1 lib1.c) + +set(TEST_MISSING_TARGET_SRC 0) +set(TEST_MISSING_TARGET_DEP 0) +set(TEST_MISSING_DEP 0) +set(TEST_DEP_CYCLE 0) + +add_executable(exe1 exe1.c) +target_link_libraries(exe1 lib1) + +add_custom_target(target_cmd ALL + COMMAND ${CMAKE_COMMAND} -E echo "target_cmd" > target_cmd + COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_extra" > target_cmd_extra.txt + BYPRODUCTS target_cmd target_cmd_extra.txt + COMMENT "CT: Processing target_cmd") + +add_custom_command(TARGET target_cmd PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_prebuild" > target_cmd_prebuild.txt + BYPRODUCTS target_cmd_prebuild.txt + COMMENT "CT: Processing target_cmd_prebuild") +#event does not run for custom targets +add_custom_command(TARGET target_cmd PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "executing target_cmd_prelink commands" + COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_prelink" > target_cmd_prelink.txt + BYPRODUCTS target_cmd_prelink.txt + COMMENT "CT: Processing target_cmd_prelink") +add_custom_command(TARGET target_cmd POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "executing target_cmd_postbuild commands" + COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_postbuild" > target_cmd_postbuild.txt + BYPRODUCTS target_cmd_postbuild.txt + COMMENT "CT: Processing target_cmd_postbuild") + +add_custom_target(target_empty ALL + COMMENT "CT: Processing target_empty") + +add_custom_command(TARGET target_empty PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "target_empty_prebuild" > target_empty_prebuild.txt + BYPRODUCTS target_empty_prebuild.txt + COMMENT "CT: Processing target_empty_prebuild") +add_custom_command(TARGET target_empty POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "target_empty_postbuild" > target_empty_postbuild.txt + BYPRODUCTS target_empty_postbuild.txt + COMMENT "CT: Processing target_empty_postbuild") + +add_dependencies(target_cmd target_empty) + +add_custom_command( + OUTPUT out_of_order_dep.txt + COMMAND ${CMAKE_COMMAND} -E echo "out_of_order_dep" > out_of_order_dep.txt + COMMENT "CT: generate text file out_of_order_dep" + DEPENDS dependsA.txt +) + +if(TEST_MISSING_TARGET_SRC) + set(SRC_FILE does_not_exist) +endif() +if(TEST_MISSING_TARGET_DEP) + set(DEP_FILE does_not_exist) +endif() + +add_custom_target(target_update_files + DEPENDS genc_do_not_list.txt ${DEP_FILE} + SOURCES gena.txt genb.txt another_file.c ${SRC_FILE} + BYPRODUCTS junkit.txt + COMMAND ${CMAKE_COMMAND} -E copy another_file.c junkit.txt + COMMENT "CT: Processing target_update_files") + +add_custom_command( + OUTPUT force_rebuild gena.txt genb.txt genc_do_not_list.txt + COMMAND ${CMAKE_COMMAND} -E copy dependsA.txt gena.txt + COMMAND ${CMAKE_COMMAND} -E echo "genb" > genb.txt + COMMAND ${CMAKE_COMMAND} -E echo "genc" > genc_do_not_list.txt + DEPENDS out_of_order_dep.txt dependsA.txt + COMMENT "CT: generate text files A, B, and C" +) + +if(TEST_MISSING_DEP) + set(MISSING_DEP MISSING_DEP) +endif() +if(TEST_DEP_CYCLE) + set(DEP_CYCLE out_of_order_dep.txt) +endif() + +add_custom_command( + OUTPUT dependsA.txt + COMMAND ${CMAKE_COMMAND} -E echo "dependsA" > dependsA.txt + DEPENDS ${MISSING_DEP} ${DEP_CYCLE} another_file.c + COMMENT "CT: generate text file dependsA" +) + +add_custom_command( + OUTPUT another_file.c + COMMAND ${CMAKE_COMMAND} -E echo "//auto-gen file" > another_file.c + COMMENT "CT: generate C file another_file" +) + +add_dependencies(target_update_files target_empty) diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/exe1.c b/Tests/GhsMulti/GhsMultiCustomTarget/exe1.c new file mode 100644 index 0000000..29ad70a --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCustomTarget/exe1.c @@ -0,0 +1,5 @@ +extern int func(void); +int main(void) +{ + return func(); +} diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/lib1.c b/Tests/GhsMulti/GhsMultiCustomTarget/lib1.c new file mode 100644 index 0000000..b35e9cc --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCustomTarget/lib1.c @@ -0,0 +1,4 @@ +int func(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiDepOrder/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/CMakeLists.txt new file mode 100644 index 0000000..2e2871b --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/CMakeLists.txt @@ -0,0 +1,12 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +#set_property( GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1) +add_subdirectory(exec) +add_subdirectory(lib) +add_subdirectory(protolib) +add_dependencies(lib1 proto) diff --git a/Tests/GhsMulti/GhsMultiDepOrder/exec/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/exec/CMakeLists.txt new file mode 100644 index 0000000..85ee805 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/exec/CMakeLists.txt @@ -0,0 +1,11 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +add_executable(exe1 exe1.c) +target_link_libraries(exe1 lib1) +target_include_directories(exe1 PRIVATE "${test_BINARY_DIR}") +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + target_link_options(exe1 PRIVATE "-non_shared") +endif() diff --git a/Tests/GhsMulti/GhsMultiDepOrder/exec/exe1.c b/Tests/GhsMulti/GhsMultiDepOrder/exec/exe1.c new file mode 100644 index 0000000..fbf4ed4 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/exec/exe1.c @@ -0,0 +1,8 @@ +#include "lib1.h" +#include "p.h" + +int main(void) +{ + return func1() + func2() + func3() + func1p() + func2p() + func3p() + + PROTO1 + PROTO2 + PROTO3; +} diff --git a/Tests/GhsMulti/GhsMultiDepOrder/lib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/lib/CMakeLists.txt new file mode 100644 index 0000000..ae30fa2 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/lib/CMakeLists.txt @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +add_library(lib1 STATIC + func1.c lib1.h + "${test_BINARY_DIR}/protolib/proto1.c" + "${test_BINARY_DIR}/protolib/proto1.h") +set_source_files_properties( + "${test_BINARY_DIR}/protolib/proto1.c" + "${test_BINARY_DIR}/protolib/proto1.h" + PROPERTIES GENERATED 1) +target_include_directories(lib1 PRIVATE "${test_BINARY_DIR}/protolib" + PUBLIC .) +add_custom_command( TARGET lib1 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${test_BINARY_DIR}/protolib/proto1.h" "${test_BINARY_DIR}/p.h" + COMMENT "Copy ${test_BINARY_DIR}/protolib/proto1.h ${test_BINARY_DIR}/p.h" + BYPRODUCTS "${test_BINARY_DIR}/p.h") diff --git a/Tests/GhsMulti/GhsMultiDepOrder/lib/func1.c b/Tests/GhsMulti/GhsMultiDepOrder/lib/func1.c new file mode 100644 index 0000000..53334fe --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/lib/func1.c @@ -0,0 +1,17 @@ +#include "lib1.h" +#include "proto1.h" + +int func1(void) +{ + return 1 + PROTO1; +} + +int func2(void) +{ + return 2 + PROTO2; +} + +int func3(void) +{ + return 3 + PROTO3; +} diff --git a/Tests/GhsMulti/GhsMultiDepOrder/lib/lib1.h b/Tests/GhsMulti/GhsMultiDepOrder/lib/lib1.h new file mode 100644 index 0000000..5e99f02 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/lib/lib1.h @@ -0,0 +1,3 @@ +extern int func1(void); +extern int func2(void); +extern int func3(void); diff --git a/Tests/GhsMulti/GhsMultiDepOrder/protolib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/protolib/CMakeLists.txt new file mode 100644 index 0000000..8cb6869 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/protolib/CMakeLists.txt @@ -0,0 +1,28 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +add_custom_target(proto ALL + DEPENDS proto1.c + proto1.h + SOURCES + ${test_SOURCE_DIR}/protolib/proto1.c.in + ${test_SOURCE_DIR}/protolib/proto1.h.in + COMMENT "Creating proto files") + +add_custom_command( + OUTPUT proto1.c + COMMAND ${CMAKE_COMMAND} -E copy + ${test_SOURCE_DIR}/protolib/proto1.c.in proto1.c + DEPENDS ${test_SOURCE_DIR}/protolib/proto1.c.in + COMMENT "generate proto C files" +) + +add_custom_command( + OUTPUT proto1.h + COMMAND ${CMAKE_COMMAND} -E copy + ${test_SOURCE_DIR}/protolib/proto1.h.in proto1.h + DEPENDS ${test_SOURCE_DIR}/protolib/proto1.h.in + COMMENT "generate proto H files" +) diff --git a/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.c.in b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.c.in new file mode 100644 index 0000000..0efb1bd --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.c.in @@ -0,0 +1,16 @@ +#include "proto1.h" + +int func1p(void) +{ + return 1; +} + +int func2p(void) +{ + return 2; +} + +int func3p(void) +{ + return 3; +} diff --git a/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.h.in b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.h.in new file mode 100644 index 0000000..f2f93af --- /dev/null +++ b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.h.in @@ -0,0 +1,7 @@ +extern int func1p(void); +extern int func2p(void); +extern int func3p(void); + +#define PROTO1 0x1 +#define PROTO2 0x2 +#define PROTO3 0x3 diff --git a/Tests/GhsMulti/GhsMultiExternalProject/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExternalProject/CMakeLists.txt new file mode 100644 index 0000000..24126c8 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiExternalProject/CMakeLists.txt @@ -0,0 +1,14 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) +include(ExternalProject) + +ExternalProject_Add(another_project + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/empty + BINARY_DIR empty_build + INSTALL_COMMAND "" + TEST_COMMAND "" + ) diff --git a/Tests/GhsMulti/GhsMultiExternalProject/empty/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExternalProject/empty/CMakeLists.txt new file mode 100644 index 0000000..6846a98 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiExternalProject/empty/CMakeLists.txt @@ -0,0 +1,8 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(empty NONE) + +message("EMPTY PROJECT") diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt index e431217..3837b5a 100644 --- a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt @@ -1,4 +1,3 @@ add_executable(App Main.c) -target_include_directories(App PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../Lib) target_link_libraries(App Lib) target_compile_options(App PUBLIC "-non_shared") diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt index 00e0f59..bb9849a 100644 --- a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt @@ -1 +1,2 @@ add_library(Lib HelperFun.c HelperFun.h) +target_include_directories(Lib PUBLIC .) diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt index c5db155..3f2f0eb 100644 --- a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt @@ -18,3 +18,4 @@ target_link_options(kernel PRIVATE -kernel) # create monolith INTEGRITY application add_executable(monolith test.int) +add_dependencies(monolith vas) diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt index a025814..98668e5c 100644 --- a/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(test C) -add_library(obj1 OBJECT testObj.c testObj.h sub/testObj.c testObj2.c) +add_library(obj1 OBJECT testOBJ.c testOBJ.h sub/testOBJ.c testOBJ2.c) add_executable(exe1 exe.c $<TARGET_OBJECTS:obj1>) if(CMAKE_C_COMPILER_ID STREQUAL "GHS") diff --git a/Tests/GhsMulti/GhsMultiPlatform/file1.c b/Tests/GhsMulti/GhsMultiPlatform/file1.c deleted file mode 100644 index 4132aa4..0000000 --- a/Tests/GhsMulti/GhsMultiPlatform/file1.c +++ /dev/null @@ -1,4 +0,0 @@ -int main(void) -{ - return -42; -} diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt index f5792b4..b2540d9 100644 --- a/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt @@ -13,7 +13,7 @@ endif() if(RUN_TEST STREQUAL "SINGLE_EXEC") add_executable(exe1 exe.c) - set(targets_to_install ${targets_to_install} exe1) + set(targets_to_install exe1) endif() if(RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED") @@ -22,7 +22,7 @@ if(RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED") set_property(TARGET exe1 PROPERTY RUNTIME_OUTPUT_DIRECTORY ${name}_bin_$<CONFIG>) set_property(TARGET exe1 PROPERTY OUTPUT_NAME ${name}_$<CONFIG>) set_property(TARGET exe1 PROPERTY SUFFIX .bin) - set(targets_to_install ${targets_to_install} exe1) + set(targets_to_install exe1) endif() if(RUN_TEST STREQUAL "EXEC_AND_LIB") @@ -33,7 +33,7 @@ if(RUN_TEST STREQUAL "EXEC_AND_LIB") add_executable(exe1 exe1.c) target_link_libraries(exe1 lib1) - set(targets_to_install ${targets_to_install} exe1 lib1) + set(targets_to_install exe1 lib1) endif() install(TARGETS ${targets_to_install} diff --git a/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt b/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt index ed3094b..f5f3c55 100644 --- a/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt @@ -5,8 +5,6 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(test C) -add_custom_target(testTarget ALL echo this is a test) - add_library(sharedLib SHARED file.c) add_library(moduleLib MODULE file.c) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index b7b8320..761c405 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6) project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja" OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 5b99ea7..a9edf9a 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -17,7 +17,8 @@ create_header(bing) create_header(bung) create_header(arguments) create_header(list) -create_header(target) +create_header(target1) +create_header(target2) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -69,14 +70,23 @@ set_property(TARGET lib4 APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BI set_property(TARGET lib4 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foh;$<TARGET_PROPERTY:lib3,INTERFACE_INCLUDE_DIRECTORIES>") add_library(somelib::withcolons UNKNOWN IMPORTED) -set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target") -set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target") +set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target1") +set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target1") set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:somelib::withcolons,INTERFACE_INCLUDE_DIRECTORIES>" ) +add_library(somelib_aliased UNKNOWN IMPORTED GLOBAL) +set_property(TARGET somelib_aliased PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target2") +add_library(somelib::withcolons2 ALIAS somelib_aliased) + +set_property(TARGET TargetIncludeDirectories + APPEND PROPERTY INCLUDE_DIRECTORIES + "$<TARGET_PROPERTY:somelib::withcolons2,INTERFACE_INCLUDE_DIRECTORIES>" +) + add_custom_target(test_custom_target "some_bogus_custom_tool" $<TARGET_PROPERTY:TargetIncludeDirectories,COMPILE_DEFINITIONS> diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp index 2ee05e2..541ef92 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -10,7 +10,8 @@ #include "foo.h" #include "list.h" #include "prefix_foo_bar_bat.h" -#include "target.h" +#include "target1.h" +#include "target2.h" #include "ting.h" int main(int, char**) diff --git a/Tests/MSVCRuntimeLibrary/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/CMakeLists.txt new file mode 100644 index 0000000..f7d9fec --- /dev/null +++ b/Tests/MSVCRuntimeLibrary/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 3.14) +cmake_policy(SET CMP0091 NEW) +project(MSVCRuntimeLibrary) + +if(CMake_TEST_CUDA) + enable_language(CUDA) +endif() + +function(verify_combinations threads lang src) + set(verify_tc_config_ Release) + set(verify_tc_config_Debug Debug) + set(verify_def_MultiThreaded -DVERIFY_MT) + set(verify_def_Debug -DVERIFY_DEBUG) + set(verify_def_DLL -DVERIFY_DLL) + foreach(dbg "" Debug) + foreach(dll "" DLL) + # Construct the name of this runtime library combination. + set(rtl "${threads}${dbg}${dll}") + + # Test that try_compile builds with this RTL. + set(CMAKE_MSVC_RUNTIME_LIBRARY "${rtl}") + set(CMAKE_TRY_COMPILE_CONFIGURATION "${verify_tc_config_${dbg}}") + set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") + try_compile(${rtl}_COMPILES + ${CMAKE_CURRENT_BINARY_DIR}/try_compile/${rtl} + ${CMAKE_CURRENT_SOURCE_DIR}/${src} + COMPILE_DEFINITIONS ${verify_def_${threads}} ${verify_def_${dbg}} ${verify_def_${dll}} + OUTPUT_VARIABLE ${rtl}_OUTPUT + ) + if(${rtl}_COMPILES) + message(STATUS "try_compile with ${rtl} worked") + else() + string(REPLACE "\n" "\n " ${rtl}_OUTPUT " ${${rtl}_OUTPUT}") + message(SEND_ERROR "try_compile with ${rtl} failed:\n${${rtl}_OUTPUT}") + endif() + + # Test that targets build with this RTL. + set(CMAKE_MSVC_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>") + add_library(${rtl}-${lang} ${src}) + set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE) + target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dbg}} ${verify_def_${dll}}) + endforeach() + endforeach() +endfunction() + +function(verify lang src) + add_library(default-${lang} ${src}) + target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL "$<$<CONFIG:Debug>:VERIFY_DEBUG>") + + verify_combinations(MultiThreaded ${lang} ${src}) + + # Test known MSVC default behavior when no flag is given. + if(CMAKE_${lang}_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_RUNTIME_LIBRARY "") + add_library(empty-${lang} ${src}) + if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 14) + # VS 2005 and above default to multi-threaded. + target_compile_definitions(empty-${lang} PRIVATE VERIFY_MT) + endif() + if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])") + # VS 2010 and above have a different default runtime library for projects than 'cl'. + target_compile_definitions(empty-${lang} PRIVATE VERIFY_DLL) + endif() + endif() +endfunction() + +verify(C verify.c) +verify(CXX verify.cxx) +if(CMake_TEST_CUDA) + verify(CUDA verify.cu) +endif() diff --git a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt new file mode 100644 index 0000000..27838a4 --- /dev/null +++ b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 3.14) +cmake_policy(SET CMP0091 NEW) +project(MSVCRuntimeLibraryFortran Fortran) + +foreach(t MultiThreaded SingleThreaded) + foreach(dbg "" Debug) + foreach(dll "" DLL) + set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_${t}${dbg}${dll}") + if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + # ifort does not actually define these, so inject them + string(REPLACE "-threads" "-threads;-D_MT" "${var}" "${${var}}") + string(REPLACE "-dbglibs" "-dbglibs;-D_DEBUG" "${var}" "${${var}}") + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Flang") + # flang does not actually define these, so inject them + string(REPLACE ";--dependent-lib=libcmt;" ";--dependent-lib=libcmt;-D_MT;" "${var}" ";${${var}};") + string(REPLACE ";--dependent-lib=msvcrt;" ";--dependent-lib=msvcrt;-D_MT;-D_DLL;" "${var}" ";${${var}};") + string(REPLACE ";--dependent-lib=libcmtd;" ";--dependent-lib=libcmtd;-D_MT;-D_DEBUG;" "${var}" ";${${var}};") + string(REPLACE ";--dependent-lib=msvcrtd;" ";--dependent-lib=msvcrtd;-D_MT;-D_DEBUG;-D_DLL;" "${var}" ";${${var}};") + endif() + endforeach() + endforeach() +endforeach() +string(APPEND CMAKE_Fortran_FLAGS " -w") + +function(verify_combinations threads lang src) + set(verify_tc_config_ Release) + set(verify_tc_config_Debug Debug) + set(verify_def_MultiThreaded -DVERIFY_MT) + set(verify_def_Debug -DVERIFY_DEBUG) + set(verify_def_DLL -DVERIFY_DLL) + foreach(dbg "" Debug) + foreach(dll "" DLL) + # Construct the name of this runtime library combination. + set(rtl "${threads}${dbg}${dll}") + + # Test that targets build with this RTL. + set(CMAKE_MSVC_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>") + add_library(${rtl}-${lang} ${src}) + set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE) + target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dbg}} ${verify_def_${dll}}) + endforeach() + endforeach() +endfunction() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +function(verify lang src) + add_library(default-${lang} ${src}) + target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL "$<$<CONFIG:Debug>:VERIFY_DEBUG>") + verify_combinations(MultiThreaded ${lang} ${src}) +endfunction() + +verify(Fortran verify.F90) +# Intel Fortran for Windows supports single-threaded RTL but it is +# not implemented by the Visual Studio integration. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + verify_combinations(SingleThreaded Fortran verify.F90) +endif() diff --git a/Tests/MSVCRuntimeLibrary/Fortran/verify.F90 b/Tests/MSVCRuntimeLibrary/Fortran/verify.F90 new file mode 100644 index 0000000..6fe5e05 --- /dev/null +++ b/Tests/MSVCRuntimeLibrary/Fortran/verify.F90 @@ -0,0 +1 @@ +#include "../verify.h" diff --git a/Tests/MSVCRuntimeLibrary/verify.c b/Tests/MSVCRuntimeLibrary/verify.c new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/MSVCRuntimeLibrary/verify.c @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/MSVCRuntimeLibrary/verify.cu b/Tests/MSVCRuntimeLibrary/verify.cu new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/MSVCRuntimeLibrary/verify.cu @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/MSVCRuntimeLibrary/verify.cxx b/Tests/MSVCRuntimeLibrary/verify.cxx new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/MSVCRuntimeLibrary/verify.cxx @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/MSVCRuntimeLibrary/verify.h b/Tests/MSVCRuntimeLibrary/verify.h new file mode 100644 index 0000000..58d65fe --- /dev/null +++ b/Tests/MSVCRuntimeLibrary/verify.h @@ -0,0 +1,29 @@ +#ifdef VERIFY_DEBUG +# ifndef _DEBUG +# error "_DEBUG not defined by debug runtime library selection" +# endif +#else +# ifdef _DEBUG +# error "_DEBUG defined by non-debug runtime library selection" +# endif +#endif + +#ifdef VERIFY_DLL +# ifndef _DLL +# error "_DLL not defined by DLL runtime library selection" +# endif +#else +# ifdef _DLL +# error "_DLL defined by non-DLL runtime library selection" +# endif +#endif + +#ifdef VERIFY_MT +# ifndef _MT +# error "_MT not defined by multi-threaded runtime library selection" +# endif +#else +# ifdef _MT +# error "_MT defined by single-threaded runtime library selection" +# endif +#endif diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt index d0e24ce..a05c38b 100644 --- a/Tests/MakeClean/ToClean/CMakeLists.txt +++ b/Tests/MakeClean/ToClean/CMakeLists.txt @@ -1,42 +1,122 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.14) project(ToClean) -# Build a simple project. -add_executable(toclean toclean.cxx) +# Utility variables +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) +set(CLEAN_FILE_CONTENT "File registered for cleaning.\n") + +# Lists build-time-generated files that should be cleaned away +set_property(GLOBAL PROPERTY TOCLEAN_FILES "") +function(addCleanFile FILENAME) + set_property(GLOBAL APPEND PROPERTY TOCLEAN_FILES "${FILENAME}") +endfunction() +function(writeCleanFile FILENAME) + file(WRITE "${FILENAME}" ${CLEAN_FILE_CONTENT}) +endfunction() -# List some build-time-generated files. -set(TOCLEAN_FILES ${TOCLEAN_FILES} - "${ToClean_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") +set(DUMMY_CONTENT_FILE ${CSD}/toclean.cxx) -# Create a file that must be registered for cleaning. -file(WRITE "${ToClean_BINARY_DIR}/Registered.txt" - "File registered for cleaning.\n") -set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${ToClean_BINARY_DIR}/Registered.txt") -set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/Registered.txt") +# Build a simple project whose compiled objects should be cleaned. +add_executable(toclean toclean.cxx) +addCleanFile( + "${CBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") + +# Create a post build custom command that copies a dummy file +# to a custom location +function(addPostBuildFile TARGET FILENAME) + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${DUMMY_CONTENT_FILE} ${FILENAME}) +endfunction() # Create a custom command whose output should be cleaned. -add_custom_command(OUTPUT ${ToClean_BINARY_DIR}/generated.txt - DEPENDS ${ToClean_SOURCE_DIR}/toclean.cxx +set(CustomCommandFile "${CBD}/CustomCommandFile.txt") +add_custom_command(OUTPUT ${CustomCommandFile} + DEPENDS ${DUMMY_CONTENT_FILE} COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${ToClean_SOURCE_DIR}/toclean.cxx - ${ToClean_BINARY_DIR}/generated.txt - ) -add_custom_target(generate ALL DEPENDS ${ToClean_BINARY_DIR}/generated.txt) -set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/generated.txt") + ARGS -E copy ${DUMMY_CONTENT_FILE} ${CustomCommandFile}) +add_custom_target(customTarget ALL DEPENDS ${CustomCommandFile}) +addCleanFile(${CustomCommandFile}) + + +### Tests ADDITIONAL_MAKE_CLEAN_FILES directory property +if("${CMAKE_GENERATOR}" MATCHES "Makefile") + # Create a file that must be registered for cleaning. + set(MakeDirPropFileAbs "${CBD}/MakeDirPropFile.txt") + writeCleanFile("${MakeDirPropFileAbs}") + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MakeDirPropFileAbs}") + addCleanFile(${MakeDirPropFileAbs}) + + # Create a custom command whose output should be cleaned, but whose name + # is not known until generate-time + set(MakeDirPropExpFileRel "MakeDirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") + set(MakeDirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${MakeDirPropExpFileRel}") + addPostBuildFile(toclean "${MakeDirPropExpFileAbs}") + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MakeDirPropExpFileAbs}) + addCleanFile("${CBD}/${MakeDirPropExpFileRel}") +endif() + + +### Tests ADDITIONAL_CLEAN_FILES directory property + +# Register a file path relative to the build directory +set(DirPropFileRel "DirPropFileRel.txt") +writeCleanFile("${CBD}/${DirPropFileRel}") +set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel}) +addCleanFile("${CBD}/${DirPropFileRel}") + +# Register an absolute file path +set(DirPropFileAbs "${CBD}/DirPropFileAbs.txt") +writeCleanFile("${DirPropFileAbs}") +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs}) +addCleanFile("${DirPropFileAbs}") # Create a custom command whose output should be cleaned, but whose name # is not known until generate-time -set(copied_exe "$<TARGET_FILE_DIR:toclean>/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}") -add_custom_command(TARGET toclean POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy $<TARGET_FILE:toclean> - ${copied_exe} - ) -set_property(DIRECTORY APPEND PROPERTY - ADDITIONAL_MAKE_CLEAN_FILES ${copied_exe}) -list(APPEND TOCLEAN_FILES "${ToClean_BINARY_DIR}/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}") +set(DirPropExpFileRel "DirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") +set(DirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${DirPropExpFileRel}") +addPostBuildFile(toclean "${DirPropExpFileAbs}") +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropExpFileAbs}) +addCleanFile("${CBD}/${DirPropExpFileRel}") + + +### Tests ADDITIONAL_CLEAN_FILES target property + +function(test_target_property TARGET) + # Register a file path relative to the build directory + set(TgtPropFileRel "${TARGET}_TargetPropFileRel.txt") + writeCleanFile("${CBD}/${TgtPropFileRel}") + set_target_properties(${TARGET} PROPERTIES ADDITIONAL_CLEAN_FILES ${TgtPropFileRel}) + addCleanFile("${CBD}/${TgtPropFileRel}") + + # Register an absolute file path + set(TgtPropFileAbs "${CBD}/${TARGET}_TargetPropFileAbs.txt") + writeCleanFile("${TgtPropFileAbs}") + set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropFileAbs}) + addCleanFile("${TgtPropFileAbs}") + + # Create a custom command whose output should be cleaned, but whose name + # is not known until generate-time + set(TgtPropExpFileRel "${TARGET}_TargetPropGenExp.txt") + set(TgtPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${TgtPropExpFileRel}") + addPostBuildFile(${TARGET} "${TgtPropExpFileAbs}") + set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropExpFileAbs}) + addCleanFile("${CBD}/${TgtPropExpFileRel}") +endfunction() + +# Test target property for various target types +add_executable(acf_exec toclean.cxx) +test_target_property(acf_exec) +add_library(acf_lib toclean.cxx) +test_target_property(acf_lib) +add_custom_target(acf_custom ALL DEPENDS ${CustomCommandFile}) +test_target_property(acf_custom) + +# Process subdirectory without targets +add_subdirectory(EmptySubDir) + # Configure a file listing these build-time-generated files. -configure_file(${ToClean_SOURCE_DIR}/ToCleanFiles.cmake.in - ${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY) +get_property(TOCLEAN_FILES GLOBAL PROPERTY TOCLEAN_FILES) +configure_file(${CSD}/ToCleanFiles.cmake.in ${CBD}/ToCleanFiles.cmake @ONLY) diff --git a/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt b/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt new file mode 100644 index 0000000..55893ae --- /dev/null +++ b/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.14) + +# Subdirectory CMakeLists.txt without targets +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) + +# Register a file path relative to the build directory +set(DirPropFileRel "DirPropFileRel.txt") +writeCleanFile("${CBD}/${DirPropFileRel}") +set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel}) +addCleanFile("${CBD}/${DirPropFileRel}") + +# Register an absolute file path +set(DirPropFileAbs "${CBD}/DirPropFileAbs.txt") +writeCleanFile("${DirPropFileAbs}") +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs}) +addCleanFile("${DirPropFileAbs}") diff --git a/Tests/MakeClean/check_clean.c.in b/Tests/MakeClean/check_clean.c.in index 5bc4ab8..e5a7945 100644 --- a/Tests/MakeClean/check_clean.c.in +++ b/Tests/MakeClean/check_clean.c.in @@ -18,7 +18,7 @@ int main() if(pf) { fclose(pf); - fprintf(stderr, "File \"%s\" exists!", *f); + fprintf(stderr, "File \"%s\" still exists!\n", *f); result = 1; } } diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt index dcb998a..06d7dce 100644 --- a/Tests/Module/FindDependency/CMakeLists.txt +++ b/Tests/Module/FindDependency/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages") find_package(Pack1 REQUIRED) find_package(Pack4 4.3 EXACT REQUIRED) +find_package(Pack7 REQUIRED) +find_package(Pack8 REQUIRED) add_executable(FindDependency main.cpp) -target_link_libraries(FindDependency Pack1::Lib Pack4::Lib) +target_link_libraries(FindDependency Pack1::Lib Pack4::Lib Pack8::Lib) diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp index 1df4cb5..4ee460f 100644 --- a/Tests/Module/FindDependency/main.cpp +++ b/Tests/Module/FindDependency/main.cpp @@ -23,6 +23,18 @@ # error Expected HAVE_PACK6 #endif +#ifndef HAVE_PACK7 +# error Expected HAVE_PACK7 +#endif + +#ifndef HAVE_PACK7_COMP1 +# error Expected HAVE_PACK7_COMP1 +#endif + +#ifndef HAVE_PACK8 +# error Expected HAVE_PACK8 +#endif + int main(int argc, char** argv) { return 0; diff --git a/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake b/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake new file mode 100644 index 0000000..9df1345 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake @@ -0,0 +1,14 @@ +if(NOT Pack7_FOUND) + set(Pack7_FOUND 1) + add_library(Pack7::Pack7 INTERFACE IMPORTED) + set_property(TARGET Pack7::Pack7 PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK7) +endif() + +foreach(module ${Pack7_FIND_COMPONENTS}) + if(module STREQUAL "Comp1") + add_library(Pack7::Comp1 INTERFACE IMPORTED) + set_property(TARGET Pack7::Comp1 PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK7_COMP1) + set_property(TARGET Pack7::Comp1 PROPERTY INTERFACE_LINK_LIBRARIES Pack7::Pack7) + set(Pack7_Comp1_FOUND 1) + endif() +endforeach() diff --git a/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake b/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake new file mode 100644 index 0000000..d7ca054 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake @@ -0,0 +1,7 @@ +include(CMakeFindDependencyMacro) + +find_dependency(Pack7 REQUIRED COMPONENTS Comp1) + +add_library(Pack8::Lib INTERFACE IMPORTED) +set_property(TARGET Pack8::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK8) +set_property(TARGET Pack8::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack7::Comp1) diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 45bb229..cffef5a 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -52,8 +52,10 @@ endmacro() # detailed features tables, not just meta-features if (CMAKE_C_COMPILE_FEATURES) - set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) - list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") + if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) + list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") + endif() endif() if (C_expected_features) string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJOR "${CMAKE_C_COMPILER_VERSION}") @@ -61,7 +63,7 @@ if (C_expected_features) string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_C_COMPILER_VERSION}") if (CMAKE_C_COMPILER_ID STREQUAL "GNU" - OR CMAKE_C_COMPILER_ID STREQUAL "Clang" + OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_C_COMPILER_ID STREQUAL "Intel") add_executable(WriteCompilerDetectionHeader_C11 main.c) @@ -93,8 +95,10 @@ if (C_expected_features) endif() if (CMAKE_CXX_COMPILE_FEATURES) - set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) - list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") + if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) + list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") + endif() endif() if (NOT CXX_expected_features) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" @@ -118,7 +122,7 @@ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINO string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_CXX_COMPILER_VERSION}") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel") @@ -128,7 +132,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" endif() # for msvc the compiler version determines which c++11 features are available. -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) if(";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;") list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt index 4bffd12..7897ab9 100644 --- a/Tests/ObjectLibrary/CMakeLists.txt +++ b/Tests/ObjectLibrary/CMakeLists.txt @@ -62,4 +62,14 @@ add_custom_target(UseABinternalDep COMMAND ${CMAKE_COMMAND} -E touch UseABintern add_custom_command(TARGET UseABinternal POST_BUILD COMMAND ${CMAKE_COMMAND} -P UseABinternalDep.cmake) add_dependencies(UseABinternal UseABinternalDep) +# Test a static library with sources from a different static library +add_library(UseCstaticObjs STATIC $<TARGET_OBJECTS:Cstatic> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>) + +# Test a shared library with sources from a different shared library +add_library(UseCsharedObjs SHARED $<TARGET_OBJECTS:Cshared> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>) + +# Test a shared executable with sources from a different shared library +add_executable(UseABstaticObjs $<TARGET_OBJECTS:UseABstatic>) +target_link_libraries(UseABstaticObjs ABstatic) + add_subdirectory(ExportLanguages) diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index 227d990..8e8fa07 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -15,6 +15,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static) set(KWSYS_NAMESPACE kwsys) set(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include) set(KWSYS_USE_DynamicLoader 1) +set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) add_subdirectory(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys) # Configure the location of plugins. diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index 8c2cdc9..588af03 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -28,6 +28,11 @@ endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") set(PP_VS 1) endif() +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND + "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND + "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + set(CLANG_GNULIKE_WINDOWS 1) +endif() # Some tests below check the PP_* variables set above. They are meant # to test the case that the build tool is at fault. Other tests below @@ -53,7 +58,7 @@ endif() string(APPEND STRING_EXTRA " ") -if(NOT PP_BORLAND AND NOT PP_WATCOM) +if(NOT PP_BORLAND AND NOT PP_WATCOM AND NOT CLANG_GNULIKE_WINDOWS) # Borland, WMake: multiple spaces # The make tool seems to remove extra whitespace from inside # quoted strings when passing to the compiler. It does not have @@ -70,14 +75,14 @@ if(NOT PP_VS) string(APPEND STRING_EXTRA ",") endif() -if(NOT PP_MINGW) +if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS) # MinGW: & # When inside -D"FOO=\"a & b\"" MinGW make wants -D"FOO=\"a "&" b\"" # but it does not like quoted ampersand elsewhere. string(APPEND STRING_EXTRA "&") endif() -if(NOT PP_MINGW) +if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS) # MinGW: | # When inside -D"FOO=\"a | b\"" MinGW make wants -D"FOO=\"a "|" b\"" # but it does not like quoted pipe elsewhere. @@ -100,7 +105,8 @@ endif() set(EXPR_OP1 "/") if((NOT MSVC OR PP_NMAKE) AND - NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND + NOT CLANG_GNULIKE_WINDOWS) # MSVC cl, Intel icl: % # When the cl compiler is invoked from the command line then % must # be written %% (to distinguish from %ENV% syntax). However cl does diff --git a/Tests/Preprocess/preprocess.c b/Tests/Preprocess/preprocess.c index 2913f93..958c77e 100644 --- a/Tests/Preprocess/preprocess.c +++ b/Tests/Preprocess/preprocess.c @@ -10,7 +10,8 @@ int check_defines_C(void) { int result = 1; if (strcmp(FILE_STRING, STRING_VALUE) != 0) { - fprintf(stderr, "FILE_STRING has wrong value in C [%s]\n", FILE_STRING); + fprintf(stderr, "FILE_STRING has wrong value in C [%s] vs [%s]\n", + FILE_STRING, STRING_VALUE); result = 0; } if (strcmp(TARGET_STRING, STRING_VALUE) != 0) { diff --git a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt index cff7022..81fd8db 100644 --- a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt +++ b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt @@ -69,6 +69,9 @@ file(MAKE_DIRECTORY ${GAT_BDIR}) message("___ Configuring GAT project ___") execute_process( COMMAND "${CMAKE_COMMAND}" "${GAT_SDIR}" + -G "${CMAKE_GENERATOR}" + -A "${CMAKE_GENERATOR_PLATFORM}" + -T "${CMAKE_GENERATOR_TOOLSET}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" diff --git a/Tests/QtAutogen/ManySources/CMakeLists.txt b/Tests/QtAutogen/ManySources/CMakeLists.txt new file mode 100644 index 0000000..df8a2a6 --- /dev/null +++ b/Tests/QtAutogen/ManySources/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.10) +project(ManySources) +include("../AutogenGuiTest.cmake") + +# Test AUTOMOC and AUTOUIC on many source files to stress the concurrent +# parsing and processing framework. + +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) + +set(SRCS main.cpp) +set(MAIN_INCLUDES "\n// Item includes\n") +set(MAIN_ITEMS "\n// Items\n") + +set(NUM 24) +foreach(III RANGE 1 ${NUM}) + configure_file(${CSD}/object.h.in ${CBD}/object_${III}.h) + configure_file(${CSD}/item.h.in ${CBD}/item_${III}.h) + configure_file(${CSD}/item.cpp.in ${CBD}/item_${III}.cpp) + configure_file(${CSD}/view.ui.in ${CBD}/view_${III}.ui) + configure_file(${CSD}/data.qrc.in ${CBD}/data_${III}.qrc) + + list(APPEND SRCS ${CBD}/item_${III}.cpp) + list(APPEND SRCS ${CBD}/data_${III}.qrc) + + string(APPEND MAIN_INCLUDES "#include \"item_${III}.h\"\n") + string(APPEND MAIN_ITEMS "Item_${III} item_${III};\n") + string(APPEND MAIN_ITEMS "item_${III}.TheSlot();\n") +endforeach() + +configure_file(${CSD}/main.cpp.in ${CBD}/main.cpp) + +add_executable(manySources ${SRCS} ${CBD}/main.cpp) +target_link_libraries(manySources ${QT_LIBRARIES}) +set_target_properties(manySources PROPERTIES AUTOMOC 1 AUTOUIC 1 AUTORCC 1) diff --git a/Tests/QtAutogen/ManySources/data.qrc.in b/Tests/QtAutogen/ManySources/data.qrc.in new file mode 100644 index 0000000..870d486 --- /dev/null +++ b/Tests/QtAutogen/ManySources/data.qrc.in @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>object_@III@.h</file> + <file>item_@III@.h</file> + <file>item_@III@.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/ManySources/item.cpp.in b/Tests/QtAutogen/ManySources/item.cpp.in new file mode 100644 index 0000000..c34ad16 --- /dev/null +++ b/Tests/QtAutogen/ManySources/item.cpp.in @@ -0,0 +1,27 @@ +#include "item_@III@.h" +#include "object_@III@.h" +// AUTOUIC include +#include <ui_view_@III@.h> + +class LocalObject_@III@ : public QObject +{ + Q_OBJECT; + +public: + LocalObject_@III@() = default; + ~LocalObject_@III@() = default; +}; + +void Item_@III@ ::TheSlot() +{ + LocalObject_@III@ localObject; + Object_@III@ obj; + obj.ObjectSlot(); + + Ui_View_@III@ ui_view; +} + +// AUTOMOC includes +#include "item_@III@.moc" +#include "moc_item_@III@.cpp" +#include "moc_object_@III@.cpp" diff --git a/Tests/QtAutogen/ManySources/item.h.in b/Tests/QtAutogen/ManySources/item.h.in new file mode 100644 index 0000000..67ad794 --- /dev/null +++ b/Tests/QtAutogen/ManySources/item.h.in @@ -0,0 +1,15 @@ +#ifndef ITEM_@III@HPP +#define ITEM_@III@HPP + +#include <QObject> + +class Item_@III@ : public QObject +{ + Q_OBJECT + +public: + Q_SLOT + void TheSlot(); +}; + +#endif diff --git a/Tests/QtAutogen/ManySources/main.cpp.in b/Tests/QtAutogen/ManySources/main.cpp.in new file mode 100644 index 0000000..e1dda40 --- /dev/null +++ b/Tests/QtAutogen/ManySources/main.cpp.in @@ -0,0 +1,7 @@ +@MAIN_INCLUDES@ + +int main(int argv, char** args) +{ + @MAIN_ITEMS@ + return 0; +} diff --git a/Tests/QtAutogen/ManySources/object.h.in b/Tests/QtAutogen/ManySources/object.h.in new file mode 100644 index 0000000..a747cbc --- /dev/null +++ b/Tests/QtAutogen/ManySources/object.h.in @@ -0,0 +1,15 @@ +#ifndef OBJECT_@III@H +#define OBJECT_@III@H + +#include <QObject> + +class Object_@III@ : public QObject +{ + Q_OBJECT + +public: + Q_SLOT + void ObjectSlot(){}; +}; + +#endif diff --git a/Tests/QtAutogen/ManySources/view.ui.in b/Tests/QtAutogen/ManySources/view.ui.in new file mode 100644 index 0000000..6901fe3 --- /dev/null +++ b/Tests/QtAutogen/ManySources/view.ui.in @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>View_@III@</class> + <widget class="QWidget" name="Base"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt index f4b726f..9b32e59 100644 --- a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt @@ -5,10 +5,48 @@ include("../AutogenCoreTest.cmake") # Dummy executable to generate a clean target add_executable(dummy dummy.cpp) -set(timeformat "%Y%j%H%M%S") +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic") set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic") +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamp When) + file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change) + if (timeAfter VERSION_GREATER timeBefore) + message(STATUS "As expected the file ${mocBasicBin} changed.") + else() + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + endif() +endmacro() + +macro(require_change_not) + if (timeAfter VERSION_GREATER timeBefore) + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + else() + message(STATUS "As expected the file ${mocBasicBin} did not change.") + endif() +endmacro() + + # Initial build configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) try_compile(MOC_RERUN @@ -21,46 +59,44 @@ try_compile(MOC_RERUN OUTPUT_VARIABLE output ) if (NOT MOC_RERUN) - message(SEND_ERROR "Initial build of mocBasic failed. Output: ${output}") + message(FATAL_ERROR "Initial build of mocBasic failed. Output: ${output}") endif() + # Get name of the output binary file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8) list(GET mocBasicList 0 mocBasicBin) -message("Changing the header content for a MOC rerun") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamp(Before) +sleep() +message(STATUS "Touching binary file to ensure a new timestamps") +file(TOUCH_NOCREATE "${mocBasicBin}") +acquire_timestamp(After) +require_change() + + # - Ensure that the timestamp will change -# - Change header file content and rebuild +# - Change header file content # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamp(Before) +sleep() +message(STATUS "Changing the header content for a MOC re-run") configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) -if (result) - message(SEND_ERROR "Second build of mocBasic failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") -# - Test if timestamps changed -if (NOT timeAfter GREATER timeBefore) - message(SEND_ERROR "File (${mocBasicBin}) should have changed!") -endif() +sleep() +rebuild(2) +acquire_timestamp(After) +require_change() -message("Changing nothing for a MOC rerun") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") # - Ensure that the timestamp would change # - Change nothing # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) -if (result) - message(SEND_ERROR "Third build of mocBasic failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") -# - Test if timestamps changed -if (timeAfter GREATER timeBefore) - message(SEND_ERROR "File (${mocBasicBin}) should not have changed!") -endif() +acquire_timestamp(Before) +sleep() +message(STATUS "Changing nothing for no MOC re-run") +rebuild(3) +acquire_timestamp(After) +require_change_not() diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt index b83e994..e1951f1 100644 --- a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt @@ -9,10 +9,53 @@ include("../AutogenCoreTest.cmake") add_executable(dummy dummy.cpp) # Utility variables -set(timeformat "%Y%j%H%M%S") +set(timeformat "%Y.%j.%H.%M%S") set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocPlugin") set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocPlugin") +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(STATUS "As expected the file ${pl${PLG}File} changed.") + else() + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} did not change!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + endif() +endmacro() + +macro(require_change_not PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} changed!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + else() + message(STATUS "As expected the file ${pl${PLG}File} did not change.") + endif() +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${plAFile}" plA${When} "${timeformat}") + file(TIMESTAMP "${plBFile}" plB${When} "${timeformat}") + file(TIMESTAMP "${plCFile}" plC${When} "${timeformat}") + file(TIMESTAMP "${plDFile}" plD${When} "${timeformat}") + file(TIMESTAMP "${plEFile}" plE${When} "${timeformat}") +endmacro() + + # Initial build try_compile(MOC_PLUGIN "${mocPlugBinDir}" @@ -24,83 +67,68 @@ try_compile(MOC_PLUGIN OUTPUT_VARIABLE output ) if (NOT MOC_PLUGIN) - message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") + message(FATAL_ERROR "Initial build of mocPlugin failed. Output: ${output}") endif() +# Get names of the output binaries find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) +# To avoid a race condition where the library has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - rebuild library to ensure it has a new timestamp +sleep() +message(STATUS "Rebuilding library files to ensure new timestamps") +rebuild(1) + + # - Ensure that the timestamp will change. # - Change the json files referenced by Q_PLUGIN_METADATA # - Rebuild -file(TIMESTAMP "${plAFile}" plABefore "${timeformat}") -file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}") -file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") -file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") -file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}") - -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files.") configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - -file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}") -file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}") -file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") -file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") -file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}") - -if (plAAfter GREATER plABefore) - message(SEND_ERROR "file (${plAFile}) should not have changed!") -endif() -if (plBAfter GREATER plBBefore) - message(SEND_ERROR "file (${plBFile}) should not have changed!") -endif() -if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") -endif() -if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") -endif() -if (NOT plEAfter GREATER plEBefore) - # There's a bug in Ninja on Windows - # https://gitlab.kitware.com/cmake/cmake/issues/16776 - if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) - message(SEND_ERROR "file (${plEFile}) should have changed!") - endif() +sleep() +rebuild(2) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows: +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) endif() + # - Ensure that the timestamp will change. # - Change the json files referenced by A_CUSTOM_MACRO # - Rebuild -file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") -file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") -file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}") - -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files") configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - -file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") -file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") -file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}") - -if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") -endif() -if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") -endif() -if (NOT plEAfter GREATER plEBefore) - # There's a bug in Ninja on Windows - # https://gitlab.kitware.com/cmake/cmake/issues/16776 - if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) - message(SEND_ERROR "file (${plEFile}) should have changed!") - endif() +sleep() +rebuild(3) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) endif() diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt index dcb7a79..33c01ac 100644 --- a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt @@ -9,10 +9,23 @@ add_executable(dummy dummy.cpp) # When a .qrc or a file listed in a .qrc file changes, # the target must be rebuilt -set(timeformat "%Y%j%H%M%S") set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccConfigChange") set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange") +# Rebuild macro +macro(rebuild CFG) + message(STATUS "Rebuilding rccConfigChange in ${CFG} configuration.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . --config "${CFG}" + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "${CFG} build of rccConfigChange failed.") + else() + message(STATUS "${CFG} build of rccConfigChange finished.") + endif() +endmacro() + # Initial build try_compile(RCC_DEPENDS "${rccDepBD}" @@ -24,19 +37,11 @@ try_compile(RCC_DEPENDS OUTPUT_VARIABLE output ) if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccConfigChange failed. Output: ${output}") + message(FATAL_ERROR "Initial build of rccConfigChange failed. Output: ${output}") endif() -# - Rebuild Release -message("Rebuilding rccConfigChange in Release configuration") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Release build of rccConfigChange failed.") -endif() +# Rebuild: Release +rebuild(Release) -# - Rebuild Debug -message("Rebuilding rccConfigChange in Debug configuration") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Debug build of rccConfigChange failed.") -endif() +# Rebuild: Debug +rebuild(Debug) diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt index 80c5cf0..1301550 100644 --- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt @@ -3,19 +3,63 @@ project(RerunRccDepends) include("../AutogenCoreTest.cmake") # Tests rcc rebuilding when a resource file changes +# When a .qrc or a file listed in a .qrc file changes, +# the target must be rebuilt # Dummy executable to generate a clean target add_executable(dummy dummy.cpp) -# When a .qrc or a file listed in a .qrc file changes, -# the target must be rebuilt -set(timeformat "%Y%j%H%M%S") +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccDepends") set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccDepends") -# Initial build +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${rccDepBinPlain}" rdPlain${When} "${timeformat}") + file(TIMESTAMP "${rccDepBinGenerated}" rdGenerated${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName} of rccDepends.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} of rccDepends failed.") + else() + message(STATUS "Build ${buildName} of rccDepends finished.") + endif() +endmacro() + +macro(require_change type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} changed.") + else() + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} did not change!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + endif() +endmacro() + +macro(require_change_not type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} changed!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + else() + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} did not change.") + endif() +endmacro() + + +# Initial configuration configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) + +# Initial build try_compile(RCC_DEPENDS "${rccDepBD}" "${rccDepSD}" @@ -26,113 +70,84 @@ try_compile(RCC_DEPENDS OUTPUT_VARIABLE output ) if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}") + message(FATAL_ERROR "Initial build of rccDepends failed. Output: ${output}") endif() # Get name of the output binaries file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8) file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8) list(GET targetListPlain 0 rccDepBinPlain) -list(GET targetListGen 0 rccDepBinGen) -message("Target that uses a plain .qrc file is:\n ${rccDepBinPlain}") -message("Target that uses a GENERATED .qrc file is:\n ${rccDepBinGen}") +list(GET targetListGen 0 rccDepBinGenerated) +message(STATUS "Target that uses a plain .qrc file is:\n ${rccDepBinPlain}") +message(STATUS "Target that uses a GENERATED .qrc file is:\n ${rccDepBinGenerated}") + +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamps(Before) +sleep() +message(STATUS "Touching binary files to ensure new timestamps") +file(TOUCH_NOCREATE "${rccDepBinPlain}" "${rccDepBinGenerated}") +acquire_timestamps(After) +require_change(Plain) +require_change(Generated) -message("Changing a resource files listed in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change a resource files listed in the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a resource file listed in the .qrc file") file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Second build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(2) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing the .qrc file") configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Third build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(3) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing a newly added resource files listed in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change a newly added resource files listed in the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a newly added resource file listed in the .qrc file") file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fourth build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(4) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing nothing in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change nothing # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fifth build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +acquire_timestamps(Before) +sleep() +message(STATUS "Changing nothing in the .qrc file") +rebuild(5) +acquire_timestamps(After) # - Test if timestamps changed -if (rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should NOT have changed!") -endif() -if (rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should NOT have changed!") -endif() +require_change_not(Plain) +require_change_not(Generated) diff --git a/Tests/QtAutogen/SameName/CMakeLists.txt b/Tests/QtAutogen/SameName/CMakeLists.txt index 8d4f71f..0a80d5e 100644 --- a/Tests/QtAutogen/SameName/CMakeLists.txt +++ b/Tests/QtAutogen/SameName/CMakeLists.txt @@ -37,7 +37,7 @@ if (QT_TEST_VERSION EQUAL 4) else() set(rccCompress "--compress") endif() -set_target_properties(sameName PROPERTIES AUTORCC_OPTIONS "${rccCompress};0" ) -set_source_files_properties(aaa/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};1" ) -set_source_files_properties(bbb/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};2" ) -set_source_files_properties(ccc/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};3" ) +set_target_properties(sameName PROPERTIES AUTORCC_OPTIONS "${rccCompress};1" ) +set_source_files_properties(aaa/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};2" ) +set_source_files_properties(bbb/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};3" ) +set_source_files_properties(ccc/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};4" ) diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index 096d5e3..6771828 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -5,6 +5,7 @@ ADD_AUTOGEN_TEST(AutogenTargetDepends) ADD_AUTOGEN_TEST(Complex QtAutogen) ADD_AUTOGEN_TEST(GlobalAutogenTarget) ADD_AUTOGEN_TEST(LowMinimumVersion lowMinimumVersion) +ADD_AUTOGEN_TEST(ManySources manySources) ADD_AUTOGEN_TEST(MocOnly mocOnly) ADD_AUTOGEN_TEST(MocOptions mocOptions) ADD_AUTOGEN_TEST(ObjectLibrary someProgram) diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.c b/Tests/RunCMake/BuildDepends/BuildUnderSource.c new file mode 100644 index 0000000..688a040 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.c @@ -0,0 +1,5 @@ +#include "BuildUnderSource.h" +int main(void) +{ + return BUILD_UNDER_SOURCE; +} diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake new file mode 100644 index 0000000..aa2a44f --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake @@ -0,0 +1,9 @@ +enable_language(C) +include_directories(include) +add_executable(BuildUnderSource BuildUnderSource.c) + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(check_pairs + \"$<TARGET_FILE:BuildUnderSource>|${CMAKE_CURRENT_SOURCE_DIR}/include/BuildUnderSource.h\" + ) +") diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake new file mode 100644 index 0000000..2cdd32b --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_SOURCE_DIR}/include/BuildUnderSource.h" [[ +#define BUILD_UNDER_SOURCE 1 +]]) diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake new file mode 100644 index 0000000..8e4b858 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_SOURCE_DIR}/include/BuildUnderSource.h" [[ +#define BUILD_UNDER_SOURCE 2 +]]) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 3445beb..14ae243 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -9,7 +9,9 @@ endif() function(run_BuildDepends CASE) # Use a single build tree for a few tests without cleaning. - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + if(NOT RunCMake_TEST_BINARY_DIR) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + endif() set(RunCMake_TEST_NO_CLEAN 1) if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) @@ -44,6 +46,18 @@ endif() run_BuildDepends(Custom-Symbolic-and-Byproduct) run_BuildDepends(Custom-Always) +# Test header dependencies with a build tree underneath a source tree. +set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource") +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource/build") +file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}/include") +foreach(f CMakeLists.txt BuildUnderSource.cmake BuildUnderSource.c) + configure_file("${RunCMake_SOURCE_DIR}/${f}" "${RunCMake_TEST_SOURCE_DIR}/${f}" COPYONLY) +endforeach() +run_BuildDepends(BuildUnderSource) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_SOURCE_DIR) + if(RunCMake_GENERATOR MATCHES "Make") run_BuildDepends(MakeCustomIncludes) if(NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}") diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt index ddb3cae..87ac88e 100644 --- a/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt +++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at CMP0069-NEW-cmake\.cmake:[0-9]+ \(add_executable\): CMake doesn't support IPO for current compiler Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt index 8decfab..cb9d19b 100644 --- a/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt +++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at CMP0069-NEW-compiler\.cmake:[0-9]+ \(add_executable\): Compiler doesn't support IPO Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt index 0e05ee7..1159ec0 100644 --- a/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt +++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at CMP0069-NEW-generator\.cmake:[0-9]+ \(add_executable\): CMake doesn't support IPO for current generator Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index f2b7ff1..69f8162 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -192,13 +192,20 @@ add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) +if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + add_RunCMake_test(MetaCompileFeatures) +endif() +if(MSVC) + add_RunCMake_test(MSVCRuntimeLibrary) + add_RunCMake_test(MSVCWarningFlags) +endif() add_RunCMake_test(ObjectLibrary) add_RunCMake_test(ParseImplicitIncludeInfo) if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") add_RunCMake_test(RuntimePath) endif() add_RunCMake_test(ScriptMode) -add_RunCMake_test(Swift) +add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER}) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) add_RunCMake_test(ToolchainFile) @@ -252,6 +259,7 @@ add_RunCMake_test(ctest_submit) add_RunCMake_test(ctest_test) add_RunCMake_test(ctest_disabled_test) add_RunCMake_test(ctest_skipped_test) +add_RunCMake_test(ctest_update) add_RunCMake_test(ctest_upload) add_RunCMake_test(ctest_fixtures) add_RunCMake_test(file) @@ -339,8 +347,7 @@ if(PKG_CONFIG_FOUND) add_RunCMake_test(FindPkgConfig) endif() -find_package(GTK2 QUIET) -if (GTK2_FOUND) +if(CMake_TEST_FindGTK2) add_RunCMake_test(FindGTK2) endif() @@ -353,7 +360,10 @@ if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^9]|9[0-9])") - add_RunCMake_test(VS10Project) + add_RunCMake_test(VS10Project + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + ) if( vs12 AND wince ) add_RunCMake_test( VS10ProjectWinCE "-DRunCMake_GENERATOR_PLATFORM=${wince_sdk}") endif() @@ -438,9 +448,11 @@ endif() add_executable(pseudo_emulator pseudo_emulator.c) add_executable(pseudo_emulator_custom_command pseudo_emulator_custom_command.c) +add_executable(pseudo_emulator_custom_command_arg pseudo_emulator_custom_command_arg.c) add_RunCMake_test(CrosscompilingEmulator -DPSEUDO_EMULATOR=$<TARGET_FILE:pseudo_emulator> - -DPSEUDO_EMULATOR_CUSTOM_COMMAND=$<TARGET_FILE:pseudo_emulator_custom_command>) + -DPSEUDO_EMULATOR_CUSTOM_COMMAND=$<TARGET_FILE:pseudo_emulator_custom_command> + -DPSEUDO_EMULATOR_CUSTOM_COMMAND_ARG=$<TARGET_FILE:pseudo_emulator_custom_command_arg>) if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") if(UNIX AND NOT CYGWIN) execute_process(COMMAND ldd --help diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index d524f41..b7f9a37 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -200,7 +200,11 @@ function(run_ShowOnly) file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " add_test(ShowOnly \"${CMAKE_COMMAND}\" -E echo) - set_tests_properties(ShowOnly PROPERTIES WILL_FAIL true _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\") + set_tests_properties(ShowOnly PROPERTIES + WILL_FAIL true + REQUIRED_FILES RequiredFileDoesNotExist + _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\" + ) add_test(ShowOnlyNotAvailable NOT_AVAILABLE) ") run_cmake_command(show-only_human ${CMAKE_CTEST_COMMAND} --show-only=human) diff --git a/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py index 4dff90c..3ad5768 100644 --- a/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py +++ b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py @@ -63,6 +63,15 @@ def check_command(c): assert is_string(c[2]) assert c[2] == "echo" +def check_reqfiles_property(p): + assert is_dict(p) + assert sorted(p.keys()) == ["name", "value"] + assert is_string(p["name"]) + assert is_list(p["value"]) + assert p["name"] == "REQUIRED_FILES" + assert len(p["value"]) == 1 + assert p["value"][0] == "RequiredFileDoesNotExist" + def check_willfail_property(p): assert is_dict(p) assert sorted(p.keys()) == ["name", "value"] @@ -81,9 +90,10 @@ def check_workingdir_property(p): def check_properties(p): assert is_list(p) - assert len(p) == 2 - check_willfail_property(p[0]) - check_workingdir_property(p[1]) + assert len(p) == 3 + check_reqfiles_property(p[0]) + check_willfail_property(p[1]) + check_workingdir_property(p[2]) def check_tests(t): assert is_list(t) diff --git a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-result.txt +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-result.txt diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-stderr.txt index f2cbaa6..94fc157 100644 --- a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-stderr.txt @@ -1,3 +1,3 @@ -^'--target' may not be specified more than once\. +^The <jobs> value is too large\. + Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-result.txt diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-stderr.txt new file mode 100644 index 0000000..8ed4fee --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-stderr.txt @@ -0,0 +1,3 @@ +^The <jobs> value requires a positive integer argument\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-stderr.txt new file mode 100644 index 0000000..94fc157 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-stderr.txt @@ -0,0 +1,3 @@ +^The <jobs> value is too large\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-stderr.txt new file mode 100644 index 0000000..8ed4fee --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-stderr.txt @@ -0,0 +1,3 @@ +^The <jobs> value requires a positive integer argument\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-jobs-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-jobs-stderr.txt new file mode 100644 index 0000000..3c2c808 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-jobs-stderr.txt @@ -0,0 +1 @@ +(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.) diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-stderr.txt new file mode 100644 index 0000000..40d9bec --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-stderr.txt @@ -0,0 +1,2 @@ +^Error: Building 'clean' and other targets together is not supported\. +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-stderr.txt new file mode 100644 index 0000000..40d9bec --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-stderr.txt @@ -0,0 +1,2 @@ +^Error: Building 'clean' and other targets together is not supported\. +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt index 6c5ea44..b4b170e 100644 --- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt +++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt @@ -1 +1 @@ -^{.*}$ +^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":0}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":true,"version":{.*}}$ diff --git a/Tests/RunCMake/CommandLine/E_make_directory-directory-with-parent-check.cmake b/Tests/RunCMake/CommandLine/E_make_directory-directory-with-parent-check.cmake new file mode 100644 index 0000000..ea3d161 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_make_directory-directory-with-parent-check.cmake @@ -0,0 +1,3 @@ +if(NOT IS_DIRECTORY ${out}/parent/child) + set(RunCMake_TEST_FAILED "child directory was not created") +endif() diff --git a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-check.cmake b/Tests/RunCMake/CommandLine/E_make_directory-three-directories-check.cmake new file mode 100644 index 0000000..c1e8474 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_make_directory-three-directories-check.cmake @@ -0,0 +1,6 @@ +if(NOT IS_DIRECTORY ${out}/d1) + set(RunCMake_TEST_FAILED "directory d1 was not created") +endif() +if(NOT IS_DIRECTORY ${out}/d2) + set(RunCMake_TEST_FAILED "directory d2 was not created") +endif() diff --git a/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-result.txt b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-stderr.txt b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt index 08a9428..08a9428 100644 --- a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-stderr.txt +++ b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-check.cmake new file mode 100644 index 0000000..fd6ea11 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-check.cmake @@ -0,0 +1,3 @@ +if(IS_DIRECTORY ${out}/parent/child) + set(RunCMake_TEST_FAILED "child directory was not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-stderr.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-check.cmake new file mode 100644 index 0000000..2b7202a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-check.cmake @@ -0,0 +1,6 @@ +if(IS_DIRECTORY ${out}/d1) + set(RunCMake_TEST_FAILED "directory d1 was not removed") +endif() +if(IS_DIRECTORY ${out}/d2) + set(RunCMake_TEST_FAILED "directory d2 was not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-stderr.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-check.cmake new file mode 100644 index 0000000..0aa4a52 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${outfile}) + set(RunCMake_TEST_FAILED "removed non-directory ${outfile}") +endif() diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-stderr.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-stderr.txt diff --git a/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt new file mode 100644 index 0000000..2b8c65c --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.14) +project(EnvGenerator C) +if(CMAKE_GENERATOR MATCHES "Visual Studio") + message(STATUS "CMAKE_VS_PLATFORM_NAME='${CMAKE_VS_PLATFORM_NAME}'") +endif() +add_custom_command( + OUTPUT output.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt + ) +add_custom_target(CustomTarget ALL DEPENDS output.txt) diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt new file mode 100644 index 0000000..4eae6aa --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ + No CMAKE_C_COMPILER could be found. diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt new file mode 100644 index 0000000..09c2d2b --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+Platform='fromcli'.+ diff --git a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt new file mode 100644 index 0000000..4dd6be1 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_VS_PLATFORM_NAME='(x64|Win32)' diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt new file mode 100644 index 0000000..b432c19 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+(Platform Toolset = 'fromcli'|Specified platform toolset \(fromcli\) is not installed or invalid).+ diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-result.txt b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt new file mode 100644 index 0000000..4a1215e --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error: No generator specified for -G +CMake Error: CMAKE_GENERATOR was set but the specified generator doesn't exist. Using CMake default. + +Generators.* +\* (Unix Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt new file mode 100644 index 0000000..d53daa5 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ + could not find specified instance of Visual Studio.+ diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt new file mode 100644 index 0000000..0d455db --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error: No generator specified for -G + +Generators.* +\* Ninja.* diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt new file mode 100644 index 0000000..4eae6aa --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ + No CMAKE_C_COMPILER could be found. diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt new file mode 100644 index 0000000..76a8f1c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+Platform='invalid'.+ diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt new file mode 100644 index 0000000..51fce60 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+(Platform Toolset = 'invalid'|Specified platform toolset \(invalid\) is not installed or invalid).+ diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-result.txt b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt new file mode 100644 index 0000000..ec6ec92 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error: No generator specified for -G + +Generators.* +\* (Unix Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt new file mode 100644 index 0000000..47f9c9e --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt @@ -0,0 +1,7 @@ +^Warning: Environment variable CMAKE_GENERATOR_INSTANCE will be ignored, because CMAKE_GENERATOR is not set. +Warning: Environment variable CMAKE_GENERATOR_PLATFORM will be ignored, because CMAKE_GENERATOR is not set. +Warning: Environment variable CMAKE_GENERATOR_TOOLSET will be ignored, because CMAKE_GENERATOR is not set. +CMake Error: No generator specified for -G + +Generators.* +\* (Unix Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt index 0ca5a0a..fc62914 100644 --- a/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt +++ b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.14) +project(ExplicitDirs NONE) add_custom_command( OUTPUT output.txt COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 23fb9ef..c9d3a4d 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -54,12 +54,23 @@ run_cmake_command(build-bad-dir run_cmake_command(build-bad-generator ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator) +run_cmake_command(install-no-dir + ${CMAKE_COMMAND} --install) +run_cmake_command(install-bad-dir + ${CMAKE_COMMAND} --install dir-does-not-exist) +run_cmake_command(install-options-to-vars + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-install-options-to-vars + --strip --prefix /var/test --config sample --component pack) + run_cmake_command(cache-bad-entry ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-entry/) run_cmake_command(cache-empty-entry ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-empty-entry/) function(run_ExplicitDirs) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_NO_SOURCE_DIR 1) + set(source_dir ${RunCMake_BINARY_DIR}/ExplicitDirsMissing) file(REMOVE_RECURSE "${source_dir}") @@ -68,29 +79,32 @@ function(run_ExplicitDirs) cmake_minimum_required(VERSION 3.13) project(ExplicitDirsMissing LANGUAGES NONE) ]=]) - run_cmake_command(no-S-B ${CMAKE_COMMAND} -E chdir ${source_dir} - ${CMAKE_COMMAND} -DFOO=BAR) + set(RunCMake_TEST_SOURCE_DIR "${source_dir}") + set(RunCMake_TEST_BINARY_DIR "${source_dir}") + run_cmake_with_options(no-S-B -DFOO=BAR) set(source_dir ${RunCMake_SOURCE_DIR}/ExplicitDirs) set(binary_dir ${RunCMake_BINARY_DIR}/ExplicitDirs-build) + set(RunCMake_TEST_SOURCE_DIR "${source_dir}") + set(RunCMake_TEST_BINARY_DIR "${binary_dir}") + file(REMOVE_RECURSE "${binary_dir}") - file(MAKE_DIRECTORY "${binary_dir}") - run_cmake_command(S-arg ${CMAKE_COMMAND} -S ${source_dir} ${binary_dir}) - run_cmake_command(S-arg-reverse-order ${CMAKE_COMMAND} ${binary_dir} -S${source_dir} ) - run_cmake_command(S-no-arg ${CMAKE_COMMAND} -S ) - run_cmake_command(S-no-arg2 ${CMAKE_COMMAND} -S -T) - run_cmake_command(S-B ${CMAKE_COMMAND} -S ${source_dir} -B ${binary_dir}) + run_cmake_with_options(S-arg -S ${source_dir} ${binary_dir}) + run_cmake_with_options(S-arg-reverse-order ${binary_dir} -S${source_dir} ) + run_cmake_with_options(S-no-arg -S ) + run_cmake_with_options(S-no-arg2 -S -T) + run_cmake_with_options(S-B -S ${source_dir} -B ${binary_dir}) # make sure that -B can explicitly construct build directories file(REMOVE_RECURSE "${binary_dir}") - run_cmake_command(B-arg ${CMAKE_COMMAND} -B ${binary_dir} ${source_dir}) + run_cmake_with_options(B-arg -B ${binary_dir} ${source_dir}) file(REMOVE_RECURSE "${binary_dir}") - run_cmake_command(B-arg-reverse-order ${CMAKE_COMMAND} ${source_dir} -B${binary_dir}) - run_cmake_command(B-no-arg ${CMAKE_COMMAND} -B ) - run_cmake_command(B-no-arg2 ${CMAKE_COMMAND} -B -T) + run_cmake_with_options(B-arg-reverse-order ${source_dir} -B${binary_dir}) + run_cmake_with_options(B-no-arg -B ) + run_cmake_with_options(B-no-arg2 -B -T) file(REMOVE_RECURSE "${binary_dir}") - run_cmake_command(B-S ${CMAKE_COMMAND} -B${binary_dir} -S${source_dir}) + run_cmake_with_options(B-S -B${binary_dir} -S${source_dir}) endfunction() run_ExplicitDirs() @@ -106,7 +120,13 @@ function(run_BuildDir) run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget) run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir .. - ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget2 --target CustomTarget3) + ${CMAKE_COMMAND} --build BuildDir-build -t CustomTarget2 --target CustomTarget3) + run_cmake_command(BuildDir--build-multiple-targets-jobs ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget CustomTarget2 -j2 --target CustomTarget3) + run_cmake_command(BuildDir--build-multiple-targets-with-clean-first ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --target clean CustomTarget) + run_cmake_command(BuildDir--build-multiple-targets-with-clean-second ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget clean) run_cmake_command(BuildDir--build-jobs-bad-number ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build -j 12ab) run_cmake_command(BuildDir--build-jobs-good-number ${CMAKE_COMMAND} -E chdir .. @@ -131,6 +151,14 @@ function(run_BuildDir) ${CMAKE_COMMAND} --build BuildDir-build --parallel2) run_cmake_command(BuildDir--build--parallel-no-space-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --parallel2 --target CustomTarget) + run_cmake_command(BuildDir--build-jobs-zero ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 0) + run_cmake_command(BuildDir--build--parallel-zero ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 0) + run_cmake_command(BuildDir--build-jobs-large ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 4294967293) + run_cmake_command(BuildDir--build--parallel-large ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 4294967293) # No default jobs for Xcode and FreeBSD build command if(NOT RunCMake_GENERATOR MATCHES "Xcode" AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") @@ -146,6 +174,74 @@ function(run_BuildDir) endfunction() run_BuildDir() +function(run_EnvironmentGenerator) + set(source_dir ${RunCMake_SOURCE_DIR}/EnvGenerator) + + set(ENV{CMAKE_GENERATOR_INSTANCE} "instance") + set(ENV{CMAKE_GENERATOR_PLATFORM} "platform") + set(ENV{CMAKE_GENERATOR_TOOLSET} "toolset") + run_cmake_command(Envgen-warnings ${CMAKE_COMMAND} -G) + unset(ENV{CMAKE_GENERATOR_INSTANCE}) + unset(ENV{CMAKE_GENERATOR_PLATFORM}) + unset(ENV{CMAKE_GENERATOR_TOOLSET}) + + # Test CMAKE_GENERATOR without actual configuring + run_cmake_command(Envgen-unset ${CMAKE_COMMAND} -G) + set(ENV{CMAKE_GENERATOR} "Ninja") + run_cmake_command(Envgen-ninja ${CMAKE_COMMAND} -G) + set(ENV{CMAKE_GENERATOR} "NoSuchGenerator") + run_cmake_command(Envgen-bad ${CMAKE_COMMAND} -G) + unset(ENV{CMAKE_GENERATOR}) + + if(RunCMake_GENERATOR MATCHES "Visual Studio.*") + set(ENV{CMAKE_GENERATOR} "${RunCMake_GENERATOR}") + run_cmake_command(Envgen ${CMAKE_COMMAND} ${source_dir}) + # Toolset is available since VS 2010. + if(RunCMake_GENERATOR MATCHES "Visual Studio [1-9][0-9]") + set(ENV{CMAKE_GENERATOR_TOOLSET} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-toolset-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + run_cmake_command(Envgen-toolset-invalid ${CMAKE_COMMAND} ${source_dir}) + # Command line -G implies -T"" + run_cmake_command(Envgen-G-implicit-toolset ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir}) + run_cmake_command(Envgen-T-toolset ${CMAKE_COMMAND} -T "fromcli" ${source_dir}) + unset(ENV{CMAKE_GENERATOR_TOOLSET}) + endif() + # Platform can be set only if not in generator name. + if(RunCMake_GENERATOR MATCHES "^Visual Studio [0-9]+ [0-9]+$") + set(ENV{CMAKE_GENERATOR_PLATFORM} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-platform-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") + set(RunCMake-stderr-file "Envgen-platform-invalid-stderr-vs9.txt") + endif() + run_cmake_command(Envgen-platform-invalid ${CMAKE_COMMAND} ${source_dir}) + unset(RunCMake-stderr-file) + # Command line -G implies -A"" + run_cmake_command(Envgen-G-implicit-platform ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir}) + if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") + set(RunCMake-stderr-file "Envgen-A-platform-stderr-vs9.txt") + endif() + run_cmake_command(Envgen-A-platform ${CMAKE_COMMAND} -A "fromcli" ${source_dir}) + unset(RunCMake-stderr-file) + unset(ENV{CMAKE_GENERATOR_PLATFORM}) + endif() + # Instance is available since VS 2017. + if(RunCMake_GENERATOR MATCHES "Visual Studio (15|16).*") + set(ENV{CMAKE_GENERATOR_INSTANCE} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-instance-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + run_cmake_command(Envgen-instance-invalid ${CMAKE_COMMAND} ${source_dir}) + unset(ENV{CMAKE_GENERATOR_INSTANCE}) + endif() + unset(ENV{CMAKE_GENERATOR}) + endif() +endfunction() +run_EnvironmentGenerator() + if(RunCMake_GENERATOR STREQUAL "Ninja") # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build) @@ -238,10 +334,16 @@ file(MAKE_DIRECTORY ${out}) file(WRITE ${outfile} "") run_cmake_command(E_make_directory-three-directories ${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${out}/d2) +run_cmake_command(E_remove_directory-three-directories + ${CMAKE_COMMAND} -E remove_directory ${out}/d1 ${out}/d2 ${out}/d2) run_cmake_command(E_make_directory-directory-with-parent ${CMAKE_COMMAND} -E make_directory ${out}/parent/child) -run_cmake_command(E_make_directory-three-directories-and-file +run_cmake_command(E_remove_directory-directory-with-parent + ${CMAKE_COMMAND} -E remove_directory ${out}/parent) +run_cmake_command(E_make_directory-two-directories-and-file ${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${outfile}) +run_cmake_command(E_remove_directory-two-directories-and-file + ${CMAKE_COMMAND} -E remove_directory ${out}/d1 ${out}/d2 ${outfile}) unset(out) unset(outfile) @@ -425,4 +527,8 @@ function(reject_fifo) endfunction() if(CMAKE_HOST_UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "CYGWIN") reject_fifo() + run_cmake_command(closed_stdin sh -c "\"${CMAKE_COMMAND}\" --version <&-") + run_cmake_command(closed_stdout sh -c "\"${CMAKE_COMMAND}\" --version >&-") + run_cmake_command(closed_stderr sh -c "\"${CMAKE_COMMAND}\" --version 2>&-") + run_cmake_command(closed_stdall sh -c "\"${CMAKE_COMMAND}\" --version <&- >&- 2>&-") endif() diff --git a/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake b/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake new file mode 100644 index 0000000..fd4e67d --- /dev/null +++ b/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake @@ -0,0 +1,15 @@ +if(CMAKE_INSTALL_PREFIX) + message("CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}") +endif() + +if(CMAKE_INSTALL_COMPONENT) + message("CMAKE_INSTALL_COMPONENT is ${CMAKE_INSTALL_COMPONENT}") +endif() + +if(CMAKE_INSTALL_CONFIG_NAME) + message("CMAKE_INSTALL_CONFIG_NAME is ${CMAKE_INSTALL_CONFIG_NAME}") +endif() + +if(CMAKE_INSTALL_DO_STRIP) + message("CMAKE_INSTALL_DO_STRIP is ${CMAKE_INSTALL_DO_STRIP}") +endif() diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-result.txt b/Tests/RunCMake/CommandLine/install-bad-dir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-bad-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt new file mode 100644 index 0000000..320aecc --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Error processing file: diff --git a/Tests/RunCMake/CommandLine/install-no-dir-result.txt b/Tests/RunCMake/CommandLine/install-no-dir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-no-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt new file mode 100644 index 0000000..d64f638 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt @@ -0,0 +1 @@ +^Usage: cmake --install <dir> \[options\] diff --git a/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt b/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt b/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt new file mode 100644 index 0000000..f7b1583 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt @@ -0,0 +1,4 @@ +CMAKE_INSTALL_PREFIX is /var/test +CMAKE_INSTALL_COMPONENT is pack +CMAKE_INSTALL_CONFIG_NAME is sample +CMAKE_INSTALL_DO_STRIP is 1 diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake index 12635db..a64af95 100644 --- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake @@ -4,25 +4,33 @@ function(external_command_test NAME) run_cmake_command(${NAME} ${CMAKE_COMMAND} -E ${ARGN}) endfunction() -external_command_test(bad-opt1 tar cvf bad.tar --bad) -external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .) -external_command_test(bad-from1 tar cvf bad.tar --files-from=bad) -external_command_test(bad-from2 tar cvf bad.tar --files-from=.) -external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt) -external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt) -external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt) -external_command_test(end-opt1 tar cvf bad.tar -- --bad) -external_command_test(end-opt2 tar cvf bad.tar --) -external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC") -external_command_test(bad-format tar cvf bad.tar "--format=bad-format") -external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip") -external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip") +external_command_test(without-files tar cvf bad.tar) +external_command_test(bad-opt1 tar cvf bad.tar --bad) +external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .) +external_command_test(bad-from1 tar cvf bad.tar --files-from=bad) +external_command_test(bad-from2 tar cvf bad.tar --files-from=.) +external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt) +external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt) +external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt) +external_command_test(bad-file tar cf bad.tar badfile.txt ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(bad-without-action tar f bad.tar ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(bad-wrong-flag tar cvfq bad.tar ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(end-opt1 tar cvf bad.tar -- --bad) +external_command_test(end-opt2 tar cvf bad.tar --) +external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(bad-format tar cvf bad.tar "--format=bad-format" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) run_cmake(7zip) run_cmake(gnutar) run_cmake(gnutar-gz) run_cmake(pax) run_cmake(pax-xz) +run_cmake(pax-zstd) run_cmake(paxr) run_cmake(paxr-bz2) run_cmake(zip) + +# Extracting only selected files or directories +run_cmake(zip-filtered) diff --git a/Tests/RunCMake/CommandLineTar/bad-file-result.txt b/Tests/RunCMake/CommandLineTar/bad-file-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/bad-file-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt new file mode 100644 index 0000000..1f9f748 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Unable to read from file 'badfile.txt': .* +CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt index 1417d4d..fb0702a 100644 --- a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt @@ -1,2 +1,2 @@ -^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.* +^CMake Error: Unable to read from file 'does-not-exist':.* CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt index 1417d4d..fb0702a 100644 --- a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt @@ -1,2 +1,2 @@ -^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.* +^CMake Error: Unable to read from file 'does-not-exist':.* CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLineTar/bad-without-action-result.txt b/Tests/RunCMake/CommandLineTar/bad-without-action-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/bad-without-action-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLineTar/bad-without-action-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-without-action-stderr.txt new file mode 100644 index 0000000..2fec254 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/bad-without-action-stderr.txt @@ -0,0 +1 @@ +^CMake Error: tar: No action specified. Please choose: 't' \(list\), 'c' \(create\) or 'x' \(extract\)$ diff --git a/Tests/RunCMake/CommandLineTar/bad-wrong-flag-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-wrong-flag-stderr.txt new file mode 100644 index 0000000..d5c1e01 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/bad-wrong-flag-stderr.txt @@ -0,0 +1 @@ +^tar: Unknown argument: q diff --git a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt index 1fddf6d..1342dc8 100644 --- a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt @@ -1,2 +1,2 @@ -^CMake Error: archive_read_disk_entry_from_file '--bad':.* +^CMake Error: Unable to read from file '--bad':.* CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt new file mode 100644 index 0000000..70166f5 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt @@ -0,0 +1 @@ +^tar: No files or directories specified diff --git a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake index 5f2674a..53ee961 100644 --- a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake +++ b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake @@ -1,9 +1,9 @@ set(OUTPUT_NAME "test.tar.gz") -set(COMPRESSION_FLAGS cvzf) +set(COMPRESSION_FLAGS -cvzf) set(COMPRESSION_OPTIONS --format=gnutar) -set(DECOMPRESSION_FLAGS xvzf) +set(DECOMPRESSION_FLAGS -xvzf) include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) diff --git a/Tests/RunCMake/CommandLineTar/pax-zstd.cmake b/Tests/RunCMake/CommandLineTar/pax-zstd.cmake new file mode 100644 index 0000000..c2a304d --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/pax-zstd.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.zstd") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=pax --zstd) + +set(DECOMPRESSION_FLAGS xvf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("28b52ffd0058" LIMIT 6 HEX) diff --git a/Tests/RunCMake/CommandLineTar/pax.cmake b/Tests/RunCMake/CommandLineTar/pax.cmake index 60ed238..77f74d1 100644 --- a/Tests/RunCMake/CommandLineTar/pax.cmake +++ b/Tests/RunCMake/CommandLineTar/pax.cmake @@ -1,9 +1,9 @@ set(OUTPUT_NAME "test.tar") -set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_FLAGS -cvf) set(COMPRESSION_OPTIONS --format=pax) -set(DECOMPRESSION_FLAGS xvf) +set(DECOMPRESSION_FLAGS -xvf) include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) diff --git a/Tests/RunCMake/CommandLineTar/roundtrip.cmake b/Tests/RunCMake/CommandLineTar/roundtrip.cmake index dc1c885..fa63d12 100644 --- a/Tests/RunCMake/CommandLineTar/roundtrip.cmake +++ b/Tests/RunCMake/CommandLineTar/roundtrip.cmake @@ -47,7 +47,11 @@ file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR}) file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR}) run_tar(${CMAKE_CURRENT_BINARY_DIR} ${COMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${COMPRESSION_OPTIONS} ${COMPRESS_DIR}) -run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS}) +run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS} -- ${DECOMPRESSION_PATHNAMES}) + +if(CUSTOM_CHECK_FILES) + set(CHECK_FILES ${CUSTOM_CHECK_FILES}) +endif() foreach(file ${CHECK_FILES}) set(input ${FULL_COMPRESS_DIR}/${file}) @@ -69,6 +73,14 @@ foreach(file ${CHECK_FILES}) endif() endforeach() +foreach(file ${NOT_EXISTING_FILES_CHECK}) + set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) + + if(EXISTS ${output}) + message(SEND_ERROR "File ${output} exists but it shouldn't") + endif() +endforeach() + function(check_magic EXPECTED) file(READ ${FULL_OUTPUT_NAME} ACTUAL ${ARGN} diff --git a/Tests/RunCMake/CommandLineTar/test-file.txt b/Tests/RunCMake/CommandLineTar/test-file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/test-file.txt diff --git a/Tests/RunCMake/CommandLineTar/without-files-stderr.txt b/Tests/RunCMake/CommandLineTar/without-files-stderr.txt new file mode 100644 index 0000000..70166f5 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/without-files-stderr.txt @@ -0,0 +1 @@ +^tar: No files or directories specified diff --git a/Tests/RunCMake/CommandLineTar/zip-filtered.cmake b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake new file mode 100644 index 0000000..c13210e --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake @@ -0,0 +1,28 @@ +set(OUTPUT_NAME "test.zip") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=zip) + +set(DECOMPRESSION_FLAGS xvf) +set(LIST_ARCHIVE TRUE) +set(DECOMPRESSION_PATHNAMES + compress_dir/f1.txt # Decompress only file + compress_dir/d1 # and whole directory +) + +set(CUSTOM_CHECK_FILES + "f1.txt" + "d1/f1.txt" +) + +# This files shouldn't exists +set(NOT_EXISTING_FILES_CHECK + "d 2/f1.txt" + "d + 3/f1.txt" + "d_4/f1.txt" + "d-4/f1.txt" +) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("504b0304" LIMIT 4 HEX) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake index c4db11b..9fcc5bc 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake @@ -26,12 +26,14 @@ add_custom_command(OUTPUT output2 # DoesNotUseEmulator: The command will fail if emulator is prepended add_custom_command(OUTPUT output3 + COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected COMMAND $<TARGET_FILE:generated_exe_emulator_unexpected> COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3 DEPENDS generated_exe_emulator_unexpected) # DoesNotUseEmulator: The command will fail if emulator is prepended add_custom_command(OUTPUT outputImp + COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected_imported COMMAND generated_exe_emulator_unexpected_imported COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp ) @@ -39,6 +41,7 @@ add_custom_command(OUTPUT outputImp # UsesEmulator: The command only succeeds if the emulator is prepended # to the command. add_custom_command(OUTPUT output4 + COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_expected COMMAND generated_exe_emulator_expected COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4 DEPENDS generated_exe_emulator_expected) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg-build-check.cmake new file mode 100644 index 0000000..9ca6106 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg-build-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/output") + message(FATAL_ERROR "Failed to create output: ${RunCMake_TEST_BINARY_DIR}/output") +endif() diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg.cmake new file mode 100644 index 0000000..d9059ca --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg.cmake @@ -0,0 +1,14 @@ +set(CMAKE_CROSSCOMPILING 1) + +# Executable: Return error code different from 0 +add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx) + +add_custom_command(OUTPUT output + COMMAND generated_exe_emulator_expected + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output + DEPENDS generated_exe_emulator_expected) + +add_custom_target(ensure_build ALL + SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/output +) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg-build-check.cmake new file mode 100644 index 0000000..13c0db9 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg-build-check.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/AddCustomCommandWithArg-build-check.cmake) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg.cmake new file mode 100644 index 0000000..dcd80d5 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg.cmake @@ -0,0 +1,9 @@ +set(CMAKE_CROSSCOMPILING 1) + +# Executable: Return error code different from 0 +add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx) + +add_custom_target(generate_output ALL + generated_exe_emulator_expected + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output + DEPENDS generated_exe_emulator_expected) diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake index 71aaad1..97b7b5a 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake @@ -11,13 +11,18 @@ function(CustomCommandGenerator_run_and_build case) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS - "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(${case}) run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .) endfunction() +set(RunCMake_TEST_OPTIONS +"-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}") CustomCommandGenerator_run_and_build(AddCustomCommand) CustomCommandGenerator_run_and_build(AddCustomTarget) + +set(RunCMake_TEST_OPTIONS +"-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND_ARG}\;custom_argument") +CustomCommandGenerator_run_and_build(AddCustomCommandWithArg) +CustomCommandGenerator_run_and_build(AddCustomTargetWithArg) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 18b9347..3096358 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -2087,7 +2087,40 @@ def gen_check_targets(c, g, inSource): ], "build": "^cxx$", "source": "^cxx$", - "install": None, + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "bin", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 37, + "command": "install", + "hasParent": True, + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": None, + "command": None, + "hasParent": True, + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": True, + }, + { + "file": "^CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], + }, + ], + }, "link": { "language": "CXX", "lto": None, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index 72073d5..c98a84c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -33,3 +33,5 @@ if(_ipo) set_property(TARGET c_static_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION ON) file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "") endif() + +install(TARGETS cxx_exe) diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt index b08ef5a..4c2e35f 100644 --- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt @@ -3,6 +3,7 @@ CMake Error at OutputNameMatchesObjects.cmake:[0-9]+ \(file\): \$<TARGET_OBJECTS:foo> - Objects of target "foo" referenced but is not an OBJECT library. + Objects of target "foo" referenced but is not an allowed library types + \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\). Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake index daa7c49..84825fe 100644 --- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake @@ -1,11 +1,8 @@ enable_language(CXX) file(GENERATE - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<BOOL:$<TARGET_OBJECTS:foo>>somefile.cpp" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>/somefile.cpp" CONTENT "static const char content[] = \"$<TARGET_OBJECTS:foo>\";\n" ) -add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/input.txt" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" "${CMAKE_CURRENT_BINARY_DIR}") - -add_executable(foo empty.cpp "${CMAKE_CURRENT_BINARY_DIR}/1somefile.cpp" "${CMAKE_CURRENT_BINARY_DIR}/input.txt") +add_library(foo INTERFACE ) diff --git a/Tests/RunCMake/FindBoost/CMP0093-NEW-stdout.txt b/Tests/RunCMake/FindBoost/CMP0093-NEW-stdout.txt new file mode 100644 index 0000000..62a6d39 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMP0093-NEW-stdout.txt @@ -0,0 +1 @@ +-- Boost_VERSION=1.70.0 diff --git a/Tests/RunCMake/FindBoost/CMP0093-NEW.cmake b/Tests/RunCMake/FindBoost/CMP0093-NEW.cmake new file mode 100644 index 0000000..64f44d2 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMP0093-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0093 NEW) +include(ModuleMode.cmake) diff --git a/Tests/RunCMake/FindBoost/CMP0093-OLD-stdout.txt b/Tests/RunCMake/FindBoost/CMP0093-OLD-stdout.txt new file mode 100644 index 0000000..9e51e35 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMP0093-OLD-stdout.txt @@ -0,0 +1 @@ +-- Boost_VERSION=107000 diff --git a/Tests/RunCMake/FindBoost/CMP0093-OLD.cmake b/Tests/RunCMake/FindBoost/CMP0093-OLD.cmake new file mode 100644 index 0000000..69a3a95 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMP0093-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0093 OLD) +include(ModuleMode.cmake) diff --git a/Tests/RunCMake/FindBoost/CMP0093-UNSET-stdout.txt b/Tests/RunCMake/FindBoost/CMP0093-UNSET-stdout.txt new file mode 100644 index 0000000..9e51e35 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMP0093-UNSET-stdout.txt @@ -0,0 +1 @@ +-- Boost_VERSION=107000 diff --git a/Tests/RunCMake/FindBoost/CMP0093-UNSET.cmake b/Tests/RunCMake/FindBoost/CMP0093-UNSET.cmake new file mode 100644 index 0000000..974094a --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMP0093-UNSET.cmake @@ -0,0 +1 @@ +include(ModuleMode.cmake) diff --git a/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt index 664e4a5..0a67488 100644 --- a/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt +++ b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt @@ -1,3 +1,2 @@ --- Boost 1\.12345 found\. --- Found Boost components: - date_time +-- Found Boost: [^ +]* \(found suitable version "1\.12345", minimum required is "1\.12345"\) found components: date_time diff --git a/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake index e69de29..36a9abd 100644 --- a/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake +++ b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake @@ -0,0 +1,4 @@ +set(Boost_DATE_TIME_FOUND 1) +add_library(Boost::boost INTERFACE IMPORTED) +add_library(Boost::headers INTERFACE IMPORTED) +add_library(Boost::date_time UNKNOWN IMPORTED) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake new file mode 100644 index 0000000..539267d --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake @@ -0,0 +1,140 @@ +# Copyright 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +# This CMake configuration file, installed as part of the Boost build +# and installation procedure done by `b2 install`, provides support +# for find_package(Boost). +# +# It's roughly, but not perfectly, compatible with the behavior +# of find_package(Boost) as provided by FindBoost.cmake. +# +# A typical use might be +# +# find_package(Boost 1.70 REQUIRED COMPONENTS filesystem regex PATHS C:/Boost) +# +# On success, the above invocation would define the targets Boost::headers, +# Boost::filesystem and Boost::regex. Boost::headers represents all +# header-only libraries. An alias, Boost::boost, for Boost::headers is +# provided for compatibility. +# +# Since Boost libraries can coexist in many variants - 32/64 bit, +# static/dynamic runtime, debug/release, the following variables can be used +# to control which variant is chosen: +# +# Boost_USE_DEBUG_LIBS: When OFF, disables debug libraries. +# Boost_USE_RELEASE_LIBS: When OFF, disables release libraries. +# Boost_USE_STATIC_LIBS: When ON, uses static Boost libraries; when OFF, +# uses shared Boost libraries; when not set, the +# default is to use shared when BUILD_SHARED_LIBS is +# ON, static otherwise. +# Boost_USE_STATIC_RUNTIME: When ON, uses Boost libraries linked against the +# static runtime. The default is shared runtime. +# Boost_USE_DEBUG_RUNTIME: When ON, uses Boost libraries linked against the +# debug runtime. When OFF, against the release +# runtime. The default is to use either. +# Boost_COMPILER: The compiler that has been used to build Boost, +# such as vc141, gcc7, clang37. The default is +# determined from CMAKE_CXX_COMPILER_ID. + +message(STATUS "Found Boost ${Boost_VERSION} at ${Boost_DIR}") + +# Output requested configuration (f.ex. "REQUIRED COMPONENTS filesystem") + +if(Boost_FIND_QUIETLY) + set(_BOOST_CONFIG "${_BOOST_CONFIG} QUIET") +endif() + +if(Boost_FIND_REQUIRED) + set(_BOOST_CONFIG "${_BOOST_CONFIG} REQUIRED") +endif() + +foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS) + if(${Boost_FIND_REQUIRED_${__boost_comp}}) + list(APPEND _BOOST_COMPONENTS ${__boost_comp}) + else() + list(APPEND _BOOST_OPTIONAL_COMPONENTS ${__boost_comp}) + endif() +endforeach() + +if(_BOOST_COMPONENTS) + set(_BOOST_CONFIG "${_BOOST_CONFIG} COMPONENTS ${_BOOST_COMPONENTS}") +endif() + +if(_BOOST_OPTIONAL_COMPONENTS) + set(_BOOST_CONFIG "${_BOOST_CONFIG} OPTIONAL_COMPONENTS ${_BOOST_OPTIONAL_COMPONENTS}") +endif() + +if(_BOOST_CONFIG) + message(STATUS " Requested configuration:${_BOOST_CONFIG}") +endif() + +unset(_BOOST_CONFIG) +unset(_BOOST_COMPONENTS) +unset(_BOOST_OPTIONAL_COMPONENTS) + +# find_dependency doesn't forward arguments until 3.9, so we have to roll our own + +macro(boost_find_dependency dep req) + + set(_BOOST_QUIET) + if(Boost_FIND_QUIETLY) + set(_BOOST_QUIET QUIET) + endif() + + set(_BOOST_REQUIRED) + if(${req} AND Boost_FIND_REQUIRED) + set(_BOOST_REQUIRED REQUIRED) + endif() + + get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) + + if(Boost_DEBUG) + message(STATUS "BoostConfig: find_package(boost_${dep} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})") + endif() + find_package(boost_${dep} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR}) + + string(TOUPPER ${dep} _BOOST_DEP) + set(Boost_${_BOOST_DEP}_FOUND ${boost_${dep}_FOUND}) + + unset(_BOOST_REQUIRED) + unset(_BOOST_QUIET) + unset(_BOOST_CMAKEDIR) + unset(_BOOST_DEP) + +endmacro() + +# Find boost_headers + +boost_find_dependency(headers 1) + +if(NOT boost_headers_FOUND) + + set(Boost_FOUND 0) + set(Boost_NOT_FOUND_MESSAGE "A required dependency, boost_headers, has not been found.") + + return() + +endif() + +# Find components + +foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS) + + boost_find_dependency(${__boost_comp} ${Boost_FIND_REQUIRED_${__boost_comp}}) + +endforeach() + +# Compatibility targets + +if(NOT TARGET Boost::boost) + + add_library(Boost::boost INTERFACE IMPORTED) + set_property(TARGET Boost::boost APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::headers) + + # All Boost:: targets already disable autolink + add_library(Boost::diagnostic_definitions INTERFACE IMPORTED) + add_library(Boost::disable_autolinking INTERFACE IMPORTED) + add_library(Boost::dynamic_linking INTERFACE IMPORTED) + +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfigVersion.cmake new file mode 100644 index 0000000..114bba0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfigVersion.cmake @@ -0,0 +1,12 @@ +# Generated by Boost 1.70.0 + +set(PACKAGE_VERSION 1.70.0) + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/BoostDetectToolset-1.70.0.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/BoostDetectToolset-1.70.0.cmake new file mode 100644 index 0000000..2f1ac01 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/BoostDetectToolset-1.70.0.cmake @@ -0,0 +1 @@ +set(BOOST_DETECTED_TOOLSET "gcc7") diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config-version.cmake new file mode 100644 index 0000000..114bba0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config-version.cmake @@ -0,0 +1,12 @@ +# Generated by Boost 1.70.0 + +set(PACKAGE_VERSION 1.70.0) + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config.cmake new file mode 100644 index 0000000..5d798b5 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config.cmake @@ -0,0 +1,98 @@ +# Generated by Boost 1.70.0 + +if(TARGET Boost::chrono) + return() +endif() + +message(STATUS "Found boost_chrono ${boost_chrono_VERSION} at ${boost_chrono_DIR}") + +# Compute the include and library directories relative to this file. +get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) +get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE) +get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE) + +# Create imported target Boost::chrono +add_library(Boost::chrono UNKNOWN IMPORTED) + +set_target_properties(Boost::chrono PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}" + INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB" +) + +include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-1.70.0.cmake) + +if(Boost_DEBUG) + message(STATUS "Scanning ${CMAKE_CURRENT_LIST_DIR}/libboost_chrono-variant*.cmake") +endif() + +file(GLOB __boost_variants "${CMAKE_CURRENT_LIST_DIR}/libboost_chrono-variant*.cmake") + +macro(_BOOST_SKIPPED fname reason) + if(Boost_DEBUG) + message(STATUS " ... skipped ${fname} (${reason})") + endif() + list(APPEND __boost_skipped "${fname} (${reason})") +endmacro() + +foreach(f IN LISTS __boost_variants) + if(Boost_DEBUG) + message(STATUS " Including ${f}") + endif() + include(${f}) +endforeach() + +unset(_BOOST_LIBDIR) +unset(_BOOST_INCLUDEDIR) +unset(_BOOST_CMAKEDIR) + +get_target_property(__boost_configs Boost::chrono IMPORTED_CONFIGURATIONS) + +if(__boost_variants AND NOT __boost_configs) + message(STATUS "No suitable boost_chrono variant has been identified!") + if(NOT Boost_DEBUG) + foreach(s IN LISTS __boost_skipped) + message(STATUS " ${s}") + endforeach() + endif() + set(boost_chrono_FOUND 0) + set(boost_chrono_NOT_FOUND_MESSAGE "No suitable build variant has been found.") + unset(__boost_skipped) + unset(__boost_configs) + unset(__boost_variants) + unset(_BOOST_CHRONO_DEPS) + return() +endif() + +unset(__boost_skipped) +unset(__boost_configs) +unset(__boost_variants) + +if(_BOOST_CHRONO_DEPS) + list(REMOVE_DUPLICATES _BOOST_CHRONO_DEPS) + message(STATUS "Adding boost_chrono dependencies: ${_BOOST_CHRONO_DEPS}") +endif() + +foreach(dep_boost_chrono IN LISTS _BOOST_CHRONO_DEPS) + set(_BOOST_QUIET) + if(boost_chrono_FIND_QUIETLY) + set(_BOOST_QUIET QUIET) + endif() + set(_BOOST_REQUIRED) + if(boost_chrono_FIND_REQUIRED) + set(_BOOST_REQUIRED REQUIRED) + endif() + get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) + find_package(boost_${dep_boost_chrono} 1.70.0 EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR}) + set_property(TARGET Boost::chrono APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_boost_chrono}) + unset(_BOOST_QUIET) + unset(_BOOST_REQUIRED) + unset(_BOOST_CMAKEDIR) + if(NOT boost_${dep_boost_chrono}_FOUND) + set(boost_chrono_FOUND 0) + set(boost_chrono_NOT_FOUND_MESSAGE "A required dependency, boost_${dep_boost_chrono}, has not been found.") + unset(_BOOST_CHRONO_DEPS) + return() + endif() +endforeach() + +unset(_BOOST_CHRONO_DEPS) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-shared.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-shared.cmake new file mode 100644 index 0000000..7f07aed --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-shared.cmake @@ -0,0 +1,62 @@ +# Generated by Boost 1.70.0 + +# address-model=64 + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "64 bit, need 32") + return() +endif() + +# layout=system + +# toolset=gcc8 + +# link=shared + +if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND Boost_USE_STATIC_LIBS) + _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}") + return() +endif() + +if(NOT BUILD_SHARED_LIBS) + _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override") + return() +endif() + +# runtime-link=shared + +if(Boost_USE_STATIC_RUNTIME) + _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}") + return() +endif() + +# runtime-debugging=off + +if(Boost_USE_DEBUG_RUNTIME) + _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}") + return() +endif() + +# threading=multi + +# variant=release + +if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS) + _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}") + return() +endif() + +message(STATUS " libboost_chrono.so.1.70.0") + +# Target file name: libboost_chrono.so.1.70.0 +set_property(TARGET Boost::chrono APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Boost::chrono PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX + IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_chrono.so.1.70.0" + ) + +set_target_properties(Boost::chrono PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_CHRONO_DYN_LINK" + ) + +list(APPEND _BOOST_CHRONO_DEPS headers) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-static.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-static.cmake new file mode 100644 index 0000000..d7477b4 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-static.cmake @@ -0,0 +1,58 @@ +# Generated by Boost 1.70.0 + +# address-model=64 + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + _BOOST_SKIPPED("libboost_chrono.a" "64 bit, need 32") + return() +endif() + +# layout=system + +# toolset=gcc8 + +# link=static + +if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND NOT Boost_USE_STATIC_LIBS) + _BOOST_SKIPPED("libboost_chrono.a" "static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}") + return() +endif() + +if(BUILD_SHARED_LIBS) + _BOOST_SKIPPED("libboost_chrono.a" "static, BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}, set Boost_USE_STATIC_LIBS=ON to override") + return() +endif() + +# runtime-link=shared + +if(Boost_USE_STATIC_RUNTIME) + _BOOST_SKIPPED("libboost_chrono.a" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}") + return() +endif() + +# runtime-debugging=off + +if(Boost_USE_DEBUG_RUNTIME) + _BOOST_SKIPPED("libboost_chrono.a" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}") + return() +endif() + +# threading=multi + +# variant=release + +if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS) + _BOOST_SKIPPED("libboost_chrono.a" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}") + return() +endif() + +message(STATUS " libboost_chrono.a") + +# Target file name: libboost_chrono.a +set_property(TARGET Boost::chrono APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Boost::chrono PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX + IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_chrono.a" + ) + +list(APPEND _BOOST_CHRONO_DEPS headers) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config-version.cmake new file mode 100644 index 0000000..114bba0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config-version.cmake @@ -0,0 +1,12 @@ +# Generated by Boost 1.70.0 + +set(PACKAGE_VERSION 1.70.0) + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config.cmake new file mode 100644 index 0000000..0305ecd --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config.cmake @@ -0,0 +1,20 @@ +# Generated by Boost 1.70.0 + +if(TARGET Boost::headers) + return() +endif() + +message(STATUS "Found boost_headers ${boost_headers_VERSION} at ${boost_headers_DIR}") + +# Compute the include and library directories relative to this file. +get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) +get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE) +get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE) + +# Create imported target Boost::headers +add_library(Boost::headers INTERFACE IMPORTED) + +set_target_properties(Boost::headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}" + INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB" +) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config-version.cmake new file mode 100644 index 0000000..114bba0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config-version.cmake @@ -0,0 +1,12 @@ +# Generated by Boost 1.70.0 + +set(PACKAGE_VERSION 1.70.0) + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config.cmake new file mode 100644 index 0000000..40b10d0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config.cmake @@ -0,0 +1,98 @@ +# Generated by Boost 1.70.0 + +if(TARGET Boost::system) + return() +endif() + +message(STATUS "Found boost_system ${boost_system_VERSION} at ${boost_system_DIR}") + +# Compute the include and library directories relative to this file. +get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) +get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE) +get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE) + +# Create imported target Boost::system +add_library(Boost::system UNKNOWN IMPORTED) + +set_target_properties(Boost::system PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}" + INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB" +) + +include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-1.70.0.cmake) + +if(Boost_DEBUG) + message(STATUS "Scanning ${CMAKE_CURRENT_LIST_DIR}/libboost_system-variant*.cmake") +endif() + +file(GLOB __boost_variants "${CMAKE_CURRENT_LIST_DIR}/libboost_system-variant*.cmake") + +macro(_BOOST_SKIPPED fname reason) + if(Boost_DEBUG) + message(STATUS " ... skipped ${fname} (${reason})") + endif() + list(APPEND __boost_skipped "${fname} (${reason})") +endmacro() + +foreach(f IN LISTS __boost_variants) + if(Boost_DEBUG) + message(STATUS " Including ${f}") + endif() + include(${f}) +endforeach() + +unset(_BOOST_LIBDIR) +unset(_BOOST_INCLUDEDIR) +unset(_BOOST_CMAKEDIR) + +get_target_property(__boost_configs Boost::system IMPORTED_CONFIGURATIONS) + +if(__boost_variants AND NOT __boost_configs) + message(STATUS "No suitable boost_system variant has been identified!") + if(NOT Boost_DEBUG) + foreach(s IN LISTS __boost_skipped) + message(STATUS " ${s}") + endforeach() + endif() + set(boost_system_FOUND 0) + set(boost_system_NOT_FOUND_MESSAGE "No suitable build variant has been found.") + unset(__boost_skipped) + unset(__boost_configs) + unset(__boost_variants) + unset(_BOOST_SYSTEM_DEPS) + return() +endif() + +unset(__boost_skipped) +unset(__boost_configs) +unset(__boost_variants) + +if(_BOOST_SYSTEM_DEPS) + list(REMOVE_DUPLICATES _BOOST_SYSTEM_DEPS) + message(STATUS "Adding boost_system dependencies: ${_BOOST_SYSTEM_DEPS}") +endif() + +foreach(dep_boost_system IN LISTS _BOOST_SYSTEM_DEPS) + set(_BOOST_QUIET) + if(boost_system_FIND_QUIETLY) + set(_BOOST_QUIET QUIET) + endif() + set(_BOOST_REQUIRED) + if(boost_system_FIND_REQUIRED) + set(_BOOST_REQUIRED REQUIRED) + endif() + get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) + find_package(boost_${dep_boost_system} 1.70.0 EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR}) + set_property(TARGET Boost::system APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_boost_system}) + unset(_BOOST_QUIET) + unset(_BOOST_REQUIRED) + unset(_BOOST_CMAKEDIR) + if(NOT boost_${dep_boost_system}_FOUND) + set(boost_system_FOUND 0) + set(boost_system_NOT_FOUND_MESSAGE "A required dependency, boost_${dep_boost_system}, has not been found.") + unset(_BOOST_SYSTEM_DEPS) + return() + endif() +endforeach() + +unset(_BOOST_SYSTEM_DEPS) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-shared.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-shared.cmake new file mode 100644 index 0000000..751db32 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-shared.cmake @@ -0,0 +1,62 @@ +# Generated by Boost 1.70.0 + +# address-model=64 + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + _BOOST_SKIPPED("libboost_system.so.1.70.0" "64 bit, need 32") + return() +endif() + +# layout=system + +# toolset=gcc8 + +# link=shared + +if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND Boost_USE_STATIC_LIBS) + _BOOST_SKIPPED("libboost_system.so.1.70.0" "shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}") + return() +endif() + +if(NOT BUILD_SHARED_LIBS) + _BOOST_SKIPPED("libboost_system.so.1.70.0" "shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override") + return() +endif() + +# runtime-link=shared + +if(Boost_USE_STATIC_RUNTIME) + _BOOST_SKIPPED("libboost_system.so.1.70.0" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}") + return() +endif() + +# runtime-debugging=off + +if(Boost_USE_DEBUG_RUNTIME) + _BOOST_SKIPPED("libboost_system.so.1.70.0" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}") + return() +endif() + +# threading=multi + +# variant=release + +if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS) + _BOOST_SKIPPED("libboost_system.so.1.70.0" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}") + return() +endif() + +message(STATUS " libboost_system.so.1.70.0") + +# Target file name: libboost_system.so.1.70.0 +set_property(TARGET Boost::system APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Boost::system PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX + IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_system.so.1.70.0" + ) + +set_target_properties(Boost::system PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_SYSTEM_DYN_LINK" + ) + +list(APPEND _BOOST_SYSTEM_DEPS headers) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-static.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-static.cmake new file mode 100644 index 0000000..b10e0b9 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-static.cmake @@ -0,0 +1,58 @@ +# Generated by Boost 1.70.0 + +# address-model=64 + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + _BOOST_SKIPPED("libboost_system.a" "64 bit, need 32") + return() +endif() + +# layout=system + +# toolset=gcc8 + +# link=static + +if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND NOT Boost_USE_STATIC_LIBS) + _BOOST_SKIPPED("libboost_system.a" "static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}") + return() +endif() + +if(BUILD_SHARED_LIBS) + _BOOST_SKIPPED("libboost_system.a" "static, BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}, set Boost_USE_STATIC_LIBS=ON to override") + return() +endif() + +# runtime-link=shared + +if(Boost_USE_STATIC_RUNTIME) + _BOOST_SKIPPED("libboost_system.a" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}") + return() +endif() + +# runtime-debugging=off + +if(Boost_USE_DEBUG_RUNTIME) + _BOOST_SKIPPED("libboost_system.a" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}") + return() +endif() + +# threading=multi + +# variant=release + +if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS) + _BOOST_SKIPPED("libboost_system.a" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}") + return() +endif() + +message(STATUS " libboost_system.a") + +# Target file name: libboost_system.a +set_property(TARGET Boost::system APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Boost::system PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX + IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_system.a" + ) + +list(APPEND _BOOST_SYSTEM_DEPS headers) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config-version.cmake new file mode 100644 index 0000000..114bba0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config-version.cmake @@ -0,0 +1,12 @@ +# Generated by Boost 1.70.0 + +set(PACKAGE_VERSION 1.70.0) + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config.cmake new file mode 100644 index 0000000..b0d0e54 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config.cmake @@ -0,0 +1,98 @@ +# Generated by Boost 1.70.0 + +if(TARGET Boost::timer) + return() +endif() + +message(STATUS "Found boost_timer ${boost_timer_VERSION} at ${boost_timer_DIR}") + +# Compute the include and library directories relative to this file. +get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) +get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE) +get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE) + +# Create imported target Boost::timer +add_library(Boost::timer UNKNOWN IMPORTED) + +set_target_properties(Boost::timer PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}" + INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB" +) + +include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-1.70.0.cmake) + +if(Boost_DEBUG) + message(STATUS "Scanning ${CMAKE_CURRENT_LIST_DIR}/libboost_timer-variant*.cmake") +endif() + +file(GLOB __boost_variants "${CMAKE_CURRENT_LIST_DIR}/libboost_timer-variant*.cmake") + +macro(_BOOST_SKIPPED fname reason) + if(Boost_DEBUG) + message(STATUS " ... skipped ${fname} (${reason})") + endif() + list(APPEND __boost_skipped "${fname} (${reason})") +endmacro() + +foreach(f IN LISTS __boost_variants) + if(Boost_DEBUG) + message(STATUS " Including ${f}") + endif() + include(${f}) +endforeach() + +unset(_BOOST_LIBDIR) +unset(_BOOST_INCLUDEDIR) +unset(_BOOST_CMAKEDIR) + +get_target_property(__boost_configs Boost::timer IMPORTED_CONFIGURATIONS) + +if(__boost_variants AND NOT __boost_configs) + message(STATUS "No suitable boost_timer variant has been identified!") + if(NOT Boost_DEBUG) + foreach(s IN LISTS __boost_skipped) + message(STATUS " ${s}") + endforeach() + endif() + set(boost_timer_FOUND 0) + set(boost_timer_NOT_FOUND_MESSAGE "No suitable build variant has been found.") + unset(__boost_skipped) + unset(__boost_configs) + unset(__boost_variants) + unset(_BOOST_TIMER_DEPS) + return() +endif() + +unset(__boost_skipped) +unset(__boost_configs) +unset(__boost_variants) + +if(_BOOST_TIMER_DEPS) + list(REMOVE_DUPLICATES _BOOST_TIMER_DEPS) + message(STATUS "Adding boost_timer dependencies: ${_BOOST_TIMER_DEPS}") +endif() + +foreach(dep_boost_timer IN LISTS _BOOST_TIMER_DEPS) + set(_BOOST_QUIET) + if(boost_timer_FIND_QUIETLY) + set(_BOOST_QUIET QUIET) + endif() + set(_BOOST_REQUIRED) + if(boost_timer_FIND_REQUIRED) + set(_BOOST_REQUIRED REQUIRED) + endif() + get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE) + find_package(boost_${dep_boost_timer} 1.70.0 EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR}) + set_property(TARGET Boost::timer APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_boost_timer}) + unset(_BOOST_QUIET) + unset(_BOOST_REQUIRED) + unset(_BOOST_CMAKEDIR) + if(NOT boost_${dep_boost_timer}_FOUND) + set(boost_timer_FOUND 0) + set(boost_timer_NOT_FOUND_MESSAGE "A required dependency, boost_${dep_boost_timer}, has not been found.") + unset(_BOOST_TIMER_DEPS) + return() + endif() +endforeach() + +unset(_BOOST_TIMER_DEPS) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-shared.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-shared.cmake new file mode 100644 index 0000000..b35b59d --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-shared.cmake @@ -0,0 +1,62 @@ +# Generated by Boost 1.70.0 + +# address-model=64 + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + _BOOST_SKIPPED("libboost_timer.so.1.70.0" "64 bit, need 32") + return() +endif() + +# layout=system + +# toolset=gcc8 + +# link=shared + +if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND Boost_USE_STATIC_LIBS) + _BOOST_SKIPPED("libboost_timer.so.1.70.0" "shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}") + return() +endif() + +if(NOT BUILD_SHARED_LIBS) + _BOOST_SKIPPED("libboost_timer.so.1.70.0" "shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override") + return() +endif() + +# runtime-link=shared + +if(Boost_USE_STATIC_RUNTIME) + _BOOST_SKIPPED("libboost_timer.so.1.70.0" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}") + return() +endif() + +# runtime-debugging=off + +if(Boost_USE_DEBUG_RUNTIME) + _BOOST_SKIPPED("libboost_timer.so.1.70.0" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}") + return() +endif() + +# threading=multi + +# variant=release + +if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS) + _BOOST_SKIPPED("libboost_timer.so.1.70.0" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}") + return() +endif() + +message(STATUS " libboost_timer.so.1.70.0") + +# Target file name: libboost_timer.so.1.70.0 +set_property(TARGET Boost::timer APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Boost::timer PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX + IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_timer.so.1.70.0" + ) + +set_target_properties(Boost::timer PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_TIMER_DYN_LINK" + ) + +list(APPEND _BOOST_TIMER_DEPS chrono headers) diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-static.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-static.cmake new file mode 100644 index 0000000..37fa9c0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-static.cmake @@ -0,0 +1,58 @@ +# Generated by Boost 1.70.0 + +# address-model=64 + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + _BOOST_SKIPPED("libboost_timer.a" "64 bit, need 32") + return() +endif() + +# layout=system + +# toolset=gcc8 + +# link=static + +if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND NOT Boost_USE_STATIC_LIBS) + _BOOST_SKIPPED("libboost_timer.a" "static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}") + return() +endif() + +if(BUILD_SHARED_LIBS) + _BOOST_SKIPPED("libboost_timer.a" "static, BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}, set Boost_USE_STATIC_LIBS=ON to override") + return() +endif() + +# runtime-link=shared + +if(Boost_USE_STATIC_RUNTIME) + _BOOST_SKIPPED("libboost_timer.a" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}") + return() +endif() + +# runtime-debugging=off + +if(Boost_USE_DEBUG_RUNTIME) + _BOOST_SKIPPED("libboost_timer.a" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}") + return() +endif() + +# threading=multi + +# variant=release + +if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS) + _BOOST_SKIPPED("libboost_timer.a" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}") + return() +endif() + +message(STATUS " libboost_timer.a") + +# Target file name: libboost_timer.a +set_property(TARGET Boost::timer APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Boost::timer PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX + IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_timer.a" + ) + +list(APPEND _BOOST_TIMER_DEPS chrono headers) diff --git a/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfig.cmake new file mode 100644 index 0000000..cf13b4a --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfig.cmake @@ -0,0 +1,26 @@ +# No boost::boost target and all targets start with lowercase letters +# Similar to https://github.com/boost-cmake/boost-cmake + +add_library(boost::headers INTERFACE IMPORTED) +target_include_directories(boost::headers INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include") + +set(Boost_date_time_FOUND 1) +add_library(boost::date_time UNKNOWN IMPORTED) +set_target_properties(boost::date_time PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a" + ) +set(Boost_python37_FOUND 1) +add_library(boost::python UNKNOWN IMPORTED) +set_target_properties(boost::python PROPERTIES + IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python_release.a" + IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python.a" + ) +set(Boost_mpi_python2_FOUND 1) +add_library(boost::mpi_python UNKNOWN IMPORTED) +set_target_properties(boost::mpi_python PROPERTIES + IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a" + IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a" + ) diff --git a/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfigVersion.cmake new file mode 100644 index 0000000..b4b6060 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfigVersion.cmake @@ -0,0 +1,7 @@ +set(PACKAGE_VERSION 1.70.42) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42) + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/include/boost/version.hpp new file mode 100644 index 0000000..fe8e72c --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/include/boost/version.hpp @@ -0,0 +1,34 @@ +// Boost version.hpp configuration header file +// ------------------------------// + +// (C) Copyright John maddock 1999. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for documentation + +#ifndef BOOST_VERSION_HPP +#define BOOST_VERSION_HPP + +// +// Caution: this is the only Boost header that is guaranteed +// to change with every Boost release. Including this header +// will cause a recompile every time a new Boost version is +// used. +// +// BOOST_VERSION % 100 is the patch level +// BOOST_VERSION / 100 % 1000 is the minor version +// BOOST_VERSION / 100000 is the major version + +#define BOOST_VERSION 1070042 + +// +// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION +// but as a *string* in the form "x_y[_z]" where x is the major version +// number, y is the minor version number, and z is the patch level if not 0. +// This is used by <config/auto_link.hpp> to select which library version to +// link to. + +#define BOOST_LIB_VERSION "1_70_42" + +#endif diff --git a/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfig.cmake new file mode 100644 index 0000000..97d4c79 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfig.cmake @@ -0,0 +1,7 @@ +# Don't have targets +set(Boost_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include") + +set(Boost_DATE_TIME_FOUND 1) +set(Boost_DATE_TIME_LIBRARY "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a") + +set(Boost_LIBRARIES ${Boost_DATE_TIME_LIBRARY}) diff --git a/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfigVersion.cmake new file mode 100644 index 0000000..b4b6060 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfigVersion.cmake @@ -0,0 +1,7 @@ +set(PACKAGE_VERSION 1.70.42) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42) + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include/boost/version.hpp new file mode 100644 index 0000000..fe8e72c --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include/boost/version.hpp @@ -0,0 +1,34 @@ +// Boost version.hpp configuration header file +// ------------------------------// + +// (C) Copyright John maddock 1999. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for documentation + +#ifndef BOOST_VERSION_HPP +#define BOOST_VERSION_HPP + +// +// Caution: this is the only Boost header that is guaranteed +// to change with every Boost release. Including this header +// will cause a recompile every time a new Boost version is +// used. +// +// BOOST_VERSION % 100 is the patch level +// BOOST_VERSION / 100 % 1000 is the minor version +// BOOST_VERSION / 100000 is the major version + +#define BOOST_VERSION 1070042 + +// +// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION +// but as a *string* in the form "x_y[_z]" where x is the major version +// number, y is the minor version number, and z is the patch level if not 0. +// This is used by <config/auto_link.hpp> to select which library version to +// link to. + +#define BOOST_LIB_VERSION "1_70_42" + +#endif diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfig.cmake new file mode 100644 index 0000000..1151514 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfig.cmake @@ -0,0 +1,29 @@ +add_library(Boost::boost INTERFACE IMPORTED) +add_library(Boost::headers INTERFACE IMPORTED) +target_include_directories(Boost::headers INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include") + +set(Boost_date_time_FOUND 1) +add_library(Boost::date_time UNKNOWN IMPORTED) +set_target_properties(Boost::date_time PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a" + ) + +set(Boost_python37_FOUND 1) +add_library(Boost::python UNKNOWN IMPORTED) +set_target_properties(Boost::python PROPERTIES + IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python_release.a" + IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python.a" + ) +# Versioned target alias for compatibility (added by upstream BoostConfig). +add_library(Boost::python37 INTERFACE IMPORTED) +set_property(TARGET Boost::python37 APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::python) + +set(Boost_mpi_python2_FOUND 1) +add_library(Boost::mpi_python UNKNOWN IMPORTED) +set_target_properties(Boost::mpi_python PROPERTIES + IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a" + IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a" + ) diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfigVersion.cmake new file mode 100644 index 0000000..b4b6060 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfigVersion.cmake @@ -0,0 +1,7 @@ +set(PACKAGE_VERSION 1.70.42) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42) + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_New/include/boost/version.hpp new file mode 100644 index 0000000..fe8e72c --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_New/include/boost/version.hpp @@ -0,0 +1,34 @@ +// Boost version.hpp configuration header file +// ------------------------------// + +// (C) Copyright John maddock 1999. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for documentation + +#ifndef BOOST_VERSION_HPP +#define BOOST_VERSION_HPP + +// +// Caution: this is the only Boost header that is guaranteed +// to change with every Boost release. Including this header +// will cause a recompile every time a new Boost version is +// used. +// +// BOOST_VERSION % 100 is the patch level +// BOOST_VERSION / 100 % 1000 is the minor version +// BOOST_VERSION / 100000 is the major version + +#define BOOST_VERSION 1070042 + +// +// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION +// but as a *string* in the form "x_y[_z]" where x is the major version +// number, y is the minor version number, and z is the patch level if not 0. +// This is used by <config/auto_link.hpp> to select which library version to +// link to. + +#define BOOST_LIB_VERSION "1_70_42" + +#endif diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_date_time.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_date_time.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_date_time.a diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_mpi_python.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_mpi_python.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_mpi_python.a diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python.a diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python_release.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python_release.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python_release.a diff --git a/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfig.cmake new file mode 100644 index 0000000..ba2269a --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfig.cmake @@ -0,0 +1,25 @@ +# UPPER_CASE FOUND vars and no header targets + +set(Boost_DATE_TIME_FOUND 1) +add_library(Boost::date_time UNKNOWN IMPORTED) +set_target_properties(Boost::date_time PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/include" + ) +set(Boost_PYTHON37_FOUND 1) +add_library(Boost::python UNKNOWN IMPORTED) +set_target_properties(Boost::python PROPERTIES + IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python_release.a" + IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python.a" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/include" + ) +set(Boost_MPI_PYTHON2_FOUND 1) +add_library(Boost::mpi_python UNKNOWN IMPORTED) +set_target_properties(Boost::mpi_python PROPERTIES + IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" + IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a" + IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/include" + ) diff --git a/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfigVersion.cmake new file mode 100644 index 0000000..b4b6060 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfigVersion.cmake @@ -0,0 +1,7 @@ +set(PACKAGE_VERSION 1.70.42) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42) + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() diff --git a/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/include/boost/version.hpp new file mode 100644 index 0000000..fe8e72c --- /dev/null +++ b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/include/boost/version.hpp @@ -0,0 +1,34 @@ +// Boost version.hpp configuration header file +// ------------------------------// + +// (C) Copyright John maddock 1999. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for documentation + +#ifndef BOOST_VERSION_HPP +#define BOOST_VERSION_HPP + +// +// Caution: this is the only Boost header that is guaranteed +// to change with every Boost release. Including this header +// will cause a recompile every time a new Boost version is +// used. +// +// BOOST_VERSION % 100 is the patch level +// BOOST_VERSION / 100 % 1000 is the minor version +// BOOST_VERSION / 100000 is the major version + +#define BOOST_VERSION 1070042 + +// +// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION +// but as a *string* in the form "x_y[_z]" where x is the major version +// number, y is the minor version number, and z is the patch level if not 0. +// This is used by <config/auto_link.hpp> to select which library version to +// link to. + +#define BOOST_LIB_VERSION "1_70_42" + +#endif diff --git a/Tests/RunCMake/FindBoost/CommonNotFound-stderr.txt b/Tests/RunCMake/FindBoost/CommonNotFound-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/FindBoost/CommonNotFound-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/FindBoost/CommonNotFound-stdout.txt b/Tests/RunCMake/FindBoost/CommonNotFound-stdout.txt new file mode 100644 index 0000000..644469e --- /dev/null +++ b/Tests/RunCMake/FindBoost/CommonNotFound-stdout.txt @@ -0,0 +1 @@ +-- Could NOT find Boost diff --git a/Tests/RunCMake/FindBoost/CommonNotFound.cmake b/Tests/RunCMake/FindBoost/CommonNotFound.cmake new file mode 100644 index 0000000..864a549 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CommonNotFound.cmake @@ -0,0 +1,2 @@ +# Make sure to use the module mode signature here to not bypass FindBoost +find_package(Boost 1.80 COMPONENTS timer foobar) diff --git a/Tests/RunCMake/FindBoost/CommonResults-stdout.txt b/Tests/RunCMake/FindBoost/CommonResults-stdout.txt new file mode 100644 index 0000000..a560843 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CommonResults-stdout.txt @@ -0,0 +1,13 @@ +-- Found Boost: [^ +]* \(found suitable version "1\.70\.0", minimum required is "1\.60"\) found components: .*timer.* +-- Boost_FOUND +-- Boost_VERSION=(107000|1\.70\.0) +-- Boost_VERSION_MAJOR=1 +-- Boost_VERSION_MINOR=70 +-- Boost_VERSION_PATCH=0 +-- Boost_VERSION_COUNT=3 +-- Boost::headers +-- Boost::boost +-- Boost::chrono +-- Boost::timer +(-- Boost::system)? diff --git a/Tests/RunCMake/FindBoost/CommonResults.cmake b/Tests/RunCMake/FindBoost/CommonResults.cmake new file mode 100644 index 0000000..6876800 --- /dev/null +++ b/Tests/RunCMake/FindBoost/CommonResults.cmake @@ -0,0 +1,25 @@ +# Make sure to use the module mode signature here to not bypass FindBoost +find_package(Boost 1.60 COMPONENTS timer MODULE) +if(Boost_FOUND) + message(STATUS "Boost_FOUND") +endif() +message(STATUS "Boost_VERSION=${Boost_VERSION}") +message(STATUS "Boost_VERSION_MAJOR=${Boost_VERSION_MAJOR}") +message(STATUS "Boost_VERSION_MINOR=${Boost_VERSION_MINOR}") +message(STATUS "Boost_VERSION_PATCH=${Boost_VERSION_PATCH}") +message(STATUS "Boost_VERSION_COUNT=${Boost_VERSION_COUNT}") +if(TARGET Boost::headers) + message(STATUS "Boost::headers") +endif() +if(TARGET Boost::boost) + message(STATUS "Boost::boost") +endif() +if(TARGET Boost::chrono) + message(STATUS "Boost::chrono") +endif() +if(TARGET Boost::timer) + message(STATUS "Boost::timer") +endif() +if(TARGET Boost::system) + message(STATUS "Boost::system") +endif() diff --git a/Tests/RunCMake/FindBoost/ConfigMode.cmake b/Tests/RunCMake/FindBoost/ConfigMode.cmake new file mode 100644 index 0000000..5600658 --- /dev/null +++ b/Tests/RunCMake/FindBoost/ConfigMode.cmake @@ -0,0 +1,2 @@ +set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackageFixtures/Boost-1.70.0) +include(${CMAKE_CURRENT_SOURCE_DIR}/CommonResults.cmake) diff --git a/Tests/RunCMake/FindBoost/ConfigModeNotFound.cmake b/Tests/RunCMake/FindBoost/ConfigModeNotFound.cmake new file mode 100644 index 0000000..7e90a3c --- /dev/null +++ b/Tests/RunCMake/FindBoost/ConfigModeNotFound.cmake @@ -0,0 +1,2 @@ +set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackageFixtures/Boost-1.70.0) +include(${CMAKE_CURRENT_SOURCE_DIR}/CommonNotFound.cmake) diff --git a/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt new file mode 100644 index 0000000..a781dce --- /dev/null +++ b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt @@ -0,0 +1,34 @@ +-- Found Boost: [^ +]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 * +-- Boost_FOUND: TRUE +-- Boost_INCLUDE_DIRS: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include +-- Boost_LIBRARY_DIRS: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib +-- Boost_LIBRARIES: boost::date_time;boost::python;boost::mpi_python +-- Boost_DATE_TIME_FOUND: 1 +-- Boost_DATE_TIME_LIBRARY: boost::date_time +-- Boost_PYTHON37_FOUND: 1 +-- Boost_PYTHON37_LIBRARY: boost::python +-- Boost_MPI_PYTHON2_FOUND: 1 +-- Boost_MPI_PYTHON2_LIBRARY: boost::mpi_python +-- Boost_VERSION_MACRO: 1070042 +-- Boost_VERSION_STRING: 1.70.42 +-- Boost_VERSION: 1.70.42 +-- Boost_LIB_VERSION: 1_70_42 +-- Boost_MAJOR_VERSION: 1 +-- Boost_MINOR_VERSION: 70 +-- Boost_SUBMINOR_VERSION: 42 +-- Boost_INCLUDE_DIR: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include +-- Boost_DATE_TIME_LIBRARY_DEBUG: * +-- Boost_DATE_TIME_LIBRARY_RELEASE: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_date_time.a +-- Boost_PYTHON37_LIBRARY_DEBUG: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python.a +-- Boost_PYTHON37_LIBRARY_RELEASE: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python_release.a +-- Boost_MPI_PYTHON2_LIBRARY_DEBUG: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a +-- Boost_MPI_PYTHON2_LIBRARY_RELEASE: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a diff --git a/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix.cmake b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix.cmake new file mode 100644 index 0000000..a398c2d --- /dev/null +++ b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix.cmake @@ -0,0 +1,6 @@ +# Use a (made up) modern style BoostConfig that defines all targets +# as boost::<component> with appropriate properties set +# No legacy variables defined in the BoostConfig +set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_LowerCaseTargetPrefix) + +include(${CMAKE_CURRENT_SOURCE_DIR}/LegacyVars.cmake) diff --git a/Tests/RunCMake/FindBoost/LegacyVars-NoHeaderTarget.cmake b/Tests/RunCMake/FindBoost/LegacyVars-NoHeaderTarget.cmake new file mode 100644 index 0000000..edb6dda --- /dev/null +++ b/Tests/RunCMake/FindBoost/LegacyVars-NoHeaderTarget.cmake @@ -0,0 +1,6 @@ +# Use a (made up?) BoostConfig that defines all targets +# as Boost::<component> with appropriate properties set +# But no Boost::headers or Boost::boost target is defined +set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_NoHeaderTarget) + +include(${CMAKE_CURRENT_SOURCE_DIR}/LegacyVars.cmake) diff --git a/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt new file mode 100644 index 0000000..a4e9c6a --- /dev/null +++ b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt @@ -0,0 +1,34 @@ +-- Found Boost: [^ +]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 * +-- Boost_FOUND: TRUE +-- Boost_INCLUDE_DIRS: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include +-- Boost_LIBRARY_DIRS: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib +-- Boost_LIBRARIES: Boost::date_time;Boost::python;Boost::mpi_python +-- Boost_DATE_TIME_FOUND: 1 +-- Boost_DATE_TIME_LIBRARY: Boost::date_time +-- Boost_PYTHON37_FOUND: 1 +-- Boost_PYTHON37_LIBRARY: Boost::python +-- Boost_MPI_PYTHON2_FOUND: 1 +-- Boost_MPI_PYTHON2_LIBRARY: Boost::mpi_python +-- Boost_VERSION_MACRO: 1070042 +-- Boost_VERSION_STRING: 1.70.42 +-- Boost_VERSION: 1.70.42 +-- Boost_LIB_VERSION: 1_70_42 +-- Boost_MAJOR_VERSION: 1 +-- Boost_MINOR_VERSION: 70 +-- Boost_SUBMINOR_VERSION: 42 +-- Boost_INCLUDE_DIR: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include +-- Boost_DATE_TIME_LIBRARY_DEBUG: * +-- Boost_DATE_TIME_LIBRARY_RELEASE: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_date_time.a +-- Boost_PYTHON37_LIBRARY_DEBUG: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python.a +-- Boost_PYTHON37_LIBRARY_RELEASE: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python_release.a +-- Boost_MPI_PYTHON2_LIBRARY_DEBUG: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a +-- Boost_MPI_PYTHON2_LIBRARY_RELEASE: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a diff --git a/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined.cmake b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined.cmake new file mode 100644 index 0000000..19ad49f --- /dev/null +++ b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined.cmake @@ -0,0 +1,6 @@ +# Use a modern style BoostConfig that defines all targets +# as Boost::<component> with appropriate properties set +# No legacy variables defined in the BoostConfig +set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_New) + +include(${CMAKE_CURRENT_SOURCE_DIR}/LegacyVars.cmake) diff --git a/Tests/RunCMake/FindBoost/LegacyVars.cmake b/Tests/RunCMake/FindBoost/LegacyVars.cmake new file mode 100644 index 0000000..d0d5ee0 --- /dev/null +++ b/Tests/RunCMake/FindBoost/LegacyVars.cmake @@ -0,0 +1,28 @@ +find_package(Boost 1.70 COMPONENTS date_time python37 mpi_python2) + +foreach(var Boost_FOUND Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS Boost_LIBRARIES + Boost_DATE_TIME_FOUND Boost_DATE_TIME_LIBRARY + Boost_PYTHON37_FOUND Boost_PYTHON37_LIBRARY + Boost_MPI_PYTHON2_FOUND Boost_MPI_PYTHON2_LIBRARY + Boost_VERSION_MACRO Boost_VERSION_STRING Boost_VERSION Boost_LIB_VERSION + Boost_MAJOR_VERSION Boost_MINOR_VERSION Boost_SUBMINOR_VERSION +) + message(STATUS "${var}: ${${var}}") +endforeach() + +foreach(cachevar Boost_INCLUDE_DIR + Boost_DATE_TIME_LIBRARY_DEBUG Boost_DATE_TIME_LIBRARY_RELEASE + Boost_PYTHON37_LIBRARY_DEBUG Boost_PYTHON37_LIBRARY_RELEASE + Boost_MPI_PYTHON2_LIBRARY_DEBUG Boost_MPI_PYTHON2_LIBRARY_RELEASE +) + unset(${cachevar}) + message(STATUS "${cachevar}: ${${cachevar}}") +endforeach() + +foreach(lib Boost::headers Boost::date_time Boost::python Boost::mpi_python + Boost::boost Boost::diagnostic_definitions Boost::disable_autolinking Boost::dynamic_linking +) + if(NOT TARGET ${lib}) + message(FATAL_ERROR "Missing target ${lib}") + endif() +endforeach() diff --git a/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt b/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt new file mode 100644 index 0000000..8e9d684 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt @@ -0,0 +1,22 @@ +-- Found Boost: [^ +]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time * +-- Boost_FOUND: TRUE +-- Boost_INCLUDE_DIRS: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include +-- Boost_LIBRARY_DIRS: * +-- Boost_LIBRARIES: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/lib/libboost_date_time.a +-- Boost_DATE_TIME_FOUND: 1 +-- Boost_DATE_TIME_LIBRARY: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/lib/libboost_date_time.a +-- Boost_VERSION_MACRO: 1070042 +-- Boost_VERSION_STRING: 1.70.42 +-- Boost_VERSION: 1.70.42 +-- Boost_LIB_VERSION: 1_70_42 +-- Boost_MAJOR_VERSION: 1 +-- Boost_MINOR_VERSION: 70 +-- Boost_SUBMINOR_VERSION: 42 +-- Boost_INCLUDE_DIR: [^ +]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include +-- Boost_DATE_TIME_LIBRARY_DEBUG: * +-- Boost_DATE_TIME_LIBRARY_RELEASE: * diff --git a/Tests/RunCMake/FindBoost/MissingTarget.cmake b/Tests/RunCMake/FindBoost/MissingTarget.cmake new file mode 100644 index 0000000..581e006 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MissingTarget.cmake @@ -0,0 +1,25 @@ +set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_MissingTarget) +find_package(Boost 1.70 COMPONENTS date_time) + +foreach(var Boost_FOUND Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS Boost_LIBRARIES + Boost_DATE_TIME_FOUND Boost_DATE_TIME_LIBRARY + Boost_VERSION_MACRO Boost_VERSION_STRING Boost_VERSION Boost_LIB_VERSION + Boost_MAJOR_VERSION Boost_MINOR_VERSION Boost_SUBMINOR_VERSION +) + message(STATUS "${var}: ${${var}}") +endforeach() + +foreach(cachevar Boost_INCLUDE_DIR + Boost_DATE_TIME_LIBRARY_DEBUG Boost_DATE_TIME_LIBRARY_RELEASE +) + unset(${cachevar}) + message(STATUS "${cachevar}: ${${cachevar}}") +endforeach() + +foreach(lib Boost::headers + Boost::boost Boost::diagnostic_definitions Boost::disable_autolinking Boost::dynamic_linking +) + if(NOT TARGET ${lib}) + message(FATAL_ERROR "Missing target ${lib}") + endif() +endforeach() diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/chrono.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/chrono.hpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/chrono.hpp diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/config.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/config.hpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/config.hpp diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/system/config.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/system/config.hpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/system/config.hpp diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/timer.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/timer.hpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/timer.hpp diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/version.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/version.hpp new file mode 100644 index 0000000..3ca02b3 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/version.hpp @@ -0,0 +1,34 @@ +// Boost version.hpp configuration header file +// ------------------------------// + +// (C) Copyright John maddock 1999. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for documentation + +#ifndef BOOST_VERSION_HPP +#define BOOST_VERSION_HPP + +// +// Caution: this is the only Boost header that is guaranteed +// to change with every Boost release. Including this header +// will cause a recompile every time a new Boost version is +// used. +// +// BOOST_VERSION % 100 is the patch level +// BOOST_VERSION / 100 % 1000 is the minor version +// BOOST_VERSION / 100000 is the major version + +#define BOOST_VERSION 107000 + +// +// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION +// but as a *string* in the form "x_y[_z]" where x is the major version +// number, y is the minor version number, and z is the patch level if not 0. +// This is used by <config/auto_link.hpp> to select which library version to +// link to. + +#define BOOST_LIB_VERSION "1_70" + +#endif diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_chrono-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_chrono-mt-1_70.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_chrono-mt-1_70.lib diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_system-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_system-mt-1_70.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_system-mt-1_70.lib diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_timer-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_timer-mt-1_70.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_timer-mt-1_70.lib diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono-mt-1_70.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono-mt-1_70.lib diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.a b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.a diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.so.1.70.0 b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.so.1.70.0 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.so.1.70.0 diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system-mt-1_70.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system-mt-1_70.lib diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.a b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.a diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.so.1.70.0 b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.so.1.70.0 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.so.1.70.0 diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer-mt-1_70.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer-mt-1_70.lib diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.a b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.a diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.so.1.70.0 b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.so.1.70.0 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.so.1.70.0 diff --git a/Tests/RunCMake/FindBoost/ModuleMode.cmake b/Tests/RunCMake/FindBoost/ModuleMode.cmake new file mode 100644 index 0000000..823fc53 --- /dev/null +++ b/Tests/RunCMake/FindBoost/ModuleMode.cmake @@ -0,0 +1,4 @@ +set(BOOST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/MockInstalls/1.70.0) +set(Boost_NO_BOOST_CMAKE ON) +set(Boost_NO_SYSTEM_PATHS ON) +include(${CMAKE_CURRENT_SOURCE_DIR}/CommonResults.cmake) diff --git a/Tests/RunCMake/FindBoost/ModuleModeNotFound.cmake b/Tests/RunCMake/FindBoost/ModuleModeNotFound.cmake new file mode 100644 index 0000000..aaffbf2 --- /dev/null +++ b/Tests/RunCMake/FindBoost/ModuleModeNotFound.cmake @@ -0,0 +1,4 @@ +set(BOOST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/MockInstalls/1.70.0) +set(Boost_NO_BOOST_CMAKE ON) +set(Boost_NO_SYSTEM_PATHS ON) +include(${CMAKE_CURRENT_SOURCE_DIR}/CommonNotFound.cmake) diff --git a/Tests/RunCMake/FindBoost/RunCMakeTest.cmake b/Tests/RunCMake/FindBoost/RunCMakeTest.cmake index eef350c..851a996 100644 --- a/Tests/RunCMake/FindBoost/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindBoost/RunCMakeTest.cmake @@ -3,3 +3,26 @@ unset(ENV{Boost_ROOT}) run_cmake(CMakePackage) run_cmake(NoCXX) + +run_cmake(LegacyVars-TargetsDefined) # "Good" BoostConfig +run_cmake(LegacyVars-LowercaseTargetPrefix) +set(RunCMake-stdout-file LegacyVars-TargetsDefined-stdout.txt) +run_cmake(LegacyVars-NoHeaderTarget) + +unset(RunCMake-stdout-file) +run_cmake(MissingTarget) + +set(RunCMake-stdout-file CommonResults-stdout.txt) +run_cmake(ConfigMode) +run_cmake(ModuleMode) +unset(RunCMake-stdout-file) +set(RunCMake-stdout-file CommonNotFound-stdout.txt) +set(RunCMake-stderr-file CommonNotFound-stderr.txt) +run_cmake(ConfigModeNotFound) +run_cmake(ModuleModeNotFound) +unset(RunCMake-stdout-file) +unset(RunCMake-stderr-file) + +run_cmake(CMP0093-NEW) +run_cmake(CMP0093-OLD) +run_cmake(CMP0093-UNSET) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH.cmake new file mode 100644 index 0000000..f5f5c8c --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH.cmake @@ -0,0 +1,21 @@ +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE) +if(WIN32) + set(ENV{CMAKE_PREFIX_PATH} "C:\\baz") + set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch\\lib\\pkgconfig;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") +else() + set(ENV{CMAKE_PREFIX_PATH} "/baz") + set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch/lib/pkgconfig:/this/directory/should/not/exist/in/the/filesystem") +endif() + +find_package(PkgConfig REQUIRED) +pkg_check_modules(BLETCH QUIET bletch) + +if (NOT BLETCH_FOUND) + message(FATAL_ERROR "Failed to find embedded package bletch via PKG_CONFIG_PATH") +endif () + +pkg_get_variable(bletchvar bletch jackpot) +if (NOT bletchvar STREQUAL "bletch-lives") + message(FATAL_ERROR "Failed to fetch variable jackpot from embedded package bletch via PKG_CONFIG_PATH") +endif () diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PREFIX_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PREFIX_PATH.cmake new file mode 100644 index 0000000..cfc0760 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PREFIX_PATH.cmake @@ -0,0 +1,21 @@ +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +if(WIN32) + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + +find_package(PkgConfig REQUIRED) +pkg_check_modules(BLETCH QUIET bletch) + +if (NOT BLETCH_FOUND) + message(FATAL_ERROR "Failed to find embedded package bletch via CMAKE_PREFIX_PATH") +endif () + +pkg_get_variable(bletchvar bletch jackpot) +if (NOT bletchvar STREQUAL "bletch-lives") + message(FATAL_ERROR "Failed to fetch variable jackpot from embedded package bletch via CMAKE_PREFIX_PATH") +endif () diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index 24e7202..e82b05f 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -109,3 +109,24 @@ pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakep if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}") endif() + +set(pname fakelinkoptionspackage) +file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc +"Name: FakeLinkOptionsPackage +Description: Dummy package for FindPkgConfig IMPORTED_TARGET INTERFACE_LINK_OPTIONS test +Version: 1.2.3 +Libs: -e dummy_main +") + +set(expected_link_options -e dummy_main) +pkg_check_modules(FakeLinkOptionsPackage REQUIRED QUIET IMPORTED_TARGET fakelinkoptionspackage) +if (NOT TARGET PkgConfig::FakeLinkOptionsPackage) + message(FATAL_ERROR "No import target for fake link options package") +endif() +get_target_property(link_options PkgConfig::FakeLinkOptionsPackage INTERFACE_LINK_OPTIONS) +if (NOT link_options STREQUAL expected_link_options) + message(FATAL_ERROR + "Additional link options not present in INTERFACE_LINK_OPTIONS property" + "expected: \"${expected_link_options}\", but got \"${link_options}\"" + ) +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index 671ff51..414d9b6 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -14,6 +14,8 @@ endif() find_package(PkgConfig) if (PKG_CONFIG_FOUND) run_cmake(FindPkgConfig_GET_VARIABLE) + run_cmake(FindPkgConfig_GET_VARIABLE_PREFIX_PATH) + run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH) run_cmake(FindPkgConfig_cache_variables) run_cmake(FindPkgConfig_IMPORTED_TARGET) run_cmake(FindPkgConfig_VERSION_OPERATORS) diff --git a/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc new file mode 100644 index 0000000..04d2c1b --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc @@ -0,0 +1,12 @@ +prefix=/opt/bletch +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +jackpot=bletch-lives + +Name: Bletch +Description: Dummy packaget to test variable support +Version: 1.0 +Libs: -L${libdir} -lbletch +Cflags: -Dbletch_version=1 diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake index 4f42459..84012aa 100644 --- a/Tests/RunCMake/Framework/FrameworkLayout.cmake +++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake @@ -11,8 +11,11 @@ add_library(Framework ${FRAMEWORK_TYPE} flatresource.txt deepresource.txt some.txt) +if("${CMAKE_FRAMEWORK}" STREQUAL "") + set_target_properties(Framework PROPERTIES + FRAMEWORK TRUE) +endif() set_target_properties(Framework PROPERTIES - FRAMEWORK TRUE PUBLIC_HEADER foo.h RESOURCE "res.txt") set_source_files_properties(flatresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources) diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index e705a31..c7e1319 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -20,11 +20,14 @@ framework_layout_test(iOSFrameworkLayout-build ios STATIC) framework_layout_test(OSXFrameworkLayout-build osx SHARED) framework_layout_test(OSXFrameworkLayout-build osx STATIC) -function(framework_type_test Toolchain Type) +function(framework_type_test Toolchain Type UseProperty) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkType-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake") list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}") + if(NOT ${UseProperty}) + list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FRAMEWORK=YES") + endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -33,7 +36,12 @@ function(framework_type_test Toolchain Type) run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .) endfunction() -framework_type_test(ios SHARED) -framework_type_test(ios STATIC) -framework_type_test(osx SHARED) -framework_type_test(osx STATIC) +framework_type_test(ios SHARED NO) +framework_type_test(ios STATIC NO) +framework_type_test(osx SHARED NO) +framework_type_test(osx STATIC NO) + +framework_type_test(ios SHARED YES) +framework_type_test(ios STATIC YES) +framework_type_test(osx SHARED YES) +framework_type_test(osx STATIC YES) diff --git a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt index 0e48ba4..86d3e04 100644 --- a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt @@ -50,4 +50,6 @@ CMake Error at BadAND.cmake:1 \(add_custom_target\): Parameters to \$<AND> must resolve to either '0' or '1'. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt index 964ea4d..42dd0ce 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt @@ -32,4 +32,6 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): Expression syntax not recognized. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt index e5e628c..627327c 100644 --- a/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt @@ -49,4 +49,6 @@ CMake Error at BadNOT.cmake:1 \(add_custom_target\): \$<NOT> parameter must resolve to exactly one '0' or '1' value. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt index eb26328..56e6af0 100644 --- a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt @@ -50,4 +50,6 @@ CMake Error at BadOR.cmake:1 \(add_custom_target\): Parameters to \$<OR> must resolve to either '0' or '1'. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt index 8d3c4cc..a08e7b2 100644 --- a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt @@ -15,3 +15,12 @@ CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\): "Relative/Path" is not an absolute path. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) ++ +CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<SHELL_PATH:;> + + "" is not an absolute path. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake index 5eff7bc..0e7c342 100644 --- a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake @@ -1,4 +1,5 @@ add_custom_target(check ALL COMMAND check $<SHELL_PATH:> $<SHELL_PATH:Relative/Path> + "$<SHELL_PATH:;>" VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt index dd0d931..2f04c78 100644 --- a/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt @@ -35,4 +35,6 @@ CMake Error at BadStrEqual.cmake:1 \(add_custom_target\): \$<STREQUAL> expression requires 2 comma separated parameters, but got 3 instead. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt index 969393a..98eed1f 100644 --- a/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt @@ -5,4 +5,6 @@ CMake Error at BadTargetName.cmake:1 \(add_custom_target\): \$<TARGET_NAME> expression requires literal input. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt new file mode 100644 index 0000000..2ee96ed --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at COMPILE_LANG_AND_ID-add_custom_command.cmake:2 \(add_custom_command\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID> + + \$<COMPILE_LANG_AND_ID> expression requires at least two parameters. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake new file mode 100644 index 0000000..9bd5e8e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake @@ -0,0 +1,4 @@ +add_custom_target(drive) +add_custom_command(TARGET drive PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID> +) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt new file mode 100644 index 0000000..589e64b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_custom_target.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:LANG,ID> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake new file mode 100644 index 0000000..398db19 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake @@ -0,0 +1,4 @@ + +add_custom_target(drive + COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID:LANG,ID> +) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt new file mode 100644 index 0000000..3b3f38d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_executable.cmake:1 \(add_executable\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:C,MSVC> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake new file mode 100644 index 0000000..2245f50 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake @@ -0,0 +1,5 @@ +add_executable(empty main.c + $<$<COMPILE_LANG_AND_ID:C,MSVC>:empty.c> + $<$<COMPILE_LANG_AND_ID:C,GNU>:empty2.c> + $<$<COMPILE_LANG_AND_ID:C,Clang>:empty3.c> + ) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt new file mode 100644 index 0000000..4cbf000 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_library.cmake:2 \(add_library\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:C,MSVC> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake new file mode 100644 index 0000000..044962a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake @@ -0,0 +1,2 @@ + +add_library(empty empty.$<COMPILE_LANG_AND_ID:C,MSVC>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt new file mode 100644 index 0000000..26a5940 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_test.cmake:5 \(add_test\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:CXX,GNU> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake new file mode 100644 index 0000000..b5b6c2b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake @@ -0,0 +1,5 @@ + +include(CTest) +enable_testing() + +add_test(NAME dummy COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID:CXX,GNU>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt new file mode 100644 index 0000000..0c4ecd0 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt @@ -0,0 +1,9 @@ +CMake Error: + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:C,MSVC> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake new file mode 100644 index 0000000..c13eda6 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake @@ -0,0 +1,5 @@ + +install(FILES + empty.$<COMPILE_LANG_AND_ID:C,MSVC> + DESTINATION src +) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt new file mode 100644 index 0000000..3ecbdc3 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at COMPILE_LANG_AND_ID-target_sources.cmake:2 \(target_sources\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID> + + \$<COMPILE_LANG_AND_ID> expression requires at least two parameters. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake new file mode 100644 index 0000000..a2c9b03 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake @@ -0,0 +1,2 @@ +add_library(empty) +target_sources(empty PRIVATE empty.$<COMPILE_LANG_AND_ID>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake new file mode 100644 index 0000000..b9e840b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake @@ -0,0 +1,4 @@ + +enable_language(C) +add_executable(empty empty.c) +target_compile_options(empty PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,GNU>:$<TARGET_EXISTS:too,many,parameters>>) diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Exclude-check.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude-check.cmake new file mode 100644 index 0000000..605ae4d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/FILTER-generated.txt" content) + +set(expected "DO_NOT_FILTER_THIS;thisisanitem") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Exclude.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude.cmake new file mode 100644 index 0000000..b879be2 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude.cmake @@ -0,0 +1,4 @@ +cmake_policy(VERSION 3.11) + +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:${mylist},EXCLUDE,^FILTER_THIS_.+>") diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Include-check.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Include-check.cmake new file mode 100644 index 0000000..9d48d98 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-Include-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/FILTER-generated.txt" content) + +set(expected "FILTER_THIS_BIT;FILTER_THIS_THING") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Include.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Include.cmake new file mode 100644 index 0000000..5e0260a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-Include.cmake @@ -0,0 +1,4 @@ +cmake_policy(VERSION 3.11) + +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:${mylist},INCLUDE,^FILTER_THIS_.+>") diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-result.txt b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-stderr.txt b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-stderr.txt new file mode 100644 index 0000000..dd10925 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at FILTER-InvalidOperator.cmake:3 \(file\): + Error evaluating generator expression: + + \$<FILTER:,RM,> + + \$<FILTER:...> second parameter must be either INCLUDE or EXCLUDE +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator.cmake new file mode 100644 index 0000000..26f3917 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:,RM,>") diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-empty-check.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-empty-check.cmake new file mode 100644 index 0000000..2844484 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-empty-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/FILTER-generated.txt" content) + +set(expected "") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-empty.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-empty.cmake new file mode 100644 index 0000000..e0fc671 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/FILTER-empty.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:,INCLUDE,>") diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-result.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt new file mode 100644 index 0000000..3b2a814 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<TARGET_PDB_FILE_BASE_NAME:empty> + + TARGET_PDB_FILE_BASE_NAME not allowed for IMPORTED targets. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake new file mode 100644 index 0000000..489d8e6 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake @@ -0,0 +1,2 @@ +add_library(empty UNKNOWN IMPORTED) +add_custom_target(custom COMMAND echo $<TARGET_PDB_FILE_BASE_NAME:empty>) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-stderr.txt new file mode 100644 index 0000000..b061ce3 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake:6 \(file\): + Error evaluating generator expression: + + \$<TARGET_PDB_FILE_BASE_NAME:empty> + + TARGET_PDB_FILE_BASE_NAME is not supported by the target linker. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake new file mode 100644 index 0000000..811c3f7 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake @@ -0,0 +1,9 @@ + +enable_language(C) + +add_library(empty STATIC empty.c) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_PDB_FILE_BASE_NAME:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt new file mode 100644 index 0000000..c7d245c --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake:6 \(file\): + Error evaluating generator expression: + + \$<TARGET_PDB_FILE_BASE_NAME:empty> + + TARGET_PDB_FILE_BASE_NAME is allowed only for targets with linker created + artifacts. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake new file mode 100644 index 0000000..811c3f7 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake @@ -0,0 +1,9 @@ + +enable_language(C) + +add_library(empty STATIC empty.c) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_PDB_FILE_BASE_NAME:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt index bf592e7..013c4f2 100644 --- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt @@ -1,4 +1,10 @@ CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): - Target 'empty1' OUTPUT_NAME depends on itself. + Target 'empty2' OUTPUT_NAME depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty2' OUTPUT_NAME depends on itself. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake index 5cb8050..006b0da 100644 --- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake @@ -1,3 +1,6 @@ enable_language(C) add_executable(empty1 empty.c) set_property(TARGET empty1 PROPERTY OUTPUT_NAME $<TARGET_FILE_NAME:empty1>) + +add_executable(empty2 empty.c) +set_property(TARGET empty2 PROPERTY OUTPUT_NAME $<TARGET_FILE_BASE_NAME:empty2>) diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake new file mode 100644 index 0000000..e127711 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake new file mode 100644 index 0000000..53934af --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:1>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake new file mode 100644 index 0000000..e127711 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake new file mode 100644 index 0000000..a8aca6e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:1$<SEMICOLON>1>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake new file mode 100644 index 0000000..e3055ce --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "2;1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake new file mode 100644 index 0000000..ee2dd3e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:2$<SEMICOLON>1>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake new file mode 100644 index 0000000..e3055ce --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "2;1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake new file mode 100644 index 0000000..557bc28 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:2$<SEMICOLON>1$<SEMICOLON>2>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake new file mode 100644 index 0000000..f779d48 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake new file mode 100644 index 0000000..3b9d674 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:>") diff --git a/Tests/RunCMake/GeneratorExpression/ResultValidator.cmake b/Tests/RunCMake/GeneratorExpression/ResultValidator.cmake new file mode 100644 index 0000000..722ae05 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ResultValidator.cmake @@ -0,0 +1,6 @@ + +function (CHECK_VALUE test_msg value expected) + if (NOT value STREQUAL expected) + string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [[${value}]]\nbut expected:\n [[${expected}]]\n") + endif() +endfunction() diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 8a5604c..68a0172 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -31,8 +31,29 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(COMPILE_LANG_AND_ID-add_custom_target) +run_cmake(COMPILE_LANG_AND_ID-add_custom_command) +run_cmake(COMPILE_LANG_AND_ID-install) +run_cmake(COMPILE_LANG_AND_ID-target_sources) +run_cmake(COMPILE_LANG_AND_ID-add_executable) +run_cmake(COMPILE_LANG_AND_ID-add_library) +run_cmake(COMPILE_LANG_AND_ID-add_test) +run_cmake(COMPILE_LANG_AND_ID-unknown-lang) run_cmake(TARGET_FILE-recursion) run_cmake(OUTPUT_NAME-recursion) +run_cmake(TARGET_FILE_PREFIX) +run_cmake(TARGET_FILE_PREFIX-imported-target) +run_cmake(TARGET_FILE_PREFIX-non-valid-target) +run_cmake(TARGET_LINKER_FILE_PREFIX-non-valid-target) +run_cmake(TARGET_FILE_SUFFIX) +run_cmake(TARGET_FILE_SUFFIX-imported-target) +run_cmake(TARGET_FILE_SUFFIX-non-valid-target) +run_cmake(TARGET_LINKER_FILE_SUFFIX-non-valid-target) +run_cmake_with_options(TARGET_FILE_BASE_NAME -DCMAKE_BUILD_TYPE:STRING=Debug) +run_cmake_with_options(TARGET_FILE_BASE_NAME-imported-target -DCMAKE_BUILD_TYPE:STRING=Debug) +run_cmake(TARGET_FILE_BASE_NAME-non-valid-target) +run_cmake(TARGET_LINKER_FILE_BASE_NAME-non-valid-target) +run_cmake(TARGET_PROPERTY-INCLUDE_DIRECTORIES) run_cmake(TARGET_PROPERTY-LOCATION) run_cmake(TARGET_PROPERTY-SOURCES) run_cmake(LINK_ONLY-not-linking) @@ -53,15 +74,28 @@ run_cmake(TARGET_GENEX_EVAL) run_cmake(GENEX_EVAL-recursion1) run_cmake(GENEX_EVAL-recursion2) run_cmake(GENEX_EVAL) +run_cmake(REMOVE_DUPLICATES-empty) +run_cmake(REMOVE_DUPLICATES-1) +run_cmake(REMOVE_DUPLICATES-2) +run_cmake(REMOVE_DUPLICATES-3) +run_cmake(REMOVE_DUPLICATES-4) +run_cmake(FILTER-empty) +run_cmake(FILTER-InvalidOperator) +run_cmake(FILTER-Exclude) +run_cmake(FILTER-Include) run_cmake(ImportedTarget-TARGET_BUNDLE_DIR) run_cmake(ImportedTarget-TARGET_BUNDLE_CONTENT_DIR) run_cmake(ImportedTarget-TARGET_PDB_FILE) +run_cmake(ImportedTarget-TARGET_PDB_FILE_BASE_NAME) if(LINKER_SUPPORTS_PDB) run_cmake(NonValidTarget-TARGET_PDB_FILE) run_cmake(ValidTarget-TARGET_PDB_FILE) + run_cmake(NonValidTarget-TARGET_PDB_FILE_BASE_NAME) + run_cmake(ValidTarget-TARGET_PDB_FILE_BASE_NAME) else() run_cmake(NonValidCompiler-TARGET_PDB_FILE) + run_cmake(NonValidCompiler-TARGET_PDB_FILE_BASE_NAME) endif() set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=OLD) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-check.cmake new file mode 100644 index 0000000..793edb1 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-check.cmake @@ -0,0 +1,2 @@ + +include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target-check.cmake new file mode 100644 index 0000000..793edb1 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target-check.cmake @@ -0,0 +1,2 @@ + +include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake new file mode 100644 index 0000000..40f7c66 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake @@ -0,0 +1,106 @@ + +cmake_minimum_required(VERSION 3.14) + +enable_language (C) + +set (GENERATE_CONTENT [[ +macro (CHECK_VALUE test_msg value expected) + if (NOT "${value}" STREQUAL "${expected}") + string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n") + endif() +endmacro() +]]) + +add_executable(exec1 IMPORTED) +add_library (shared1 SHARED IMPORTED) +add_library (static1 STATIC IMPORTED) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable default" "$<TARGET_FILE_BASE_NAME:exec1>" "exec1") +check_value ("TARGET_FILE_BASE_NAME shared default" "$<TARGET_FILE_BASE_NAME:shared1>" "shared1") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker default" "$<TARGET_LINKER_FILE_BASE_NAME:shared1>" "shared1") +check_value ("TARGET_FILE_BASE_NAME static default" "$<TARGET_FILE_BASE_NAME:static1>" "static1") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker default" "$<TARGET_LINKER_FILE_BASE_NAME:static1>" "static1") +]]) + + +add_executable (exec2 IMPORTED) +set_property (TARGET exec2 PROPERTY OUTPUT_NAME exec2_custom) +add_library (shared2 SHARED IMPORTED) +set_property (TARGET shared2 PROPERTY OUTPUT_NAME shared2_custom) +add_library (static2 STATIC IMPORTED) +set_property (TARGET static2 PROPERTY OUTPUT_NAME static2_custom) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable custom" "$<TARGET_FILE_BASE_NAME:exec2>" "exec2_custom") +check_value ("TARGET_FILE_BASE_NAME shared custom" "$<TARGET_FILE_BASE_NAME:shared2>" "shared2_custom") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:shared2>" "shared2_custom") +check_value ("TARGET_FILE_BASE_NAME static custom" "$<TARGET_FILE_BASE_NAME:static2>" "static2_custom") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:static2>" "static2_custom") +]]) + + +add_executable (exec3 IMPORTED) +set_property (TARGET exec3 PROPERTY RUNTIME_OUTPUT_NAME exec3_runtime) +set_property (TARGET exec3 PROPERTY LIBRARY_OUTPUT_NAME exec3_library) +set_property (TARGET exec3 PROPERTY ARCHIVE_OUTPUT_NAME exec3_archive) +add_library (shared3 SHARED IMPORTED) +set_property (TARGET shared3 PROPERTY RUNTIME_OUTPUT_NAME shared3_runtime) +set_property (TARGET shared3 PROPERTY LIBRARY_OUTPUT_NAME shared3_library) +set_property (TARGET shared3 PROPERTY ARCHIVE_OUTPUT_NAME shared3_archive) +add_library (static3 STATIC IMPORTED) +set_property (TARGET static3 PROPERTY RUNTIME_OUTPUT_NAME static3_runtime) +set_property (TARGET static3 PROPERTY LIBRARY_OUTPUT_NAME static3_library) +set_property (TARGET static3 PROPERTY ARCHIVE_OUTPUT_NAME static3_archive) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable all properties" "$<TARGET_FILE_BASE_NAME:exec3>" "exec3_runtime") +check_value ("TARGET_FILE_BASE_NAME shared all properties" "$<TARGET_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_runtime,shared3_library>") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_archive,shared3_library>") +check_value ("TARGET_FILE_BASE_NAME static all properties" "$<TARGET_FILE_BASE_NAME:static3>" "static3_archive") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:static3>" "static3_archive") +]]) + + +unset(GENERATE_CONDITION) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG) + set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>) +else() + set (FIRST_CONFIG ${CMAKE_BUILD_TYPE}) +endif() +string (TOUPPER "${FIRST_CONFIG}" FIRST_CONFIG) + + +add_executable (exec4 IMPORTED) +set_property (TARGET exec4 PROPERTY RUNTIME_OUTPUT_NAME exec4_runtime) +set_property (TARGET exec4 PROPERTY LIBRARY_OUTPUT_NAME exec4_library) +set_property (TARGET exec4 PROPERTY ARCHIVE_OUTPUT_NAME exec4_archive) +set_property (TARGET exec4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (shared4 SHARED IMPORTED) +set_property (TARGET shared4 PROPERTY RUNTIME_OUTPUT_NAME shared4_runtime) +set_property (TARGET shared4 PROPERTY LIBRARY_OUTPUT_NAME shared4_library) +set_property (TARGET shared4 PROPERTY ARCHIVE_OUTPUT_NAME shared4_archive) +set_property (TARGET shared4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (static4 STATIC IMPORTED) +set_property (TARGET static4 PROPERTY RUNTIME_OUTPUT_NAME static4_runtime) +set_property (TARGET static4 PROPERTY LIBRARY_OUTPUT_NAME static4_library) +set_property (TARGET static4 PROPERTY ARCHIVE_OUTPUT_NAME static4_archive) +set_property (TARGET static4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable all properties + postfix" "$<TARGET_FILE_BASE_NAME:exec4>" "exec4_runtime_postfix") +check_value ("TARGET_FILE_BASE_NAME shared all properties + postfix" "$<TARGET_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_runtime,shared4_library>_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_archive,shared4_library>_postfix") +check_value ("TARGET_FILE_BASE_NAME static all properties + postfix" "$<TARGET_FILE_BASE_NAME:static4>" "static4_archive_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:static4>" "static4_archive_postfix") +]]) + + +file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake" + CONTENT "${GENERATE_CONTENT}" ${GENERATE_CONDITION}) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-stderr.txt new file mode 100644 index 0000000..ecb9e5d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at TARGET_FILE_BASE_NAME-non-valid-target.cmake:[0-9]+ \(file\): + Error evaluating generator expression: + + \$<TARGET_FILE_BASE_NAME:empty> + + Target "empty" is not an executable or library\. diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target.cmake new file mode 100644 index 0000000..8622b7d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target.cmake @@ -0,0 +1,7 @@ + +add_custom_target(empty) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_FILE_BASE_NAME:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake new file mode 100644 index 0000000..f88d710 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake @@ -0,0 +1,135 @@ + +cmake_minimum_required(VERSION 3.14) + +enable_language (C) + +set (GENERATE_CONTENT [[ +macro (CHECK_VALUE test_msg value expected) + if (NOT "${value}" STREQUAL "${expected}") + string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n") + endif() +endmacro() +]]) + +add_executable (exec1 empty.c) +add_library (shared1 SHARED empty.c) +add_library (static1 STATIC empty.c) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable default" "$<TARGET_FILE_BASE_NAME:exec1>" "exec1") +check_value ("TARGET_FILE_BASE_NAME shared default" "$<TARGET_FILE_BASE_NAME:shared1>" "shared1") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker default" "$<TARGET_LINKER_FILE_BASE_NAME:shared1>" "shared1") +check_value ("TARGET_FILE_BASE_NAME static default" "$<TARGET_FILE_BASE_NAME:static1>" "static1") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker default" "$<TARGET_LINKER_FILE_BASE_NAME:static1>" "static1") +]]) +if (CMAKE_C_LINKER_SUPPORTS_PDB) + string(APPEND GENERATE_CONTENT [[ +check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB default" "$<TARGET_PDB_FILE_BASE_NAME:exec1>" "exec1") +check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB default" "$<TARGET_PDB_FILE_BASE_NAME:shared1>" "shared1") +]]) +endif() + + +add_executable (exec2 empty.c) +set_property (TARGET exec2 PROPERTY OUTPUT_NAME exec2_custom) +add_library (shared2 SHARED empty.c) +set_property (TARGET shared2 PROPERTY OUTPUT_NAME shared2_custom) +add_library (static2 STATIC empty.c) +set_property (TARGET static2 PROPERTY OUTPUT_NAME static2_custom) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable custom" "$<TARGET_FILE_BASE_NAME:exec2>" "exec2_custom") +check_value ("TARGET_FILE_BASE_NAME shared custom" "$<TARGET_FILE_BASE_NAME:shared2>" "shared2_custom") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:shared2>" "shared2_custom") +check_value ("TARGET_FILE_BASE_NAME static custom" "$<TARGET_FILE_BASE_NAME:static2>" "static2_custom") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:static2>" "static2_custom") +]]) +if (CMAKE_C_LINKER_SUPPORTS_PDB) + string (APPEND GENERATE_CONTENT [[ +check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB custom" "$<TARGET_PDB_FILE_BASE_NAME:exec2>" "exec2_custom") +check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB custom" "$<TARGET_PDB_FILE_BASE_NAME:shared2>" "shared2_custom") + ]]) +endif() + +add_executable (exec3 empty.c) +set_property (TARGET exec3 PROPERTY RUNTIME_OUTPUT_NAME exec3_runtime) +set_property (TARGET exec3 PROPERTY LIBRARY_OUTPUT_NAME exec3_library) +set_property (TARGET exec3 PROPERTY ARCHIVE_OUTPUT_NAME exec3_archive) +set_property (TARGET exec3 PROPERTY PDB_NAME exec3_pdb) +add_library (shared3 SHARED empty.c) +set_property (TARGET shared3 PROPERTY RUNTIME_OUTPUT_NAME shared3_runtime) +set_property (TARGET shared3 PROPERTY LIBRARY_OUTPUT_NAME shared3_library) +set_property (TARGET shared3 PROPERTY ARCHIVE_OUTPUT_NAME shared3_archive) +set_property (TARGET shared3 PROPERTY PDB_NAME shared3_pdb) +add_library (static3 STATIC empty.c) +set_property (TARGET static3 PROPERTY RUNTIME_OUTPUT_NAME static3_runtime) +set_property (TARGET static3 PROPERTY LIBRARY_OUTPUT_NAME static3_library) +set_property (TARGET static3 PROPERTY ARCHIVE_OUTPUT_NAME static3_archive) +set_property (TARGET static3 PROPERTY PDB_NAME static3_pdb) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable all properties" "$<TARGET_FILE_BASE_NAME:exec3>" "exec3_runtime") +check_value ("TARGET_FILE_BASE_NAME shared all properties" "$<TARGET_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_runtime,shared3_library>") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_archive,shared3_library>") +check_value ("TARGET_FILE_BASE_NAME static all properties" "$<TARGET_FILE_BASE_NAME:static3>" "static3_archive") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:static3>" "static3_archive") +]]) +if (CMAKE_C_LINKER_SUPPORTS_PDB) + string (APPEND GENERATE_CONTENT [[ +check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB all properties" "$<TARGET_PDB_FILE_BASE_NAME:exec3>" "exec3_pdb") +check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB all properties" "$<TARGET_PDB_FILE_BASE_NAME:shared3>" "shared3_pdb") +]]) +endif() + + +unset(GENERATE_CONDITION) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG) + set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>) +else() + set (FIRST_CONFIG ${CMAKE_BUILD_TYPE}) +endif() +string (TOUPPER "${FIRST_CONFIG}" FIRST_CONFIG) + + +add_executable (exec4 empty.c) +set_property (TARGET exec4 PROPERTY RUNTIME_OUTPUT_NAME exec4_runtime) +set_property (TARGET exec4 PROPERTY LIBRARY_OUTPUT_NAME exec4_library) +set_property (TARGET exec4 PROPERTY ARCHIVE_OUTPUT_NAME exec4_archive) +set_property (TARGET exec4 PROPERTY PDB_NAME exec4_pdb) +set_property (TARGET exec4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (shared4 SHARED empty.c) +set_property (TARGET shared4 PROPERTY RUNTIME_OUTPUT_NAME shared4_runtime) +set_property (TARGET shared4 PROPERTY LIBRARY_OUTPUT_NAME shared4_library) +set_property (TARGET shared4 PROPERTY ARCHIVE_OUTPUT_NAME shared4_archive) +set_property (TARGET shared4 PROPERTY PDB_NAME shared4_pdb) +set_property (TARGET shared4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (static4 STATIC empty.c) +set_property (TARGET static4 PROPERTY RUNTIME_OUTPUT_NAME static4_runtime) +set_property (TARGET static4 PROPERTY LIBRARY_OUTPUT_NAME static4_library) +set_property (TARGET static4 PROPERTY ARCHIVE_OUTPUT_NAME static4_archive) +set_property (TARGET static4 PROPERTY PDB_NAME static4_pdb) +set_property (TARGET static4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable all properties + postfix" "$<TARGET_FILE_BASE_NAME:exec4>" "exec4_runtime_postfix") +check_value ("TARGET_FILE_BASE_NAME shared all properties + postfix" "$<TARGET_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_runtime,shared4_library>_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_archive,shared4_library>_postfix") +check_value ("TARGET_FILE_BASE_NAME static all properties + postfix" "$<TARGET_FILE_BASE_NAME:static4>" "static4_archive_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:static4>" "static4_archive_postfix") +]]) +if (CMAKE_C_LINKER_SUPPORTS_PDB) + string (APPEND GENERATE_CONTENT [[ +check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:exec4>" "exec4_pdb_postfix") +check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:shared4>" "shared4_pdb_postfix") +]]) +endif() + + +file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake" + CONTENT "${GENERATE_CONTENT}" ${GENERATE_CONDITION}) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-check.cmake new file mode 100644 index 0000000..676ad4b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-check.cmake @@ -0,0 +1,2 @@ + +include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target-check.cmake new file mode 100644 index 0000000..676ad4b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target-check.cmake @@ -0,0 +1,2 @@ + +include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake new file mode 100644 index 0000000..34e500a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake @@ -0,0 +1,49 @@ + +cmake_minimum_required(VERSION 3.14) + +enable_language (C) + +set (win_platforms Windows CYGWIN) + +set (GENERATE_CONTENT [[ +macro (CHECK_VALUE test_msg value expected) + if (NOT "${value}" STREQUAL "${expected}") + string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n") + endif() +endmacro() +]]) + +add_executable(exec1 IMPORTED) +add_library (shared1 SHARED IMPORTED) +add_library (static1 STATIC IMPORTED) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_PREFIX executable default\" \"$<TARGET_FILE_PREFIX:exec1>\" \"\") +check_value (\"TARGET_FILE_PREFIX shared default\" \"$<TARGET_FILE_PREFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_PREFIX}\") +check_value (\"TARGET_LINKER_FILE_PREFIX shared linker default\" \"$<TARGET_LINKER_FILE_PREFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_PREFIX},${CMAKE_SHARED_LIBRARY_PREFIX}>\") +check_value (\"TARGET_FILE_PREFIX static default\" \"$<TARGET_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\") +check_value (\"TARGET_LINKER_FILE_PREFIX static linker default\" \"$<TARGET_LINKER_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\")\n") + + +add_executable (exec2 IMPORTED) +set_property (TARGET exec2 PROPERTY PREFIX exec2_prefix) +set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE) +set_property (TARGET exec2 PROPERTY IMPORT_PREFIX exec2_import_prefix) +add_library (shared2 SHARED IMPORTED) +set_property (TARGET shared2 PROPERTY PREFIX shared2_prefix) +set_property (TARGET shared2 PROPERTY IMPORT_PREFIX shared2_import_prefix) +add_library (static2 STATIC IMPORTED) +set_property (TARGET static2 PROPERTY PREFIX static2_prefix) +set_property (TARGET static2 PROPERTY IMPORT_PREFIX static2_import_prefix) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_PREFIX executable custom\" \"$<TARGET_FILE_PREFIX:exec2>\" \"exec2_prefix\") +check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_prefix,exec2_prefix>\") +check_value (\"TARGET_FILE_PREFIX shared custom\" \"$<TARGET_FILE_PREFIX:shared2>\" \"shared2_prefix\") +check_value (\"TARGET_LINKER_FILE_PREFIX shared linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_prefix,shared2_prefix>\") +check_value (\"TARGET_FILE_PREFIX static custom\" \"$<TARGET_FILE_PREFIX:static2>\" \"static2_prefix\") +check_value (\"TARGET_LINKER_FILE_PREFIX static linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:static2>\" \"static2_prefix\")\n") + + +file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake" + CONTENT "${GENERATE_CONTENT}") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-stderr.txt new file mode 100644 index 0000000..81362ef --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at TARGET_FILE_PREFIX-non-valid-target.cmake:[0-9]+ \(file\): + Error evaluating generator expression: + + \$<TARGET_FILE_PREFIX:empty> + + Target "empty" is not an executable or library\. diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target.cmake new file mode 100644 index 0000000..d1095fa --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target.cmake @@ -0,0 +1,7 @@ + +add_custom_target(empty) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_FILE_PREFIX:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake new file mode 100644 index 0000000..6bb1e44 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake @@ -0,0 +1,49 @@ + +cmake_minimum_required(VERSION 3.14) + +enable_language (C) + +set (win_platforms Windows CYGWIN) + +set (GENERATE_CONTENT [[ +macro (CHECK_VALUE test_msg value expected) + if (NOT "${value}" STREQUAL "${expected}") + string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n") + endif() +endmacro() +]]) + +add_executable (exec1 empty.c) +add_library (shared1 SHARED empty.c) +add_library (static1 STATIC empty.c) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_PREFIX executable default\" \"$<TARGET_FILE_PREFIX:exec1>\" \"\") +check_value (\"TARGET_FILE_PREFIX shared default\" \"$<TARGET_FILE_PREFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_PREFIX}\") +check_value (\"TARGET_LINKER_FILE_PREFIX shared linker default\" \"$<TARGET_LINKER_FILE_PREFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_PREFIX},${CMAKE_SHARED_LIBRARY_PREFIX}>\") +check_value (\"TARGET_FILE_PREFIX static default\" \"$<TARGET_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\") +check_value (\"TARGET_LINKER_FILE_PREFIX static linker default\" \"$<TARGET_LINKER_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\")\n") + + +add_executable (exec2 empty.c) +set_property (TARGET exec2 PROPERTY PREFIX exec2_prefix) +set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE) +set_property (TARGET exec2 PROPERTY IMPORT_PREFIX exec2_import_prefix) +add_library (shared2 SHARED empty.c) +set_property (TARGET shared2 PROPERTY PREFIX shared2_prefix) +set_property (TARGET shared2 PROPERTY IMPORT_PREFIX shared2_import_prefix) +add_library (static2 STATIC empty.c) +set_property (TARGET static2 PROPERTY PREFIX static2_prefix) +set_property (TARGET static2 PROPERTY IMPORT_PREFIX static2_import_prefix) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_PREFIX executable custom\" \"$<TARGET_FILE_PREFIX:exec2>\" \"exec2_prefix\") +check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_prefix,exec2_prefix>\") +check_value (\"TARGET_FILE_PREFIX shared custom\" \"$<TARGET_FILE_PREFIX:shared2>\" \"shared2_prefix\") +check_value (\"TARGET_LINKER_FILE_PREFIX shared linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_prefix,shared2_prefix>\") +check_value (\"TARGET_FILE_PREFIX static custom\" \"$<TARGET_FILE_PREFIX:static2>\" \"static2_prefix\") +check_value (\"TARGET_LINKER_FILE_PREFIX static linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:static2>\" \"static2_prefix\")\n") + + +file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake" + CONTENT "${GENERATE_CONTENT}") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-check.cmake new file mode 100644 index 0000000..f159370 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-check.cmake @@ -0,0 +1,2 @@ + +include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target-check.cmake new file mode 100644 index 0000000..f159370 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target-check.cmake @@ -0,0 +1,2 @@ + +include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake new file mode 100644 index 0000000..e1b7654 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake @@ -0,0 +1,49 @@ + +cmake_minimum_required(VERSION 3.14) + +enable_language (C) + +set (win_platforms Windows CYGWIN) + +set (GENERATE_CONTENT [[ +macro (CHECK_VALUE test_msg value expected) + if (NOT "${value}" STREQUAL "${expected}") + string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n") + endif() +endmacro() +]]) + +add_executable (exec1 IMPORTED) +add_library (shared1 SHARED IMPORTED) +add_library (static1 STATIC IMPORTED) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_SUFFIX executable default\" \"$<TARGET_FILE_SUFFIX:exec1>\" \"${CMAKE_EXECUTABLE_SUFFIX}\") +check_value (\"TARGET_FILE_SUFFIX shared default\" \"$<TARGET_FILE_SUFFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_SUFFIX}\") +check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>\") +check_value (\"TARGET_FILE_SUFFIX static default\" \"$<TARGET_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\") +check_value (\"TARGET_LINKER_FILE_SUFFIX static linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\")\n") + + +add_executable (exec2 IMPORTED) +set_property (TARGET exec2 PROPERTY SUFFIX exec2_suffix) +set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE) +set_property (TARGET exec2 PROPERTY IMPORT_SUFFIX exec2_import_suffix) +add_library (shared2 SHARED IMPORTED) +set_property (TARGET shared2 PROPERTY SUFFIX shared2_suffix) +set_property (TARGET shared2 PROPERTY IMPORT_SUFFIX shared2_import_suffix) +add_library (static2 STATIC IMPORTED) +set_property (TARGET static2 PROPERTY SUFFIX static2_suffix) +set_property (TARGET static2 PROPERTY IMPORT_SUFFIX static2_import_suffix) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_SUFFIX executable custom\" \"$<TARGET_FILE_SUFFIX:exec2>\" \"exec2_suffix\") +check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_suffix,exec2_suffix>\") +check_value (\"TARGET_FILE_SUFFIX shared custom\" \"$<TARGET_FILE_SUFFIX:shared2>\" \"shared2_suffix\") +check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_suffix,shared2_suffix>\") +check_value (\"TARGET_FILE_SUFFIX static custom\" \"$<TARGET_FILE_SUFFIX:static2>\" \"static2_suffix\") +check_value (\"TARGET_LINKER_FILE_SUFFIX static linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:static2>\" \"static2_suffix\")\n") + + +file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake" + CONTENT "${GENERATE_CONTENT}") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-stderr.txt new file mode 100644 index 0000000..9ea09d1 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at TARGET_FILE_SUFFIX-non-valid-target.cmake:[0-9]+ \(file\): + Error evaluating generator expression: + + \$<TARGET_FILE_SUFFIX:empty> + + Target "empty" is not an executable or library\. diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target.cmake new file mode 100644 index 0000000..f7089f9 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target.cmake @@ -0,0 +1,7 @@ + +add_custom_target(empty) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_FILE_SUFFIX:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake new file mode 100644 index 0000000..78afecd --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake @@ -0,0 +1,49 @@ + +cmake_minimum_required(VERSION 3.14) + +enable_language (C) + +set (win_platforms Windows CYGWIN) + +set (GENERATE_CONTENT [[ +macro (CHECK_VALUE test_msg value expected) + if (NOT "${value}" STREQUAL "${expected}") + string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n") + endif() +endmacro() +]]) + +add_executable (exec1 empty.c) +add_library (shared1 SHARED empty.c) +add_library (static1 STATIC empty.c) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_SUFFIX executable default\" \"$<TARGET_FILE_SUFFIX:exec1>\" \"${CMAKE_EXECUTABLE_SUFFIX}\") +check_value (\"TARGET_FILE_SUFFIX shared default\" \"$<TARGET_FILE_SUFFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_SUFFIX}\") +check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>\") +check_value (\"TARGET_FILE_SUFFIX static default\" \"$<TARGET_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\") +check_value (\"TARGET_LINKER_FILE_SUFFIX static linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\")\n") + + +add_executable (exec2 empty.c) +set_property (TARGET exec2 PROPERTY SUFFIX exec2_suffix) +set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE) +set_property (TARGET exec2 PROPERTY IMPORT_SUFFIX exec2_import_suffix) +add_library (shared2 SHARED empty.c) +set_property (TARGET shared2 PROPERTY SUFFIX shared2_suffix) +set_property (TARGET shared2 PROPERTY IMPORT_SUFFIX shared2_import_suffix) +add_library (static2 STATIC empty.c) +set_property (TARGET static2 PROPERTY SUFFIX static2_suffix) +set_property (TARGET static2 PROPERTY IMPORT_SUFFIX static2_import_suffix) + +string (APPEND GENERATE_CONTENT +"\ncheck_value (\"TARGET_FILE_SUFFIX executable custom\" \"$<TARGET_FILE_SUFFIX:exec2>\" \"exec2_suffix\") +check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_suffix,exec2_suffix>\") +check_value (\"TARGET_FILE_SUFFIX shared custom\" \"$<TARGET_FILE_SUFFIX:shared2>\" \"shared2_suffix\") +check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_suffix,shared2_suffix>\") +check_value (\"TARGET_FILE_SUFFIX static custom\" \"$<TARGET_FILE_SUFFIX:static2>\" \"static2_suffix\") +check_value (\"TARGET_LINKER_FILE_SUFFIX static linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:static2>\" \"static2_suffix\")\n") + + +file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake" + CONTENT "${GENERATE_CONTENT}") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-stderr.txt new file mode 100644 index 0000000..1ae2f2c --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake:[0-9]+ \(file\): + Error evaluating generator expression: + + \$<TARGET_LINKER_FILE_BASE_NAME:empty> + + Target "empty" is not an executable or library\. diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake new file mode 100644 index 0000000..776fb4b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake @@ -0,0 +1,7 @@ + +add_custom_target(empty) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_LINKER_FILE_BASE_NAME:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-stderr.txt new file mode 100644 index 0000000..7a36cef --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake:[0-9]+ \(file\): + Error evaluating generator expression: + + \$<TARGET_LINKER_FILE_PREFIX:empty> + + Target "empty" is not an executable or library\. diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake new file mode 100644 index 0000000..8dad4da --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake @@ -0,0 +1,7 @@ + +add_custom_target(empty) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_LINKER_FILE_PREFIX:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-stderr.txt new file mode 100644 index 0000000..cc5217a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake:[0-9]+ \(file\): + Error evaluating generator expression: + + \$<TARGET_LINKER_FILE_SUFFIX:empty> + + Target "empty" is not an executable or library\. diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake new file mode 100644 index 0000000..82c2f3a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake @@ -0,0 +1,7 @@ + +add_custom_target(empty) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_LINKER_FILE_SUFFIX:empty>]" +) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake new file mode 100644 index 0000000..cb6f4d8 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.14) +enable_language(C) + +add_library(foo1 STATIC empty.c) +target_include_directories(foo1 PUBLIC include) +target_link_libraries(foo1 PRIVATE foo2 foo3 foo4) + +add_library(foo2 STATIC empty.c) +target_include_directories(foo2 PUBLIC $<TARGET_PROPERTY:foo1,INCLUDE_DIRECTORIES>) + +add_library(foo3 STATIC empty.c) +target_include_directories(foo3 PUBLIC $<TARGET_PROPERTY:foo2,INCLUDE_DIRECTORIES>) + +add_library(foo4 STATIC empty.c) +target_include_directories(foo4 PUBLIC $<TARGET_PROPERTY:foo3,INCLUDE_DIRECTORIES>) + +# Evaluate a genex that looks up INCLUDE_DIRECTORIES on multiple targets. +file(GENERATE OUTPUT out.txt CONTENT "$<TARGET_PROPERTY:foo4,INCLUDE_DIRECTORIES>") diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME-check.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME-check.cmake new file mode 100644 index 0000000..996d2d4 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME-check.cmake @@ -0,0 +1,7 @@ +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/test.txt TEST_TXT ENCODING UTF-8) + +list(GET TEST_TXT 0 PDB_FILE_BASE_NAME) + +if(NOT PDB_FILE_BASE_NAME MATCHES "empty") + set(RunCMake_TEST_FAILED "unexpected PDB_FILE_BASE_NAME [${PDB_FILE_BASE_NAME}]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake new file mode 100644 index 0000000..cc53bdf --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake @@ -0,0 +1,16 @@ + +enable_language(C) + +add_library(empty SHARED empty.c) + +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG) + set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>) +endif() + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "$<TARGET_PDB_FILE_BASE_NAME:empty>" + ${GENERATE_CONDITION} +) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt new file mode 100644 index 0000000..9afa461 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error in CMakeLists.txt: + MSVC_RUNTIME_LIBRARY value 'BogusValue' not known for this C compiler. ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake new file mode 100644 index 0000000..c3ea2fd --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0091 NEW) +include(CMP0091-common.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake new file mode 100644 index 0000000..734cc9f --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0091 OLD) +include(CMP0091-common.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake new file mode 100644 index 0000000..26f86a0 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0091-common.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake new file mode 100644 index 0000000..7827d2a --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake @@ -0,0 +1,37 @@ +enable_language(C) + +cmake_policy(GET CMP0091 cmp0091) +if(cmp0091 STREQUAL "NEW") + if(NOT CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + message(SEND_ERROR "CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT not set under NEW behavior") + endif() +else() + if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + message(SEND_ERROR "CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT is set under OLD behavior") + endif() +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + if(CMAKE_C_FLAGS_DEBUG MATCHES "[/-]MDd( |$)") + set(have_MDd 1) + else() + set(have_MDd 0) + endif() + if(CMAKE_C_FLAGS_RELEASE MATCHES "[/-]MD( |$)") + set(have_MD 1) + else() + set(have_MD 0) + endif() + if(cmp0091 STREQUAL "NEW") + if(have_MDd OR have_MD) + message(SEND_ERROR "Have a -MD* flag under NEW behavior.") + endif() + else() + if(NOT (have_MDd AND have_MD)) + message(SEND_ERROR "Do not have -MD* flags under OLD behavior.") + endif() + endif() +endif() + +set(CMAKE_MSVC_RUNTIME_LIBRARY BogusValue) +add_library(foo empty.c) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt new file mode 100644 index 0000000..3e470a2 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake new file mode 100644 index 0000000..fad18da --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0091-WARN) +run_cmake(CMP0091-OLD) +run_cmake(CMP0091-NEW) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/empty.c b/Tests/RunCMake/MSVCRuntimeLibrary/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/empty.c diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-NEW.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-NEW.cmake new file mode 100644 index 0000000..15c52d2 --- /dev/null +++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0092 NEW) +include(CMP0092-common.cmake) diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD.cmake new file mode 100644 index 0000000..ea75445 --- /dev/null +++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0092 OLD) +include(CMP0092-common.cmake) diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-WARN.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-WARN.cmake new file mode 100644 index 0000000..45e183f --- /dev/null +++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0092-common.cmake) diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-common.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-common.cmake new file mode 100644 index 0000000..87d7f67 --- /dev/null +++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-common.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +cmake_policy(GET CMP0092 cmp0092) +if(cmp0092 STREQUAL "NEW") + if("${CMAKE_C_FLAGS}" MATCHES "([/-]W[0-9])") + message(SEND_ERROR "CMAKE_C_FLAGS has '${CMAKE_MATCH_1}' under NEW behavior") + endif() +else() + if(NOT " ${CMAKE_C_FLAGS} " MATCHES " /W3 ") + message(SEND_ERROR "CMAKE_C_FLAGS does not have '/W3' under OLD behavior") + endif() +endif() diff --git a/Tests/RunCMake/MSVCWarningFlags/CMakeLists.txt b/Tests/RunCMake/MSVCWarningFlags/CMakeLists.txt new file mode 100644 index 0000000..3e470a2 --- /dev/null +++ b/Tests/RunCMake/MSVCWarningFlags/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MSVCWarningFlags/RunCMakeTest.cmake b/Tests/RunCMake/MSVCWarningFlags/RunCMakeTest.cmake new file mode 100644 index 0000000..7ce448d --- /dev/null +++ b/Tests/RunCMake/MSVCWarningFlags/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0092-WARN) +run_cmake(CMP0092-OLD) +run_cmake(CMP0092-NEW) diff --git a/Tests/RunCMake/MetaCompileFeatures/C.cmake b/Tests/RunCMake/MetaCompileFeatures/C.cmake new file mode 100644 index 0000000..3bb6181 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/C.cmake @@ -0,0 +1,27 @@ + +enable_language(C) + +function(check_language_feature_flags lang level) + if(CMAKE_${lang}${level}_STANDARD_COMPILE_OPTION) + #this property is an internal implementation detail of CMake + get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES) + list(LENGTH known_features len) + if(len LESS 1) + message(FATAL_ERROR "unable to find known features of ${lang}${level}") + endif() + + string(TOLOWER ${lang} lang_lower) + set(known_name ${lang_lower}${level}_known_features) + set(meta_name ${lang_lower}${level}_meta_feature) + + add_library(${known_name} STATIC a.c) + target_compile_features(${known_name} PUBLIC ${known_features}) + add_library(${meta_name} STATIC a.c) + target_compile_features(${meta_name} PUBLIC ${lang_lower}_std_${level}) + endif() +endfunction() + + +check_language_feature_flags(C 90) +check_language_feature_flags(C 99) +check_language_feature_flags(C 11) diff --git a/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt b/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt new file mode 100644 index 0000000..3e470a2 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MetaCompileFeatures/CXX.cmake b/Tests/RunCMake/MetaCompileFeatures/CXX.cmake new file mode 100644 index 0000000..ef3b9d4 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/CXX.cmake @@ -0,0 +1,27 @@ + +enable_language(CXX) + +function(check_language_feature_flags lang level) + if(CMAKE_${lang}${level}_STANDARD_COMPILE_OPTION) + #this property is an internal implementation detail of CMake + get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES) + list(LENGTH known_features len) + if(len LESS 1) + message(FATAL_ERROR "unable to find known features of ${lang}${level}") + endif() + + string(TOLOWER ${lang} lang_lower) + set(known_name ${lang_lower}${level}_known_features) + set(meta_name ${lang_lower}${level}_meta_feature) + + add_library(${known_name} STATIC a.cxx) + target_compile_features(${known_name} PUBLIC ${known_features}) + add_library(${meta_name} STATIC a.cxx) + target_compile_features(${meta_name} PUBLIC ${lang_lower}_std_${level}) + endif() +endfunction() + + +check_language_feature_flags(CXX 98) +check_language_feature_flags(CXX 11) +check_language_feature_flags(CXX 14) diff --git a/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake new file mode 100644 index 0000000..009cde4 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(C) +run_cmake(CXX) diff --git a/Tests/RunCMake/MetaCompileFeatures/a.c b/Tests/RunCMake/MetaCompileFeatures/a.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/a.c diff --git a/Tests/RunCMake/MetaCompileFeatures/a.cxx b/Tests/RunCMake/MetaCompileFeatures/a.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/MetaCompileFeatures/a.cxx diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake new file mode 100644 index 0000000..7f7fa33 --- /dev/null +++ b/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake @@ -0,0 +1,8 @@ +set(log "${RunCMake_BINARY_DIR}/CustomCommandJobPool-build/build.ninja") +file(READ "${log}" build_file) +if(NOT "${build_file}" MATCHES "pool = custom_command_pool") + set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: pool = custom_command_pool") +endif() +if(NOT "${build_file}" MATCHES "pool = custom_target_pool") + set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: pool = custom_target_pool") +endif() diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake new file mode 100644 index 0000000..1e36e65 --- /dev/null +++ b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake @@ -0,0 +1,17 @@ +add_custom_command( + OUTPUT hello.copy.c + COMMAND "${CMAKE_COMMAND}" -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/hello.c" + hello.copy.c + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + JOB_POOL "custom_command_pool" + ) +add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hello.copy.c") + +add_custom_target( + hello.echo + COMMAND echo + JOB_POOL "custom_target_pool" +) + +include(CheckNoPrefixSubDir.cmake) diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt new file mode 100644 index 0000000..45975ca --- /dev/null +++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at JobPoolUsesTerminal.cmake:1 \(add_custom_command\): + add_custom_command JOB_POOL is shadowed by USES_TERMINAL. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at JobPoolUsesTerminal.cmake:2 \(add_custom_target\): + add_custom_target JOB_POOL is shadowed by USES_TERMINAL. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake b/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake new file mode 100644 index 0000000..b7e440c --- /dev/null +++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake @@ -0,0 +1,2 @@ +add_custom_command(OUTPUT x COMMAND y USES_TERMINAL JOB_POOL z) +add_custom_target(CustomTarget COMMAND y USES_TERMINAL JOB_POOL z) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 8fa650a..808a872 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -57,6 +57,8 @@ run_CMP0058(NEW-no) run_CMP0058(NEW-by) run_cmake(CustomCommandDepfile) +run_cmake(CustomCommandJobPool) +run_cmake(JobPoolUsesTerminal) run_cmake(RspFileC) run_cmake(RspFileCXX) diff --git a/Tests/RunCMake/Ninja/greeting.c b/Tests/RunCMake/Ninja/greeting.c index ba3e55b..1124d14 100644 --- a/Tests/RunCMake/Ninja/greeting.c +++ b/Tests/RunCMake/Ninja/greeting.c @@ -6,4 +6,5 @@ __declspec(dllexport) void greeting(void) { printf("Hello world!\n"); + fflush(stdout); } diff --git a/Tests/RunCMake/Ninja/greeting2.c b/Tests/RunCMake/Ninja/greeting2.c index c6ed87d..cc8409c 100644 --- a/Tests/RunCMake/Ninja/greeting2.c +++ b/Tests/RunCMake/Ninja/greeting2.c @@ -3,4 +3,5 @@ void greeting2(void) { printf("Hello world 2!\n"); + fflush(stdout); } diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt index 838b3d8..4dbd861 100644 --- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt @@ -3,6 +3,7 @@ CMake Error at BadSourceExpression3.cmake:2 \(add_library\): \$<TARGET_OBJECTS:NotObjLib> - Objects of target "NotObjLib" referenced but is not an OBJECT library. + Objects of target "NotObjLib" referenced but is not an allowed library + types \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\). Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake index c3d9a62..4e07ea6 100644 --- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake @@ -1,2 +1,2 @@ -add_library(NotObjLib STATIC a.c) +add_library(NotObjLib INTERFACE) add_library(A STATIC a.c $<TARGET_OBJECTS:NotObjLib>) diff --git a/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake b/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake new file mode 100644 index 0000000..0c85c72 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake @@ -0,0 +1,32 @@ +add_library(StaticLib STATIC a.c) + +add_custom_command(TARGET StaticLib POST_BUILD + VERBATIM + COMMAND ${CMAKE_COMMAND} + "-DTARGET_OBJECTS=$<TARGET_OBJECTS:StaticLib>" + -DEXPECTED_NUM_OBJECTFILES=2 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + ) + +add_library(SharedLib SHARED a.c b.c) +target_compile_definitions(SharedLib PRIVATE REQUIRED) + +add_custom_command(TARGET SharedLib POST_BUILD + VERBATIM + COMMAND ${CMAKE_COMMAND} + "-DTARGET_OBJECTS:STRING=$<TARGET_OBJECTS:SharedLib>" + -DEXPECTED_NUM_OBJECTFILES=2 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + ) + +add_executable(ExecObjs a.c b.c exe.c) +target_compile_definitions(ExecObjs PRIVATE REQUIRED) + +add_custom_target(check_exec_objs ALL + VERBATIM + COMMAND ${CMAKE_COMMAND} + "-DTARGET_OBJECTS=$<TARGET_OBJECTS:ExecObjs>" + -DEXPECTED_NUM_OBJECTFILES=3 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS ExecObjs + ) diff --git a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt index 40d650e..208f3c9 100644 --- a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt @@ -2,4 +2,6 @@ The SOURCES of "A" use a generator expression that depends on the SOURCES themselves. Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index 6ca33b8..5ec4018 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -37,6 +37,10 @@ function (run_object_lib_build2 name) run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .) endfunction () +if(NOT (RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")) + run_object_lib_build(CheckTargetObjects) +endif() + run_object_lib_build(LinkObjLHSShared) run_object_lib_build(LinkObjLHSStatic) run_object_lib_build(LinkObjRHSShared) @@ -54,6 +58,7 @@ run_cmake(PostBuild) run_cmake(PreBuild) run_cmake(PreLink) + function(run_Dependencies) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Dependencies-build) set(RunCMake_TEST_NO_CLEAN 1) diff --git a/Tests/RunCMake/ObjectLibrary/check_object_files.cmake b/Tests/RunCMake/ObjectLibrary/check_object_files.cmake new file mode 100644 index 0000000..3c34229 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/check_object_files.cmake @@ -0,0 +1,17 @@ + +if (NOT TARGET_OBJECTS) + message(SEND_ERROR "Object not passed as -DTARGET_OBJECTS") +endif() + +foreach(objlib_file IN LISTS objects) + message(STATUS "objlib_file: =${objlib_file}=") + + set(file_exists False) + if (EXISTS "${objlib_file}") + set(file_exists True) + endif() + + if (NOT file_exists) + message(SEND_ERROR "File \"${objlib_file}\" does not exist!${tried}") + endif() +endforeach() diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake index a696264..5880378 100644 --- a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake @@ -10,6 +10,7 @@ project(Minimal NONE) # set(targets aix-C-XL-13.1.3 aix-CXX-XL-13.1.3 + aix-C-XLClang-16.1.0.1 aix-CXX-XLClang-16.1.0.1 craype-C-Cray-8.7 craype-CXX-Cray-8.7 craype-Fortran-Cray-8.7 craype-C-Cray-9.0-hlist-ad craype-CXX-Cray-9.0-hlist-ad craype-Fortran-Cray-9.0-hlist-ad craype-C-GNU-7.3.0 craype-CXX-GNU-7.3.0 craype-Fortran-GNU-7.3.0 diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt b/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt index b854e2e..bffe819 100644 --- a/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt @@ -12,6 +12,9 @@ # cmake_minimum_required(VERSION 3.3) +if(POLICY CMP0089) + cmake_policy(SET CMP0089 NEW) +endif() set(lngs C CXX) set(LANGUAGES "${lngs}" CACHE STRING "List of languages to generate inputs for") diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.input new file mode 100644 index 0000000..2f018e6 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.input @@ -0,0 +1,40 @@ +CMAKE_LANG=C +CMAKE_C_COMPILER_ABI= +CMAKE_C_COMPILER_AR= +CMAKE_C_COMPILER_ARCHITECTURE_ID= +CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_C_COMPILER_ID=XLClang +CMAKE_C_COMPILER_LAUNCHER= +CMAKE_C_COMPILER_LOADED=1 +CMAKE_C_COMPILER_RANLIB= +CMAKE_C_COMPILER_TARGET= +CMAKE_C_COMPILER_VERSION=16.1.0.1 +CMAKE_C_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command(s):/usr/bin/gmake cmTC_fcf21/fast +/usr/bin/gmake -f CMakeFiles/cmTC_fcf21.dir/build.make CMakeFiles/cmTC_fcf21.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building C object CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o +/opt/IBM/xlC/16.1.0/bin/xlclang -V -o CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang +export XL_ASMOBJFILES=/tmp/xlcASuz87id +export "XL_DIS=/opt/IBM/xlc/16.1.0/exe/dis -o "CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o"" +/opt/IBM/xlC/16.1.0/exe/xlC2entry -qosvar=aix.7.2 -qalias=ansi -qthreaded -D_THREAD_SAFE -Wno-parentheses -Wno-unused-value -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -xc -qasm_as=/bin/as -qc_stdinc=/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -qvac_include_path=/opt/IBM/xlc/16.1.0/include -oCMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o /tmp/CMake/Modules/CMakeCCompilerABI.c /tmp/xlcW0tZ87ia /tmp/xlcW1ub87ib /dev/null /tmp/xlcLu487ieF.lst /dev/null /tmp/xlcW2uj87ic +export XL_BACKEND=/opt/IBM/xlc/16.1.0/exe/xlCcode +export XL_LINKER=/bin/ld +/opt/IBM/xlc/16.1.0/exe/xlCcode -qalias=ansi -qthreaded /tmp/xlcW0tZ87ia /tmp/xlcW1ub87ib CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o /tmp/xlcLu487ieB.lst /tmp/xlcW2uj87ic +rm /tmp/xlcASuz87id +rm /tmp/xlcLu487ie +rm /tmp/xlcW0tZ87ia +rm /tmp/xlcW1ub87ib +rm /tmp/xlcW2uj87ic +Linking C executable cmTC_fcf21 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_fcf21.dir/link.txt --verbose=1 +/opt/IBM/xlC/16.1.0/bin/xlclang -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -o cmTC_fcf21 -Wl,-blibpath:/usr/lib:/lib +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang +/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -o cmTC_fcf21 -blibpath:/usr/lib:/lib -L/opt/IBM/xlmass/9.1.0/lib/aix61 -L/opt/IBM/xlc/16.1.0/lib -lxlopt -lxlipa -lxl -lc -lpthreads +rm /tmp/xlcW0vJG7ia +rm /tmp/xlcW1vNG7ib +rm /tmp/xlcW2vRG7ic +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.output new file mode 100644 index 0000000..85399b7 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-C-XLClang-16.1.0.1.output @@ -0,0 +1 @@ +/opt/IBM/xlC/16.1.0/include2;/opt/IBM/xlC/16.1.0/include2/aix;/opt/IBM/xlmass/9.1.0/include;/usr/include diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.input b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.input new file mode 100644 index 0000000..da16db3 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.input @@ -0,0 +1,44 @@ +CMAKE_LANG=CXX +CMAKE_CXX_COMPILER_ABI= +CMAKE_CXX_COMPILER_AR= +CMAKE_CXX_COMPILER_ARCHITECTURE_ID= +CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN= +CMAKE_CXX_COMPILER_ID=XLClang +CMAKE_CXX_COMPILER_LAUNCHER= +CMAKE_CXX_COMPILER_LOADED=1 +CMAKE_CXX_COMPILER_RANLIB= +CMAKE_CXX_COMPILER_TARGET= +CMAKE_CXX_COMPILER_VERSION=16.1.0.1 +CMAKE_CXX_COMPILER_VERSION_INTERAL= +Change Dir: /tmp/ii/CMakeFiles/CMakeTmp + +Run Build Command(s):/usr/bin/gmake cmTC_b8490/fast +/usr/bin/gmake -f CMakeFiles/cmTC_b8490.dir/build.make CMakeFiles/cmTC_b8490.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building CXX object CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o +/opt/IBM/xlC/16.1.0/bin/xlclang++ -x c++ -V -o CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang++ +export XL_XLCMP_PATH=/opt/IBM/xlc/16.1.0:/opt/IBM/xlC/16.1.0 +export XL_COMPILER=xlc++ +export XL_ASMOBJFILES=/tmp/xlcAS3IXqid +export "XL_DIS=/opt/IBM/xlc/16.1.0/exe/dis -o "CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o"" +/opt/IBM/xlC/16.1.0/exe/xlC2entry -qosvar=aix.7.2 -qalias=ansi -qthreaded -D_THREAD_SAFE -Wno-parentheses -Wno-unused-value -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -xc++ -qasm_as=/bin/as -qcpp_stdinc=/opt/IBM/xlC/16.1.0/include2/c++:/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -qc_stdinc=/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -oCMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW03uXqia /tmp/xlcW137Xqib /dev/null /tmp/xlcL3QXqieF.lst /dev/null /tmp/xlcW23AXqic +export XL_BACKEND=/opt/IBM/xlc/16.1.0/exe/xlCcode +export XL_LINKER=/bin/ld +/opt/IBM/xlc/16.1.0/exe/xlCcode -qalias=ansi -qthreaded /tmp/xlcW03uXqia /tmp/xlcW137Xqib CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcL3QXqieB.lst /tmp/xlcW23AXqic +rm /tmp/xlcAS3IXqid +rm /tmp/xlcL3QXqie +rm /tmp/xlcW03uXqia +rm /tmp/xlcW137Xqib +rm /tmp/xlcW23AXqic +Linking CXX executable cmTC_b8490 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b8490.dir/link.txt --verbose=1 +/opt/IBM/xlC/16.1.0/bin/xlclang++ -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b8490 -Wl,-blibpath:/usr/lib:/lib +export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang++ +/bin/ld -b32 /lib/crt0.o /lib/crti.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b8490 -blibpath:/usr/lib:/lib -bcdtors:all:0:s -btmplrename -L/opt/IBM/xlmass/9.1.0/lib/aix61 -L/opt/IBM/xlc/16.1.0/lib -lxlopt -lxlipa -lxl -L/opt/IBM/xlC/16.1.0/lib -lc++ -lCcore -lpthreads -lm -lc | +/opt/IBM/xlC/16.1.0/bin/c++filt -S | +/bin/sed '/317.*::virtual-fn-table-ptr$/ s/^\(.*: \)*{*\([^}]*\)\(}*.*\)::virtual-fn-table-ptr$/\1Virtual table for class "\2": Some possible causes are: first non-inline virtual function in "\2" is not defined or the class is a template instantiation and an explicit instantiation definition of the class is missing./' +rm /tmp/xlcW05fS7ia +rm /tmp/xlcW15rS7ib +rm /tmp/xlcW25vS7ic +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.output new file mode 100644 index 0000000..7666f7e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitIncludeInfo/data/aix-CXX-XLClang-16.1.0.1.output @@ -0,0 +1 @@ +/opt/IBM/xlC/16.1.0/include2/c\+\+;/opt/IBM/xlC/16.1.0/include2;/opt/IBM/xlC/16.1.0/include2/aix;/opt/IBM/xlmass/9.1.0/include;/usr/include diff --git a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt index 16bcb36..66ff016 100644 --- a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt +++ b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt @@ -2,4 +2,4 @@ add_library(foo STATIC foo.cpp) string(TOLOWER ${CMAKE_CXX_COMPILER_ID} compiler_id) -target_compile_definitions(foo PRIVATE Foo=$<CXX_COMPILER_ID:${compiler_id}>) +target_compile_definitions(foo PRIVATE Foo=$<CXX_COMPILER_ID:invalid,${compiler_id}>) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 644da60..c743a02 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -101,8 +101,14 @@ function(run_cmake test) else() set(_D_CMAKE_GENERATOR_INSTANCE "") endif() + if(NOT RunCMake_TEST_NO_SOURCE_DIR) + set(maybe_source_dir "${RunCMake_TEST_SOURCE_DIR}") + else() + set(maybe_source_dir "") + endif() execute_process( - COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" + COMMAND ${CMAKE_COMMAND} + ${maybe_source_dir} -G "${RunCMake_GENERATOR}" -A "${RunCMake_GENERATOR_PLATFORM}" -T "${RunCMake_GENERATOR_TOOLSET}" @@ -185,5 +191,10 @@ function(run_cmake_command test) run_cmake(${test}) endfunction() +function(run_cmake_with_options test) + set(RunCMake_TEST_OPTIONS "${ARGN}") + run_cmake(${test}) +endfunction() + # Protect RunCMake tests from calling environment. unset(ENV{MAKEFLAGS}) diff --git a/Tests/RunCMake/Swift/E.swift b/Tests/RunCMake/Swift/E.swift new file mode 100644 index 0000000..a415467 --- /dev/null +++ b/Tests/RunCMake/Swift/E.swift @@ -0,0 +1,2 @@ +func f() { +} diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index 4864295..4817045 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -4,6 +4,10 @@ if(RunCMake_GENERATOR STREQUAL Xcode) if(XCODE_BELOW_6_1) run_cmake(XcodeTooOld) endif() +elseif(RunCMake_GENERATOR STREQUAL Ninja) + if(CMAKE_Swift_COMPILER) + run_cmake(Win32ExecutableDisallowed) + endif() else() run_cmake(NotSupported) endif() diff --git a/Tests/RunCMake/Swift/Win32ExecutableDisallowed-result.txt b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Swift/Win32ExecutableDisallowed-stderr.txt b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-stderr.txt new file mode 100644 index 0000000..d78101a --- /dev/null +++ b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at Win32ExecutableDisallowed.cmake:[0-9]+ \(add_executable\): + WIN32_EXECUTABLE property is not supported on Swift executables +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake b/Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake new file mode 100644 index 0000000..02d5447 --- /dev/null +++ b/Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake @@ -0,0 +1,4 @@ +enable_language(Swift) +add_executable(E E.swift) +set_target_properties(E PROPERTIES + WIN32_EXECUTABLE TRUE) diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt index 3f52244..f3ee895 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt +++ b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at UnterminatedCall1.cmake:2: +CMake Error at UnterminatedCall1.cmake:1: Parse error. Function missing ending "\)". End of file reached. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1.cmake b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake index 1166109..e1d2118 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall1.cmake +++ b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake @@ -1 +1,4 @@ message( + + +message("Additional message") diff --git a/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt index 18656f7..04216c3 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt +++ b/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at UnterminatedCall2.cmake:4: +CMake Error at UnterminatedCall2.cmake:3: Parse error. Function missing ending "\)". End of file reached. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/UnterminatedCall2.cmake b/Tests/RunCMake/Syntax/UnterminatedCall2.cmake index 26e9e62..8d4088d 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall2.cmake +++ b/Tests/RunCMake/Syntax/UnterminatedCall2.cmake @@ -1,3 +1,6 @@ set(var "\ ") message( + + +message("Additional message") diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt index a66794c..77c4afd 100644 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt @@ -1,8 +1,9 @@ -CMake Error at NotObjlibTarget.cmake:3 \(file\): +CMake Error at NotObjlibTarget.cmake:[0-9]+ \(file\): Error evaluating generator expression: - \$<TARGET_OBJECTS:StaticLib> + \$<TARGET_OBJECTS:IFaceLib> - Objects of target "StaticLib" referenced but is not an OBJECT library. + Objects of target "IFaceLib" referenced but is not an allowed library types + \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\). Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake index 3bb3e37..9fec369 100644 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake @@ -1,3 +1,3 @@ -add_library(StaticLib empty.cpp) +add_library(IFaceLib INTERFACE ) -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:StaticLib>) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:IFaceLib>) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt index fec12ae..6da79b7 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt @@ -47,4 +47,6 @@ \$<TARGET_PROPERTY:> \$<TARGET_PROPERTY:...> expression requires a non-empty property name. -*)+$ +*)+ ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt index 75865ad..d40b16b 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt @@ -5,4 +5,6 @@ CMake Error at BadNonTarget.cmake:7 \(include_directories\): Target "NonExistent" not found. Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt index f0f71ec..fa26861 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt @@ -34,4 +34,6 @@ \$<TARGET_PROPERTY:BadSelfReference6,COMPILE_DEFINITIONS> Self reference on target "BadSelfReference6". -*)+$ +*)+ ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/UseSWIG/CMP0086-common.cmake b/Tests/RunCMake/UseSWIG/CMP0086-common.cmake index c02592a..ef90218 100644 --- a/Tests/RunCMake/UseSWIG/CMP0086-common.cmake +++ b/Tests/RunCMake/UseSWIG/CMP0086-common.cmake @@ -8,4 +8,4 @@ include(UseSWIG) set_property (SOURCE example.i PROPERTY SWIG_MODULE_NAME "new_example") swig_add_library(example LANGUAGE python TYPE MODULE SOURCES example.i) -target_link_libraries(example PRIVATE Python::Python) +target_link_libraries(example PRIVATE Python::Module) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index df253a9..27b81b7 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,7 +1,9 @@ include(RunCMake) +cmake_policy(SET CMP0054 NEW) run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) +run_cmake(RuntimeLibrary) run_cmake(SourceGroupCMakeLists) run_cmake(VsConfigurationType) @@ -18,3 +20,13 @@ run_cmake(VsCSharpDeployFiles) run_cmake(VSCSharpDefines) run_cmake(VsSdkDirectories) run_cmake(VsGlobals) +run_cmake(VsProjectImport) +run_cmake(VsPackageReferences) + +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) + run_cmake(VsJustMyCode) +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20) + run_cmake(VsSpectreMitigation) +endif() diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake new file mode 100644 index 0000000..689b35f --- /dev/null +++ b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake @@ -0,0 +1,36 @@ +macro(RuntimeLibrary_check tgt rtl_expect) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(HAVE_Runtimelibrary 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<RuntimeLibrary>([^<>]+)</RuntimeLibrary>") + set(rtl_actual "${CMAKE_MATCH_1}") + if(NOT "${rtl_actual}" STREQUAL "${rtl_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has RuntimeLibrary '${rtl_actual}', not '${rtl_expect}'.") + return() + endif() + set(HAVE_Runtimelibrary 1) + break() + endif() + endforeach() + + if(NOT HAVE_Runtimelibrary AND NOT "${rtl_expect}" STREQUAL "") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a RuntimeLibrary field.") + return() + endif() +endmacro() + +RuntimeLibrary_check(default-C MultiThreadedDebugDLL) +RuntimeLibrary_check(default-CXX MultiThreadedDebugDLL) +RuntimeLibrary_check(empty-C "") +RuntimeLibrary_check(empty-CXX "") +RuntimeLibrary_check(MTd-C MultiThreadedDebug) +RuntimeLibrary_check(MTd-CXX MultiThreadedDebug) +RuntimeLibrary_check(MT-C MultiThreaded) +RuntimeLibrary_check(MT-CXX MultiThreaded) diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake new file mode 100644 index 0000000..d7787c8 --- /dev/null +++ b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake @@ -0,0 +1,20 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +cmake_policy(SET CMP0091 NEW) +enable_language(C) +enable_language(CXX) + +add_library(default-C empty.c) +add_library(default-CXX empty.cxx) + +set(CMAKE_MSVC_RUNTIME_LIBRARY "") +add_library(empty-C empty.c) +add_library(empty-CXX empty.cxx) + +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") +add_library(MTd-C empty.c) +add_library(MTd-CXX empty.cxx) + +add_library(MT-C empty.c) +set_property(TARGET MT-C PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") +add_library(MT-CXX empty.cxx) +set_property(TARGET MT-CXX PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") diff --git a/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake new file mode 100644 index 0000000..7119976 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake @@ -0,0 +1,38 @@ +macro(VsJustMyCode_check tgt jmc_expect) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(HAVE_JMC 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<SupportJustMyCode>([^<>]+)</SupportJustMyCode>") + set(jmc_actual "${CMAKE_MATCH_1}") + if(NOT "${jmc_actual}" STREQUAL "${jmc_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SupportJustMyCode> '${jmc_actual}', not '${jmc_expect}'.") + return() + endif() + set(HAVE_JMC 1) + break() + endif() + endforeach() + + if(NOT HAVE_JMC AND NOT "${jmc_expect}" STREQUAL "") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <SupportJustMyCode> property group.") + return() + endif() +endmacro() + +VsJustMyCode_check(JMC-default-C "") +VsJustMyCode_check(JMC-default-CXX "") +VsJustMyCode_check(JMC-ON-C true) +VsJustMyCode_check(JMC-ON-CXX true) +VsJustMyCode_check(JMC-OFF-C "") +VsJustMyCode_check(JMC-OFF-CXX "") +VsJustMyCode_check(JMC-TGT-ON-C true) +VsJustMyCode_check(JMC-TGT-ON-CXX true) +VsJustMyCode_check(JMC-TGT-OFF-C "") +VsJustMyCode_check(JMC-TGT-OFF-CXX "") diff --git a/Tests/RunCMake/VS10Project/VsJustMyCode.cmake b/Tests/RunCMake/VS10Project/VsJustMyCode.cmake new file mode 100644 index 0000000..b39f30f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsJustMyCode.cmake @@ -0,0 +1,24 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +enable_language(C) +enable_language(CXX) + +add_library(JMC-default-C empty.c) +add_library(JMC-default-CXX empty.cxx) + +set(CMAKE_VS_JUST_MY_CODE_DEBUGGING OFF) +add_library(JMC-OFF-C empty.c) +add_library(JMC-OFF-CXX empty.cxx) + +set(CMAKE_VS_JUST_MY_CODE_DEBUGGING ON) +add_library(JMC-ON-C empty.c) +add_library(JMC-ON-CXX empty.cxx) + +set(CMAKE_VS_JUST_MY_CODE_DEBUGGING OFF) +add_library(JMC-TGT-ON-C empty.c) +set_property(TARGET JMC-TGT-ON-C PROPERTY VS_JUST_MY_CODE_DEBUGGING ON) +add_library(JMC-TGT-ON-CXX empty.cxx) +set_property(TARGET JMC-TGT-ON-CXX PROPERTY VS_JUST_MY_CODE_DEBUGGING ON) +add_library(JMC-TGT-OFF-C empty.c) +set_property(TARGET JMC-TGT-OFF-C PROPERTY VS_JUST_MY_CODE_DEBUGGING OFF) +add_library(JMC-TGT-OFF-CXX empty.cxx) +set_property(TARGET JMC-TGT-OFF-CXX PROPERTY VS_JUST_MY_CODE_DEBUGGING OFF) diff --git a/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake new file mode 100644 index 0000000..4ff5327 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake @@ -0,0 +1,39 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file foo.vcxproj does not exist.") + return() +endif() + + +set(test1Library "boost") +set(test1Version "1.7.0") + + +set(test2Library "SFML") +set(test2Version "2.2.0") + +set(Library1Found FALSE) +set(Library2Found FALSE) + +file(STRINGS "${vcProjectFile}" lines) + +foreach(i 1 2) + set(testLibrary "${test${i}Library}") + set(testVersion "${test${i}Version}") + foreach(line IN LISTS lines) + if(line MATCHES "^ *<PackageReference Include=\"${testLibrary}\".*>$") + if(line MATCHES "^ *<PackageReference .* Version=\"${testVersion}\".*>$") + set(Library${i}Found TRUE) + message(STATUS "foo.vcxproj is using package reference ${testLibrary} with version ${testVersion}") + elseif() + message(STATUS "foo.vcxproj failed to define reference ${testLibrary} with version ${testVersion}") + set(Library${i}Found FALSE) + endif() + endif() + endforeach() +endforeach() + +if(NOT Library1Found OR NOT Library2Found) + set(RunCMake_TEST_FAILED "Failed to find package references") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsPackageReferences.cmake b/Tests/RunCMake/VS10Project/VsPackageReferences.cmake new file mode 100644 index 0000000..224ab18 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPackageReferences.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set_property(TARGET foo PROPERTY VS_PACKAGE_REFERENCES "boost_1.7.0;SFML_2.2.0") diff --git a/Tests/RunCMake/VS10Project/VsProjectImport-check.cmake b/Tests/RunCMake/VS10Project/VsProjectImport-check.cmake new file mode 100644 index 0000000..e438bf4 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsProjectImport-check.cmake @@ -0,0 +1,28 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(test1Import "path\\\\to\\\\nuget_packages\\\\Foo.1.0.0\\\\build\\\\Foo.props") +set(test2Import "path\\\\to\\\\nuget_packages\\\\Bar.1.0.0\\\\build\\\\Bar.props") + +set(import1Found FALSE) +set(import2Found FALSE) + +file(STRINGS "${vcProjectFile}" lines) + +foreach(i 1 2) + set(testImport "${test${i}Import}") + foreach(line IN LISTS lines) + if(line MATCHES "^ *<Import Project=\".*${test1Import}\" />$") + message(STATUS "foo.vcxproj is using project import ${testImport}") + set(import${i}Found TRUE) + endif() + endforeach() +endforeach() + +if(NOT import1Found OR NOT import2Found) + set(RunCMake_TEST_FAILED "Imported project not found.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsProjectImport.cmake b/Tests/RunCMake/VS10Project/VsProjectImport.cmake new file mode 100644 index 0000000..70bdded --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsProjectImport.cmake @@ -0,0 +1,11 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set(test1Import "path/to/nuget_packages/Foo.1.0.0/build/Foo.props") +set(test2Import "path/to/nuget_packages/Bar.1.0.0/build/Bar.props") + +set_property(TARGET foo PROPERTY + VS_PROJECT_IMPORT + ${test1Import} + ${test2Import} + ) diff --git a/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake b/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake new file mode 100644 index 0000000..6117763 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake @@ -0,0 +1,30 @@ +macro(VsSpectreMitigation_check tgt spectre_expect) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(HAVE_SpectreMitigation 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<SpectreMitigation>([^<>]+)</SpectreMitigation>") + set(spectre_actual "${CMAKE_MATCH_1}") + if(NOT "${spectre_actual}" STREQUAL "${spectre_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SpectreMitigation> '${spectre_actual}', not '${spectre_expect}'.") + return() + endif() + set(HAVE_SpectreMitigation 1) + break() + endif() + endforeach() + + if(NOT HAVE_SpectreMitigation AND NOT "${spectre_expect}" STREQUAL "") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <SpectreMitigation> field.") + return() + endif() +endmacro() + +VsSpectreMitigation_check(SpectreMitigationOn-C "Spectre") +VsSpectreMitigation_check(SpectreMitigationOff-C "false") diff --git a/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake b/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake new file mode 100644 index 0000000..b3779d7 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake @@ -0,0 +1,8 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +enable_language(C) + +add_library(SpectreMitigationOn-C empty.c) +target_compile_options(SpectreMitigationOn-C PRIVATE -Qspectre) + +add_library(SpectreMitigationOff-C empty.c) +target_compile_options(SpectreMitigationOff-C PRIVATE -Qspectre-) diff --git a/Tests/RunCMake/VS10Project/empty.c b/Tests/RunCMake/VS10Project/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/VS10Project/empty.c diff --git a/Tests/RunCMake/VS10Project/empty.cxx b/Tests/RunCMake/VS10Project/empty.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/VS10Project/empty.cxx diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake index 6ab3833..dab1c33 100644 --- a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake +++ b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake @@ -40,3 +40,62 @@ if(NOT FoundToolsVersion4) set(RunCMake_TEST_FAILED "Failed to find correct ToolsVersion=\"4.0\" .") return() endif() + +# +# Test solution file deployment items. +# + +set(vcSlnFile "${RunCMake_TEST_BINARY_DIR}/VsCEDebuggerDeploy.sln") +if(NOT EXISTS "${vcSlnFile}") + set(RunCMake_TEST_FAILED "Solution file ${vcSlnFile} does not exist.") + return() +endif() + + +if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsCE" ) + set(RunCMake_TEST_FAILED "Test only valid for WindowsCE") + return() +endif() + + +set(FooProjGUID "") +set(FoundFooProj FALSE) +set(InFooProj FALSE) +set(FoundReleaseDeploy FALSE) +set(DeployConfigs Debug MinSizeRel RelWithDebInfo ) + +file(STRINGS "${vcSlnFile}" lines) +foreach(line IN LISTS lines) +#message(STATUS "${line}") + if( (NOT InFooProj ) AND (line MATCHES "^[ \\t]*Project\\(\"{[A-F0-9-]+}\"\\) = \"foo\", \"foo.vcxproj\", \"({[A-F0-9-]+})\"[ \\t]*$")) + # First, identify the GUID for the foo project, and record it. + set(FoundFooProj TRUE) + set(InFooProj TRUE) + set(FooProjGUID ${CMAKE_MATCH_1}) + elseif(InFooProj AND line MATCHES "EndProject") + set(InFooProj FALSE) + elseif((NOT InFooProj) AND line MATCHES "${FooProjGUID}\\.Release.*\\.Deploy\\.0") + # If foo's Release configuration is set to deploy, this is the error. + set(FoundReleaseDeploy TRUE) + endif() + if( line MATCHES "{[A-F0-9-]+}\\.([^\\|]+).*\\.Deploy\\.0" ) + # Check that the other configurations ARE set to deploy. + list( REMOVE_ITEM DeployConfigs ${CMAKE_MATCH_1}) + endif() +endforeach() + +if(FoundReleaseDeploy) + set(RunCMake_TEST_FAILED "Release deployment not inhibited by VS_NO_SOLUTION_DEPLOY_Release.") + return() +endif() + +if(NOT FoundFooProj) + set(RunCMake_TEST_FAILED "Failed to find foo project in the solution.") + return() +endif() + +list(LENGTH DeployConfigs length) +if( length GREATER 0 ) + set(RunCMake_TEST_FAILED "Failed to find Deploy lines for non-Release configurations. (${length})") + return() +endif() diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake index 948f14c..611db0a 100644 --- a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake +++ b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake @@ -4,10 +4,11 @@ set(DEPLOY_DIR "temp\\foodir" ) -add_library(foo foo.cpp) +add_library(foo SHARED foo.cpp) set_target_properties(foo PROPERTIES DEPLOYMENT_ADDITIONAL_FILES "foo.dll|\\foo\\src\\dir\\on\\host|$(RemoteDirectory)|0;bar.dll|\\bar\\src\\dir|$(RemoteDirectory)bardir|0" DEPLOYMENT_REMOTE_DIRECTORY ${DEPLOY_DIR} + VS_NO_SOLUTION_DEPLOY $<CONFIG:Release> ) diff --git a/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt index ca8c33f..a63591f 100644 --- a/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt +++ b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt @@ -1 +1 @@ -CMake Error: Target visibility_preset uses unsupported value \"hiden\" for CXX_VISIBILITY_PRESET +CMake Error: Target visibility_preset uses unsupported value \"hiden\" for CXX_VISIBILITY_PRESET. The supported values are: default, hidden, protected, and internal. diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt index 46a294d..69c61e6 100644 --- a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt @@ -5,4 +5,6 @@ specified for source: - .*/Tests/RunCMake/XcodeProject/main.c$ + .*/Tests/RunCMake/XcodeProject/main.c ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt index 6500649..c3e9e31 100644 --- a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt @@ -5,4 +5,6 @@ specified for source: - .*/Tests/RunCMake/XcodeProject/main.c$ + .*/Tests/RunCMake/XcodeProject/main.c ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt index f9b8ee7..ff70b95 100644 --- a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt @@ -5,4 +5,6 @@ specified for source: - .*/Tests/RunCMake/XcodeProject/main.c$ + .*/Tests/RunCMake/XcodeProject/main.c ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt index bfca020..100008a 100644 --- a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt @@ -5,4 +5,6 @@ specified for source: - .*/Tests/RunCMake/XcodeProject/main.c$ + .*/Tests/RunCMake/XcodeProject/main.c ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake index f675d81..88077b3 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake @@ -7,6 +7,13 @@ function(check_property property matcher) endif() endfunction() +function(expect_no_schema target) + set(schema "${RunCMake_TEST_BINARY_DIR}/XcodeSchemaProperty.xcodeproj/xcshareddata/xcschemes/${target}.xcscheme") + if(EXISTS ${schema}) + message(SEND_ERROR "Found unexpected schema ${schema}") + endif() +endfunction() + check_property("ADDRESS_SANITIZER" "enableAddressSanitizer") check_property("ADDRESS_SANITIZER_USE_AFTER_RETURN" "enableASanStackUseAfterReturn") check_property("THREAD_SANITIZER" "enableThreadSanitizer") @@ -31,3 +38,5 @@ check_property("ENVIRONMENT" [=[key="FOO"]=]) check_property("ENVIRONMENT" [=[value="foo"]=]) check_property("ENVIRONMENT" [=[key="BAR"]=]) check_property("ENVIRONMENT" [=[value="bar"]=]) + +expect_no_schema("NoSchema") diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake index 2b72a64..73ef5ca 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake @@ -35,3 +35,6 @@ endfunction() create_scheme_for_property(EXECUTABLE myExecutable) create_scheme_for_property(ARGUMENTS "--foo;--bar=baz") create_scheme_for_property(ENVIRONMENT "FOO=foo;BAR=bar") + +add_executable(NoSchema main.cpp) +set_target_properties(NoSchema PROPERTIES XCODE_GENERATE_SCHEME OFF) diff --git a/Tests/RunCMake/add_executable/NoSources-stderr.txt b/Tests/RunCMake/add_executable/NoSources-stderr.txt index 4fcfd49..abefc6d 100644 --- a/Tests/RunCMake/add_executable/NoSources-stderr.txt +++ b/Tests/RunCMake/add_executable/NoSources-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at NoSources.cmake:[0-9]+ \(add_executable\): No SOURCES given to target: TestExeWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt index 5561daa..80026bf 100644 --- a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt +++ b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at NoSourcesButLinkObjects.cmake:[0-9]+ \(add_executable\): No SOURCES given to target: TestExeWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt b/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt index 41da381..72b92ce 100644 --- a/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt +++ b/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at MODULEwithNoSources.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestModuleLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt index 67dd87c..1490524 100644 --- a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt +++ b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at MODULEwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestModuleLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt index 20d3a8a..be7634c 100644 --- a/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt +++ b/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at OBJECTwithNoSources.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestObjectLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt index 1bcc114..3f85916 100644 --- a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt +++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at OBJECTwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestObjectLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt b/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt index 5cedd62..471eda1 100644 --- a/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt +++ b/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at SHAREDwithNoSources.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestSharedLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt index d621e76..4bec7ae 100644 --- a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt +++ b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at SHAREDwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestSharedLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt b/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt index 10b2112..f655221 100644 --- a/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt +++ b/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at STATICwithNoSources.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestStaticLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt index 33c23b2..185aad8 100644 --- a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt +++ b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at STATICwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\): No SOURCES given to target: TestStaticLibWithoutSources Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake b/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake new file mode 100644 index 0000000..561f9c0 --- /dev/null +++ b/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake @@ -0,0 +1,133 @@ +include(${CMAKE_CURRENT_LIST_DIR}/test_utils.cmake) + +# No keywords that miss any values, _KEYWORDS_MISSING_VALUES should not be defined +cmake_parse_arguments(PREF "" "P1" "P2" P1 p1 P2 p2_a p2_b) + +TEST(PREF_KEYWORDS_MISSING_VALUES "UNDEFINED") + +# Keyword should even be deleted from the actual scope +set(PREF_KEYWORDS_MISSING_VALUES "What ever") +cmake_parse_arguments(PREF "" "" "") + +TEST(PREF_KEYWORDS_MISSING_VALUES "UNDEFINED") + +# Given missing keywords as only option +cmake_parse_arguments(PREF "" "P1" "P2" P1) + +TEST(PREF_KEYWORDS_MISSING_VALUES "P1") +TEST(PREF_P1 "UNDEFINED") +TEST(PREF_UNPARSED_ARGUMENTS "UNDEFINED") + +# Mixed with unparsed arguments +cmake_parse_arguments(UPREF "" "P1" "P2" A B P2 C P1) +TEST(UPREF_KEYWORDS_MISSING_VALUES "P1") +TEST(UPREF_UNPARSED_ARGUMENTS A B) + +# one_value_keyword followed by option +cmake_parse_arguments(REF "OP" "P1" "" P1 OP) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_OP "TRUE") + +# Counter Test +cmake_parse_arguments(REF "OP" "P1" "" P1 p1 OP) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_OP "TRUE") + +# one_value_keyword followed by a one_value_keyword +cmake_parse_arguments(REF "" "P1;P2" "" P1 P2 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "p2") + +# Counter Test +cmake_parse_arguments(REF "" "P1;P2" "" P1 p1 P2 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "p2") + +# one_value_keyword followed by a multi_value_keywords +cmake_parse_arguments(REF "" "P1" "P2" P1 P2 p1 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 p1 p2) + +# Counter Examples +cmake_parse_arguments(REF "" "P1" "P2" P1 p1 P2 p1 p2) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 p1 p2) + +# multi_value_keywords as only option +cmake_parse_arguments(REF "" "P1" "P2" P2) +TEST(REF_KEYWORDS_MISSING_VALUES "P2") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# multi_value_keywords followed by option +cmake_parse_arguments(REF "O1" "" "P1" P1 O1) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_O1 "TRUE") + +# counter test +cmake_parse_arguments(REF "O1" "" "P1" P1 p1 p2 O1) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1;p2") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_O1 "TRUE") + +# multi_value_keywords followed by one_value_keyword +cmake_parse_arguments(REF "" "P1" "P2" P2 P1 p1) +TEST(REF_KEYWORDS_MISSING_VALUES "P2") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# counter test +cmake_parse_arguments(REF "" "P1" "P2" P2 p2 P1 p1) +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_P1 "p1") +TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED") +TEST(REF_P2 "p2") + +# one_value_keyword as last argument +cmake_parse_arguments(REF "" "P1" "P2" A P2 p2 P1) +TEST(REF_KEYWORDS_MISSING_VALUES "P1") +TEST(REF_P1 "UNDEFINED") +TEST(REF_UNPARSED_ARGUMENTS "A") +TEST(REF_P2 "p2") + +# multi_value_keywords as last argument +cmake_parse_arguments(REF "" "P1" "P2" P1 p1 P2) +TEST(REF_KEYWORDS_MISSING_VALUES "P2") +TEST(REF_P1 "p1") +TEST(REF_P2 "UNDEFINED") + +# Multiple one_value_keyword and multi_value_keywords at different places +cmake_parse_arguments(REF "O1;O2" "P1" "P2" P1 O1 P2 O2) +TEST(REF_KEYWORDS_MISSING_VALUES P1 P2) +TEST(REF_P1 "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# Duplicated missing keywords +cmake_parse_arguments(REF "O1;O2" "P1" "P2" P1 O1 P2 O2 P1 P2) +TEST(REF_KEYWORDS_MISSING_VALUES P1 P2) +TEST(REF_P1 "UNDEFINED") +TEST(REF_P2 "UNDEFINED") + +# make sure keywords that are never used, don't get added to KEYWORDS_MISSING_VALUES +cmake_parse_arguments(REF "O1;O2" "P1" "P2") +TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED") +TEST(REF_O1 FALSE) +TEST(REF_O2 FALSE) +TEST(REF_P1 UNDEFINED) +TEST(REF_P2 UNDEFINED) diff --git a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake index 1e15b3b..505840d 100644 --- a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake @@ -11,3 +11,4 @@ run_cmake(BadArgvN2) run_cmake(BadArgvN3) run_cmake(BadArgvN4) run_cmake(CornerCasesArgvN) +run_cmake(KeyWordsMissingValues) diff --git a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake index 4d7d29b..78856b4 100644 --- a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake @@ -31,7 +31,7 @@ run_ctest_submit(CDashUploadNone CDASH_UPLOAD) run_ctest_submit(CDashUploadMissingFile CDASH_UPLOAD bad-upload) run_ctest_submit(CDashUploadRetry CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo RETRY_COUNT 2 RETRY_DELAY 1 INTERNAL_TEST_CHECKSUM) run_ctest_submit(CDashSubmitQuiet QUIET) -run_ctest_submit_debug(CDashSubmitVerbose) +run_ctest_submit_debug(CDashSubmitVerbose BUILD_ID my_build_id) run_ctest_submit_debug(FILESNoBuildId FILES ${CMAKE_CURRENT_LIST_FILE}) run_ctest_submit_debug(CDashSubmitHeaders HTTPHEADER "Authorization: Bearer asdf") run_ctest_submit_debug(CDashUploadHeaders CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo HTTPHEADER "Authorization: Bearer asdf") diff --git a/Tests/RunCMake/ctest_update/CMakeLists.txt.in b/Tests/RunCMake/ctest_update/CMakeLists.txt.in new file mode 100644 index 0000000..ecf0e54 --- /dev/null +++ b/Tests/RunCMake/ctest_update/CMakeLists.txt.in @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.1) +project(CTestTest@CASE_NAME@ NONE) +include(CTest) +@CASE_CMAKELISTS_SUFFIX_CODE@ diff --git a/Tests/RunCMake/ctest_update/RunCMakeTest.cmake b/Tests/RunCMake/ctest_update/RunCMakeTest.cmake new file mode 100644 index 0000000..f8d7665 --- /dev/null +++ b/Tests/RunCMake/ctest_update/RunCMakeTest.cmake @@ -0,0 +1,25 @@ +include(RunCTest) +set(CASE_CTEST_UPDATE_ARGS "") +function(run_ctest_update CASE_NAME) + set(CASE_CTEST_UPDATE_ARGS "${ARGN}") + run_ctest(${CASE_NAME}) +endfunction() + +run_ctest_update(UpdateQuiet QUIET) + +function(run_UpdateChangeId) + set(CASE_TEST_PREFIX_CODE [[ + set(CTEST_CHANGE_ID "<>1") + ]]) + + run_ctest(UpdateChangeId) +endfunction() +run_UpdateChangeId() + +function(run_UpdateVersionOverride) + set(CASE_TEST_PREFIX_CODE [[ + set(CTEST_UPDATE_VERSION_OVERRIDE "qwertyuiop") + ]]) + run_ctest(UpdateVersionOverride) +endfunction() +run_UpdateVersionOverride() diff --git a/Tests/RunCMake/ctest_update/UpdateActualVersion-check.cmake b/Tests/RunCMake/ctest_update/UpdateActualVersion-check.cmake new file mode 100644 index 0000000..12bd5a0 --- /dev/null +++ b/Tests/RunCMake/ctest_update/UpdateActualVersion-check.cmake @@ -0,0 +1,12 @@ +file(GLOB update_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Update.xml") +if(update_xml_file) + file(READ "${update_xml_file}" update_xml LIMIT 4096) + if(NOT update_xml MATCHES "qwertyuiop") + string(REPLACE "\n" "\n " update_xml " ${update_xml}") + set(RunCMake_TEST_FAILED + "Did not find 'qwertyuiop' in Update.xml:\n${update_xml}" + ) + endif() +else() + set(RunCMake_TEST_FAILED "Update.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_update/UpdateChangeId-check.cmake b/Tests/RunCMake/ctest_update/UpdateChangeId-check.cmake new file mode 100644 index 0000000..382fbec --- /dev/null +++ b/Tests/RunCMake/ctest_update/UpdateChangeId-check.cmake @@ -0,0 +1,12 @@ +file(GLOB update_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Update.xml") +if(update_xml_file) + file(READ "${update_xml_file}" update_xml LIMIT 4096) + if(NOT update_xml MATCHES [[ChangeId><>1]]) + string(REPLACE "\n" "\n " update_xml " ${update_xml}") + set(RunCMake_TEST_FAILED + "Update.xml does not have expected ChangeId:\n${update_xml}" + ) + endif() +else() + set(RunCMake_TEST_FAILED "Update.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_update/test.cmake.in b/Tests/RunCMake/ctest_update/test.cmake.in new file mode 100644 index 0000000..25b8423 --- /dev/null +++ b/Tests/RunCMake/ctest_update/test.cmake.in @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.1) +@CASE_TEST_PREFIX_CODE@ + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +# FIXME: update test to do someting meaningful with this. +set(CTEST_UPDATE_COMMAND "not-actually-used") + +set(ctest_test_args "@CASE_CTEST_UPDATE_ARGS@") +ctest_start(Experimental) +ctest_update(${ctest_update_args}) diff --git a/Tests/RunCMake/execute_process/EchoCommand-result.txt b/Tests/RunCMake/execute_process/EchoCommand-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/EchoCommand-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand-stderr.txt new file mode 100644 index 0000000..f10ece8 --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand-stderr.txt @@ -0,0 +1,5 @@ +.*cmake.*-E' 'echo' '-- 2 COMMAND_ECHO STDERR' +.*cmake.*-E' 'echo' '-- 4 COMMAND_ECHO STDERR' +.*cmake.*-E' 'echo' '-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR' +CMake Error at .*EchoCommand.cmake:.* \(execute_process\): + CMAKE_EXECUTE_PROCESS_COMMAND_ECHO set to 'BAD' expected STDERR|STDOUT|NONE$ diff --git a/Tests/RunCMake/execute_process/EchoCommand-stdout.txt b/Tests/RunCMake/execute_process/EchoCommand-stdout.txt new file mode 100644 index 0000000..0954b3b --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand-stdout.txt @@ -0,0 +1,12 @@ +.*cmake.*-E' 'echo' '-- 1 COMMAND_ECHO STDOUT' +-- 1 COMMAND_ECHO STDOUT +-- 2 COMMAND_ECHO STDERR +.*cmake.* '-E' 'echo' '-- 3 COMMAND_ECHO STDOUT' +-- 3 COMMAND_ECHO STDOUT +-- 4 COMMAND_ECHO STDERR +.*cmake.* '-E' 'echo' '-- 5 COMMAND_ECHO STDOUT' +-- 5 COMMAND_ECHO STDOUT +-- 6 COMMAND_ECHO NONE +.*cmake.* '-E' 'echo' '-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT' +-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT +-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR$ diff --git a/Tests/RunCMake/execute_process/EchoCommand.cmake b/Tests/RunCMake/execute_process/EchoCommand.cmake new file mode 100644 index 0000000..9c7d13d --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand.cmake @@ -0,0 +1,41 @@ +if(CHECK_ERROR_OUTPUT_LOCATION) + execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 1 COMMAND_ECHO " COMMAND_ECHO ) +endif() +# test COMMAND_ECHO STDOUT +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 1 COMMAND_ECHO STDOUT" COMMAND_ECHO STDOUT ) +# test COMMAND_ECHO STDERR +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 2 COMMAND_ECHO STDERR" COMMAND_ECHO STDERR ) +# test CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT +set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT) +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 3 COMMAND_ECHO STDOUT" ) +# test CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDERR +set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDERR) +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 4 COMMAND_ECHO STDERR" ) +# make sure local will override global settings +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 5 COMMAND_ECHO STDOUT" COMMAND_ECHO STDOUT ) +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 6 COMMAND_ECHO NONE" COMMAND_ECHO NONE) +# test both and make sure override works +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT" COMMAND_ECHO STDERR + COMMAND_ECHO STDOUT) +execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR" COMMAND_ECHO STDOUT + COMMAND_ECHO STDERR) + +# check for bad arguments to global and local +if(CHECK_GLOBAL) + # make sure a non STDERR or STDOUT value is an error + set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO BAD) + execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 9 - 1 CMAKE_EXECUTE_PROCESS_COMMAND_ECHO BAD" ) +else() + execute_process(COMMAND ${CMAKE_COMMAND} -E echo + "-- 9 - 2 COMMAND_ECHO BAD" COMMAND_ECHO BAD) +endif() diff --git a/Tests/RunCMake/execute_process/EchoCommand2-result.txt b/Tests/RunCMake/execute_process/EchoCommand2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt new file mode 100644 index 0000000..4ae01c4 --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt @@ -0,0 +1,5 @@ +.*cmake.*-E' 'echo' '-- 2 COMMAND_ECHO STDERR' +.*cmake.*-E' 'echo' '-- 4 COMMAND_ECHO STDERR' +.*cmake.*-E' 'echo' '-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR' +CMake Error at .*EchoCommand.cmake:.* \(execute_process\): + called with 'BAD' expected STDERR|STDOUT|NONE for COMMAND_ECHO.$ diff --git a/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt b/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt new file mode 100644 index 0000000..0954b3b --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt @@ -0,0 +1,12 @@ +.*cmake.*-E' 'echo' '-- 1 COMMAND_ECHO STDOUT' +-- 1 COMMAND_ECHO STDOUT +-- 2 COMMAND_ECHO STDERR +.*cmake.* '-E' 'echo' '-- 3 COMMAND_ECHO STDOUT' +-- 3 COMMAND_ECHO STDOUT +-- 4 COMMAND_ECHO STDERR +.*cmake.* '-E' 'echo' '-- 5 COMMAND_ECHO STDOUT' +-- 5 COMMAND_ECHO STDOUT +-- 6 COMMAND_ECHO NONE +.*cmake.* '-E' 'echo' '-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT' +-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT +-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR$ diff --git a/Tests/RunCMake/execute_process/EchoCommand3-result.txt b/Tests/RunCMake/execute_process/EchoCommand3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt new file mode 100644 index 0000000..e27f1e6 --- /dev/null +++ b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*EchoCommand.cmake:.*\(execute_process\): + execute_process called with no value for COMMAND_ECHO. diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index cb40b40..b203aab 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -16,3 +16,11 @@ endif() if(EXIT_CODE_EXE) run_cmake_command(ExitValues ${CMAKE_COMMAND} -DEXIT_CODE_EXE=${EXIT_CODE_EXE} -P ${RunCMake_SOURCE_DIR}/ExitValues.cmake) endif() + +run_cmake_command(EchoCommand ${CMAKE_COMMAND} -DCHECK_GLOBAL=TRUE + -P ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) +run_cmake_command(EchoCommand2 ${CMAKE_COMMAND} -P + ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) +run_cmake_command(EchoCommand3 ${CMAKE_COMMAND} + -DCHECK_ERROR_OUTPUT_LOCATION=TRUE -P + ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) diff --git a/Tests/RunCMake/export/AppendExport-stderr.txt b/Tests/RunCMake/export/AppendExport-stderr.txt index d71620e..d12124c 100644 --- a/Tests/RunCMake/export/AppendExport-stderr.txt +++ b/Tests/RunCMake/export/AppendExport-stderr.txt @@ -1,4 +1,4 @@ CMake Error at AppendExport.cmake:[0-9]+ \(export\): - export EXPORT signature does not recognise the APPEND option. + export Unknown argument: "APPEND". Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/Empty.cmake b/Tests/RunCMake/export/Empty.cmake new file mode 100644 index 0000000..2198ddf --- /dev/null +++ b/Tests/RunCMake/export/Empty.cmake @@ -0,0 +1 @@ +export(TARGETS FILE targets.cmake) diff --git a/Tests/RunCMake/export/OldIface-stderr.txt b/Tests/RunCMake/export/OldIface-stderr.txt index 818c2cb..3cc1033 100644 --- a/Tests/RunCMake/export/OldIface-stderr.txt +++ b/Tests/RunCMake/export/OldIface-stderr.txt @@ -1,5 +1,4 @@ CMake Error at OldIface.cmake:[0-9]+ \(export\): - export EXPORT signature does not recognise the - EXPORT_LINK_INTERFACE_LIBRARIES option. + export Unknown argument: "EXPORT_LINK_INTERFACE_LIBRARIES". Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 46bb1fc..97a0ca6 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -1,6 +1,7 @@ include(RunCMake) run_cmake(CustomTarget) +run_cmake(Empty) run_cmake(TargetNotFound) run_cmake(AppendExport) run_cmake(OldIface) diff --git a/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake b/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake new file mode 100644 index 0000000..d8a12eb --- /dev/null +++ b/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake @@ -0,0 +1,168 @@ +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dest1") + +file(TOUCH "${CMAKE_BINARY_DIR}/file1.txt") +file(CREATE_LINK file1.txt "${CMAKE_BINARY_DIR}/file1.txt.sym" SYMBOLIC) +file(TOUCH "${CMAKE_BINARY_DIR}/dest1/file1.txt.sym") + +file(TOUCH "${CMAKE_BINARY_DIR}/file2.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file2") +file(CREATE_LINK ../file2.txt "${CMAKE_BINARY_DIR}/file2/file2.txt.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file3.txt") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file3.txt" "${CMAKE_BINARY_DIR}/file3.txt.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file4.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file4") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file4.txt" "${CMAKE_BINARY_DIR}/file4/file4.txt.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file5.txt") + +file(TOUCH "${CMAKE_BINARY_DIR}/file6.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file6/file6") +file(CREATE_LINK file6.txt "${CMAKE_BINARY_DIR}/file6.txt.sym.1" SYMBOLIC) +file(CREATE_LINK ../file6.txt.sym.1 "${CMAKE_BINARY_DIR}/file6/file6.txt.sym.2" SYMBOLIC) +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file6/file6.txt.sym.2" "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.3" SYMBOLIC) +file(CREATE_LINK file6.txt.sym.3 "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file7.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file7") + +file(TOUCH "${CMAKE_BINARY_DIR}/file8.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file8") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file8/../file8.txt" "${CMAKE_BINARY_DIR}/file8/file8.txt.sym" SYMBOLIC) + +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file9") +file(TOUCH "${CMAKE_BINARY_DIR}/file9/file9.txt") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file9" "${CMAKE_BINARY_DIR}/file9.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file10.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file10") +file(CREATE_LINK "." "${CMAKE_BINARY_DIR}/file10/file10" SYMBOLIC) +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file10/file10/../file10.txt" "${CMAKE_BINARY_DIR}/file10/file10.txt.sym" SYMBOLIC) + +file(INSTALL + "${CMAKE_BINARY_DIR}/file1.txt.sym" + DESTINATION "${CMAKE_BINARY_DIR}/dest1" + FOLLOW_SYMLINK_CHAIN + ) + +file(INSTALL + "${CMAKE_BINARY_DIR}/file1.txt.sym" + "${CMAKE_BINARY_DIR}/file2/file2.txt.sym" + "${CMAKE_BINARY_DIR}/file3.txt.sym" + "${CMAKE_BINARY_DIR}/file4/file4.txt.sym" + "${CMAKE_BINARY_DIR}/file5.txt" + "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4" + "${CMAKE_BINARY_DIR}/file8/file8.txt.sym" + "${CMAKE_BINARY_DIR}/file7/../file7.txt" + "${CMAKE_BINARY_DIR}/file8.txt" + "${CMAKE_BINARY_DIR}/file9.sym/file9.txt" + "${CMAKE_BINARY_DIR}/file10/file10/file10.txt.sym" + DESTINATION "${CMAKE_BINARY_DIR}/dest2" + FOLLOW_SYMLINK_CHAIN + ) + +set(resolved_file1.txt.sym file1.txt) +set(resolved_file10.txt.sym file10.txt) +set(resolved_file2.txt.sym file2.txt) +set(resolved_file3.txt.sym file3.txt) +set(resolved_file4.txt.sym file4.txt) +set(resolved_file6.txt.sym.1 file6.txt) +set(resolved_file6.txt.sym.2 file6.txt.sym.1) +set(resolved_file6.txt.sym.3 file6.txt.sym.2) +set(resolved_file6.txt.sym.4 file6.txt.sym.3) +set(resolved_file8.txt.sym file8.txt) +set(syms) +foreach(f + file1.txt + file1.txt.sym + file10.txt + file10.txt.sym + file2.txt + file2.txt.sym + file3.txt + file3.txt.sym + file4.txt + file4.txt.sym + file5.txt + file6.txt + file6.txt.sym.1 + file6.txt.sym.2 + file6.txt.sym.3 + file6.txt.sym.4 + file7.txt + file8.txt + file8.txt.sym + file9.txt + ) + string(REPLACE "." "\\." r "${f}") + list(APPEND syms "[^;]*/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/dest2/${r}") + set(filename "${CMAKE_BINARY_DIR}/dest2/${f}") + if(DEFINED resolved_${f}) + file(READ_SYMLINK "${filename}" resolved) + if(NOT resolved STREQUAL "${resolved_${f}}") + message(SEND_ERROR "Expected symlink resolution for ${f}: ${resolved_${f}}\nActual resolution: ${resolved}") + endif() + elseif(NOT EXISTS "${filename}" OR IS_SYMLINK "${filename}" OR IS_DIRECTORY "${filename}") + message(SEND_ERROR "${f} should be a regular file") + endif() +endforeach() + +file(GLOB_RECURSE actual_syms LIST_DIRECTORIES true "${CMAKE_BINARY_DIR}/dest2/*") +if(NOT actual_syms MATCHES "^${syms}$") + message(SEND_ERROR "Expected files:\n\n ^${syms}$\n\nActual files:\n\n ${actual_syms}") +endif() + +file(INSTALL + "${CMAKE_BINARY_DIR}/file1.txt.sym" + "${CMAKE_BINARY_DIR}/file2/file2.txt.sym" + "${CMAKE_BINARY_DIR}/file3.txt.sym" + "${CMAKE_BINARY_DIR}/file4/file4.txt.sym" + "${CMAKE_BINARY_DIR}/file5.txt" + "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4" + "${CMAKE_BINARY_DIR}/file8/file8.txt.sym" + "${CMAKE_BINARY_DIR}/file7/../file7.txt" + "${CMAKE_BINARY_DIR}/file8.txt" + "${CMAKE_BINARY_DIR}/file9.sym/file9.txt" + "${CMAKE_BINARY_DIR}/file10/file10/file10.txt.sym" + DESTINATION "${CMAKE_BINARY_DIR}/dest3" + ) + +set(resolved_file1.txt.sym [[^file1\.txt$]]) +set(resolved_file10.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file10/file10/\.\./file10\.txt$]]) +set(resolved_file2.txt.sym [[^\.\./file2\.txt$]]) +set(resolved_file3.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file3\.txt$]]) +set(resolved_file4.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file4\.txt$]]) +set(resolved_file6.txt.sym.4 [[^file6\.txt\.sym\.3$]]) +set(resolved_file8.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file8/\.\./file8\.txt$]]) +set(syms) +foreach(f + file1.txt.sym + file10.txt.sym + file2.txt.sym + file3.txt.sym + file4.txt.sym + file5.txt + file6.txt.sym.4 + file7.txt + file8.txt + file8.txt.sym + file9.txt + ) + string(REPLACE "." "\\." r "${f}") + list(APPEND syms "[^;]*/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/dest3/${r}") + set(filename "${CMAKE_BINARY_DIR}/dest3/${f}") + if(DEFINED resolved_${f}) + file(READ_SYMLINK "${filename}" resolved) + if(NOT resolved MATCHES "${resolved_${f}}") + message(SEND_ERROR "Expected symlink resolution for ${f}: ${resolved_${f}}\nActual resolution: ${resolved}") + endif() + elseif(NOT EXISTS "${filename}" OR IS_SYMLINK "${filename}" OR IS_DIRECTORY "${filename}") + message(SEND_ERROR "${f} should be a regular file") + endif() +endforeach() + +file(GLOB_RECURSE actual_syms LIST_DIRECTORIES true "${CMAKE_BINARY_DIR}/dest3/*") +if(NOT actual_syms MATCHES "^${syms}$") + message(SEND_ERROR "Expected files:\n\n ^${syms}$\n\nActual files:\n\n ${actual_syms}") +endif() diff --git a/Tests/RunCMake/file/REMOVE-empty-stderr.txt b/Tests/RunCMake/file/REMOVE-empty-stderr.txt new file mode 100644 index 0000000..898a6e1 --- /dev/null +++ b/Tests/RunCMake/file/REMOVE-empty-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at REMOVE-empty.cmake:1 \(file\): + Ignoring empty file name in REMOVE. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9] \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at REMOVE-empty.cmake:2 \(file\): + Ignoring empty file name in REMOVE_RECURSE. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9] \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/file/REMOVE-empty.cmake b/Tests/RunCMake/file/REMOVE-empty.cmake new file mode 100644 index 0000000..38046fb --- /dev/null +++ b/Tests/RunCMake/file/REMOVE-empty.cmake @@ -0,0 +1,2 @@ +file(REMOVE "") +file(REMOVE_RECURSE "") diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 128e8f3..5db4b3b 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -43,6 +43,8 @@ run_cmake(GLOB_RECURSE-noexp-FOLLOW_SYMLINKS) run_cmake(SIZE) run_cmake(SIZE-error-does-not-exist) +run_cmake(REMOVE-empty) + # tests are valid both for GLOB and GLOB_RECURSE run_cmake(GLOB-sort-dedup) run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean) @@ -64,6 +66,7 @@ if(NOT WIN32 OR CYGWIN) run_cmake(READ_SYMLINK) run_cmake(READ_SYMLINK-noexist) run_cmake(READ_SYMLINK-notsymlink) + run_cmake(INSTALL-FOLLOW_SYMLINK_CHAIN) endif() if(RunCMake_GENERATOR STREQUAL "Ninja") diff --git a/Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt b/Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt new file mode 100644 index 0000000..8f21eb8 --- /dev/null +++ b/Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt @@ -0,0 +1 @@ +-- VAR-NOTFOUND diff --git a/Tests/RunCMake/find_path/EmptyOldStyle.cmake b/Tests/RunCMake/find_path/EmptyOldStyle.cmake new file mode 100644 index 0000000..d78bb65 --- /dev/null +++ b/Tests/RunCMake/find_path/EmptyOldStyle.cmake @@ -0,0 +1,2 @@ +find_path(VAR ONLY_CMAKE_FIND_ROOT_PATH) +message(STATUS "${VAR}") diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake index bf0fa89..3afbedc 100644 --- a/Tests/RunCMake/find_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(EmptyOldStyle) if(WIN32 OR CYGWIN) run_cmake(PrefixInPATH) endif() diff --git a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake index c41cb2a..15335b2 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake @@ -4,6 +4,8 @@ if(WIN32) [[bin/exe\.exe]] [[bin/(lib)?lib1\.dll]] [[include]] + [[include/obj1\.h]] + [[include/obj2\.h]] [[include/obj4\.h]] [[include/obj5\.h]] [[lib]] @@ -20,6 +22,8 @@ elseif(CYGWIN) [[bin/cyglib1\.dll]] [[bin/exe\.exe]] [[include]] + [[include/obj1\.h]] + [[include/obj2\.h]] [[include/obj4\.h]] [[include/obj5\.h]] [[lib]] @@ -35,6 +39,8 @@ else() [[bin]] [[bin/exe]] [[include]] + [[include/obj1\.h]] + [[include/obj2\.h]] [[include/obj4\.h]] [[include/obj5\.h]] [[lib]] diff --git a/Tests/RunCMake/install/TARGETS-Defaults.cmake b/Tests/RunCMake/install/TARGETS-Defaults.cmake index bfd8c2c..324aa11 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults.cmake @@ -8,6 +8,11 @@ set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj add_library(lib4 SHARED obj5.c) set_property(TARGET lib4 PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj5.h) +add_library(iface INTERFACE) +set_target_properties(iface PROPERTIES + PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj1.h + PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj2.h) + install(TARGETS exe lib1 lib2) install(TARGETS lib3 LIBRARY DESTINATION lib3 @@ -17,3 +22,6 @@ install(TARGETS lib4 LIBRARY DESTINATION lib4 RUNTIME DESTINATION lib4 ) +install(TARGETS iface + PUBLIC_HEADER DESTINATION include + PRIVATE_HEADER DESTINATION include) diff --git a/Tests/RunCMake/install/obj2.h b/Tests/RunCMake/install/obj2.h new file mode 100644 index 0000000..90bcd34 --- /dev/null +++ b/Tests/RunCMake/install/obj2.h @@ -0,0 +1,6 @@ +#ifndef OBJ2_H +#define OBJ2_H + +int obj2(void); + +#endif /* OBJ2_H */ diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake index bf64f01..0db6375 100644 --- a/Tests/RunCMake/interface_library/whitelist.cmake +++ b/Tests/RunCMake/interface_library/whitelist.cmake @@ -14,3 +14,12 @@ get_target_property(outname iface "_custom_property") set_property(TARGET iface PROPERTY "custom_property" output) set_property(TARGET iface APPEND PROPERTY "custom_property" append) get_target_property(outname iface "custom_property") + +# PUBLIC_HEADER / PRIVATE_HEADER properties are allowed +set_property(TARGET iface PROPERTY PUBLIC_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PUBLIC_HEADER bar.h) +get_target_property(outname iface PUBLIC_HEADER) + +set_property(TARGET iface PROPERTY PRIVATE_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PRIVATE_HEADER bar.h) +get_target_property(outname iface PRIVATE_HEADER) diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt b/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt b/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt new file mode 100644 index 0000000..83060b4 --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt @@ -0,0 +1 @@ +list must be called with at least two arguments diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs.cmake b/Tests/RunCMake/list/POP_BACK-NoArgs.cmake new file mode 100644 index 0000000..518924d --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK-NoArgs.cmake @@ -0,0 +1 @@ +list(POP_FRONT) diff --git a/Tests/RunCMake/list/POP_BACK.cmake b/Tests/RunCMake/list/POP_BACK.cmake new file mode 100644 index 0000000..4794796 --- /dev/null +++ b/Tests/RunCMake/list/POP_BACK.cmake @@ -0,0 +1,79 @@ +cmake_policy(SET CMP0054 NEW) + +function(assert_expected_list_len list_var expected_size) + list(LENGTH ${list_var} _size) + if(NOT _size EQUAL ${expected_size}) + message(FATAL_ERROR "list size expected to be `${expected_size}`, got `${_size}` instead") + endif() +endfunction() + +# Pop from undefined list +list(POP_BACK test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Pop from empty list +set(test) +list(POP_BACK test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Default pop from 1-item list +list(APPEND test one) +list(POP_BACK test) +assert_expected_list_len(test 0) + +# Pop from 1-item list to var +list(APPEND test one) +list(POP_BACK test one) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() + +unset(one) +unset(two) + +# Pop from 1-item list to vars +list(APPEND test one) +list(POP_BACK test one two) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() +if(DEFINED two) + message(FATAL_ERROR "`two` expected to be undefined") +endif() + +unset(one) +unset(two) + +# Default pop from 2-item list +list(APPEND test one two) +list(POP_BACK test) +assert_expected_list_len(test 1) +if(NOT test STREQUAL "one") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() + +# Pop from 2-item list +list(APPEND test two) +list(POP_BACK test two) +assert_expected_list_len(test 1) +if(NOT DEFINED two) + message(FATAL_ERROR "`two` expected to be defined") +endif() +if(NOT two STREQUAL "two") + message(FATAL_ERROR "`two` has unexpected value `${two}`") +endif() +if(NOT test STREQUAL "one") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt b/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt b/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt new file mode 100644 index 0000000..83060b4 --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt @@ -0,0 +1 @@ +list must be called with at least two arguments diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake b/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake new file mode 100644 index 0000000..c5cf837 --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake @@ -0,0 +1 @@ +list(POP_BACK) diff --git a/Tests/RunCMake/list/POP_FRONT.cmake b/Tests/RunCMake/list/POP_FRONT.cmake new file mode 100644 index 0000000..70f757a --- /dev/null +++ b/Tests/RunCMake/list/POP_FRONT.cmake @@ -0,0 +1,92 @@ +cmake_policy(SET CMP0054 NEW) + +function(assert_expected_list_len list_var expected_size) + list(LENGTH ${list_var} _size) + if(NOT _size EQUAL ${expected_size}) + message(FATAL_ERROR "list size expected to be `${expected_size}`, got `${_size}` instead") + endif() +endfunction() + +# Pop from undefined list +list(POP_FRONT test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Pop from empty list +set(test) +list(POP_FRONT test) +if(DEFINED test) + message(FATAL_ERROR "`test` expected to be undefined") +endif() + +# Default pop from 1-item list +list(APPEND test one) +list(POP_FRONT test) +assert_expected_list_len(test 0) + +# Pop from 1-item list to var +list(APPEND test one) +list(POP_FRONT test one) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() + +unset(one) +unset(two) + +# Pop from 1-item list to vars +list(APPEND test one) +list(POP_FRONT test one two) +assert_expected_list_len(test 0) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() +if(DEFINED two) + message(FATAL_ERROR "`two` expected to be undefined") +endif() + +unset(one) +unset(two) + +# Default pop from 2-item list +list(APPEND test one two) +list(POP_FRONT test) +assert_expected_list_len(test 1) +if(NOT test STREQUAL "two") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() + +# Pop from 2-item list +list(PREPEND test one) +list(POP_FRONT test one) +assert_expected_list_len(test 1) +if(NOT DEFINED one) + message(FATAL_ERROR "`one` expected to be defined") +endif() +if(NOT one STREQUAL "one") + message(FATAL_ERROR "`one` has unexpected value `${one}`") +endif() +if(NOT test STREQUAL "two") + message(FATAL_ERROR "`test` has unexpected value `${test}`") +endif() + +# BUG 19436 +set(myList a b c) +list(POP_FRONT myList first second) +if(NOT first STREQUAL "a") + message(FATAL_ERROR "BUG#19436: `first` has unexpected value `${first}`") +endif() +if(NOT second STREQUAL "b") + message(FATAL_ERROR "BUG#19436: `second` has unexpected value `${second}`") +endif() +if(NOT myList STREQUAL "c") + message(FATAL_ERROR "BUG#19436: `myList` has unexpected value `${myList}`") +endif() diff --git a/Tests/RunCMake/list/PREPEND-NoArgs-result.txt b/Tests/RunCMake/list/PREPEND-NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/PREPEND-NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt b/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt new file mode 100644 index 0000000..83060b4 --- /dev/null +++ b/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt @@ -0,0 +1 @@ +list must be called with at least two arguments diff --git a/Tests/RunCMake/list/PREPEND-NoArgs.cmake b/Tests/RunCMake/list/PREPEND-NoArgs.cmake new file mode 100644 index 0000000..8935fa9 --- /dev/null +++ b/Tests/RunCMake/list/PREPEND-NoArgs.cmake @@ -0,0 +1 @@ +list(PREPEND) diff --git a/Tests/RunCMake/list/PREPEND.cmake b/Tests/RunCMake/list/PREPEND.cmake new file mode 100644 index 0000000..17b2921 --- /dev/null +++ b/Tests/RunCMake/list/PREPEND.cmake @@ -0,0 +1,33 @@ +list(PREPEND test) +if(test) + message(FATAL_ERROR "failed") +endif() + +list(PREPEND test satu) +if(NOT test STREQUAL "satu") + message(FATAL_ERROR "failed") +endif() + +list(PREPEND test dua) +if(NOT test STREQUAL "dua;satu") + message(FATAL_ERROR "failed") +endif() + +list(PREPEND test tiga) +if(NOT test STREQUAL "tiga;dua;satu") + message(FATAL_ERROR "failed") +endif() + +# Scope test +function(foo) + list(PREPEND test empat) + if(NOT test STREQUAL "empat;tiga;dua;satu") + message(FATAL_ERROR "failed") + endif() +endfunction() + +foo() + +if(NOT test STREQUAL "tiga;dua;satu") + message(FATAL_ERROR "failed") +endif() diff --git a/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake b/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake new file mode 100644 index 0000000..91abbd6 --- /dev/null +++ b/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake @@ -0,0 +1,5 @@ +set(mylist "b;c;b;a;a;c;b;a;c;b") +list(REMOVE_DUPLICATES mylist) +if(NOT mylist STREQUAL "b;c;a") + message(SEND_ERROR "Expected b;c;a, got ${mylist}") +endif() diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index bf3d22d..b4a91bc 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -24,6 +24,8 @@ run_cmake(SUBLIST-TooManyArguments) run_cmake(REMOVE_AT-EmptyList) +run_cmake(REMOVE_DUPLICATES-PreserveOrder) + run_cmake(FILTER-NotList) run_cmake(REMOVE_AT-NotList) run_cmake(REMOVE_DUPLICATES-NotList) @@ -98,3 +100,15 @@ run_cmake(SORT-NoCaseOption) # Successful tests run_cmake(SORT) + +# argument tests +run_cmake(PREPEND-NoArgs) +# Successful tests +run_cmake(PREPEND) + +# argument tests +run_cmake(POP_BACK-NoArgs) +run_cmake(POP_FRONT-NoArgs) +# Successful tests +run_cmake(POP_BACK) +run_cmake(POP_FRONT) diff --git a/Tests/RunCMake/message/RunCMakeTest.cmake b/Tests/RunCMake/message/RunCMakeTest.cmake index 24dad03..cecfc7f 100644 --- a/Tests/RunCMake/message/RunCMakeTest.cmake +++ b/Tests/RunCMake/message/RunCMakeTest.cmake @@ -10,3 +10,45 @@ run_cmake(warnmessage) # separately run_cmake(errormessage_deprecated) run_cmake(errormessage_dev) + +run_cmake_command( + message-loglevel-invalid + ${CMAKE_COMMAND} --loglevel=blah -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) + +# Checking various combinations of `message(...)` and log levels `WARNING` to `TRACE` +# - no CLI option -> `WARNING` to `STATUS` output +run_cmake_command( + message-loglevel-default + ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - Only `WARNING` output +run_cmake_command( + message-loglevel-warning + ${CMAKE_COMMAND} --loglevel=warning -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - Only `WARNING` and `NOTICE` output +run_cmake_command( + message-loglevel-notice + ${CMAKE_COMMAND} --loglevel=notice -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `STATUS` output +run_cmake_command( + message-loglevel-status + ${CMAKE_COMMAND} --loglevel=status -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `VERBOSE` output +run_cmake_command( + message-loglevel-verbose + ${CMAKE_COMMAND} --loglevel=verbose -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `DEBUG` output +run_cmake_command( + message-loglevel-debug + ${CMAKE_COMMAND} --loglevel=debug -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `TRACE` output +run_cmake_command( + message-loglevel-trace + ${CMAKE_COMMAND} --loglevel=trace -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) diff --git a/Tests/RunCMake/message/message-all-loglevels.cmake b/Tests/RunCMake/message/message-all-loglevels.cmake new file mode 100644 index 0000000..f8d8841 --- /dev/null +++ b/Tests/RunCMake/message/message-all-loglevels.cmake @@ -0,0 +1,10 @@ +# Produce a message for everything except FATAL_ERROR and SEND_ERROR +message(DEPRECATION "Deprecation warning") +message(AUTHOR_WARNING "Author warning message") +message(WARNING "Warning message") +message("Default NOTICE message") +message(NOTICE "NOTICE message") +message(STATUS "STATUS message") +message(VERBOSE "VERBOSE message") +message(DEBUG "DEBUG message") +message(TRACE "TRACE message") diff --git a/Tests/RunCMake/message/message-loglevel-debug-stderr.txt b/Tests/RunCMake/message/message-loglevel-debug-stderr.txt new file mode 100644 index 0000000..efec736 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-debug-stderr.txt @@ -0,0 +1,12 @@ +^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\): + Deprecation warning ++ +CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\): + Author warning message +This warning is for project developers\. Use -Wno-dev to suppress it\. ++ +CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\): + Warning message ++ +Default NOTICE message +NOTICE message$ diff --git a/Tests/RunCMake/message/message-loglevel-debug-stdout.txt b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt new file mode 100644 index 0000000..1452137 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt @@ -0,0 +1,3 @@ +-- STATUS message +-- VERBOSE message +-- DEBUG message diff --git a/Tests/RunCMake/message/message-loglevel-default-stderr.txt b/Tests/RunCMake/message/message-loglevel-default-stderr.txt new file mode 100644 index 0000000..efec736 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-default-stderr.txt @@ -0,0 +1,12 @@ +^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\): + Deprecation warning ++ +CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\): + Author warning message +This warning is for project developers\. Use -Wno-dev to suppress it\. ++ +CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\): + Warning message ++ +Default NOTICE message +NOTICE message$ diff --git a/Tests/RunCMake/message/message-loglevel-default-stdout.txt b/Tests/RunCMake/message/message-loglevel-default-stdout.txt new file mode 100644 index 0000000..809f4cc --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-default-stdout.txt @@ -0,0 +1 @@ +-- STATUS message diff --git a/Tests/RunCMake/message/message-loglevel-invalid-result.txt b/Tests/RunCMake/message/message-loglevel-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt b/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt new file mode 100644 index 0000000..f54d0f8 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt @@ -0,0 +1 @@ +CMake Error: Invalid level specified for --loglevel diff --git a/Tests/RunCMake/message/message-loglevel-notice-stderr.txt b/Tests/RunCMake/message/message-loglevel-notice-stderr.txt new file mode 100644 index 0000000..efec736 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-notice-stderr.txt @@ -0,0 +1,12 @@ +^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\): + Deprecation warning ++ +CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\): + Author warning message +This warning is for project developers\. Use -Wno-dev to suppress it\. ++ +CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\): + Warning message ++ +Default NOTICE message +NOTICE message$ diff --git a/Tests/RunCMake/message/message-loglevel-status-stderr.txt b/Tests/RunCMake/message/message-loglevel-status-stderr.txt new file mode 100644 index 0000000..efec736 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-status-stderr.txt @@ -0,0 +1,12 @@ +^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\): + Deprecation warning ++ +CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\): + Author warning message +This warning is for project developers\. Use -Wno-dev to suppress it\. ++ +CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\): + Warning message ++ +Default NOTICE message +NOTICE message$ diff --git a/Tests/RunCMake/message/message-loglevel-status-stdout.txt b/Tests/RunCMake/message/message-loglevel-status-stdout.txt new file mode 100644 index 0000000..809f4cc --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-status-stdout.txt @@ -0,0 +1 @@ +-- STATUS message diff --git a/Tests/RunCMake/message/message-loglevel-trace-stderr.txt b/Tests/RunCMake/message/message-loglevel-trace-stderr.txt new file mode 100644 index 0000000..efec736 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-trace-stderr.txt @@ -0,0 +1,12 @@ +^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\): + Deprecation warning ++ +CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\): + Author warning message +This warning is for project developers\. Use -Wno-dev to suppress it\. ++ +CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\): + Warning message ++ +Default NOTICE message +NOTICE message$ diff --git a/Tests/RunCMake/message/message-loglevel-trace-stdout.txt b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt new file mode 100644 index 0000000..1cfce6f --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt @@ -0,0 +1,4 @@ +-- STATUS message +-- VERBOSE message +-- DEBUG message +-- TRACE message diff --git a/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt b/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt new file mode 100644 index 0000000..efec736 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt @@ -0,0 +1,12 @@ +^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\): + Deprecation warning ++ +CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\): + Author warning message +This warning is for project developers\. Use -Wno-dev to suppress it\. ++ +CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\): + Warning message ++ +Default NOTICE message +NOTICE message$ diff --git a/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt new file mode 100644 index 0000000..c15d43f --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt @@ -0,0 +1,2 @@ +-- STATUS message +-- VERBOSE message diff --git a/Tests/RunCMake/message/message-loglevel-warning-stderr.txt b/Tests/RunCMake/message/message-loglevel-warning-stderr.txt new file mode 100644 index 0000000..c721b06 --- /dev/null +++ b/Tests/RunCMake/message/message-loglevel-warning-stderr.txt @@ -0,0 +1,9 @@ +^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\): + Deprecation warning ++ +CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\): + Author warning message +This warning is for project developers\. Use -Wno-dev to suppress it\. ++ +CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\): + Warning message$ diff --git a/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt b/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt new file mode 100644 index 0000000..fc1a02b --- /dev/null +++ b/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt @@ -0,0 +1,12 @@ +^CMake Warning \(dev\) in CMakeLists.txt: + No project\(\) command is present. The top-level CMakeLists.txt file must + contain a literal, direct call to the project\(\) command. Add a line of + code such as + + project\(ProjectName\) + + near the top of the file, but after cmake_minimum_required\(\). + + CMake is pretending there is a "project\(Project\)" command on the first + line. +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/pseudo_emulator_custom_command_arg.c b/Tests/RunCMake/pseudo_emulator_custom_command_arg.c new file mode 100644 index 0000000..d00deda --- /dev/null +++ b/Tests/RunCMake/pseudo_emulator_custom_command_arg.c @@ -0,0 +1,30 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +// Usage: +// +// /path/to/program arg1 [arg2 [...]] +// +// Return EXIT_SUCCESS if 'custom_argument' string was found +// in <arg1> and 'generated_exe_emulator_expected' +// string was found in <arg2> +// Return EXIT_FAILURE if 'custom_argument' string was not +// found in <arg1> or 'generated_exe_emulator_expected' +// string was not found in <arg2>. + +int main(int argc, const char* argv[]) +{ + // Require a slash to make sure it is a path and not a target name. + const char* substring_success = "/generated_exe_emulator_expected"; + const char* substring_custom_argument = "custom_argument"; + + if (argc < 2) { + return EXIT_FAILURE; + } + if (strstr(argv[1], substring_custom_argument) != 0 && + strstr(argv[2], substring_success) != 0) { + return EXIT_SUCCESS; + } + return EXIT_FAILURE; +} diff --git a/Tests/RunCMake/string/Repeat.cmake b/Tests/RunCMake/string/Repeat.cmake new file mode 100644 index 0000000..fc390aa --- /dev/null +++ b/Tests/RunCMake/string/Repeat.cmake @@ -0,0 +1,45 @@ +string(REPEAT "q" 4 q_out) + +if(NOT DEFINED q_out) + message(FATAL_ERROR "q_out is not defined") +endif() + +if(NOT q_out STREQUAL "qqqq") + message(FATAL_ERROR "unexpected result") +endif() + +string(REPEAT "1234" 0 zero_out) + +if(NOT DEFINED zero_out) + message(FATAL_ERROR "zero_out is not defined") +endif() + +if(NOT zero_out STREQUAL "") + message(FATAL_ERROR "unexpected result") +endif() + +unset(zero_out) + +string(REPEAT "" 100 zero_out) + +if(NOT DEFINED zero_out) + message(FATAL_ERROR "zero_out is not defined") +endif() + +if(NOT zero_out STREQUAL "") + message(FATAL_ERROR "unexpected result") +endif() + +string(REPEAT "1" 1 one_out) + +if(NOT one_out STREQUAL "1") + message(FATAL_ERROR "unexpected result") +endif() + +unset(one_out) + +string(REPEAT "one" 1 one_out) + +if(NOT one_out STREQUAL "one") + message(FATAL_ERROR "unexpected result") +endif() diff --git a/Tests/RunCMake/string/RepeatNegativeCount-result.txt b/Tests/RunCMake/string/RepeatNegativeCount-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/string/RepeatNegativeCount-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/RepeatNegativeCount-stderr.txt b/Tests/RunCMake/string/RepeatNegativeCount-stderr.txt new file mode 100644 index 0000000..bbd498e --- /dev/null +++ b/Tests/RunCMake/string/RepeatNegativeCount-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at RepeatNegativeCount.cmake:[0-9]+ \(string\): + repeat count is not a positive number. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/RepeatNegativeCount.cmake b/Tests/RunCMake/string/RepeatNegativeCount.cmake new file mode 100644 index 0000000..769e7c0 --- /dev/null +++ b/Tests/RunCMake/string/RepeatNegativeCount.cmake @@ -0,0 +1 @@ +string(REPEAT "blah" -1 out) diff --git a/Tests/RunCMake/string/RepeatNoArgs-result.txt b/Tests/RunCMake/string/RepeatNoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/string/RepeatNoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/RepeatNoArgs-stderr.txt b/Tests/RunCMake/string/RepeatNoArgs-stderr.txt new file mode 100644 index 0000000..5abcb3b --- /dev/null +++ b/Tests/RunCMake/string/RepeatNoArgs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at RepeatNoArgs.cmake:[0-9]+ \(string\): + sub-command REPEAT requires three arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/RepeatNoArgs.cmake b/Tests/RunCMake/string/RepeatNoArgs.cmake new file mode 100644 index 0000000..e327e99 --- /dev/null +++ b/Tests/RunCMake/string/RepeatNoArgs.cmake @@ -0,0 +1 @@ +string(REPEAT) diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index 211337a..c432b4e 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -33,3 +33,7 @@ run_cmake(UTF-16BE) run_cmake(UTF-16LE) run_cmake(UTF-32BE) run_cmake(UTF-32LE) + +run_cmake(Repeat) +run_cmake(RepeatNoArgs) +run_cmake(RepeatNegativeCount) diff --git a/Tests/RunCMake/try_compile/CMP0066-stderr.txt b/Tests/RunCMake/try_compile/CMP0066-stderr.txt index b14e290..0b92dcf 100644 --- a/Tests/RunCMake/try_compile/CMP0066-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0066-stderr.txt @@ -12,4 +12,15 @@ CMake Warning \(dev\) at CMP0066.cmake:[0-9]+ \(try_compile\): test project. Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it.$ +This warning is for project developers. Use -Wno-dev to suppress it. +* +CMake Deprecation Warning at CMP0066.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0066 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/try_compile/LinkOptions.cmake b/Tests/RunCMake/try_compile/LinkOptions.cmake index 9b246c4..7fae35c 100644 --- a/Tests/RunCMake/try_compile/LinkOptions.cmake +++ b/Tests/RunCMake/try_compile/LinkOptions.cmake @@ -5,7 +5,9 @@ cmake_policy(SET CMP0054 NEW) set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}") if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if (RunCMake_C_COMPILER_ID STREQUAL "MSVC") + if (RunCMake_C_COMPILER_ID STREQUAL "MSVC" + OR ("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND + NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")) if (CMAKE_SIZEOF_VOID_P EQUAL 4) set (undef_flag /INCLUDE:_func) else() diff --git a/Tests/RunCMake/try_run/LinkOptions.cmake b/Tests/RunCMake/try_run/LinkOptions.cmake index 17af2f7..b9a87f3 100644 --- a/Tests/RunCMake/try_run/LinkOptions.cmake +++ b/Tests/RunCMake/try_run/LinkOptions.cmake @@ -5,7 +5,9 @@ cmake_policy(SET CMP0054 NEW) set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}") if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - if (RunCMake_C_COMPILER_ID STREQUAL "MSVC") + if (RunCMake_C_COMPILER_ID STREQUAL "MSVC" + OR ("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND + NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")) if (CMAKE_SIZEOF_VOID_P EQUAL 4) set (undef_flag /INCLUDE:_func) else() diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt index 813774d..a5740bb 100644 --- a/Tests/SourceGroups/CMakeLists.txt +++ b/Tests/SourceGroups/CMakeLists.txt @@ -42,8 +42,16 @@ set(tree_files_with_prefix ${root}/tree_prefix_foo.c set(tree_files_with_empty_prefix ${root}/tree_empty_prefix_foo.c tree_empty_prefix_bar.c) +set(tree_files_which_are_actually_directories ${root} + ${root}/ + ${root}/sub1 + ${root}/sub1/) + source_group(TREE ${root} FILES ${tree_files_without_prefix}) +# Should not crash and not add any files - just silently ignore the directories +source_group(TREE ${root} FILES ${tree_files_which_are_actually_directories}) + source_group(FILES ${tree_files_with_prefix} PREFIX tree_root/subgroup TREE ${root}) source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root}) diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt index 64a3cd2..8d2519e 100644 --- a/Tests/StagingPrefix/CMakeLists.txt +++ b/Tests/StagingPrefix/CMakeLists.txt @@ -5,11 +5,12 @@ project(StagingPrefix) # Wipe out the install tree add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/CleanupProject - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ConsumerBuild - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ProducerBuild - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/stage - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/prefix - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ignored + COMMAND ${CMAKE_COMMAND} -E remove_directory + ${CMAKE_BINARY_DIR}/ConsumerBuild + ${CMAKE_BINARY_DIR}/ProducerBuild + ${CMAKE_BINARY_DIR}/stage + ${CMAKE_BINARY_DIR}/prefix + ${CMAKE_BINARY_DIR}/ignored ) add_custom_target(CleanupTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/CleanupProject) set_property( diff --git a/Tests/SwiftMix/CMain.c b/Tests/SwiftMix/CMain.c index 8877da4..519058e 100644 --- a/Tests/SwiftMix/CMain.c +++ b/Tests/SwiftMix/CMain.c @@ -1,5 +1,5 @@ -extern int ObjCMain(int argc, char const* const argv[]); -int main(int argc, char* argv[]) +extern int ObjCMain(void); +int main(void) { - return ObjCMain(argc, argv); + return ObjCMain(); } diff --git a/Tests/SwiftMix/CMakeLists.txt b/Tests/SwiftMix/CMakeLists.txt index 5e50470..6d8e48b 100644 --- a/Tests/SwiftMix/CMakeLists.txt +++ b/Tests/SwiftMix/CMakeLists.txt @@ -3,3 +3,4 @@ project(SwiftMix C Swift) add_executable(SwiftMix CMain.c ObjCMain.m SwiftMain.swift ObjC-Swift.h) set_property(TARGET SwiftMix PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "ObjC-Swift.h") +target_compile_options(SwiftMix PRIVATE "$<$<COMPILE_LANGUAGE:C>:-Werror=objc-method-access>") diff --git a/Tests/SwiftMix/ObjCMain.m b/Tests/SwiftMix/ObjCMain.m index 20f0bf1..afc92438 100644 --- a/Tests/SwiftMix/ObjCMain.m +++ b/Tests/SwiftMix/ObjCMain.m @@ -1,4 +1,4 @@ #import "SwiftMix-Swift.h" -int ObjCMain(int argc, char const* const argv[]) { +int ObjCMain(void) { return [SwiftMainClass SwiftMain]; } diff --git a/Tests/SwiftMix/SwiftMain.swift b/Tests/SwiftMix/SwiftMain.swift index a4a0a62..d9c8cd7 100644 --- a/Tests/SwiftMix/SwiftMain.swift +++ b/Tests/SwiftMix/SwiftMain.swift @@ -1,7 +1,7 @@ import Foundation @objc class SwiftMainClass : NSObject { - class func SwiftMain() -> Int32 { + @objc class func SwiftMain() -> Int32 { dump("Hello World!"); return 0; } diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt index e5f8588..f4cbac2 100644 --- a/Tests/SwiftOnly/CMakeLists.txt +++ b/Tests/SwiftOnly/CMakeLists.txt @@ -8,3 +8,6 @@ elseif(NOT XCODE_VERSION VERSION_LESS 8.0) endif() add_executable(SwiftOnly main.swift) + +# Dummy to make sure generation works with such targets. +add_library(SwiftIface INTERFACE) diff --git a/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt new file mode 100644 index 0000000..a2c239c --- /dev/null +++ b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.14...3.15) + +project(TestAlternateLibraryName CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) + +# Path separator +if (WIN32) + set (PS "$<SEMICOLON>") +else() + set (PS ":") +endif() + +unset(CMAKE_SWIG_FLAGS) + +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../example.i" PROPERTY COMPILE_OPTIONS -includeall) + +swig_add_library(example_python + LANGUAGE python + SOURCES ../example.i ../example.cxx) +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) + + +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") diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index 434895e..3cc910f 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -123,3 +123,15 @@ add_test(NAME UseSWIG.SwigSrcFileExtension COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + +add_test(NAME UseSWIG.AlternateLibraryName COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/AlternateLibraryName" + "${CMake_BINARY_DIR}/Tests/UseSWIG/AlternateLibraryName" + ${build_generator_args} + --build-project TestAlternateLibraryName + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/UseSWIG/ModuleName/CMakeLists.txt b/Tests/UseSWIG/ModuleName/CMakeLists.txt index de63883..435b441 100644 --- a/Tests/UseSWIG/ModuleName/CMakeLists.txt +++ b/Tests/UseSWIG/ModuleName/CMakeLists.txt @@ -34,7 +34,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 Python2::Python) +target_link_libraries(example1 PRIVATE Python2::Module) add_test (NAME ModuleName.example1 diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt index a7ee210..093e858 100644 --- a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt +++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt @@ -33,7 +33,7 @@ set_target_properties (example1 PROPERTIES 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::Python) +target_link_libraries(example1 PRIVATE Python2::Module) # re-use sample interface file for another plugin swig_add_library(example2 @@ -44,7 +44,7 @@ set_target_properties (example2 PROPERTIES 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::Python) +target_link_libraries(example2 PRIVATE Python3::Module) add_test (NAME ModuleVersion2.example1 diff --git a/Tests/UseSWIG/MultipleModules/CMakeLists.txt b/Tests/UseSWIG/MultipleModules/CMakeLists.txt index f1dc379..4380080 100644 --- a/Tests/UseSWIG/MultipleModules/CMakeLists.txt +++ b/Tests/UseSWIG/MultipleModules/CMakeLists.txt @@ -36,7 +36,7 @@ set_target_properties (example1 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python" ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python") -target_link_libraries(example1 PRIVATE Python::Python) +target_link_libraries(example1 PRIVATE Python::Module) # re-use sample interface file for another plugin set_property(SOURCE "../example.i" APPEND PROPERTY diff --git a/Tests/UseSWIG/MultiplePython/CMakeLists.txt b/Tests/UseSWIG/MultiplePython/CMakeLists.txt index 8f87755..cf6c80e 100644 --- a/Tests/UseSWIG/MultiplePython/CMakeLists.txt +++ b/Tests/UseSWIG/MultiplePython/CMakeLists.txt @@ -34,7 +34,7 @@ set_target_properties (example1 PROPERTIES 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::Python) +target_link_libraries(example1 PRIVATE Python2::Module) # re-use sample interface file for another plugin swig_add_library(example2 @@ -46,7 +46,7 @@ set_target_properties (example2 PROPERTIES 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::Python) +target_link_libraries(example2 PRIVATE Python3::Module) diff --git a/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt b/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt index 7eb73d4..f70ce49 100644 --- a/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt +++ b/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt @@ -16,11 +16,11 @@ set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swg") # Generate a Python module out of `.i` swig_add_library(my_add LANGUAGE python SOURCES my_add.i) -target_link_libraries(my_add Python::Python) +target_link_libraries(my_add Python::Module) # Generate a Python module out of `.swg` swig_add_library(my_sub LANGUAGE python SOURCES my_sub.swg) -target_link_libraries(my_sub Python::Python) +target_link_libraries(my_sub Python::Module) # Add a test add_test(NAME SwigSrcFileExtension diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt index fbb72d5..80a2e16 100644 --- a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt +++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt @@ -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::Python) +target_link_libraries(example1 PRIVATE Python3::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::Python) +target_link_libraries(example2 PRIVATE Python3::Module) diff --git a/Tests/WarnUnusedCliUnused/CMakeLists.txt b/Tests/WarnUnusedCliUnused/CMakeLists.txt index 7ed69bf..a149f04 100644 --- a/Tests/WarnUnusedCliUnused/CMakeLists.txt +++ b/Tests/WarnUnusedCliUnused/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.14) project(WarnUnusedCliUnused) -set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/CMakeCache.txt" -) +# Remove UNUSED_CLI_VARIABLE from the cache to trigger the +# CMake warning message on re-builds as well. +unset(UNUSED_CLI_VARIABLE CACHE) add_library(dummy empty.cpp) |