diff options
Diffstat (limited to 'Tests')
815 files changed, 10656 insertions, 376 deletions
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt index 21b265c..a3c9946 100644 --- a/Tests/Assembler/CMakeLists.txt +++ b/Tests/Assembler/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.8) project(Assembler C) message("CTEST_FULL_OUTPUT ") set(CMAKE_VERBOSE_MAKEFILE 1) @@ -22,7 +22,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode|Ninja" AND set(SRCS main.s) add_custom_command( OUTPUT main.s - COMMAND ${CMAKE_C_COMPILER} ${C_FLAGS} -S ${CMAKE_CURRENT_SOURCE_DIR}/main.c -o main.s + COMMAND ${CMAKE_C_COMPILER} ${C_FLAGS} + "$<$<CONFIG:Debug>:${CMAKE_C_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL}>" + "$<$<NOT:$<CONFIG:Debug>>:${CMAKE_C_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL}>" + -S ${CMAKE_CURRENT_SOURCE_DIR}/main.c -o main.s + COMMAND_EXPAND_LISTS DEPENDS main.c VERBATIM ) diff --git a/Tests/CFBundleTest/VerifyResult.cmake b/Tests/CFBundleTest/VerifyResult.cmake index e637bb1..ac14e5d 100644 --- a/Tests/CFBundleTest/VerifyResult.cmake +++ b/Tests/CFBundleTest/VerifyResult.cmake @@ -14,7 +14,7 @@ message(STATUS "CTEST_CONFIGURATION_TYPE='${CTEST_CONFIGURATION_TYPE}'") message(STATUS "dir='${dir}'") message(STATUS "gen='${gen}'") -if(gen STREQUAL "Xcode") +if(gen MATCHES "^(Xcode$|Ninja Multi-Config$)") set(expected_filename "${dir}/${CTEST_CONFIGURATION_TYPE}/CFBundleTest.plugin/Contents/MacOS/CFBundleTest") else() set(expected_filename "${dir}/CFBundleTest.plugin/Contents/MacOS/CFBundleTest") diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt index 7c918e6..06d1111 100644 --- a/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt @@ -2,7 +2,11 @@ add_executable(SubDirB SubDirB.c) # Link to a target imported in this directory that would not normally # be visible to the directory in which TopDir is defined. -target_link_libraries(TopDir PUBLIC SameNameImported) +target_link_libraries(TopDir PUBLIC debug SameNameImported optimized SameNameImported) + +# Link to a list of targets imported in this directory that would not +# normally be visible to the directory in which TopDir is defined. +target_link_libraries(TopDir PUBLIC "$<1:SameNameImported;SameNameImported>") # Link SubDirA to a target imported in this directory that has the same # name as a target imported in SubDirA's directory. We verify when diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 840afc1..bb50d76 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -11,6 +11,7 @@ set(CMakeLib_TESTS testCTestResourceAllocator.cxx testCTestResourceSpec.cxx testCTestResourceGroups.cxx + testGccDepfileReader.cxx testGeneratedFileStream.cxx testRST.cxx testRange.cxx @@ -25,6 +26,8 @@ set(CMakeLib_TESTS testUVProcessChain.cxx testUVRAII.cxx testUVStreambuf.cxx + testCMExtMemory.cxx + testCMExtAlgorithm.cxx ) add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx) @@ -33,6 +36,7 @@ set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}) set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>) set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>) set(testCTestResourceSpec_ARGS ${CMAKE_CURRENT_SOURCE_DIR}) +set(testGccDepfileReader_ARGS ${CMAKE_CURRENT_SOURCE_DIR}) if(WIN32) list(APPEND CMakeLib_TESTS diff --git a/Tests/CMakeLib/testCMExtAlgorithm.cxx b/Tests/CMakeLib/testCMExtAlgorithm.cxx new file mode 100644 index 0000000..b8319c3 --- /dev/null +++ b/Tests/CMakeLib/testCMExtAlgorithm.cxx @@ -0,0 +1,118 @@ +#include <iostream> +#include <memory> +#include <type_traits> +#include <utility> +#include <vector> + +#include <cmext/algorithm> + +namespace { + +int failed = 0; + +void testAppend() +{ + std::cout << "testAppend()" << std::endl; + + // ---------------------------------------------------- + // cm::append(Vector, Iterator, Iterator) + { + std::vector<int> v1{ 1, 2, 3 }; + std::vector<int> v1_ref{ 1, 2, 3, 4, 5, 6 }; + std::vector<int> v2{ 4, 5, 6 }; + std::vector<int> v2_ref{ 4, 5, 6 }; + + cm::append(v1, v2.begin(), v2.end()); + + if (v1 != v1_ref || v2 != v2_ref) { + ++failed; + } + } + + // ---------------------------------------------------- + // cm::append(Vector, Range) + { + std::vector<int> v1{ 1, 2, 3 }; + std::vector<int> v1_ref{ 1, 2, 3, 4, 5, 6 }; + std::vector<int> v2{ 4, 5, 6 }; + std::vector<int> v2_ref{ 4, 5, 6 }; + + cm::append(v1, v2); + + if (v1 != v1_ref || v2 != v2_ref) { + ++failed; + } + } + + // ---------------------------------------------------- + // cm::append(Vector<*>, Vector<unique_ptr>) + { + std::vector<int*> v1{ new int(1), new int(2), new int(3) }; + std::vector<int*> v1_ref = v1; + std::vector<std::unique_ptr<int>> v2; + + v2.emplace_back(new int(4)); + v2.emplace_back(new int(5)); + v2.emplace_back(new int(6)); + + cm::append(v1, v2); + + if (v1.size() == 6 && v2.size() == 3) { + for (int i = 0; i < 3; i++) { + if (v1[i] != v1_ref[i]) { + ++failed; + break; + } + } + for (int i = 0; i < 3; i++) { + if (v1[i + 3] != v2[i].get()) { + ++failed; + break; + } + } + } else { + ++failed; + } + + // free memory to please memory sanitizer + delete v1[0]; + delete v1[1]; + delete v1[2]; + } + + // ---------------------------------------------------- + // cm::append(Vector<unique_ptr>, Vector<unique_ptr>) + { + std::vector<std::unique_ptr<int>> v1; + std::vector<std::unique_ptr<int>> v2; + + v1.emplace_back(new int(1)); + v1.emplace_back(new int(2)); + v1.emplace_back(new int(3)); + + v2.emplace_back(new int(4)); + v2.emplace_back(new int(5)); + v2.emplace_back(new int(6)); + + cm::append(v1, std::move(v2)); + + if (v1.size() == 6 && v2.empty()) { + for (int i = 0; i < 6; i++) { + if (*v1[i] != i + 1) { + ++failed; + break; + } + } + } else { + ++failed; + } + } +} +} + +int testCMExtAlgorithm(int /*unused*/, char* /*unused*/ []) +{ + testAppend(); + + return failed; +} diff --git a/Tests/CMakeLib/testCMExtMemory.cxx b/Tests/CMakeLib/testCMExtMemory.cxx new file mode 100644 index 0000000..6663c17 --- /dev/null +++ b/Tests/CMakeLib/testCMExtMemory.cxx @@ -0,0 +1,65 @@ +#include <iostream> +#include <memory> + +#include <cmext/memory> + +namespace { +class Base +{ +public: + virtual ~Base() = default; +}; + +class Derived : public Base +{ +public: + ~Derived() = default; + + void method() {} +}; + +template <typename T> +class Wrapper +{ +public: + Wrapper(T* v) + : value(v) + { + } + ~Wrapper() { delete value; } + + T* get() const { return value; } + +private: + T* value; +}; + +bool testReferenceCast() +{ + std::cout << "testReferenceCast()" << std::endl; + + std::unique_ptr<Base> u(new Derived); + cm::static_reference_cast<Derived>(u).method(); + cm::dynamic_reference_cast<Derived>(u).method(); + + std::shared_ptr<Base> s(new Derived); + cm::static_reference_cast<Derived>(s).method(); + cm::dynamic_reference_cast<Derived>(s).method(); + + // can also be used with custom wrappers + Wrapper<Base> w(new Derived); + cm::static_reference_cast<Derived>(w).method(); + cm::dynamic_reference_cast<Derived>(w).method(); + + return true; +} +} + +int testCMExtMemory(int /*unused*/, char* /*unused*/ []) +{ + if (!testReferenceCast()) { + return 1; + } + + return 0; +} diff --git a/Tests/CMakeLib/testGccDepfileReader.cxx b/Tests/CMakeLib/testGccDepfileReader.cxx new file mode 100644 index 0000000..924d87b --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader.cxx @@ -0,0 +1,131 @@ +#include <cstddef> +#include <iostream> +#include <memory> +#include <string> +#include <utility> +#include <vector> + +#include "cmsys/FStream.hxx" + +#include "cmGccDepfileReader.h" +#include "cmGccDepfileReaderTypes.h" // for cmGccDepfileContent, cmGccStyle... +#include "cmSystemTools.h" + +namespace { + +cmGccDepfileContent readPlainDepfile(const char* filePath) +{ + cmGccDepfileContent result; + cmsys::ifstream is(filePath); + if (!is.is_open()) + return result; + std::string line; + + cmGccStyleDependency dep; + bool readingRules = true; + while (cmSystemTools::GetLineFromStream(is, line)) { + if (line == "--RULES--") { + if (!dep.rules.empty()) { + result.push_back(std::move(dep)); + dep = cmGccStyleDependency(); + } + readingRules = true; + } else if (line == "--DEPENDENCIES--") { + readingRules = false; + } else { + std::vector<std::string>& dst = readingRules ? dep.rules : dep.paths; + dst.push_back(std::move(line)); + line = std::string(); + } + } + + if (!dep.rules.empty()) { + result.push_back(std::move(dep)); + } + + return result; +} + +bool compare(const std::vector<std::string>& actual, + const std::vector<std::string>& expected, const char* msg) +{ + if (actual.size() != expected.size()) { + std::cerr << msg << "expected " << expected.size() << " entries." + << std::endl + << "Actual number of entries: " << actual.size() << std::endl; + return false; + } + for (std::size_t i = 0; i < actual.size(); ++i) { + if (actual[i] != expected[i]) { + std::cerr << msg << std::endl + << "expected: " << expected[i] << std::endl + << "actual: " << actual[i] << std::endl; + return false; + } + } + return true; +} + +bool compare(const cmGccDepfileContent& actual, + const cmGccDepfileContent& expected) +{ + if (actual.size() != expected.size()) { + std::cerr << "Expected " << expected.size() << " entries." << std::endl + << "Actual number of entries: " << actual.size() << std::endl; + return false; + } + for (std::size_t i = 0; i < actual.size(); ++i) { + if (!compare(actual[i].rules, expected[i].rules, "Rules differ: ") || + !compare(actual[i].paths, expected[i].paths, "Paths differ: ")) { + return false; + } + } + return true; +} + +void dump(const char* label, const cmGccDepfileContent& dfc) +{ + std::cerr << label << std::endl; + for (const auto& entry : dfc) { + auto rit = entry.rules.cbegin(); + if (rit != entry.rules.cend()) { + std::cerr << *rit; + for (++rit; rit != entry.rules.cend(); ++rit) { + std::cerr << " " << *rit; + } + std::cerr << ": " << std::endl; + } + for (const auto& path : entry.paths) { + std::cerr << " " << path << std::endl; + } + } +} + +} // anonymous namespace + +int testGccDepfileReader(int argc, char* argv[]) +{ + if (argc < 2) { + std::cout << "Invalid arguments.\n"; + return -1; + } + + std::string dataDirPath = argv[1]; + dataDirPath += "/testGccDepfileReader_data"; + const int numberOfTestFiles = 3; + for (int i = 1; i <= numberOfTestFiles; ++i) { + const std::string base = dataDirPath + "/deps" + std::to_string(i); + const std::string depfile = base + ".d"; + const std::string plainDepfile = base + ".txt"; + std::cout << "Comparing " << base << " with " << plainDepfile << std::endl; + const auto actual = cmReadGccDepfile(depfile.c_str()); + const auto expected = readPlainDepfile(plainDepfile.c_str()); + if (!compare(actual, expected)) { + dump("actual", actual); + dump("expected", expected); + return 1; + } + } + + return 0; +} diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps1.d b/Tests/CMakeLib/testGccDepfileReader_data/deps1.d new file mode 100644 index 0000000..9e34863 --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps1.d @@ -0,0 +1,20 @@ +main.o: main.cpp /usr/include/stdc-predef.h /usr/include/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/bits/long-double.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \ + /usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \ + /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \ + /usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps1.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps1.txt new file mode 100644 index 0000000..fd2679f --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps1.txt @@ -0,0 +1,26 @@ +--RULES-- +main.o +--DEPENDENCIES-- +main.cpp +/usr/include/stdc-predef.h +/usr/include/stdio.h +/usr/include/x86_64-linux-gnu/bits/libc-header-start.h +/usr/include/features.h +/usr/include/x86_64-linux-gnu/sys/cdefs.h +/usr/include/x86_64-linux-gnu/bits/wordsize.h +/usr/include/x86_64-linux-gnu/bits/long-double.h +/usr/include/x86_64-linux-gnu/gnu/stubs.h +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h +/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h +/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h +/usr/include/x86_64-linux-gnu/bits/types.h +/usr/include/x86_64-linux-gnu/bits/typesizes.h +/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h +/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h +/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h +/usr/include/x86_64-linux-gnu/bits/types/__FILE.h +/usr/include/x86_64-linux-gnu/bits/types/FILE.h +/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h +/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps2.d b/Tests/CMakeLib/testGccDepfileReader_data/deps2.d new file mode 100644 index 0000000..25f0d78 --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps2.d @@ -0,0 +1 @@ +foo.o bar.o: foobar.c diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps2.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps2.txt new file mode 100644 index 0000000..afaf78e --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps2.txt @@ -0,0 +1,5 @@ +--RULES-- +foo.o +bar.o +--DEPENDENCIES-- +foobar.c diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps3.d b/Tests/CMakeLib/testGccDepfileReader_data/deps3.d new file mode 100644 index 0000000..d75ceed --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps3.d @@ -0,0 +1,2 @@ +main.o: main.cpp foo\#bar.h foo\\#bar.h foo\ bar.h \ + foo\\\ bar.h foo\\\\\ bar.h foo\\\\ foo$$bar.h diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps3.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps3.txt new file mode 100644 index 0000000..448f69c --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps3.txt @@ -0,0 +1,11 @@ +--RULES-- +main.o +--DEPENDENCIES-- +main.cpp +foo#bar.h +foo\#bar.h +foo bar.h +foo\ bar.h +foo\\ bar.h +foo\\\\ +foo$bar.h diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index d7b3200..1fd3f38 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -191,7 +191,7 @@ static bool testConstructFromView() { std::cout << "testConstructFromView()\n"; cm::string_view view = cstr; - return testFromCStr(view); + return testFromCStr(cm::String(view)); } static bool testAssignFromView() @@ -297,7 +297,7 @@ static bool testFromStaticStringView(cm::String str) static bool testConstructFromStaticStringView() { std::cout << "testConstructFromStaticStringView()\n"; - return testFromStaticStringView(staticStringView); + return testFromStaticStringView(cm::String(staticStringView)); } static bool testAssignFromStaticStringView() @@ -796,7 +796,7 @@ static bool testMethod_substr_AtEnd(cm::String str) static bool testMethod_substr_AtEndBorrowed() { std::cout << "testMethod_substr_AtEndBorrowed()\n"; - return testMethod_substr_AtEnd("abc"_s); + return testMethod_substr_AtEnd(cm::String("abc"_s)); } static bool testMethod_substr_AtEndOwned() @@ -855,7 +855,7 @@ static bool testMethod_substr_AtStart(cm::String str) static bool testMethod_substr_AtStartBorrowed() { std::cout << "testMethod_substr_AtStartBorrowed()\n"; - return testMethod_substr_AtStart("abc"_s); + return testMethod_substr_AtStart(cm::String("abc"_s)); } static bool testMethod_substr_AtStartOwned() @@ -1146,7 +1146,7 @@ static bool testAddition() static bool testStability() { std::cout << "testStability()\n"; - cm::String str = "abc"_s; + cm::String str("abc"_s); ASSERT_TRUE(!str.is_stable()); ASSERT_TRUE(str.str_if_stable() == nullptr); str.stabilize(); diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx index 986f595..1bf88cf 100644 --- a/Tests/CMakeLib/testUTF8.cxx +++ b/Tests/CMakeLib/testUTF8.cxx @@ -9,9 +9,11 @@ typedef char test_utf8_char[5]; static void test_utf8_char_print(test_utf8_char const c) { unsigned char const* d = reinterpret_cast<unsigned char const*>(c); +#ifndef __clang_analyzer__ // somehow thinks arguments are not initialized printf("[0x%02X,0x%02X,0x%02X,0x%02X]", static_cast<int>(d[0]), static_cast<int>(d[1]), static_cast<int>(d[2]), static_cast<int>(d[3])); +#endif } static void byte_array_print(char const* s) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 57fa7fc..aff7383 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -211,6 +211,13 @@ if(BUILD_TESTING) #--------------------------------------------------------------------------- # Add tests below here. + if(NOT DEFINED CMake_TEST_Qt5) + set(CMake_TEST_Qt5 1) + endif() + if(CMake_TEST_Qt5) + find_package(Qt5Widgets QUIET NO_MODULE) + endif() + if(NOT CMake_TEST_EXTERNAL_CMAKE) add_subdirectory(CMakeLib) @@ -436,7 +443,9 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Assembler HelloAsm) ADD_TEST_MACRO(SourceGroups SourceGroups) ADD_TEST_MACRO(Preprocess Preprocess) - set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) + set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} + -DCMake_TEST_CUDA:BOOL=${CMake_TEST_CUDA} + ) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) @@ -451,8 +460,12 @@ if(BUILD_TESTING) ADD_TEST_MACRO(StagingPrefix StagingPrefix) ADD_TEST_MACRO(ImportedSameName ImportedSameName) ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) - if(NOT _isMultiConfig) - set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>) + if(NOT CMAKE_GENERATOR STREQUAL "Xcode") + if(_isMultiConfig) + set(ConfigSources_CTEST_OPTIONS --build-config $<CONFIGURATION>) + else() + set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>) + endif() ADD_TEST_MACRO(ConfigSources ConfigSources) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) @@ -976,6 +989,27 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH endif() endif() + # On Windows run the CPackNSISGenerator test + # if the nsis is available + if(WIN32 AND NSIS_MAKENSIS_EXECUTABLE) + add_test(CPackNSISGenerator ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackNSISGenerator" + "${CMake_BINARY_DIR}/Tests/CPackNSISGenerator" + ${build_generator_args} + --build-project CPackNSISGenerator + --build-options + --test-command ${CMAKE_CMAKE_COMMAND} + "-DCPackNSISGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackNSISGenerator" + "-Dconfig=\${CTEST_CONFIGURATION_TYPE}" + -P "${CMake_SOURCE_DIR}/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake") + + set_property(TEST CPackNSISGenerator PROPERTY + ATTACHED_FILES_ON_FAIL + "${CMake_BINARY_DIR}/Tests/CPackNSISGenerator/_CPack_Packages/win32/NSIS/NSISOutput.log") + endif() + if(CTEST_TEST_CPACK) add_test(CPackUseDefaultVersion ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1128,8 +1162,8 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH foreach(CPackDEBConfiguration IN LISTS DEB_CONFIGURATIONS_TO_TEST) set(CPackRun_CPackDEBConfiguration "-DCPackDEBConfiguration=${CPackDEBConfiguration}") - add_test(${DEB_TEST_NAMES}-${CPackDEBConfiguration} - ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} + add_test(NAME ${DEB_TEST_NAMES}-${CPackDEBConfiguration} COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --build-and-test "${CMake_SOURCE_DIR}/Tests/${DEB_TEST_NAMES}" "${CMake_BINARY_DIR}/Tests/${DEB_TEST_NAMES}/build${CPackGen}-${CPackDEBConfiguration}" @@ -1146,6 +1180,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH "-D${DEB_TEST_NAMES}_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/${DEB_TEST_NAMES}/build${CPackGen}-${CPackDEBConfiguration}" "${CPackRun_CPackGen}" "${CPackRun_CPackDEBConfiguration}" + "-DCONFIG=$<CONFIG>" -P "${CMake_SOURCE_DIR}/Tests/${DEB_TEST_NAMES}/RunCPackVerifyResult-${CPackDEBConfiguration}.cmake") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${DEB_TEST_NAMES}/build${CPackGen}-${CPackDEBConfiguration}") endforeach() @@ -1325,12 +1360,6 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt") - if(NOT DEFINED CMake_TEST_Qt5) - set(CMake_TEST_Qt5 1) - endif() - if(CMake_TEST_Qt5) - find_package(Qt5Widgets QUIET NO_MODULE) - endif() if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) add_subdirectory(Qt5Autogen) endif() @@ -1401,6 +1430,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH ICU JPEG JsonCpp + LibArchive LibLZMA LibRHash Libinput @@ -1440,7 +1470,8 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_subdirectory(GoogleTest) endif() - if(CMake_TEST_FindPython OR CMake_TEST_FindPython_NumPy) + if(CMake_TEST_FindPython OR CMake_TEST_FindPython_NumPy + OR CMake_TEST_FindPython_Conda OR CMake_TEST_FindPython_IronPython) add_subdirectory(FindPython) endif() @@ -1586,6 +1617,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH set(tutorial_build_options -DUSE_MYMATH:BOOL=OFF) endif() add_test(${tutorial_test_name} ${CMAKE_CTEST_COMMAND} + -C "Release" --build-and-test "${CMake_SOURCE_DIR}/Help/guide/tutorial/${step_name}" ${tutorial_build_dir}_Build @@ -1597,11 +1629,11 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH endfunction() if(NOT CMake_TEST_EXTERNAL_CMAKE) - foreach(STP RANGE 2 11) + foreach(STP RANGE 2 12) add_tutorial_test(Step${STP} TRUE) endforeach() add_tutorial_test(Complete TRUE) - foreach(STP RANGE 3 11) + foreach(STP RANGE 3 12) add_tutorial_test(Step${STP} FALSE) endforeach() add_tutorial_test(Complete FALSE) @@ -1861,7 +1893,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR - "${CMAKE_GENERATOR}" MATCHES "Ninja") + "${CMAKE_GENERATOR}" MATCHES "^Ninja$") add_test(MakeClean ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MakeClean" @@ -3392,17 +3424,6 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400) endif() - # If this is not an in-source build, provide a target to wipe out - # all the test build directories. - if(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") - configure_file(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in - ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY) - add_custom_target(test_clean - COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake - COMMENT "Removing test build directories." - ) - endif() - # Define a set of "contract" tests, each activated by a cache entry # named "CMake_TEST_CONTRACT_<project>". For each Contract test, # the project should provide a directory with a CMakeLists.txt file @@ -3477,4 +3498,16 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH if(NOT CMake_TEST_EXTERNAL_CMAKE) add_subdirectory(CMakeTests) endif() + + # If this is not an in-source build, provide a target to wipe out + # all the test build directories. This must come at the end after + # all the above logic has finished adding to TEST_BUILD_DIRS + if(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") + configure_file(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in + ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY) + add_custom_target(test_clean + COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake + COMMENT "Removing test build directories." + ) + endif() endif() diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 03babd2..361cf5f 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -31,12 +31,9 @@ add_CMakeOnly_test(CheckStructHasMember) add_CMakeOnly_test(CompilerIdC) add_CMakeOnly_test(CompilerIdCXX) -if(CMAKE_OBJC_COMPILER) +if (APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") add_CMakeOnly_test(CompilerIdOBJC) add_CMakeOnly_test(CheckOBJCCompilerFlag) -endif() - -if(CMAKE_OBJCXX_COMPILER) add_CMakeOnly_test(CompilerIdOBJCXX) add_CMakeOnly_test(CheckOBJCXXCompilerFlag) endif() @@ -75,6 +72,12 @@ add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND} add_test(CMakeOnly.ProjectIncludeBefore ${CMAKE_CMAKE_COMMAND} -DTEST=ProjectIncludeBefore + -DCMAKE_ARGS=-DCMAKE_PROJECT_ProjectInclude_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) + +add_test(CMakeOnly.ProjectIncludeBeforeAny ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectIncludeBeforeAny -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake ) diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt index 90aa921..1570c37 100644 --- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -18,16 +18,16 @@ if(APPLE) list(APPEND LANGUAGES OBJC OBJCXX) endif() -foreach(lang ${LANGUAGES}) - check_language(${lang}) - if(NOT DEFINED CMAKE_${lang}_COMPILER) - message(FATAL_ERROR "check_language(${lang}) did not set result") +foreach(test_lang ${LANGUAGES}) + check_language(${test_lang}) + if(NOT DEFINED CMAKE_${test_lang}_COMPILER) + message(FATAL_ERROR "check_language(${test_lang}) did not set result") endif() - if(DEFINED expect_${lang}) - if(expect_${lang} AND NOT CMAKE_${lang}_COMPILER) - message(FATAL_ERROR "check_language(${lang}) should not fail!") - elseif(NOT expect_${lang} AND CMAKE_${lang}_COMPILER) - message(FATAL_ERROR "check_language(${lang}) should not succeed!") + if(DEFINED expect_${test_lang}) + if(expect_${test_lang} AND NOT CMAKE_${test_lang}_COMPILER) + message(FATAL_ERROR "check_language(${test_lang}) should not fail!") + elseif(NOT expect_${test_lang} AND CMAKE_${test_lang}_COMPILER) + message(FATAL_ERROR "check_language(${test_lang}) should not succeed!") endif() endif() endforeach() diff --git a/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt index a9a96ee..a714b73 100644 --- a/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt @@ -1,17 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) - -project(CheckOBJCCompilerFlag) - +cmake_minimum_required(VERSION 3.16) +project(CheckOBJCCompilerFlag OBJC) include(CheckOBJCCompilerFlag) - -if(CMAKE_COMPILER_IS_GNUOBJC) - set(COMPILER_FLAG -fobjc-direct-dispatch) -else() - set(COMPILER_FLAG -fobjc-gc) -endif() - -CHECK_OBJC_COMPILER_FLAGS(${COMPILER_FLAG} HAS_COMPILER_FLAG) - +check_objc_compiler_flag(-DFOO HAS_COMPILER_FLAG) if(NOT HAS_COMPILER_FLAG) message(SEND_ERROR "Test fail: HAS_COMPILER_FLAG: ${COMPILER_FLAG}") -endif +endif() diff --git a/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt index f83b738..d09f0b9 100644 --- a/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt @@ -1,17 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) - -project(CheckOBJCXXCompilerFlag) - +cmake_minimum_required(VERSION 3.16) +project(CheckOBJCXXCompilerFlag OBJCXX) include(CheckOBJCXXCompilerFlag) - -if(CMAKE_COMPILER_IS_GNUOBJCXX) - set(COMPILER_FLAG -fobjc-direct-dispatch) -else() - set(COMPILER_FLAG -fobjc-gc) -endif() - -CHECK_OBJCXX_COMPILER_FLAGS(${COMPILER_FLAG} HAS_COMPILER_FLAG) - +check_objcxx_compiler_flag(-DFOO HAS_COMPILER_FLAG) if(NOT HAS_COMPILER_FLAG) message(SEND_ERROR "Test fail: HAS_COMPILER_FLAG: ${COMPILER_FLAG}") endif() diff --git a/Tests/CMakeOnly/CheckStructHasMember/CMakeLists.txt b/Tests/CMakeOnly/CheckStructHasMember/CMakeLists.txt index a584505..859ec41 100644 --- a/Tests/CMakeOnly/CheckStructHasMember/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckStructHasMember/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}") include(CheckStructHasMember) -foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) +foreach(_config_type Release RelWithDebInfo Debug) set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type}) unset(CSHM_RESULT_S1_${_config_type} CACHE) unset(CSHM_RESULT_S2_${_config_type} CACHE) @@ -26,7 +26,7 @@ foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) endif() endforeach() -foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) +foreach(_config_type Release RelWithDebInfo Debug) set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type}) unset(CSHM_RESULT_S1_${_config_type}_C CACHE) unset(CSHM_RESULT_S2_${_config_type}_C CACHE) @@ -46,7 +46,7 @@ foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) endif() endforeach() -foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) +foreach(_config_type Release RelWithDebInfo Debug) set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type}) unset(CSHM_RESULT_S1_${_config_type}_CXX CACHE) unset(CSHM_RESULT_S2_${_config_type}_CXX CACHE) diff --git a/Tests/CMakeOnly/ProjectIncludeBeforeAny/CMakeLists.txt b/Tests/CMakeOnly/ProjectIncludeBeforeAny/CMakeLists.txt new file mode 100644 index 0000000..5cd9cba --- /dev/null +++ b/Tests/CMakeOnly/ProjectIncludeBeforeAny/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/ProjectIncludeBeforeAny/include.cmake b/Tests/CMakeOnly/ProjectIncludeBeforeAny/include.cmake new file mode 100644 index 0000000..0a4799d --- /dev/null +++ b/Tests/CMakeOnly/ProjectIncludeBeforeAny/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/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in index 0ae8af1..c531e8b 100644 --- a/Tests/CMakeOnly/Test.cmake.in +++ b/Tests/CMakeOnly/Test.cmake.in @@ -7,6 +7,13 @@ if(make_program) set(maybe_make_program "-DCMAKE_MAKE_PROGRAM=${make_program}") endif() +set(_isMultiConfig "@_isMultiConfig@") +if(_isMultiConfig) + set(cfg_opts "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;RelWithDebInfo") +else() + set(cfg_opts) +endif() + set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST_SOURCE}") set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build") file(REMOVE_RECURSE "${binary_dir}") @@ -16,6 +23,7 @@ execute_process( "${source_dir}" -G "@CMAKE_GENERATOR@" -A "@CMAKE_GENERATOR_PLATFORM@" -T "@CMAKE_GENERATOR_TOOLSET@" + ${cfg_opts} ${maybe_make_program} WORKING_DIRECTORY "${binary_dir}" RESULT_VARIABLE result diff --git a/Tests/CMakeTestMultipleConfigures/RunCMake.cmake b/Tests/CMakeTestMultipleConfigures/RunCMake.cmake index 9632664..a79bfcb 100644 --- a/Tests/CMakeTestMultipleConfigures/RunCMake.cmake +++ b/Tests/CMakeTestMultipleConfigures/RunCMake.cmake @@ -21,11 +21,11 @@ set(N 7) # First setup source and binary trees: # -execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory +execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf ${dir}/Source ) -execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory +execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf ${dir}/Build ) @@ -69,7 +69,7 @@ foreach(i RANGE 1 ${N}) # Save this iteration of the Build directory: # - execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory + execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf ${dir}/b${i} ) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 1619081..e32d693 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -33,8 +33,9 @@ AddCMakeTest(While "") AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") -set_property(TEST CMake.FileDownload PROPERTY +set_tests_properties(CMake.FileDownload PROPERTIES PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" + FAIL_REGULAR_EXPRESSION "Unexpected status" ) AddCMakeTest(FileDownloadBadHash "") set_property(TEST CMake.FileDownloadBadHash PROPERTY diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 3935449..76c0000 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -1,23 +1,50 @@ +# We do not contact any real URLs, but do try a bogus one. +# Remove any proxy configuration that may change behavior. +unset(ENV{http_proxy}) +unset(ENV{https_proxy}) + +set(timeout 4) + if(NOT "@CMAKE_CURRENT_SOURCE_DIR@" MATCHES "^/") set(slash /) endif() set(url "file://${slash}@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") set(dir "@CMAKE_CURRENT_BINARY_DIR@/downloads") +# Beware Windows asynchronous file/directory removal, rename and then +# remove the renamed dir so we can be certain the dir isn't there when +# we get to the file() commands below +if(EXISTS "${dir}") + file(RENAME ${dir} "${dir}_beingRemoved") + file(REMOVE_RECURSE "${dir}_beingRemoved") +endif() + +function(__reportIfWrongStatus statusPair expectedStatusCode) + list(GET statusPair 0 statusCode) + if(NOT statusCode EQUAL expectedStatusCode) + message(SEND_ERROR + "Unexpected status: ${statusCode}, expected: ${expectedStatusCode}") + endif() +endfunction() + message(STATUS "FileDownload:1") file(DOWNLOAD ${url} ${dir}/file1.png - TIMEOUT 2 + TIMEOUT ${timeout} + STATUS status ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:2") file(DOWNLOAD ${url} ${dir}/file2.png - TIMEOUT 2 + TIMEOUT ${timeout} + STATUS status SHOW_PROGRESS ) +__reportIfWrongStatus("${status}" 0) # Two calls in a row, exactly the same arguments. # Since downloaded file should exist already for 2nd call, @@ -31,82 +58,108 @@ message(STATUS "FileDownload:3") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} + STATUS status EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:4") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA1=67eee17f79d9ac557284fc0b8ad19f25723fb578 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:5") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA224=ba283726bbb602776818b463943189afd91836cb7ee5dd6e2c7b5ae4 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:6") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA256=cf3334b1275071e1da6e8c396ccb72cf1b2388d8c937526f3af26230affb9423 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:7") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA384=43a5d13978d97c660db44481aee0604cb4ff6ca0775cd5c2cd68cd8000e107e507c4caf6c228941231041e282ffb8950 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:8") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH SHA512=6984e0909a1018030ccaa418e3be1654223cdccff0fe6adc745f9aea7e377f178be53b9fc7d54a6f81c2b62ef9ddcd38ba1978fedf4c5e7139baaf355eefad5b ) +__reportIfWrongStatus("${status}" 0) + message(STATUS "FileDownload:9") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_HASH MD5=dbd330d52f4dbd60115d4191904ded92 ) +__reportIfWrongStatus("${status}" 0) message(STATUS "FileDownload:10") file(DOWNLOAD ${url} ${dir}/file3.png - TIMEOUT 2 + TIMEOUT ${timeout} STATUS status EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) +__reportIfWrongStatus("${status}" 0) +# Print status because we check its message too message(STATUS "${status}") message(STATUS "FileDownload:11") file(DOWNLOAD - badhostname.png + badhostname.invalid ${dir}/file11.png - TIMEOUT 2 + TIMEOUT 30 STATUS status ) message(STATUS "${status}") -list(GET status 0 status_code) -if(NOT ${status_code} EQUAL 6) - message(SEND_ERROR "error: expected status code 6 for bad host name, got: ${status_code}") +__reportIfWrongStatus("${status}" 6) # 6 corresponds to an unresolvable host name + +message(STATUS "FileDownload:12") +set(absFile "@CMAKE_CURRENT_BINARY_DIR@/file12.png") +if(EXISTS "${absFile}") + file(RENAME ${absFile} "${absFile}_beingRemoved") + file(REMOVE "${absFile}_beingRemoved") +endif() +file(DOWNLOAD + ${url} + file12.png + TIMEOUT ${timeout} + EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 + STATUS status + ) +__reportIfWrongStatus("${status}" 0) +if(NOT EXISTS file12.png) + message(SEND_ERROR "file12.png not downloaded: ${status}") endif() diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake index 9a43569..145f28a 100644 --- a/Tests/CMakeTests/FileTestScript.cmake +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -183,7 +183,7 @@ elseif(testname STREQUAL to_native_path) # pass elseif(testname STREQUAL download_wrong_number_of_args) # fail file(DOWNLOAD zzzz://bogus/ffff) -elseif(testname STREQUAL download_file_with_no_path) # fail +elseif(testname STREQUAL download_file_with_no_path) # pass file(DOWNLOAD zzzz://bogus/ffff ffff) elseif(testname STREQUAL download_missing_time) # fail diff --git a/Tests/CPackComponentsDEB/CMakeLists.txt b/Tests/CPackComponentsDEB/CMakeLists.txt index bc5b6a9..4363f1b 100644 --- a/Tests/CPackComponentsDEB/CMakeLists.txt +++ b/Tests/CPackComponentsDEB/CMakeLists.txt @@ -104,7 +104,7 @@ install(FILES ${CPackComponentsDEB_BINARY_DIR}/symtest COMPONENT applications) if(EXISTS "./dirtest") - execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ./dirtest) + execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf ./dirtest) endif() # NOTE: directory left empty on purpose execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ./dirtest) diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in index 67b108b..fb973ad 100644 --- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in +++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in @@ -16,7 +16,7 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1) # overriding previous descriptions set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description") # This become a summary line (the first one) of all descriptions -set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description") +set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description\n") set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description") # libraries does not have any description and should inherit from CPACK_PACKAGE_DESCRIPTION_SUMMARY # plus content of the `CPACK_PACKAGE_DESCRIPTION_FILE`. diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake index b172da2..3bc8d2a 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake @@ -45,7 +45,7 @@ function(run_cpack output_expected_file CPack_output_parent CPack_error_parent) message("config_args = ${run_cpack_deb_CONFIG_ARGS}") message("config_verbose = ${run_cpack_deb_CONFIG_VERBOSE}") - execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${run_cpack_deb_CONFIG_VERBOSE} -G ${CPackGen} ${run_cpack_deb_CONFIG_ARGS} + execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${run_cpack_deb_CONFIG_VERBOSE} -G ${CPackGen} -C "${CONFIG}" ${run_cpack_deb_CONFIG_ARGS} RESULT_VARIABLE CPack_result OUTPUT_VARIABLE CPack_output ERROR_VARIABLE CPack_error diff --git a/Tests/CPackNSISGenerator/CMakeLists.txt b/Tests/CPackNSISGenerator/CMakeLists.txt new file mode 100644 index 0000000..b8b2ed6 --- /dev/null +++ b/Tests/CPackNSISGenerator/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.16) + +project(CPackNSISGenerator) + +add_executable(hello main.cpp) + +install(TARGETS hello + ARCHIVE DESTINATION . + RUNTIME DESTINATION . + LIBRARY DESTINATION . + BUNDLE DESTINATION .) + +set(CPACK_NSIS_MUI_HEADERIMAGE "${PROJECT_SOURCE_DIR}\\\\header-image.bmp") +set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}\\\\header-icon.bmp") +set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}\\\\install.ico") +set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}\\\\uninstall.ico") +set(CPACK_GENERATOR "NSIS") +set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) + +include(CPack) diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake new file mode 100644 index 0000000..01b37c5 --- /dev/null +++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake @@ -0,0 +1,46 @@ +message(STATUS "=============================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackNSISGenerator_BINARY_DIR) + message(FATAL_ERROR "CPackNSISGenerator_BINARY_DIR not set") +endif() + +message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") +message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}") +message(STATUS "CPackNSISGenerator_BINARY_DIR: ${CPackNSISGenerator_BINARY_DIR}") + +if(config) + set(_C_config -C ${config}) +endif() + +execute_process(COMMAND "${CMAKE_CPACK_COMMAND}" + ${_C_config} + RESULT_VARIABLE CPack_result + OUTPUT_VARIABLE CPack_output + ERROR_VARIABLE CPack_error + WORKING_DIRECTORY "${CPackNSISGenerator_BINARY_DIR}") + +if(CPack_result) + message(FATAL_ERROR "CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}") +else () + message(STATUS "CPack_output=${CPack_output}") +endif() + +set(expected_file_mask "${CPackNSISGenerator_BINARY_DIR}/_CPack_Packages/*/NSIS/*.nsi") +file(GLOB project_file "${expected_file_mask}") + +message(STATUS "project_file='${project_file}'") +message(STATUS "expected_file_mask='${expected_file_mask}'") + +if(NOT project_file) + message(FATAL_ERROR "project_file does not exist.") +endif() + +# should match !define MUI_HEADERIMAGE_BITMAP "${PROJECT_SOURCE_DIR}\header-image.bmp" +file(STRINGS "${project_file}" line REGEX "^!define MUI_HEADERIMAGE_BITMAP") +string(FIND "${line}" "header-image.bmp" output_index) +message(STATUS "Found the bitmap at index ${output_index}") +if("${output_index}" EQUAL "-1") + message(FATAL_ERROR "MUI_HEADERIMAGE_BITMAP not found in the project") +endif() diff --git a/Tests/CPackNSISGenerator/header-icon.bmp b/Tests/CPackNSISGenerator/header-icon.bmp Binary files differnew file mode 100644 index 0000000..ef6a656 --- /dev/null +++ b/Tests/CPackNSISGenerator/header-icon.bmp diff --git a/Tests/CPackNSISGenerator/header-image.bmp b/Tests/CPackNSISGenerator/header-image.bmp Binary files differnew file mode 100644 index 0000000..15b1730 --- /dev/null +++ b/Tests/CPackNSISGenerator/header-image.bmp diff --git a/Tests/CPackNSISGenerator/install.ico b/Tests/CPackNSISGenerator/install.ico Binary files differnew file mode 100644 index 0000000..3b1e480 --- /dev/null +++ b/Tests/CPackNSISGenerator/install.ico diff --git a/Tests/CPackNSISGenerator/main.cpp b/Tests/CPackNSISGenerator/main.cpp new file mode 100644 index 0000000..956f345 --- /dev/null +++ b/Tests/CPackNSISGenerator/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 42; +} diff --git a/Tests/CPackNSISGenerator/uninstall.ico b/Tests/CPackNSISGenerator/uninstall.ico Binary files differnew file mode 100644 index 0000000..c4f6316 --- /dev/null +++ b/Tests/CPackNSISGenerator/uninstall.ico diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in index 4bb1262..34824e3 100644 --- a/Tests/CTestConfig/dashboard.cmake.in +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -13,6 +13,8 @@ message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'") set(arg "") if(NOT _isMultiConfig) set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@") +else() + set(arg "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo") endif() message("cmake initial configure") diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in index 973c7b8..59c585b 100644 --- a/Tests/CTestConfig/script.cmake.in +++ b/Tests/CTestConfig/script.cmake.in @@ -6,7 +6,14 @@ set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script") ctest_start(Experimental) -ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +set(_isMultiConfig "@_isMultiConfig@") +if(_isMultiConfig) + set(cfg_opts "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo") +else() + set(cfg_opts) +endif() + +ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "${cfg_opts}" RETURN_VALUE rv) if(NOT rv STREQUAL 0) message(FATAL_ERROR "*** error in ctest_configure ***") endif() diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 2e41754..9fd85be 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -324,7 +324,7 @@ if (WIN32) ${file} "[${hkey}]" DOC "Registry_Test_Path") exec_program(${CMAKE_COMMAND} ARGS "-E delete_regv \"${hkey}\"") - exec_program(${CMAKE_COMMAND} ARGS "-E remove \"${dir}/${file}\"") + exec_program(${CMAKE_COMMAND} ARGS "-E rm -f \"${dir}/${file}\"") endif () endif () diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index 64f6dc8..df874ef 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -131,7 +131,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) # Custom target to try preprocessing invocation. add_custom_target(test_preprocess ${MAYBE_ALL} - COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i + COMMAND ${CMAKE_COMMAND} -E rm -f CMakeFiles/create_file.dir/create_file.i COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 628cd4e..28b73af 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -281,7 +281,7 @@ if (WIN32) ${file} "[${hkey}]" DOC "Registry_Test_Path") exec_program(${CMAKE_COMMAND} ARGS "-E delete_regv \"${hkey}\"") - exec_program(${CMAKE_COMMAND} ARGS "-E remove \"${dir}/${file}\"") + exec_program(${CMAKE_COMMAND} ARGS "-E rm -f \"${dir}/${file}\"") endif () endif () diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index 64f6dc8..df874ef 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -131,7 +131,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) # Custom target to try preprocessing invocation. add_custom_target(test_preprocess ${MAYBE_ALL} - COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i + COMMAND ${CMAKE_COMMAND} -E rm -f CMakeFiles/create_file.dir/create_file.i COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} diff --git a/Tests/Contracts/VTK/CMakeLists.txt b/Tests/Contracts/VTK/CMakeLists.txt index c946499..6ae2732 100644 --- a/Tests/Contracts/VTK/CMakeLists.txt +++ b/Tests/Contracts/VTK/CMakeLists.txt @@ -21,7 +21,7 @@ configure_file( # build & test VTK's release branch ExternalProject_Add(${PROJECT_NAME} - GIT_REPOSITORY "git://vtk.org/VTK.git" + GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git" GIT_TAG "release" PREFIX ${base_dir} CONFIGURE_COMMAND "" diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 44c6005..58b9b03 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -1,11 +1,25 @@ ADD_TEST_MACRO(Cuda.Complex CudaComplex) ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures) +ADD_TEST_MACRO(Cuda.CXXStandardSetTwice CXXStandardSetTwice) ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary) -ADD_TEST_MACRO(Cuda.MixedStandardLevels MixedStandardLevels) +ADD_TEST_MACRO(Cuda.MixedStandardLevels1 MixedStandardLevels1) +ADD_TEST_MACRO(Cuda.MixedStandardLevels2 MixedStandardLevels2) +ADD_TEST_MACRO(Cuda.MixedStandardLevels3 MixedStandardLevels3) +ADD_TEST_MACRO(Cuda.MixedStandardLevels4 MixedStandardLevels4) +ADD_TEST_MACRO(Cuda.MixedStandardLevels5 MixedStandardLevels5) ADD_TEST_MACRO(Cuda.NotEnabled CudaNotEnabled) ADD_TEST_MACRO(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly) -ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude) +ADD_TEST_MACRO(Cuda.Toolkit Toolkit) +ADD_TEST_MACRO(Cuda.IncludePathNoToolkit IncludePathNoToolkit) ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries) ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) +ADD_TEST_MACRO(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) + +# The CUDA only ships the shared version of the toolkit libraries +# on windows +if(NOT WIN32) + ADD_TEST_MACRO(Cuda.StaticRuntimePlusToolkit StaticRuntimePlusToolkit) +endif() + ADD_TEST_MACRO(Cuda.WithC CudaWithC) diff --git a/Tests/Cuda/MixedStandardLevels/CMakeLists.txt b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt index b399662..1941c49 100644 --- a/Tests/Cuda/MixedStandardLevels/CMakeLists.txt +++ b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.7) -project(MixedStandardLevels CXX CUDA) +project(CXXStandardSetTwice CXX CUDA) string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") set(CMAKE_CXX_STANDARD 11) -add_executable(MixedStandardLevels main.cu) -target_compile_features(MixedStandardLevels PUBLIC cxx_std_11) +add_executable(CXXStandardSetTwice main.cu) +target_compile_features(CXXStandardSetTwice PUBLIC cxx_std_11) if(APPLE) # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. - set_property(TARGET MixedStandardLevels PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) + set_property(TARGET CXXStandardSetTwice PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/Cuda/MixedStandardLevels/main.cu b/Tests/Cuda/CXXStandardSetTwice/main.cu index d57c05a..d57c05a 100644 --- a/Tests/Cuda/MixedStandardLevels/main.cu +++ b/Tests/Cuda/CXXStandardSetTwice/main.cu diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt index d3d4b7c..08d1e16 100644 --- a/Tests/Cuda/Complex/CMakeLists.txt +++ b/Tests/Cuda/Complex/CMakeLists.txt @@ -22,18 +22,11 @@ set(CMAKE_CUDA_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) add_library(CudaComplexCppBase SHARED dynamic.cpp) -add_library(CudaComplexSeperableLib STATIC file1.cu file2.cu file3.cu) -set_target_properties(CudaComplexSeperableLib - PROPERTIES CUDA_SEPARABLE_COMPILATION ON) -set_target_properties( CudaComplexSeperableLib - PROPERTIES POSITION_INDEPENDENT_CODE ON) - add_library(CudaComplexSharedLib SHARED dynamic.cu) target_link_libraries(CudaComplexSharedLib PUBLIC CudaComplexCppBase) +add_library(CudaComplexSeperableLib STATIC file1.cu file2.cu file3.cu) add_library(CudaComplexMixedLib SHARED mixed.cpp mixed.cu) -set_target_properties(CudaComplexMixedLib - PROPERTIES CUDA_SEPARABLE_COMPILATION ON) target_link_libraries(CudaComplexMixedLib PUBLIC CudaComplexSharedLib PRIVATE CudaComplexSeperableLib) @@ -41,7 +34,27 @@ target_link_libraries(CudaComplexMixedLib add_executable(CudaComplex main.cpp) target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib) + +set_target_properties(CudaComplexMixedLib + CudaComplexSeperableLib + PROPERTIES + POSITION_INDEPENDENT_CODE ON + CUDA_SEPARABLE_COMPILATION ON + ) +set_target_properties(CudaComplexMixedLib + CudaComplexSharedLib + PROPERTIES + CUDA_RUNTIME_LIBRARY shared + ) + + if(APPLE) # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. set_property(TARGET CudaComplex PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() + +if(UNIX) + # Help the shared cuda runtime find libcudart as it is not located + # in a default system searched location + set_property(TARGET CudaComplexMixedLib PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/Cuda/Complex/dynamic.cu b/Tests/Cuda/Complex/dynamic.cu index 9da8853..7f2f2b5 100644 --- a/Tests/Cuda/Complex/dynamic.cu +++ b/Tests/Cuda/Complex/dynamic.cu @@ -54,17 +54,20 @@ EXPORT int choose_cuda_device() return 1; } -EXPORT void cuda_dynamic_lib_func() +EXPORT bool cuda_dynamic_lib_func() { - DetermineIfValidCudaDevice<<<1, 1>>>(); cudaError_t err = cudaGetLastError(); if (err != cudaSuccess) { - std::cerr << "DetermineIfValidCudaDevice [SYNC] failed: " + std::cerr << "DetermineIfValidCudaDevice [Per Launch] failed: " << cudaGetErrorString(err) << std::endl; + return false; } + DetermineIfValidCudaDevice<<<1, 1>>>(); err = cudaDeviceSynchronize(); if (err != cudaSuccess) { - std::cerr << "DetermineIfValidCudaDevice [ASYNC] failed: " + std::cerr << "DetermineIfValidCudaDevice [SYNC] failed: " << cudaGetErrorString(cudaGetLastError()) << std::endl; + return false; } + return true; } diff --git a/Tests/Cuda/Complex/main.cpp b/Tests/Cuda/Complex/main.cpp index 6ca5952..da09b44 100644 --- a/Tests/Cuda/Complex/main.cpp +++ b/Tests/Cuda/Complex/main.cpp @@ -22,5 +22,6 @@ int main(int argc, char** argv) int r1 = call_cuda_seperable_code(42); int r2 = mixed_launch_kernel(42); + return (r1 == 42 || r2 == 42) ? 1 : 0; } diff --git a/Tests/Cuda/Complex/mixed.cu b/Tests/Cuda/Complex/mixed.cu index 5b85aec..76119ad 100644 --- a/Tests/Cuda/Complex/mixed.cu +++ b/Tests/Cuda/Complex/mixed.cu @@ -15,7 +15,7 @@ result_type __device__ file1_func(int x); result_type_dynamic __device__ file2_func(int x); -IMPORT void __host__ cuda_dynamic_lib_func(); +IMPORT bool __host__ cuda_dynamic_lib_func(); static __global__ void mixed_kernel(result_type* r, int x) { @@ -25,7 +25,9 @@ static __global__ void mixed_kernel(result_type* r, int x) EXPORT int mixed_launch_kernel(int x) { - cuda_dynamic_lib_func(); + if (!cuda_dynamic_lib_func()) { + return x; + } result_type* r; cudaError_t err = cudaMallocManaged(&r, sizeof(result_type)); diff --git a/Tests/Cuda/ToolkitInclude/CMakeLists.txt b/Tests/Cuda/IncludePathNoToolkit/CMakeLists.txt index f246b54..7be1561 100644 --- a/Tests/Cuda/ToolkitInclude/CMakeLists.txt +++ b/Tests/Cuda/IncludePathNoToolkit/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.8) -project (ToolkitInclude CXX CUDA) +project (IncludePathNoToolkit CXX CUDA) #Goal for this example: # Validate that between the CXX implicit include directories and the # CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES directories we can find # the cuda runtime headers -add_executable(CudaToolkitInclude main.cpp) -target_include_directories(CudaToolkitInclude PRIVATE +add_executable(IncludePathNoToolkit main.cpp) +target_include_directories(IncludePathNoToolkit PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) diff --git a/Tests/Cuda/ToolkitInclude/main.cpp b/Tests/Cuda/IncludePathNoToolkit/main.cpp index c8d5c6b..c8d5c6b 100644 --- a/Tests/Cuda/ToolkitInclude/main.cpp +++ b/Tests/Cuda/IncludePathNoToolkit/main.cpp diff --git a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt new file mode 100644 index 0000000..b03e51e --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.7) +project(MixedStandardLevels1 CXX CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CUDA_STANDARD 11) + +add_executable(MixedStandardLevels1 main.cu lib.cpp) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET MixedStandardLevels1 PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/Cuda/MixedStandardLevels1/lib.cpp b/Tests/Cuda/MixedStandardLevels1/lib.cpp new file mode 100644 index 0000000..cabbacb --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels1/lib.cpp @@ -0,0 +1,7 @@ + +int func(int A, int B) +{ + // Verify that we have at least c++14 + auto mult_func = [](auto a, auto b) { return a * b; }; + return mult_func(A, B); +} diff --git a/Tests/Cuda/MixedStandardLevels1/main.cu b/Tests/Cuda/MixedStandardLevels1/main.cu new file mode 100644 index 0000000..bc02c6d --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels1/main.cu @@ -0,0 +1,9 @@ + +#include <type_traits> + +int main(int argc, char** argv) +{ + // Verify that we have at least c++11 + using returnv = std::integral_constant<int, 0>; + return returnv::value; +} diff --git a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt new file mode 100644 index 0000000..12dd328 --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.7) +project(MixedStandardLevels2 CXX CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +set(CMAKE_CXX_STANDARD 17) #this can decay + +add_executable(MixedStandardLevels2 main.cu lib.cpp) +target_compile_features(MixedStandardLevels2 PUBLIC cuda_std_11) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET MixedStandardLevels2 PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/Cuda/MixedStandardLevels2/lib.cpp b/Tests/Cuda/MixedStandardLevels2/lib.cpp new file mode 100644 index 0000000..cabbacb --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels2/lib.cpp @@ -0,0 +1,7 @@ + +int func(int A, int B) +{ + // Verify that we have at least c++14 + auto mult_func = [](auto a, auto b) { return a * b; }; + return mult_func(A, B); +} diff --git a/Tests/Cuda/MixedStandardLevels2/main.cu b/Tests/Cuda/MixedStandardLevels2/main.cu new file mode 100644 index 0000000..a97a41e --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels2/main.cu @@ -0,0 +1,11 @@ + +#if __cplusplus < 201103L && !defined(_MSC_VER) +# error "invalid standard value" +#endif +#include <type_traits> + +int main(int argc, char** argv) +{ + using returnv = std::integral_constant<int, 0>; + return returnv::value; +} diff --git a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt new file mode 100644 index 0000000..2b611be --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.7) +project(MixedStandardLevels3 CXX CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +add_executable(MixedStandardLevels3 main.cu lib.cpp) +target_compile_features(MixedStandardLevels3 PUBLIC cuda_std_03 cxx_std_14) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET MixedStandardLevels3 PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/Cuda/MixedStandardLevels3/lib.cpp b/Tests/Cuda/MixedStandardLevels3/lib.cpp new file mode 100644 index 0000000..cabbacb --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels3/lib.cpp @@ -0,0 +1,7 @@ + +int func(int A, int B) +{ + // Verify that we have at least c++14 + auto mult_func = [](auto a, auto b) { return a * b; }; + return mult_func(A, B); +} diff --git a/Tests/Cuda/MixedStandardLevels3/main.cu b/Tests/Cuda/MixedStandardLevels3/main.cu new file mode 100644 index 0000000..1c19e8d --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels3/main.cu @@ -0,0 +1,5 @@ + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt new file mode 100644 index 0000000..faf6869 --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.7) +project(MixedStandardLevels4 CXX CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +set(CMAKE_CUDA_STANDARD 03) + +add_executable(MixedStandardLevels4 main.cu lib.cpp) +target_compile_features(MixedStandardLevels4 PUBLIC cxx_std_14) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET MixedStandardLevels4 PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/Cuda/MixedStandardLevels4/lib.cpp b/Tests/Cuda/MixedStandardLevels4/lib.cpp new file mode 100644 index 0000000..ef6fc20 --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels4/lib.cpp @@ -0,0 +1,16 @@ + + +constexpr int func(int A, int B) +{ +#if defined(_MSC_VER) && _MSC_VER < 1913 + // no suppport for extended constexpr + return B * A; +#else + // Verify that we have at least c++14 + if (A < B) { + return A + B; + } else { + return B * A; + } +#endif +} diff --git a/Tests/Cuda/MixedStandardLevels4/main.cu b/Tests/Cuda/MixedStandardLevels4/main.cu new file mode 100644 index 0000000..1c19e8d --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels4/main.cu @@ -0,0 +1,5 @@ + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt new file mode 100644 index 0000000..7209f60 --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.7) +project(MixedStandardLevels5 CXX CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +set(CMAKE_CXX_STANDARD 98) + +add_executable(MixedStandardLevels5 main.cu lib.cpp) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET MixedStandardLevels5 PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/Cuda/MixedStandardLevels5/lib.cpp b/Tests/Cuda/MixedStandardLevels5/lib.cpp new file mode 100644 index 0000000..dd7b31b --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels5/lib.cpp @@ -0,0 +1,13 @@ + +#if __cplusplus >= 201103L +# error "invalid standard value" +#endif +int func(int A, int B) +{ + // Verify that we have at least c++14 + if (A < B) { + return A + B; + } else { + return B * A; + } +} diff --git a/Tests/Cuda/MixedStandardLevels5/main.cu b/Tests/Cuda/MixedStandardLevels5/main.cu new file mode 100644 index 0000000..c79afd6 --- /dev/null +++ b/Tests/Cuda/MixedStandardLevels5/main.cu @@ -0,0 +1,8 @@ + +#if __cplusplus >= 201103L +# error "invalid standard value" +#endif +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt new file mode 100644 index 0000000..48df558 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.15) +project(SharedRuntimePlusToolkit CXX) + +#Goal for this example: +# Validate that with c++ we can use some components of the CUDA toolkit, and +# specify the cuda runtime +find_package(CUDAToolkit REQUIRED) + +add_library(Common OBJECT curand.cpp nppif.cpp) +target_link_libraries(Common PRIVATE CUDA::toolkit) +set_target_properties(Common PROPERTIES POSITION_INDEPENDENT_CODE ON) + +#shared runtime with shared toolkit libraries +add_library(SharedToolkit SHARED shared.cpp) +target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::nppif) +target_link_libraries(SharedToolkit PUBLIC CUDA::cudart) + +# The CUDA only ships the shared version of the toolkit libraries +# on windows +if(NOT WIN32) + #shared runtime with static toolkit libraries + add_library(StaticToolkit SHARED static.cpp) + target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) + target_link_libraries(StaticToolkit PUBLIC CUDA::cudart) + + #static runtime with mixed toolkit libraries + add_library(MixedToolkit SHARED mixed.cpp) + target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand_static CUDA::nppif) + target_link_libraries(MixedToolkit PUBLIC CUDA::cudart) +endif() + +add_executable(SharedRuntimePlusToolkit main.cpp) +target_link_libraries(SharedRuntimePlusToolkit PRIVATE SharedToolkit + $<TARGET_NAME_IF_EXISTS:StaticToolkit> + $<TARGET_NAME_IF_EXISTS:MixedToolkit>) diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/curand.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/curand.cpp new file mode 100644 index 0000000..fdd7b53 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/curand.cpp @@ -0,0 +1,65 @@ +// Comes from: +// https://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-example + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +/* + * This program uses the host CURAND API to generate 100 + * pseudorandom floats. + */ +#include <cuda.h> +#include <curand.h> +#include <stdio.h> +#include <stdlib.h> + +#define CUDA_CALL(x) \ + do { \ + if ((x) != cudaSuccess) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) +#define CURAND_CALL(x) \ + do { \ + if ((x) != CURAND_STATUS_SUCCESS) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) + +EXPORT int curand_main() +{ + size_t n = 100; + size_t i; + curandGenerator_t gen; + float *devData, *hostData; + + /* Allocate n floats on host */ + hostData = (float*)calloc(n, sizeof(float)); + + /* Allocate n floats on device */ + CUDA_CALL(cudaMalloc((void**)&devData, n * sizeof(float))); + + /* Create pseudo-random number generator */ + CURAND_CALL(curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT)); + + /* Set seed */ + CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL)); + + /* Generate n floats on device */ + CURAND_CALL(curandGenerateUniform(gen, devData, n)); + + /* Copy device memory to host */ + CUDA_CALL( + cudaMemcpy(hostData, devData, n * sizeof(float), cudaMemcpyDeviceToHost)); + + /* Cleanup */ + CURAND_CALL(curandDestroyGenerator(gen)); + CUDA_CALL(cudaFree(devData)); + free(hostData); + return EXIT_SUCCESS; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp new file mode 100644 index 0000000..2a4da22 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp @@ -0,0 +1,23 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +IMPORT int shared_version(); +int static_version() +{ + return 0; +} +int mixed_version() +{ + return 0; +} +#else +int shared_version(); +int static_version(); +int mixed_version(); +#endif + +int main() +{ + return mixed_version() == 0 && shared_version() == 0 && + static_version() == 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/mixed.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/mixed.cpp new file mode 100644 index 0000000..6de6886 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/mixed.cpp @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int mixed_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/nppif.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/nppif.cpp new file mode 100644 index 0000000..ac5341c --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/nppif.cpp @@ -0,0 +1,92 @@ +// Comes from +// https://devtalk.nvidia.com/default/topic/1037482/gpu-accelerated-libraries/help-me-help-you-with-modern-cmake-and-cuda-mwe-for-npp/post/5271066/#5271066 + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +#include <cstdio> +#include <iostream> + +#include <assert.h> +#include <cuda_runtime_api.h> +#include <nppi_filtering_functions.h> + +EXPORT int nppif_main() +{ + /** + * 8-bit unsigned single-channel 1D row convolution. + */ + const int simgrows = 32; + const int simgcols = 32; + Npp8u *d_pSrc, *d_pDst; + const int nMaskSize = 3; + NppiSize oROI; + oROI.width = simgcols - nMaskSize; + oROI.height = simgrows; + const int simgsize = simgrows * simgcols * sizeof(d_pSrc[0]); + const int dimgsize = oROI.width * oROI.height * sizeof(d_pSrc[0]); + const int simgpix = simgrows * simgcols; + const int dimgpix = oROI.width * oROI.height; + const int nSrcStep = simgcols * sizeof(d_pSrc[0]); + const int nDstStep = oROI.width * sizeof(d_pDst[0]); + const int pixval = 1; + const int nDivisor = 1; + const Npp32s h_pKernel[nMaskSize] = { pixval, pixval, pixval }; + Npp32s* d_pKernel; + const Npp32s nAnchor = 2; + cudaError_t err = cudaMalloc((void**)&d_pSrc, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pDst, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pKernel, nMaskSize * sizeof(d_pKernel[0])); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // set image to pixval initially + err = cudaMemset(d_pSrc, pixval, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemset(d_pDst, 0, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemcpy(d_pKernel, h_pKernel, nMaskSize * sizeof(d_pKernel[0]), + cudaMemcpyHostToDevice); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // copy src to dst + NppStatus ret = + nppiFilterRow_8u_C1R(d_pSrc, nSrcStep, d_pDst, nDstStep, oROI, d_pKernel, + nMaskSize, nAnchor, nDivisor); + assert(ret == NPP_NO_ERROR); + Npp8u* h_imgres = new Npp8u[dimgpix]; + err = cudaMemcpy(h_imgres, d_pDst, dimgsize, cudaMemcpyDeviceToHost); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // test for filtering + for (int i = 0; i < dimgpix; i++) { + if (h_imgres[i] != (pixval * pixval * nMaskSize)) { + fprintf(stderr, "h_imgres at index %d failed to match\n", i); + return 1; + } + } + + return 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/shared.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/shared.cpp new file mode 100644 index 0000000..f3c3dbc --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/shared.cpp @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +int curand_main(); +int nppif_main(); + +EXPORT int shared_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/static.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/static.cpp new file mode 100644 index 0000000..6932fa3 --- /dev/null +++ b/Tests/Cuda/SharedRuntimePlusToolkit/static.cpp @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int static_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt b/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt new file mode 100644 index 0000000..df6c392 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15) +project(StaticRuntimePlusToolkit CXX) + +#Goal for this example: +# Validate that with c++ we can use some components of the CUDA toolkit, and +# specify the cuda runtime +find_package(CUDAToolkit REQUIRED) + +add_library(Common OBJECT curand.cpp nppif.cpp) +target_link_libraries(Common PRIVATE CUDA::toolkit) +set_target_properties(Common PROPERTIES POSITION_INDEPENDENT_CODE ON) + +#static runtime with shared toolkit libraries +add_library(SharedToolkit SHARED shared.cpp) +target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::nppif) +target_link_libraries(SharedToolkit PUBLIC CUDA::cudart_static) + +#static runtime with static toolkit libraries +add_library(StaticToolkit SHARED static.cpp) +target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) +target_link_libraries(StaticToolkit PUBLIC CUDA::cudart_static) + +#static runtime with mixed toolkit libraries +add_library(MixedToolkit SHARED mixed.cpp) +target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand CUDA::nppif_static) +target_link_libraries(MixedToolkit PUBLIC CUDA::cudart_static) + +add_executable(StaticRuntimePlusToolkit main.cpp) +target_link_libraries(StaticRuntimePlusToolkit PRIVATE SharedToolkit StaticToolkit MixedToolkit) diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp new file mode 100644 index 0000000..95872f0 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp @@ -0,0 +1,59 @@ +// Comes from: +// https://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-example + +/* + * This program uses the host CURAND API to generate 100 + * pseudorandom floats. + */ +#include <cuda.h> +#include <curand.h> +#include <stdio.h> +#include <stdlib.h> + +#define CUDA_CALL(x) \ + do { \ + if ((x) != cudaSuccess) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) +#define CURAND_CALL(x) \ + do { \ + if ((x) != CURAND_STATUS_SUCCESS) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) + +int curand_main() +{ + size_t n = 100; + size_t i; + curandGenerator_t gen; + float *devData, *hostData; + + /* Allocate n floats on host */ + hostData = (float*)calloc(n, sizeof(float)); + + /* Allocate n floats on device */ + CUDA_CALL(cudaMalloc((void**)&devData, n * sizeof(float))); + + /* Create pseudo-random number generator */ + CURAND_CALL(curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT)); + + /* Set seed */ + CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL)); + + /* Generate n floats on device */ + CURAND_CALL(curandGenerateUniform(gen, devData, n)); + + /* Copy device memory to host */ + CUDA_CALL( + cudaMemcpy(hostData, devData, n * sizeof(float), cudaMemcpyDeviceToHost)); + + /* Cleanup */ + CURAND_CALL(curandDestroyGenerator(gen)); + CUDA_CALL(cudaFree(devData)); + free(hostData); + return EXIT_SUCCESS; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp new file mode 100644 index 0000000..5a09f8e --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp @@ -0,0 +1,11 @@ + + +int shared_version(); +int static_version(); +int mixed_version(); + +int main() +{ + return mixed_version() == 0 && shared_version() == 0 && + static_version() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp new file mode 100644 index 0000000..a05140d --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int mixed_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp new file mode 100644 index 0000000..2871090 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp @@ -0,0 +1,86 @@ +// Comes from +// https://devtalk.nvidia.com/default/topic/1037482/gpu-accelerated-libraries/help-me-help-you-with-modern-cmake-and-cuda-mwe-for-npp/post/5271066/#5271066 + +#include <cstdio> +#include <iostream> + +#include <assert.h> +#include <cuda_runtime_api.h> +#include <nppi_filtering_functions.h> + +int nppif_main() +{ + /** + * 8-bit unsigned single-channel 1D row convolution. + */ + const int simgrows = 32; + const int simgcols = 32; + Npp8u *d_pSrc, *d_pDst; + const int nMaskSize = 3; + NppiSize oROI; + oROI.width = simgcols - nMaskSize; + oROI.height = simgrows; + const int simgsize = simgrows * simgcols * sizeof(d_pSrc[0]); + const int dimgsize = oROI.width * oROI.height * sizeof(d_pSrc[0]); + const int simgpix = simgrows * simgcols; + const int dimgpix = oROI.width * oROI.height; + const int nSrcStep = simgcols * sizeof(d_pSrc[0]); + const int nDstStep = oROI.width * sizeof(d_pDst[0]); + const int pixval = 1; + const int nDivisor = 1; + const Npp32s h_pKernel[nMaskSize] = { pixval, pixval, pixval }; + Npp32s* d_pKernel; + const Npp32s nAnchor = 2; + cudaError_t err = cudaMalloc((void**)&d_pSrc, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pDst, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pKernel, nMaskSize * sizeof(d_pKernel[0])); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // set image to pixval initially + err = cudaMemset(d_pSrc, pixval, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemset(d_pDst, 0, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemcpy(d_pKernel, h_pKernel, nMaskSize * sizeof(d_pKernel[0]), + cudaMemcpyHostToDevice); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // copy src to dst + NppStatus ret = + nppiFilterRow_8u_C1R(d_pSrc, nSrcStep, d_pDst, nDstStep, oROI, d_pKernel, + nMaskSize, nAnchor, nDivisor); + assert(ret == NPP_NO_ERROR); + Npp8u* h_imgres = new Npp8u[dimgpix]; + err = cudaMemcpy(h_imgres, d_pDst, dimgsize, cudaMemcpyDeviceToHost); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // test for filtering + for (int i = 0; i < dimgpix; i++) { + if (h_imgres[i] != (pixval * pixval * nMaskSize)) { + fprintf(stderr, "h_imgres at index %d failed to match\n", i); + return 1; + } + } + + return 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp new file mode 100644 index 0000000..9967b66 --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int shared_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp new file mode 100644 index 0000000..ca7eb4c --- /dev/null +++ b/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int static_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/Cuda/Toolkit/CMakeLists.txt b/Tests/Cuda/Toolkit/CMakeLists.txt new file mode 100644 index 0000000..86b4652 --- /dev/null +++ b/Tests/Cuda/Toolkit/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.15) +project(Toolkit CXX) + +#Goal for this example: +# Validate that we can use CUDAToolkit to find cuda include paths +find_package(CUDAToolkit REQUIRED) + +message(STATUS "CUDAToolkit_VERSION: ${CUDAToolkit_VERSION}") +message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}") +message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}") +message(STATUS "CUDAToolkit_VERSION_PATCH: ${CUDAToolkit_VERSION_PATCH}") +message(STATUS "CUDAToolkit_BIN_DIR: ${CUDAToolkit_BIN_DIR}") +message(STATUS "CUDAToolkit_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}") +message(STATUS "CUDAToolkit_LIBRARY_DIR: ${CUDAToolkit_LIBRARY_DIR}") +message(STATUS "CUDAToolkit_NVCC_EXECUTABLE ${CUDAToolkit_NVCC_EXECUTABLE}") + +# Verify that all the CUDA:: targets exist even when the CUDA language isn't enabled + +foreach (cuda_lib cudart cuda_driver cublas cufft cufftw curand cusolver cusparse nvgraph) + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found") + endif() +endforeach() + +foreach (cuda_lib nppc nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu) + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found") + endif() +endforeach() + +foreach (cuda_lib nvrtc nvToolsExt OpenCL) + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found") + endif() +endforeach() + +add_executable(Toolkit main.cpp) +target_link_libraries(Toolkit PRIVATE CUDA::toolkit) diff --git a/Tests/Cuda/Toolkit/main.cpp b/Tests/Cuda/Toolkit/main.cpp new file mode 100644 index 0000000..c8d5c6b --- /dev/null +++ b/Tests/Cuda/Toolkit/main.cpp @@ -0,0 +1,8 @@ +// Only thing we care about is that these headers are found +#include <cuda.h> +#include <cuda_runtime_api.h> + +int main() +{ + return 0; +} diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index f1fd344..3e3e44c 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -5,8 +5,22 @@ ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) +ADD_TEST_MACRO(CudaOnly.SharedRuntimePlusToolkit CudaOnlySharedRuntimePlusToolkit) +ADD_TEST_MACRO(CudaOnly.SharedRuntimeViaCUDAFlags CudaOnlySharedRuntimeViaCUDAFlags) +ADD_TEST_MACRO(CudaOnly.Standard98 CudaOnlyStandard98) +ADD_TEST_MACRO(CudaOnly.Toolkit CudaOnlyToolkit) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) +# The CUDA only ships the shared version of the toolkit libraries +# on windows +if(NOT WIN32) + ADD_TEST_MACRO(Cuda.StaticRuntimePlusToolkit StaticRuntimePlusToolkit) +endif() + +if(MSVC) + ADD_TEST_MACRO(CudaOnly.PDB CudaOnlyPDB) +endif() + add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -18,6 +32,14 @@ add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) -if(MSVC) - ADD_TEST_MACRO(CudaOnly.PDB CudaOnlyPDB) -endif() +add_test(NAME CudaOnly.RuntimeControls COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}/RuntimeControls/" + "${CMAKE_CURRENT_BINARY_DIR}/RuntimeControls/" + --build-two-config + ${build_generator_args} + --build-project RuntimeControls + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt index 54e2c14..dfcb8da 100644 --- a/Tests/CudaOnly/EnableStandard/CMakeLists.txt +++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt @@ -11,8 +11,9 @@ add_library(CUDADynamic11 SHARED shared.cu) add_executable(CudaOnlyEnableStandard main.cu) target_link_libraries(CudaOnlyEnableStandard PRIVATE CUDAStatic11 CUDADynamic11) -set_target_properties(CUDAStatic11 CUDADynamic11 PROPERTIES CUDA_STANDARD 11) -set_target_properties(CUDAStatic11 CUDADynamic11 PROPERTIES CUDA_STANDARD_REQUIRED TRUE) +target_compile_features(CUDADynamic11 PRIVATE cuda_std_11) +set_target_properties(CUDAStatic11 PROPERTIES CUDA_STANDARD 11) +set_target_properties(CUDAStatic11 PROPERTIES CUDA_STANDARD_REQUIRED TRUE) #Verify CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES foreach(dir ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index 64845c5..57aa0b9 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -22,11 +22,11 @@ endif() # 3. Verify that we can't use those device symbols from anything that links # to the static library string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[sm_30] -gencode arch=compute_50,code=\\\"compute_50\\\"") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CUDA_STANDARD 11) add_library(CUDAResolveDeviceDepsA STATIC file1.cu) add_library(CUDAResolveDeviceDepsB STATIC file2.cu) +target_compile_features(CUDAResolveDeviceDepsA PUBLIC cuda_std_11) +target_compile_features(CUDAResolveDeviceDepsB PUBLIC cuda_std_11) set_target_properties(CUDAResolveDeviceDepsA CUDAResolveDeviceDepsB PROPERTIES CUDA_SEPARABLE_COMPILATION ON diff --git a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt new file mode 100644 index 0000000..8b58fec --- /dev/null +++ b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 3.7) +project (RuntimeControls CUDA) + +# Find nm and dumpbin +if(CMAKE_NM) + set(dump_command ${CMAKE_NM}) + set(dump_args -g) +else() + include(GetPrerequisites) + message(STATUS "calling list_prerequisites to find dumpbin") + list_prerequisites("${CMAKE_COMMAND}" 0 0 0) + if(gp_dumpbin) + set(dump_command ${gp_dumpbin}) + set(dump_args /ARCHIVEMEMBERS) + endif() +endif() + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]") + +set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_RUNTIME_LIBRARY static) + +if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") + add_library(UsesNoCudaRT SHARED file1.cu) + set_target_properties(UsesNoCudaRT PROPERTIES CUDA_RUNTIME_LIBRARY none) +endif() + +add_library(UsesStaticCudaRT SHARED file2.cu) + +add_executable(CudaOnlyRuntimeControls main.cu) +set_target_properties(CudaOnlyRuntimeControls PROPERTIES CUDA_RUNTIME_LIBRARY shared) + +target_link_libraries(CudaOnlyRuntimeControls PRIVATE $<TARGET_NAME_IF_EXISTS:UsesNoCudaRT> UsesStaticCudaRT) + + +if(dump_command) + if(TARGET UsesNoCudaRT) + add_custom_command(TARGET UsesNoCudaRT POST_BUILD + COMMAND ${CMAKE_COMMAND} + -DDUMP_COMMAND=${dump_command} + -DDUMP_ARGS=${dump_args} + -DTEST_LIBRARY_PATH=$<TARGET_FILE:UsesNoCudaRT> + -P ${CMAKE_CURRENT_SOURCE_DIR}/no_runtime.cmake + ) + endif() + add_custom_command(TARGET UsesStaticCudaRT POST_BUILD + COMMAND ${CMAKE_COMMAND} + -DDUMP_COMMAND=${dump_command} + -DDUMP_ARGS=${dump_args} + -DTEST_LIBRARY_PATH=$<TARGET_FILE:UsesStaticCudaRT> + -P ${CMAKE_CURRENT_SOURCE_DIR}/uses_static_runtime.cmake + ) + string(REPLACE ";" "|" dirs "${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") + add_custom_command(TARGET CudaOnlyRuntimeControls POST_BUILD + COMMAND ${CMAKE_COMMAND} + -DEXEC_PATH=$<TARGET_FILE:CudaOnlyRuntimeControls> + -DEXTRA_LIB_DIRS="${dirs}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/verify_runtime.cmake + ) +endif() diff --git a/Tests/CudaOnly/RuntimeControls/file1.cu b/Tests/CudaOnly/RuntimeControls/file1.cu new file mode 100644 index 0000000..28beb5e --- /dev/null +++ b/Tests/CudaOnly/RuntimeControls/file1.cu @@ -0,0 +1,18 @@ + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +void __global__ file1_kernel(int x, int& r) +{ + r = -x; +} + +EXPORT int file1_launch_kernel(int x) +{ + int r = 0; + file1_kernel<<<1, 1>>>(x, r); + return r; +} diff --git a/Tests/CudaOnly/RuntimeControls/file2.cu b/Tests/CudaOnly/RuntimeControls/file2.cu new file mode 100644 index 0000000..ff68a70 --- /dev/null +++ b/Tests/CudaOnly/RuntimeControls/file2.cu @@ -0,0 +1,18 @@ + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +void __global__ file2_kernel(int x, int& r) +{ + r = -x; +} + +EXPORT int file2_launch_kernel(int x) +{ + int r = 0; + file2_kernel<<<1, 1>>>(x, r); + return r; +} diff --git a/Tests/CudaOnly/RuntimeControls/main.cu b/Tests/CudaOnly/RuntimeControls/main.cu new file mode 100644 index 0000000..0be22af --- /dev/null +++ b/Tests/CudaOnly/RuntimeControls/main.cu @@ -0,0 +1,81 @@ + +#include <iostream> + +#include "cuda.h" + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +#else +# define IMPORT +#endif + +#ifndef _WIN32 +IMPORT int file1_launch_kernel(int x); +#endif + +IMPORT int file2_launch_kernel(int x); + +int choose_cuda_device() +{ + int nDevices = 0; + cudaError_t err = cudaGetDeviceCount(&nDevices); + if (err != cudaSuccess) { + std::cerr << "Failed to retrieve the number of CUDA enabled devices" + << std::endl; + return 1; + } + for (int i = 0; i < nDevices; ++i) { + cudaDeviceProp prop; + cudaError_t err = cudaGetDeviceProperties(&prop, i); + if (err != cudaSuccess) { + std::cerr << "Could not retrieve properties from CUDA device " << i + << std::endl; + return 1; + } + std::cout << "prop.major: " << prop.major << std::endl; + if (prop.major >= 3) { + err = cudaSetDevice(i); + if (err != cudaSuccess) { + std::cout << "Could not select CUDA device " << i << std::endl; + } else { + return 0; + } + } + } + + std::cout << "Could not find a CUDA enabled card supporting compute >=3.0" + << std::endl; + + return 1; +} + +int main(int argc, char** argv) +{ + int ret = choose_cuda_device(); + if (ret) { + return 0; + } + + cudaError_t err; +#ifndef _WIN32 + file1_launch_kernel(1); + err = cudaGetLastError(); + if (err != cudaSuccess) { + std::cerr << "file1_launch_kernel: kernel launch should have passed.\n " + "Error message: " + << cudaGetErrorString(err) << std::endl; + return 1; + } +#endif + + file2_launch_kernel(1); + err = cudaGetLastError(); + if (err != cudaSuccess) { + std::cerr << "file2_launch_kernel: kernel launch should have passed.\n " + "Error message: " + << cudaGetErrorString(err) << std::endl; + return 1; + } + + return 0; +} diff --git a/Tests/CudaOnly/RuntimeControls/no_runtime.cmake b/Tests/CudaOnly/RuntimeControls/no_runtime.cmake new file mode 100644 index 0000000..55f28cc --- /dev/null +++ b/Tests/CudaOnly/RuntimeControls/no_runtime.cmake @@ -0,0 +1,14 @@ +execute_process(COMMAND ${DUMP_COMMAND} ${DUMP_ARGS} ${TEST_LIBRARY_PATH} + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE ERROR +) + +if(NOT "${RESULT}" STREQUAL "0") + message(FATAL_ERROR "${DUMP_COMMAND} failed [${RESULT}] [${OUTPUT}] [${ERROR}]") +endif() + +if(NOT "${OUTPUT}" MATCHES "(__cuda)") + message(FATAL_ERROR + "not missing cuda device symbols, static runtime linking was used.") +endif() diff --git a/Tests/CudaOnly/RuntimeControls/uses_static_runtime.cmake b/Tests/CudaOnly/RuntimeControls/uses_static_runtime.cmake new file mode 100644 index 0000000..b372fea --- /dev/null +++ b/Tests/CudaOnly/RuntimeControls/uses_static_runtime.cmake @@ -0,0 +1,14 @@ +execute_process(COMMAND ${DUMP_COMMAND} ${DUMP_ARGS} ${TEST_LIBRARY_PATH} + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE ERROR +) + +if(NOT "${RESULT}" STREQUAL "0") + message(FATAL_ERROR "${DUMP_COMMAND} failed [${RESULT}] [${OUTPUT}] [${ERROR}]") +endif() + +if("${OUTPUT}" MATCHES "__cuda") + message(FATAL_ERROR + "missing cuda device symbols, static runtime linking was not used.") +endif() diff --git a/Tests/CudaOnly/RuntimeControls/verify_runtime.cmake b/Tests/CudaOnly/RuntimeControls/verify_runtime.cmake new file mode 100644 index 0000000..b313dac --- /dev/null +++ b/Tests/CudaOnly/RuntimeControls/verify_runtime.cmake @@ -0,0 +1,16 @@ + +string(REPLACE "|" ";" dirs "${EXTRA_LIB_DIRS}") +file(GET_RUNTIME_DEPENDENCIES + RESOLVED_DEPENDENCIES_VAR resolved_libs + UNRESOLVED_DEPENDENCIES_VAR unresolved_libs + DIRECTORIES ${dirs} + EXECUTABLES ${EXEC_PATH} + ) + +list(FILTER resolved_libs INCLUDE REGEX ".*cudart.*") +list(LENGTH resolved_libs has_cudart) + +if(has_cudart EQUAL 0) + message(FATAL_ERROR + "missing cudart shared library from runtime dependency output.") +endif() diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index 1e574d6..c1bd64a 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -11,11 +11,10 @@ project (SeparateCompilation CUDA) #all containing cuda separable compilation code links properly string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=\\\"compute_30,sm_30,sm_35\\\"") string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu) +target_compile_features(CUDASeparateLibA PRIVATE cuda_std_11) get_property(sep_comp TARGET CUDASeparateLibA PROPERTY CUDA_SEPARABLE_COMPILATION) if(NOT sep_comp) message(FATAL_ERROR "CUDA_SEPARABLE_COMPILATION not initialized") @@ -36,11 +35,14 @@ endif() #cause a segv when trying to run the executable # add_library(CUDASeparateLibB STATIC file4.cu file5.cu) +target_compile_features(CUDASeparateLibB PRIVATE cuda_std_11) target_link_libraries(CUDASeparateLibB PRIVATE CUDASeparateLibA) add_executable(CudaOnlySeparateCompilation main.cu) target_link_libraries(CudaOnlySeparateCompilation PRIVATE CUDASeparateLibB) +set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD 11) +set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD_REQUIRED TRUE) set_target_properties(CUDASeparateLibA CUDASeparateLibB diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt b/Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt new file mode 100644 index 0000000..03fba22 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.15) +project(SharedRuntimePlusToolkit CUDA) + +#Goal for this example: +# Validate that with c++ we can use some components of the CUDA toolkit, and +# specify the cuda runtime +find_package(CUDAToolkit REQUIRED) + +add_library(Common OBJECT curand.cu nppif.cu) +target_link_libraries(Common PRIVATE CUDA::toolkit) +set_target_properties(Common PROPERTIES POSITION_INDEPENDENT_CODE ON) + +#shared runtime with shared toolkit libraries +add_library(SharedToolkit SHARED shared.cu) +target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::nppif) +set_target_properties(SharedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY none) +target_link_libraries(SharedToolkit PUBLIC CUDA::cudart) + +# The CUDA only ships the shared version of the toolkit libraries +# on windows +if(NOT WIN32) + #shared runtime with static toolkit libraries + add_library(StaticToolkit SHARED static.cu) + target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) + set_target_properties(StaticToolkit PROPERTIES CUDA_RUNTIME_LIBRARY Shared) + + #static runtime with mixed toolkit libraries + add_library(MixedToolkit SHARED mixed.cu) + target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand_static CUDA::nppif) + set_target_properties(MixedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY Shared) +endif() + +add_executable(CudaOnlySharedRuntimePlusToolkit main.cu) +target_link_libraries(CudaOnlySharedRuntimePlusToolkit PRIVATE SharedToolkit + $<TARGET_NAME_IF_EXISTS:StaticToolkit> + $<TARGET_NAME_IF_EXISTS:MixedToolkit>) + +if(UNIX) + # Help the shared cuda runtime find libcudart as it is not located + # in a default system searched location + set_property(TARGET CudaOnlySharedRuntimePlusToolkit PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/curand.cu b/Tests/CudaOnly/SharedRuntimePlusToolkit/curand.cu new file mode 100644 index 0000000..fdd7b53 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/curand.cu @@ -0,0 +1,65 @@ +// Comes from: +// https://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-example + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +/* + * This program uses the host CURAND API to generate 100 + * pseudorandom floats. + */ +#include <cuda.h> +#include <curand.h> +#include <stdio.h> +#include <stdlib.h> + +#define CUDA_CALL(x) \ + do { \ + if ((x) != cudaSuccess) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) +#define CURAND_CALL(x) \ + do { \ + if ((x) != CURAND_STATUS_SUCCESS) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) + +EXPORT int curand_main() +{ + size_t n = 100; + size_t i; + curandGenerator_t gen; + float *devData, *hostData; + + /* Allocate n floats on host */ + hostData = (float*)calloc(n, sizeof(float)); + + /* Allocate n floats on device */ + CUDA_CALL(cudaMalloc((void**)&devData, n * sizeof(float))); + + /* Create pseudo-random number generator */ + CURAND_CALL(curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT)); + + /* Set seed */ + CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL)); + + /* Generate n floats on device */ + CURAND_CALL(curandGenerateUniform(gen, devData, n)); + + /* Copy device memory to host */ + CUDA_CALL( + cudaMemcpy(hostData, devData, n * sizeof(float), cudaMemcpyDeviceToHost)); + + /* Cleanup */ + CURAND_CALL(curandDestroyGenerator(gen)); + CUDA_CALL(cudaFree(devData)); + free(hostData); + return EXIT_SUCCESS; +} diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu b/Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu new file mode 100644 index 0000000..2a4da22 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu @@ -0,0 +1,23 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +IMPORT int shared_version(); +int static_version() +{ + return 0; +} +int mixed_version() +{ + return 0; +} +#else +int shared_version(); +int static_version(); +int mixed_version(); +#endif + +int main() +{ + return mixed_version() == 0 && shared_version() == 0 && + static_version() == 0; +} diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/mixed.cu b/Tests/CudaOnly/SharedRuntimePlusToolkit/mixed.cu new file mode 100644 index 0000000..6de6886 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/mixed.cu @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int mixed_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/nppif.cu b/Tests/CudaOnly/SharedRuntimePlusToolkit/nppif.cu new file mode 100644 index 0000000..ac5341c --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/nppif.cu @@ -0,0 +1,92 @@ +// Comes from +// https://devtalk.nvidia.com/default/topic/1037482/gpu-accelerated-libraries/help-me-help-you-with-modern-cmake-and-cuda-mwe-for-npp/post/5271066/#5271066 + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +#include <cstdio> +#include <iostream> + +#include <assert.h> +#include <cuda_runtime_api.h> +#include <nppi_filtering_functions.h> + +EXPORT int nppif_main() +{ + /** + * 8-bit unsigned single-channel 1D row convolution. + */ + const int simgrows = 32; + const int simgcols = 32; + Npp8u *d_pSrc, *d_pDst; + const int nMaskSize = 3; + NppiSize oROI; + oROI.width = simgcols - nMaskSize; + oROI.height = simgrows; + const int simgsize = simgrows * simgcols * sizeof(d_pSrc[0]); + const int dimgsize = oROI.width * oROI.height * sizeof(d_pSrc[0]); + const int simgpix = simgrows * simgcols; + const int dimgpix = oROI.width * oROI.height; + const int nSrcStep = simgcols * sizeof(d_pSrc[0]); + const int nDstStep = oROI.width * sizeof(d_pDst[0]); + const int pixval = 1; + const int nDivisor = 1; + const Npp32s h_pKernel[nMaskSize] = { pixval, pixval, pixval }; + Npp32s* d_pKernel; + const Npp32s nAnchor = 2; + cudaError_t err = cudaMalloc((void**)&d_pSrc, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pDst, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pKernel, nMaskSize * sizeof(d_pKernel[0])); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // set image to pixval initially + err = cudaMemset(d_pSrc, pixval, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemset(d_pDst, 0, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemcpy(d_pKernel, h_pKernel, nMaskSize * sizeof(d_pKernel[0]), + cudaMemcpyHostToDevice); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // copy src to dst + NppStatus ret = + nppiFilterRow_8u_C1R(d_pSrc, nSrcStep, d_pDst, nDstStep, oROI, d_pKernel, + nMaskSize, nAnchor, nDivisor); + assert(ret == NPP_NO_ERROR); + Npp8u* h_imgres = new Npp8u[dimgpix]; + err = cudaMemcpy(h_imgres, d_pDst, dimgsize, cudaMemcpyDeviceToHost); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // test for filtering + for (int i = 0; i < dimgpix; i++) { + if (h_imgres[i] != (pixval * pixval * nMaskSize)) { + fprintf(stderr, "h_imgres at index %d failed to match\n", i); + return 1; + } + } + + return 0; +} diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/shared.cu b/Tests/CudaOnly/SharedRuntimePlusToolkit/shared.cu new file mode 100644 index 0000000..f3c3dbc --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/shared.cu @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +int curand_main(); +int nppif_main(); + +EXPORT int shared_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/static.cu b/Tests/CudaOnly/SharedRuntimePlusToolkit/static.cu new file mode 100644 index 0000000..6932fa3 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/static.cu @@ -0,0 +1,16 @@ + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int static_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt new file mode 100644 index 0000000..24ff478 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.17) +project(SharedRuntimeViaCUDAFlags NONE) + +set(CMAKE_CUDA_FLAGS "") +string(APPEND CMAKE_CUDA_FLAGS "-cudart shared") + +enable_language(CUDA) + +add_executable(CudaOnlySharedRuntimeViaCUDAFlags main.cu) + +if(UNIX) + # Help the shared cuda runtime find libcudart as it is not located + # in a default system searched location + set_property(TARGET CudaOnlySharedRuntimeViaCUDAFlags PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/CudaOnly/Standard98/CMakeLists.txt b/Tests/CudaOnly/Standard98/CMakeLists.txt new file mode 100644 index 0000000..ef9a685 --- /dev/null +++ b/Tests/CudaOnly/Standard98/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.7) +project(CudaOnlyStandard98 CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +# Support setting CUDA Standard to 98 which internally gets transformed to +# CUDA03 +set(CMAKE_CUDA_STANDARD 98) + +add_executable(CudaOnlyStandard98 main.cu) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyStandard98 PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/Standard98/main.cu b/Tests/CudaOnly/Standard98/main.cu new file mode 100644 index 0000000..c79afd6 --- /dev/null +++ b/Tests/CudaOnly/Standard98/main.cu @@ -0,0 +1,8 @@ + +#if __cplusplus >= 201103L +# error "invalid standard value" +#endif +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt b/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt new file mode 100644 index 0000000..97ac229 --- /dev/null +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15) +project(StaticRuntimePlusToolkit CUDA) + +#Goal for this example: +# Validate that with cuda we can use some components of the CUDA toolkit, and +# specify the cuda runtime +find_package(CUDAToolkit REQUIRED) + +add_library(Common OBJECT curand.cu nppif.cu) +target_link_libraries(Common PRIVATE CUDA::toolkit) +set_target_properties(Common PROPERTIES POSITION_INDEPENDENT_CODE ON) + +#static runtime with shared toolkit libraries +add_library(SharedToolkit SHARED shared.cu) +target_link_libraries(SharedToolkit PRIVATE Common CUDA::curand CUDA::nppif ) +set_target_properties(SharedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY none) +target_link_libraries(SharedToolkit PUBLIC CUDA::cudart_static) + +#static runtime with static toolkit libraries +add_library(StaticToolkit SHARED static.cu) +target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) + +#static runtime with mixed toolkit libraries +add_library(MixedToolkit SHARED mixed.cu) +target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand CUDA::nppif_static) +set_target_properties(MixedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY Static) + +add_executable(CudaOnlyStaticRuntimePlusToolkit main.cu) +target_link_libraries(CudaOnlyStaticRuntimePlusToolkit PRIVATE SharedToolkit StaticToolkit MixedToolkit) diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu new file mode 100644 index 0000000..95872f0 --- /dev/null +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu @@ -0,0 +1,59 @@ +// Comes from: +// https://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-example + +/* + * This program uses the host CURAND API to generate 100 + * pseudorandom floats. + */ +#include <cuda.h> +#include <curand.h> +#include <stdio.h> +#include <stdlib.h> + +#define CUDA_CALL(x) \ + do { \ + if ((x) != cudaSuccess) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) +#define CURAND_CALL(x) \ + do { \ + if ((x) != CURAND_STATUS_SUCCESS) { \ + printf("Error at %s:%d\n", __FILE__, __LINE__); \ + return EXIT_FAILURE; \ + } \ + } while (0) + +int curand_main() +{ + size_t n = 100; + size_t i; + curandGenerator_t gen; + float *devData, *hostData; + + /* Allocate n floats on host */ + hostData = (float*)calloc(n, sizeof(float)); + + /* Allocate n floats on device */ + CUDA_CALL(cudaMalloc((void**)&devData, n * sizeof(float))); + + /* Create pseudo-random number generator */ + CURAND_CALL(curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT)); + + /* Set seed */ + CURAND_CALL(curandSetPseudoRandomGeneratorSeed(gen, 1234ULL)); + + /* Generate n floats on device */ + CURAND_CALL(curandGenerateUniform(gen, devData, n)); + + /* Copy device memory to host */ + CUDA_CALL( + cudaMemcpy(hostData, devData, n * sizeof(float), cudaMemcpyDeviceToHost)); + + /* Cleanup */ + CURAND_CALL(curandDestroyGenerator(gen)); + CUDA_CALL(cudaFree(devData)); + free(hostData); + return EXIT_SUCCESS; +} diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/main.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/main.cu new file mode 100644 index 0000000..5a09f8e --- /dev/null +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/main.cu @@ -0,0 +1,11 @@ + + +int shared_version(); +int static_version(); +int mixed_version(); + +int main() +{ + return mixed_version() == 0 && shared_version() == 0 && + static_version() == 0; +} diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/mixed.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/mixed.cu new file mode 100644 index 0000000..a05140d --- /dev/null +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/mixed.cu @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int mixed_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/nppif.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/nppif.cu new file mode 100644 index 0000000..2871090 --- /dev/null +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/nppif.cu @@ -0,0 +1,86 @@ +// Comes from +// https://devtalk.nvidia.com/default/topic/1037482/gpu-accelerated-libraries/help-me-help-you-with-modern-cmake-and-cuda-mwe-for-npp/post/5271066/#5271066 + +#include <cstdio> +#include <iostream> + +#include <assert.h> +#include <cuda_runtime_api.h> +#include <nppi_filtering_functions.h> + +int nppif_main() +{ + /** + * 8-bit unsigned single-channel 1D row convolution. + */ + const int simgrows = 32; + const int simgcols = 32; + Npp8u *d_pSrc, *d_pDst; + const int nMaskSize = 3; + NppiSize oROI; + oROI.width = simgcols - nMaskSize; + oROI.height = simgrows; + const int simgsize = simgrows * simgcols * sizeof(d_pSrc[0]); + const int dimgsize = oROI.width * oROI.height * sizeof(d_pSrc[0]); + const int simgpix = simgrows * simgcols; + const int dimgpix = oROI.width * oROI.height; + const int nSrcStep = simgcols * sizeof(d_pSrc[0]); + const int nDstStep = oROI.width * sizeof(d_pDst[0]); + const int pixval = 1; + const int nDivisor = 1; + const Npp32s h_pKernel[nMaskSize] = { pixval, pixval, pixval }; + Npp32s* d_pKernel; + const Npp32s nAnchor = 2; + cudaError_t err = cudaMalloc((void**)&d_pSrc, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pDst, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMalloc((void**)&d_pKernel, nMaskSize * sizeof(d_pKernel[0])); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // set image to pixval initially + err = cudaMemset(d_pSrc, pixval, simgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemset(d_pDst, 0, dimgsize); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + err = cudaMemcpy(d_pKernel, h_pKernel, nMaskSize * sizeof(d_pKernel[0]), + cudaMemcpyHostToDevice); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // copy src to dst + NppStatus ret = + nppiFilterRow_8u_C1R(d_pSrc, nSrcStep, d_pDst, nDstStep, oROI, d_pKernel, + nMaskSize, nAnchor, nDivisor); + assert(ret == NPP_NO_ERROR); + Npp8u* h_imgres = new Npp8u[dimgpix]; + err = cudaMemcpy(h_imgres, d_pDst, dimgsize, cudaMemcpyDeviceToHost); + if (err != cudaSuccess) { + fprintf(stderr, "Cuda error %d\n", __LINE__); + return 1; + } + // test for filtering + for (int i = 0; i < dimgpix; i++) { + if (h_imgres[i] != (pixval * pixval * nMaskSize)) { + fprintf(stderr, "h_imgres at index %d failed to match\n", i); + return 1; + } + } + + return 0; +} diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/shared.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/shared.cu new file mode 100644 index 0000000..9967b66 --- /dev/null +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/shared.cu @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int shared_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/static.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/static.cu new file mode 100644 index 0000000..ca7eb4c --- /dev/null +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/static.cu @@ -0,0 +1,8 @@ + +int curand_main(); +int nppif_main(); + +int static_version() +{ + return curand_main() == 0 && nppif_main() == 0; +} diff --git a/Tests/CudaOnly/Toolkit/CMakeLists.txt b/Tests/CudaOnly/Toolkit/CMakeLists.txt new file mode 100644 index 0000000..0d5d574 --- /dev/null +++ b/Tests/CudaOnly/Toolkit/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.15) +project(CudaOnlyToolkit CUDA) +find_package(CUDAToolkit REQUIRED) + +message(STATUS "CUDAToolkit_VERSION: ${CUDAToolkit_VERSION}") +message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}") +message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}") +message(STATUS "CUDAToolkit_VERSION_PATCH: ${CUDAToolkit_VERSION_PATCH}") +message(STATUS "CUDAToolkit_BIN_DIR: ${CUDAToolkit_BIN_DIR}") +message(STATUS "CUDAToolkit_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}") +message(STATUS "CUDAToolkit_LIBRARY_DIR: ${CUDAToolkit_LIBRARY_DIR}") +message(STATUS "CUDAToolkit_NVCC_EXECUTABLE ${CUDAToolkit_NVCC_EXECUTABLE}") + +# Verify that all the CUDA:: targets and variables exist +foreach (cuda_lib cudart cuda_driver cublas cufft cufftw curand cusolver cusparse nvgraph) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() +endforeach() + +foreach (cuda_lib nppc nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() +endforeach() + +foreach (cuda_lib nvrtc nvToolsExt OpenCL) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() +endforeach() + +add_executable(CudaOnlyToolkit main.cu) +target_link_libraries(CudaOnlyToolkit PRIVATE CUDA::toolkit) diff --git a/Tests/CudaOnly/Toolkit/main.cu b/Tests/CudaOnly/Toolkit/main.cu new file mode 100644 index 0000000..0f3ccdc --- /dev/null +++ b/Tests/CudaOnly/Toolkit/main.cu @@ -0,0 +1,8 @@ +// Only thing we care about is that these headers are found +#include <cuda.h> +#include <cuda_runtime_api.h> + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index 00fd7d2..ba9bf04 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -28,7 +28,7 @@ target_compile_options(CudaOnlyWithDefs PRIVATE -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE> -DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> - -Xcompiler=-DHOST_DEFINE + --compiler-options=-DHOST_DEFINE $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>> ) diff --git a/Tests/CustComDepend/CMakeLists.txt b/Tests/CustComDepend/CMakeLists.txt index 46276b2..777cdcc 100644 --- a/Tests/CustComDepend/CMakeLists.txt +++ b/Tests/CustComDepend/CMakeLists.txt @@ -6,9 +6,9 @@ set(EXECUTABLE_OUTPUT_PATH ${CustComDepend_BINARY_DIR}/bin) add_executable(foo foo.cxx) add_custom_command( OUTPUT ${CustComDepend_BINARY_DIR}/bar.c - COMMAND ${CustComDepend_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/foo + COMMAND $<TARGET_FILE:foo> ${CustComDepend_BINARY_DIR}/bar.c - DEPENDS ${CustComDepend_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/foo + DEPENDS $<TARGET_FILE:foo> ) add_library(bar SHARED ${CustComDepend_BINARY_DIR}/bar.c) diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index e9a9f52..53d56bf 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -70,7 +70,7 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h APPEND COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1temp.h ${PROJECT_BINARY_DIR}/doc1.h COMMAND ${CMAKE_COMMAND} -E echo " Removing doc1temp.h." - COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/doc1temp.h + COMMAND ${CMAKE_COMMAND} -E rm -f ${PROJECT_BINARY_DIR}/doc1temp.h ) # Add custom command to generate foo.h. @@ -412,7 +412,7 @@ add_custom_target(do_check_command_line ALL add_dependencies(do_check_command_line check_command_line) add_custom_target(pre_check_command_line - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt + COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt ) add_dependencies(do_check_command_line pre_check_command_line) @@ -534,3 +534,43 @@ add_custom_command( set_property(SOURCE "${gen_file}" PROPERTY SYMBOLIC ON) add_custom_target(command_expand_lists ALL DEPENDS "${gen_file}") set_property(TARGET command_expand_lists PROPERTY CMPARGS "${cmp_args}") + +# This also tests that `./` is squeezed out of the resulting path. +set(depends_path "./depended_upon_path.txt") + +add_custom_command( + OUTPUT ${depends_path} + COMMAND ${CMAKE_COMMAND} -E touch ${depends_path} +) + +add_custom_command( + OUTPUT "depends_on_path.txt" + COMMAND ${CMAKE_COMMAND} -E touch "depends_on_path.txt" + DEPENDS ${depends_path} +) + +add_custom_target(depends_on_path ALL DEPENDS "depends_on_path.txt") + +add_custom_command( + OUTPUT "depends_on_in_source_path.txt" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/main.cxx" depends_on_in_source_path.txt + DEPENDS main.cxx +) + +add_custom_target(depends_on_in_source_path ALL DEPENDS "depends_on_in_source_path.txt") + +add_custom_command( + OUTPUT "depends_on_in_rel_source_path.txt" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/main.cxx" depends_on_in_rel_source_path.txt + DEPENDS ./main.cxx +) + +add_custom_target(depends_on_in_rel_source_path ALL DEPENDS "depends_on_in_rel_source_path.txt") + +add_library(mac_fw SHARED mac_fw.c) +set_target_properties(mac_fw PROPERTIES + FRAMEWORK 1 + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib + ) +add_custom_command(OUTPUT mac_fw.txt COMMAND ${CMAKE_COMMAND} -E touch mac_fw.txt DEPENDS mac_fw) +add_custom_target(drive_mac_fw ALL DEPENDS mac_fw.txt) diff --git a/Tests/CustomCommand/mac_fw.c b/Tests/CustomCommand/mac_fw.c new file mode 100644 index 0000000..cb35b44 --- /dev/null +++ b/Tests/CustomCommand/mac_fw.c @@ -0,0 +1,4 @@ +int mac_fw(void) +{ + return 0; +} diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index b7587aa..7781ded 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -33,5 +33,6 @@ unset(ENV{CMAKE_GENERATOR}) unset(ENV{CMAKE_GENERATOR_INSTANCE}) unset(ENV{CMAKE_GENERATOR_PLATFORM}) unset(ENV{CMAKE_GENERATOR_TOOLSET}) +unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS}) @TEST_HOME_ENV_CODE@ diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index dc621eb..d88eb11 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -7,7 +7,7 @@ endif() # Wipe out the install tree to make sure the exporter works. add_custom_command( OUTPUT ${ExportImport_BINARY_DIR}/CleanupProject - COMMAND ${CMAKE_COMMAND} -E remove_directory ${ExportImport_BINARY_DIR}/Root + COMMAND ${CMAKE_COMMAND} -E rm -rf ${ExportImport_BINARY_DIR}/Root ) add_custom_target(CleanupTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/CleanupProject) set_property( diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 9d8a248..387fe6b 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -156,6 +156,7 @@ target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate) cmake_policy(POP) cmake_policy(PUSH) +cmake_policy(SET CMP0022 NEW) cmake_policy(SET CMP0079 NEW) add_library(TopDirLib STATIC testTopDirLib.c) add_subdirectory(SubDirLinkA) @@ -240,6 +241,10 @@ set_property(TARGET testLibRequired APPEND PROPERTY ) include(GenerateExportHeader) +# Test deprecation of imported library +add_library(testLibDeprecation STATIC testLib1.c) +set_property(TARGET testLibDeprecation PROPERTY DEPRECATION "Deprecated version. Please use latest version") + add_subdirectory(renamed) add_library(testSharedLibRequired SHARED testSharedLibRequired.cpp) @@ -515,6 +520,7 @@ install( testExe2lib testLib4lib testLib4libdbg testLib4libopt testLib6 testLib7 testLib8 testLib9 + testLibDeprecation testLibCycleA testLibCycleB testLibNoSONAME cmp0022NEW cmp0022OLD @@ -585,6 +591,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib testLib8 testLib9 testLib9ObjPub testLib9ObjPriv testLib9ObjIface + testLibDeprecation testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibNoSONAME @@ -646,6 +653,18 @@ if(CMAKE_GENERATOR MATCHES "Make|Ninja") export(TARGETS testLinkDepends NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) endif() +#------------------------------------------------------------------------------ +# test export of CUDA language +if(CMake_TEST_CUDA) + enable_language(CUDA) + add_library(cudaInterfaceLib INTERFACE) + target_compile_features(cudaInterfaceLib INTERFACE $<BUILD_INTERFACE:cuda_std_11> $<INSTALL_INTERFACE:cuda_std_14>) + + install(TARGETS cudaInterfaceLib + EXPORT RequiredExp DESTINATION lib) + export(TARGETS cudaInterfaceLib NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) +endif() + # Test the presence of targets named the same as languages. # IMPORTED_LINK_INTERFACE_LANGUAGES entries should not be targets. add_library(C INTERFACE) diff --git a/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt b/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt index 1c3c9dc..1aa41d2 100644 --- a/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt +++ b/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(SubDirLinkAImported IMPORTED INTERFACE) target_compile_definitions(SubDirLinkAImported INTERFACE DEF_SubDirLinkAImportedForExport) -target_link_libraries(TopDirLib PUBLIC SubDirLinkAImported) +target_link_libraries(TopDirLib PUBLIC debug "$<1:SubDirLinkAImported;SubDirLinkAImported>" optimized "$<1:SubDirLinkAImported;SubDirLinkAImported>") add_library(SubDirLinkA STATIC SubDirLinkA.c) diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index b5df961..3cb3833 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -51,6 +51,12 @@ checkForProperty(bld_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1") checkForProperty(exp_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1") checkForProperty(bld_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2") checkForProperty(exp_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2") +checkForProperty(bld_testLibDeprecation "DEPRECATION" "Deprecated version. Please use latest version") +checkForProperty(exp_testLibDeprecation "DEPRECATION" "Deprecated version. Please use latest version") + +# Try linking to a deprecated library +target_link_libraries(imp_testExe1 exp_testLibDeprecation) + # Try linking to a library imported from the install tree. target_link_libraries(imp_testExe1 @@ -499,3 +505,10 @@ if(CMAKE_GENERATOR MATCHES "Make|Ninja") checkForProperty(bld_testLinkDepends "INTERFACE_LINK_DEPENDS" "BUILD_LINK_DEPENDS") checkForProperty(Req::testLinkDepends "INTERFACE_LINK_DEPENDS" "${CMAKE_INSTALL_PREFIX}/INSTALL_LINK_DEPENDS") endif() + +#------------------------------------------------------------------------------ +# test import of CUDA language level +if(CMake_TEST_CUDA) + checkForProperty(bld_cudaInterfaceLib "INTERFACE_COMPILE_FEATURES" "cuda_std_11") + checkForProperty(Req::cudaInterfaceLib "INTERFACE_COMPILE_FEATURES" "cuda_std_14") +endif() diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in index f600d90..44cd179 100644 --- a/Tests/ExportImport/InitialCache.cmake.in +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -14,3 +14,4 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@" CACHE STRI set(CMAKE_INSTALL_PREFIX "@ExportImport_BINARY_DIR@/Root" CACHE STRING "Installation Prefix") set(CMAKE_SKIP_RPATH ON CACHE BOOL "No RPATH") set(CMAKE_GNUtoMS "@ExportImport_GNUtoMS@" CACHE BOOL "CMAKE_GNUtoMS") +set(CMake_TEST_CUDA "@CMake_TEST_CUDA@" CACHE BOOL "CMake_TEST_CUDA") diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 093391e..c8850ea 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -100,6 +100,15 @@ ExternalProject_Add(${proj} INSTALL_COMMAND "" ) +set(proj NoExtractBool) +ExternalProject_Add(${proj} + URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo.tgz + DOWNLOAD_NO_EXTRACT 0 + LOG_DOWNLOAD 1 + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + INSTALL_COMMAND "" +) # CVS-based tests: # @@ -380,7 +389,9 @@ if(do_git_tests) set(proj TutorialStep1-GIT-config) ExternalProject_Add(${proj} GIT_REPOSITORY "${local_git_repo}" - GIT_CONFIG core.eol=lf core.autocrlf=input + GIT_CONFIG core.eol=lf + core.autocrlf=input + "http.extraheader=AUTHORIZATION: bearer --unsupportedOption" CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> INSTALL_COMMAND "" @@ -482,6 +493,66 @@ if(do_git_tests) ) set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + # Unzip/untar the git repository in our source folder so that other + # projects below may use it to test git args of ExternalProject_Add + # + set(proj SetupLocalGITRepositoryWithRecursiveSubmodules) + ExternalProject_Add(${proj} + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/GIT-with-recursive-submodules + URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo-sub-rec.tgz + BUILD_COMMAND "" + CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version + INSTALL_COMMAND "" + ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + + set(local_git_repo "../../LocalRepositories/GIT-with-recursive-submodules") + + set(proj TS1-GIT-RECURSIVE_SUBMODULES-default) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + -DWITH_RECURSIVE:BOOL=ON + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + "SetupLocalGITRepositoryWithSubmodules" + "SetupLocalGITRepositoryWithRecursiveSubmodules" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + + set(proj TS1-GIT-RECURSIVE_SUBMODULES-exclusive) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_SUBMODULES_RECURSE TRUE + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + -DWITH_RECURSIVE:BOOL=ON + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + "SetupLocalGITRepositoryWithSubmodules" + "SetupLocalGITRepositoryWithRecursiveSubmodules" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + + set(proj TS1-GIT-RECURSIVE_SUBMODULES-off) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_SUBMODULES_RECURSE FALSE + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + -DWITH_RECURSIVE:BOOL=OFF + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + "SetupLocalGITRepositoryWithSubmodules" + "SetupLocalGITRepositoryWithRecursiveSubmodules" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + endif() set(do_hg_tests 0) @@ -601,11 +672,19 @@ if(do_git_tests) add_test(TutorialStep1-GIT-bytag "${binary_base}/TutorialStep1-GIT-bytag/Tutorial" 99) + add_test(TutorialStep1-GIT-bytag-withsubmodules + "${binary_base}/TutorialStep1-GIT-bytag-withsubmodules/Tutorial" 99) + add_test(TutorialStep1-GIT-shallow-master "${binary_base}/TutorialStep1-GIT-shallow-master/Tutorial" 98) add_test(TutorialStep1-GIT-master "${binary_base}/TutorialStep1-GIT-master/Tutorial" 98) + + if(NOT git_version VERSION_LESS 1.7.7) + add_test(TutorialStep1-GIT-config + "${binary_base}/TutorialStep1-GIT-config/Tutorial" 98) + endif() endif() diff --git a/Tests/ExternalProject/gitrepo-sub-rec.tgz b/Tests/ExternalProject/gitrepo-sub-rec.tgz Binary files differnew file mode 100644 index 0000000..b0f3f18 --- /dev/null +++ b/Tests/ExternalProject/gitrepo-sub-rec.tgz diff --git a/Tests/FindGTest/Test/CMakeLists.txt b/Tests/FindGTest/Test/CMakeLists.txt index b65b9d2..6537238 100644 --- a/Tests/FindGTest/Test/CMakeLists.txt +++ b/Tests/FindGTest/Test/CMakeLists.txt @@ -8,6 +8,10 @@ add_executable(test_gtest_tgt main.cxx) target_link_libraries(test_gtest_tgt GTest::Main) add_test(NAME test_gtest_tgt COMMAND test_gtest_tgt) +add_executable(test_gtest_tgt_upstream main.cxx) +target_link_libraries(test_gtest_tgt_upstream GTest::gtest_main) +add_test(NAME test_gtest_tgt_upstream COMMAND test_gtest_tgt_upstream) + add_executable(test_gtest_var main.cxx) target_include_directories(test_gtest_var PRIVATE ${GTEST_INCLUDE_DIRS}) target_link_libraries(test_gtest_var PRIVATE ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/Tests/FindLibArchive/CMakeLists.txt b/Tests/FindLibArchive/CMakeLists.txt new file mode 100644 index 0000000..f532ef2 --- /dev/null +++ b/Tests/FindLibArchive/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindLibArchive.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLibArchive/Test" + "${CMake_BINARY_DIR}/Tests/FindLibArchive/Test" + ${build_generator_args} + --build-project TestFindLibArchive + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindLibArchive/Test/CMakeLists.txt b/Tests/FindLibArchive/Test/CMakeLists.txt new file mode 100644 index 0000000..35843bb --- /dev/null +++ b/Tests/FindLibArchive/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.12) +project(TestFindLibArchive C) +include(CTest) + +find_package(LibArchive REQUIRED) + +add_executable(test_libarchive_tgt main.c) +target_link_libraries(test_libarchive_tgt LibArchive::LibArchive) +add_test(NAME test_libarchive_tgt COMMAND test_libarchive_tgt) + +add_executable(test_libarchive_var main.c) +target_include_directories(test_libarchive_var PRIVATE ${LibArchive_INCLUDE_DIRS}) +target_link_libraries(test_libarchive_var PRIVATE ${LibArchive_LIBRARIES}) +add_test(NAME test_libarchive_var COMMAND test_libarchive_var) diff --git a/Tests/FindLibArchive/Test/main.c b/Tests/FindLibArchive/Test/main.c new file mode 100644 index 0000000..03e7ece --- /dev/null +++ b/Tests/FindLibArchive/Test/main.c @@ -0,0 +1,7 @@ +#include <archive.h> + +int main(void) +{ + archive_read_free(archive_read_new()); + return 0; +} diff --git a/Tests/FindLibXml2/Test/CMakeLists.txt b/Tests/FindLibXml2/Test/CMakeLists.txt index df5d8c3..041cc13 100644 --- a/Tests/FindLibXml2/Test/CMakeLists.txt +++ b/Tests/FindLibXml2/Test/CMakeLists.txt @@ -14,3 +14,7 @@ add_executable(test_var main.c) target_include_directories(test_var PRIVATE ${LIBXML2_INCLUDE_DIRS}) target_link_libraries(test_var PRIVATE ${LIBXML2_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +add_test(NAME xmllint_tgt COMMAND LibXml2::xmllint --version) + +add_test(NAME xmllint_var COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --version) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 23832da..8a87a8c 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -19,6 +19,14 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND # configure a FindFoo.cmake so it knows where the library can be found configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) + # Need the -isysroot flag on recentish macOS after command line tools + # no longer provide headers in /usr/include + if(APPLE AND CMAKE_OSX_SYSROOT) + set(__EXTRA_OSX_SYSROOT_FLAGS "-isysroot ${CMAKE_OSX_SYSROOT}") + else() + set(__EXTRA_OSX_SYSROOT_FLAGS "") + endif() + # now set up the test: file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk" CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n" diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 8e7ff72..5ef67d0 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -5,6 +5,7 @@ CMAKE_CURRENT_BINARY_DIR = "@CMAKE_CURRENT_BINARY_DIR@" CMAKE_CXX_COMPILER = "@CMAKE_CXX_COMPILER@" CMAKE_CXX_COMPILER_ID = "@CMAKE_CXX_COMPILER_ID@" CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@ +__EXTRA_OSX_SYSROOT_FLAGS = @__EXTRA_OSX_SYSROOT_FLAGS@ CMAKE_FOO = $(CMAKE) --find-package -DCMAKE_MODULE_PATH=$(CMAKE_CURRENT_BINARY_DIR) -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=$(CMAKE_CXX_COMPILER_ID) @@ -15,7 +16,7 @@ all: pngtest main.o: clean main.cpp @$(CMAKE_FOO) -DMODE=COMPILE >$(tmp) @foo="`cat $(tmp)`"; \ - printf '"%s" %s %s -c main.cpp\n' $(CMAKE_CXX_COMPILER) "$(CMAKE_CXX_FLAGS)" "$$foo" >$(tmp) + printf '"%s" %s %s %s -c main.cpp\n' $(CMAKE_CXX_COMPILER) "$(CMAKE_CXX_FLAGS)" "$(__EXTRA_OSX_SYSROOT_FLAGS)" "$$foo" >$(tmp) @cat $(tmp) @sh $(tmp) @rm -f $(tmp) diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index 868cfe0..9b89832 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -67,14 +67,157 @@ if(CMake_TEST_FindPython) set_tests_properties(FindPython.Python3Fail PROPERTIES PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") - add_test(NAME FindPython.Python COMMAND + add_test(NAME FindPython.Python.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.LOCATION" ${build_generator_args} --build-project TestPython - --build-options ${build_options} + --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.VERSION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V2.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.LOCATION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V2.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VERSION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V3.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.LOCATION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V3.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.VERSION" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + add_test(NAME FindPython.Python2.ExactVersion.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.LOCATION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_MAJOR_VERSION=2 + -DPython_REQUESTED_VERSION=2.1.2 + -DPython2_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python2.ExactVersion.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.VERSION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_MAJOR_VERSION=2 + -DPython_REQUESTED_VERSION=2.1.2 + -DPython2_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python3.ExactVersion.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.ExactVersion.LOCATION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_MAJOR_VERSION=3 + -DPython_REQUESTED_VERSION=3.1.2 + -DPython3_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python3.ExactVersion.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.ExactVersion.VERSION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_MAJOR_VERSION=3 + -DPython_REQUESTED_VERSION=3.1.2 + -DPython3_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V2.ExactVersion.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.LOCATION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 + -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V2.ExactVersion.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.VERSION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 + -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V3.ExactVersion.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.ExactVersion.LOCATION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_REQUESTED_VERSION=3.1.2 + -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python.V3.ExactVersion.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" + "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.ExactVersion.VERSION" + ${build_generator_args} + --build-project TestExactVersion + --build-options ${build_options} -DPython_REQUESTED_VERSION=3.1.2 + -DPython_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -134,6 +277,48 @@ if(CMake_TEST_FindPython) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + add_test(NAME FindPython.CustomFailureMessage COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage" + "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage" + ${build_generator_args} + --build-project TestCustomFailureMessage + --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" + "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" + "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" + "-DCMake_TEST_FindPython_NumPy=${CMake_TEST_FindPython_NumPy}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + if (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") + add_test(NAME FindPython.Interpreter.SOABI COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/SOABI" + "${CMake_BINARY_DIR}/Tests/FindPython/SOABI.Interpreter" + ${build_generator_args} + --build-project TestSOABI + --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" + "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" + "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" + "-DCMake_TEST_FindPython_COMPONENT=Interpreter" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Development.SOABI COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/SOABI" + "${CMake_BINARY_DIR}/Tests/FindPython/SOABI.Development" + ${build_generator_args} + --build-project TestSOABI + --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" + "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" + "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" + "-DCMake_TEST_FindPython_COMPONENT=Development" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + endif() endif() if(CMake_TEST_FindPython_NumPy) @@ -157,4 +342,81 @@ if(CMake_TEST_FindPython_NumPy) --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) - endif() +endif() + +if(CMake_TEST_FindPython_Conda) + add_test(NAME FindPython.VirtualEnvConda COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/VirtualEnvConda" + "${CMake_BINARY_DIR}/Tests/FindPython/VirtualEnvConda" + ${build_generator_args} + --build-project TestVirtualEnvConda + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +endif() + +if(CMake_TEST_FindPython_IronPython) + add_test(NAME FindPython.IronPython2.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.LOCATION" + ${build_generator_args} + --build-project TestIronPython2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.IronPython2.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VERSION" + ${build_generator_args} + --build-project TestIronPython2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + add_test(NAME FindPython.IronPython.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.LOCATION" + ${build_generator_args} + --build-project TestIronPython + --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.IronPython.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.VERSION" + ${build_generator_args} + --build-project TestIronPython + --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.IronPython.V2.LOCATION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V2.LOCATION" + ${build_generator_args} + --build-project TestIronPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.IronPython.V2.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" + "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V2.VERSION" + ${build_generator_args} + --build-project TestIronPython + --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +endif() diff --git a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt new file mode 100644 index 0000000..a0d8eb2 --- /dev/null +++ b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt @@ -0,0 +1,79 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestCustomFailureMessage LANGUAGES NONE) + +include(CTest) + +add_test(NAME FindPython.CustomFailureMessage.Interpreter COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Interpreter" + ${build_generator_args} + --build-project TestCustomFailureMessage.Check + --build-options "-DCHECK_COMPONENTS=Interpreter" + "-DPython3_EXECUTABLE=/not/found/interpreter" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +set_tests_properties(FindPython.CustomFailureMessage.Interpreter PROPERTIES + PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter") + +add_test(NAME FindPython.CustomFailureMessage.Library COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Library" + ${build_generator_args} + --build-project TestCustomFailureMessage.Check + --build-options "-DCHECK_COMPONENTS=Development" + "-DPython3_LIBRARY=/not/found/library" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +set_tests_properties(FindPython.CustomFailureMessage.Library PROPERTIES + PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the library") + +add_test(NAME FindPython.CustomFailureMessage.Include COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Include" + ${build_generator_args} + --build-project TestCustomFailureMessage.Check + --build-options "-DCHECK_COMPONENTS=Development" + "-DPython3_INCLUDE_DIR=/not/found/include" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +set_tests_properties(FindPython.CustomFailureMessage.Include PROPERTIES + PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the directory") + +add_test(NAME FindPython.CustomFailureMessage.Multiple COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Multiple" + ${build_generator_args} + --build-project TestCustomFailureMessage.Check + --build-options "-DCHECK_COMPONENTS=Interpreter;Development" + "-DPython3_EXECUTABLE=/not/found/interpreter" + "-DPython3_LIBRARY=/not/found/library" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +set_tests_properties(FindPython.CustomFailureMessage.Multiple PROPERTIES + PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter.+Development: Cannot find the library") + + +if (CMake_TEST_FindPython_NumPy) + add_test(NAME FindPython.CustomFailureMessage.NumPy COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/NumPy" + ${build_generator_args} + --build-project TestCustomFailureMessage.Check + --build-options "-DCHECK_COMPONENTS=Interpreter;Development;NumPy" + "-DPython3_NumPy_INCLUDE_DIR=/not/found/numpy/include" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + set_tests_properties(FindPython.CustomFailureMessage.NumPy PROPERTIES + PASS_REGULAR_EXPRESSION "Reason given by package:.+NumPy: Cannot find the directory") +endif() diff --git a/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt new file mode 100644 index 0000000..fed963e --- /dev/null +++ b/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestCustomFailureMessage.Check LANGUAGES C) + +find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS}) diff --git a/Tests/FindPython/ExactVersion/CMakeLists.txt b/Tests/FindPython/ExactVersion/CMakeLists.txt new file mode 100644 index 0000000..e09f73a --- /dev/null +++ b/Tests/FindPython/ExactVersion/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestExactVersion C) + +find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development) +if (NOT Python${Python_MAJOR_VERSION}_FOUND) + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") +endif() +if (NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Interpreter") +endif() +if (NOT Python${Python_MAJOR_VERSION}_Development_FOUND) + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Development") +endif() + +if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter) + message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Interpreter not found") +endif() + +if(NOT TARGET Python${Python_MAJOR_VERSION}::Python) + message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Python not found") +endif() +if(NOT TARGET Python${Python_MAJOR_VERSION}::Module) + message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Module not found") +endif() + + +# reset artifacts and second search with exact version already founded +unset (Python${Python_MAJOR_VERSION}_EXECUTABLE) +unset (_Python${Python_MAJOR_VERSION}_EXECUTABLE CACHE) + +unset (_Python${Python_MAJOR_VERSION}_LIBRARY_RELEASE CACHE) +unset (_Python${Python_MAJOR_VERSION}_INCLUDE_DIR CACHE) + +set (Python_REQUESTED_VERSION ${Python${Python_MAJOR_VERSION}_VERSION}) +find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter Development) +if (NOT Python${Python_MAJOR_VERSION}_FOUND) + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") +endif() +if (NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Interpreter") +endif() +if (NOT Python${Python_MAJOR_VERSION}_Development_FOUND) + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION} Development") +endif() + +if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter) + message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Interpreter not found") +endif() + +if(NOT TARGET Python${Python_MAJOR_VERSION}::Python) + message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Python not found") +endif() +if(NOT TARGET Python${Python_MAJOR_VERSION}::Module) + message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Module not found") +endif() diff --git a/Tests/FindPython/IronPython/CMakeLists.txt b/Tests/FindPython/IronPython/CMakeLists.txt new file mode 100644 index 0000000..c96a3e0 --- /dev/null +++ b/Tests/FindPython/IronPython/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestIronPython C) + +find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Compiler) +if (NOT Python_FOUND) + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") +endif() + +if (NOT Python_Compiler_FOUND) + message (FATAL_ERROR "Fail to found Python Compiler") +endif() +if (NOT Python_COMPILER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous compiler ID (${Python_COMPILER_ID})") +endif() + +if(NOT TARGET Python::Interpreter) + message(SEND_ERROR "Python::Interpreter not found") +endif() +if(NOT TARGET Python::Compiler) + message(SEND_ERROR "Python::Interpreter not found") +endif() diff --git a/Tests/FindPython/IronPython2/CMakeLists.txt b/Tests/FindPython/IronPython2/CMakeLists.txt new file mode 100644 index 0000000..43ec309 --- /dev/null +++ b/Tests/FindPython/IronPython2/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestIronPython2 C) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Compiler) +if (NOT Python2_FOUND) + message (FATAL_ERROR "Fail to found Python 2") +endif() + +if (NOT Python2_Compiler_FOUND) + message (FATAL_ERROR "Fail to found Python 2 Compiler") +endif() +if (NOT Python2_COMPILER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous compiler ID (${Python2_COMPILER_ID})") +endif() + +if(NOT TARGET Python2::Interpreter) + message(SEND_ERROR "Python2::Interpreter not found") +endif() +if(NOT TARGET Python2::Compiler) + message(SEND_ERROR "Python2::Compiler not found") +endif() diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt index 62c805e..3ee38e3 100644 --- a/Tests/FindPython/Python/CMakeLists.txt +++ b/Tests/FindPython/Python/CMakeLists.txt @@ -4,9 +4,9 @@ project(TestPython C) include(CTest) -find_package(Python 3 REQUIRED COMPONENTS Interpreter Development) +find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development) if (NOT Python_FOUND) - message (FATAL_ERROR "Fail to found Python 3") + message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}") endif() if(NOT TARGET Python::Interpreter) @@ -20,13 +20,15 @@ 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) - -add_test (NAME python_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" - "${Python_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") - -add_test(NAME findpython_script - COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python - -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") +if (Python_REQUESTED_VERSION) + Python_add_library (spam${Python_REQUESTED_VERSION} MODULE ../spam.c) + target_compile_definitions (spam${Python_REQUESTED_VERSION} PRIVATE PYTHON${Python_REQUESTED_VERSION}) + + add_test (NAME python_spam${Python_REQUESTED_VERSION} + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam${Python_REQUESTED_VERSION}>" + "${Python_EXECUTABLE}" -c "import spam${Python_REQUESTED_VERSION}; spam${Python_REQUESTED_VERSION}.system(\"cd\")") +else() + add_test(NAME findpython_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python + -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") +endif() diff --git a/Tests/FindPython/SOABI/CMakeLists.txt b/Tests/FindPython/SOABI/CMakeLists.txt new file mode 100644 index 0000000..4a6aea3 --- /dev/null +++ b/Tests/FindPython/SOABI/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestSOABI C) + +find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Fail to found Python 3") +endif() + +if(NOT DEFINED Python3_SOABI) + message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") +endif() + +if (Python3_Development_FOUND AND Python3_SOABI) + Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c) + target_compile_definitions (spam3 PRIVATE PYTHON3) + + get_property (suffix TARGET spam3 PROPERTY SUFFIX) + if (NOT suffix MATCHES "^.${Python3_SOABI}") + message(FATAL_ERROR "Module suffix do not include Python3_SOABI") + endif() +endif() diff --git a/Tests/FindPython/VirtualEnv/CMakeLists.txt b/Tests/FindPython/VirtualEnv/CMakeLists.txt index 64ba201..045a3f2 100644 --- a/Tests/FindPython/VirtualEnv/CMakeLists.txt +++ b/Tests/FindPython/VirtualEnv/CMakeLists.txt @@ -10,6 +10,7 @@ if (NOT Python3_FOUND) endif() set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/py3venv") +file (REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/py3venv") execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv "${Python3_VIRTUAL_ENV}" RESULT_VARIABLE result @@ -21,22 +22,26 @@ endif() add_test(NAME FindPython3.VirtualEnvDefault COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=CONDA_PREFIX "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake") add_test(NAME FindPython3.VirtualEnvOnly COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=CONDA_PREFIX "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") add_test(NAME FindPython3.UnsetVirtualEnvOnly COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME --unset=VIRTUAL_ENV + --unset=CONDA_PREFIX "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") add_test(NAME FindPython3.VirtualEnvStandard COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=CONDA_PREFIX "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake") diff --git a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt new file mode 100644 index 0000000..565095a --- /dev/null +++ b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestVirtualEnvConda LANGUAGES NONE) + +include(CTest) + +find_program(CONDA_EXECUTABLE conda) +if (CONDA_EXECUTABLE EQUAL NOTFOUND) + message (FATAL_ERROR "Fail to found Conda") +endif() + +set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/condaenv") + +execute_process (COMMAND "${CONDA_EXECUTABLE}" create --no-default-packages --prefix "${Python3_VIRTUAL_ENV}" --yes python=3 + 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.VirtualEnvDefaultConda + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=VIRTUAL_ENV + "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" + "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake") + +add_test(NAME FindPython3.VirtualEnvOnlyConda + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=VIRTUAL_ENV + "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" + "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") +add_test(NAME FindPython3.UnsetVirtualEnvOnlyConda + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=CONDA_PREFIX + --unset=VIRTUAL_ENV + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") + +add_test(NAME FindPython3.VirtualEnvStandardConda + COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME + --unset=VIRTUAL_ENV + "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" + "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" + -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake") diff --git a/Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake b/Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake new file mode 100644 index 0000000..020ecac --- /dev/null +++ b/Tests/FindPython/VirtualEnvConda/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/VirtualEnvConda/VirtualEnvOnly.cmake b/Tests/FindPython/VirtualEnvConda/VirtualEnvOnly.cmake new file mode 100644 index 0000000..29a4924 --- /dev/null +++ b/Tests/FindPython/VirtualEnvConda/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/VirtualEnvConda/VirtualEnvStandard.cmake b/Tests/FindPython/VirtualEnvConda/VirtualEnvStandard.cmake new file mode 100644 index 0000000..89f27d8 --- /dev/null +++ b/Tests/FindPython/VirtualEnvConda/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/FortranModules/Executable/CMakeLists.txt b/Tests/FortranModules/Executable/CMakeLists.txt index de08d86..f31a3e6 100644 --- a/Tests/FortranModules/Executable/CMakeLists.txt +++ b/Tests/FortranModules/Executable/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${Library_MODDIR}) include_directories(${External_BINARY_DIR}) -link_directories(${External_BINARY_DIR}) +link_directories(${External_BINARY_DIR}/${CMAKE_CFG_INTDIR}) add_executable(subdir_exe2 main.f90) target_link_libraries(subdir_exe2 subdir_mods subdir_mods2) diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index de887fa..d945375 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -103,11 +103,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) # Custom target to try preprocessing invocation. add_custom_target(test_preprocess ${MAYBE_ALL} - COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/preprocess.dir/preprocess.F.i + COMMAND ${CMAKE_COMMAND} -E rm -f CMakeFiles/preprocess.dir/preprocess.F.i COMMAND ${CMAKE_MAKE_PROGRAM} preprocess.i COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake # Remove bogus file some compilers leave behind. - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/preprocess.s + COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_SOURCE_DIR}/preprocess.s WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif() diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 761c405..fa3309f 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -94,6 +94,6 @@ if (NOT incs STREQUAL ";/one/two") message(SEND_ERROR "Empty include_directories entry was not ignored.") endif() -if(NOT CMAKE_GENERATOR STREQUAL Xcode AND NOT CMAKE_GENERATOR STREQUAL Ninja) +if(NOT CMAKE_GENERATOR STREQUAL "Xcode" AND NOT CMAKE_GENERATOR MATCHES "Ninja") add_subdirectory(CMP0021) endif() diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 954c02d..311ca2a 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -3,6 +3,12 @@ cmake_minimum_required(VERSION 2.8) project(InterfaceLibrary) +set(cfg_dir) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + set(cfg_dir /$<CONFIG>) +endif() + add_library(iface_nodepends INTERFACE) target_compile_definitions(iface_nodepends INTERFACE IFACE_DEFINE) @@ -32,7 +38,7 @@ add_library(item_iface INTERFACE IMPORTED) set_property(TARGET item_iface PROPERTY IMPORTED_LIBNAME item_real) add_dependencies(item_iface item_real) get_property(item_iface_dependencies TARGET item_iface PROPERTY MANUALLY_ADDED_DEPENDENCIES) -link_directories(${CMAKE_CURRENT_BINARY_DIR}) +link_directories(${CMAKE_CURRENT_BINARY_DIR}${cfg_dir}) add_executable(InterfaceLibrary definetestexe.cpp) target_link_libraries(InterfaceLibrary diff --git a/Tests/JavaExportImport/CMakeLists.txt b/Tests/JavaExportImport/CMakeLists.txt index c70704a..7a2d020 100644 --- a/Tests/JavaExportImport/CMakeLists.txt +++ b/Tests/JavaExportImport/CMakeLists.txt @@ -9,7 +9,7 @@ find_package(Java COMPONENTS Development) # Wipe out the install tree to make sure the exporter works. add_custom_command( OUTPUT ${JavaExportImport_BINARY_DIR}/CleanupProject - COMMAND ${CMAKE_COMMAND} -E remove_directory ${JavaExportImport_BINARY_DIR}/Root + COMMAND ${CMAKE_COMMAND} -E rm -rf ${JavaExportImport_BINARY_DIR}/Root ) add_custom_target(CleanupTarget ALL DEPENDS ${JavaExportImport_BINARY_DIR}/CleanupProject) set_property( diff --git a/Tests/LinkDirectory/CMakeLists.txt b/Tests/LinkDirectory/CMakeLists.txt index c60de84..c7a2700 100644 --- a/Tests/LinkDirectory/CMakeLists.txt +++ b/Tests/LinkDirectory/CMakeLists.txt @@ -33,7 +33,7 @@ ExternalProject_Add(ExternalTarget # directly because it does not know the full paths to the libraries. # (The purpose of this test is to check that link_directories works.) ExternalProject_Add_Step(ExternalTarget cleanup - COMMAND ${CMAKE_COMMAND} -E remove_directory ${LinkDirectory_BINARY_DIR}/bin + COMMAND ${CMAKE_COMMAND} -E rm -rf ${LinkDirectory_BINARY_DIR}/bin DEPENDEES download DEPENDERS configure DEPENDS mylibA mylibB diff --git a/Tests/LinkDirectory/External/CMakeLists.txt b/Tests/LinkDirectory/External/CMakeLists.txt index d2a1f9f..c877913 100644 --- a/Tests/LinkDirectory/External/CMakeLists.txt +++ b/Tests/LinkDirectory/External/CMakeLists.txt @@ -2,13 +2,19 @@ cmake_minimum_required(VERSION 2.8) project(LinkDirectoryExternal C) +set(cfg_dir) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + set(cfg_dir /$<CONFIG>) +endif() + add_executable(myexe2 myexe.c) set_property(TARGET myexe2 PROPERTY OUTPUT_NAME LinkDirectory2) -target_link_directories(myexe2 PRIVATE lib "${CMAKE_CURRENT_SOURCE_DIR}/../lib") +target_link_directories(myexe2 PRIVATE lib${cfg_dir} "${CMAKE_CURRENT_SOURCE_DIR}/../lib${cfg_dir}") target_link_libraries(myexe2 PRIVATE mylibA mylibB) add_library (mylibs INTERFACE) -target_link_directories(mylibs INTERFACE lib "${CMAKE_CURRENT_SOURCE_DIR}/../lib") +target_link_directories(mylibs INTERFACE lib${cfg_dir} "${CMAKE_CURRENT_SOURCE_DIR}/../lib${cfg_dir}") target_link_libraries(mylibs INTERFACE mylibA mylibB) add_executable(myexe3 myexe.c) set_property(TARGET myexe3 PROPERTY OUTPUT_NAME LinkDirectory3) @@ -17,11 +23,11 @@ target_link_libraries(myexe3 PRIVATE mylibs) # Test CMP0015 OLD behavior: -L../lib cmake_policy(SET CMP0015 OLD) -link_directories(../lib) +link_directories(../lib${cfg_dir}) # Test CMP0015 NEW behavior: -L${CMAKE_CURRENT_SOURCE_DIR}/lib cmake_policy(SET CMP0015 NEW) -link_directories(lib) +link_directories(lib${cfg_dir}) add_executable(myexe myexe.c) set_property(TARGET myexe PROPERTY OUTPUT_NAME LinkDirectory) diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt index a3c6fd9..9f1bf1a 100644 --- a/Tests/MacRuntimePath/CMakeLists.txt +++ b/Tests/MacRuntimePath/CMakeLists.txt @@ -7,7 +7,7 @@ endif() # Wipe out the install tree to make sure the exporter works. add_custom_command( OUTPUT ${MacRuntimePath_BINARY_DIR}/CleanupProject - COMMAND ${CMAKE_COMMAND} -E remove_directory ${MacRuntimePath_BINARY_DIR}/Root + COMMAND ${CMAKE_COMMAND} -E rm -rf ${MacRuntimePath_BINARY_DIR}/Root ) add_custom_target(CleanupTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/CleanupProject) set_property( diff --git a/Tests/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt index 823ab08..8afe036 100644 --- a/Tests/OutDir/CMakeLists.txt +++ b/Tests/OutDir/CMakeLists.txt @@ -20,7 +20,7 @@ set(top "${OutDir_BINARY_DIR}") foreach(config ${configs}) foreach(type archive runtime library) string(TOUPPER "${type}" TYPE) - set(CMAKE_${TYPE}_OUTPUT_DIRECTORY_${config} "${top}/${type}") + set(CMAKE_${TYPE}_OUTPUT_DIRECTORY_${config} "${top}/${type}/$<CONFIG>") file(REMOVE_RECURSE "${top}/${type}") endforeach() endforeach() @@ -29,7 +29,7 @@ add_subdirectory(../COnly COnly) add_custom_command( OUTPUT OutDir.h - COMMAND ${CMAKE_COMMAND} -Dtop=${top} -P ${OutDir_SOURCE_DIR}/OutDir.cmake + COMMAND ${CMAKE_COMMAND} -Dtop=${top} -Dcfg_dir=$<CONFIG> -P ${OutDir_SOURCE_DIR}/OutDir.cmake DEPENDS COnly ${OutDir_SOURCE_DIR}/OutDir.cmake ) include_directories(${top}) diff --git a/Tests/OutDir/OutDir.cmake b/Tests/OutDir/OutDir.cmake index a1f13e7..2a003b8 100644 --- a/Tests/OutDir/OutDir.cmake +++ b/Tests/OutDir/OutDir.cmake @@ -3,17 +3,17 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a" ".so" ".sl" ".dylib" ".dll.a") find_library(TESTC1_LIB NAMES testc1 testc1_test_debug_postfix - PATHS ${top}/archive + PATHS ${top}/archive/${cfg_dir} NO_DEFAULT_PATH) find_library(TESTC2_LIB NAMES testc2 testc2_test_debug_postfix - PATHS ${top}/archive ${top}/library + PATHS ${top}/archive/${cfg_dir} ${top}/library/${cfg_dir} NO_DEFAULT_PATH) find_program(CONLY_EXE NAMES COnly - PATHS ${top}/runtime + PATHS ${top}/runtime/${cfg_dir} NO_DEFAULT_PATH) file(RELATIVE_PATH TESTC1_LIB_FILE "${top}" "${TESTC1_LIB}") diff --git a/Tests/Qt4Autogen/CMakeLists.txt b/Tests/Qt4Autogen/CMakeLists.txt index 68b885b..e7f1ae3 100644 --- a/Tests/Qt4Autogen/CMakeLists.txt +++ b/Tests/Qt4Autogen/CMakeLists.txt @@ -7,3 +7,5 @@ ADD_AUTOGEN_TEST(DefinesTest) # Common tests include("../QtAutogen/Tests.cmake") + +set(TEST_BUILD_DIRS "${TEST_BUILD_DIRS}" PARENT_SCOPE) diff --git a/Tests/Qt5Autogen/CMakeLists.txt b/Tests/Qt5Autogen/CMakeLists.txt index 49d33cc..df4927a 100644 --- a/Tests/Qt5Autogen/CMakeLists.txt +++ b/Tests/Qt5Autogen/CMakeLists.txt @@ -4,3 +4,5 @@ include("../QtAutogen/TestMacros.cmake") # Common tests include("../QtAutogen/Tests.cmake") + +set(TEST_BUILD_DIRS "${TEST_BUILD_DIRS}" PARENT_SCOPE) diff --git a/Tests/QtAutogen/MocCMP0100/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/CMakeLists.txt new file mode 100644 index 0000000..559cffe --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(MocCMP0100) +include("../AutogenCoreTest.cmake") + +set(CMAKE_AUTOMOC ON) +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) + +add_subdirectory(OLD) +add_subdirectory(NEW) diff --git a/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt new file mode 100644 index 0000000..654b31e --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.16) +cmake_policy(SET CMP0100 NEW) + +add_executable(mocCMP0100New + ${CSD}/main.cpp + ${CSD}/Obj.hh # Manually include Obj.hh + ${CSD}/Obj.cpp + ${CSD}/Obj2.cpp # Let AUTOMOC detect Obj2.hh +) +target_link_libraries(mocCMP0100New ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt new file mode 100644 index 0000000..2be0535 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.16) +cmake_policy(SET CMP0100 OLD) + +# Generate moc files externally. +# If AUTOMOC generates the header moc files as well +# (it should not in OLD behavior), the test will fail with a +# multiple definition error when linking the executable. +qtx_wrap_cpp(mocCMP0100OldMoc ${CSD}/Obj.hh ${CSD}/Obj2.hh) +qtx_generate_moc(${CBD}/Obj.cpp ${CMAKE_CURRENT_BINARY_DIR}/Obj.moc) +qtx_generate_moc(${CBD}/Obj2.cpp ${CMAKE_CURRENT_BINARY_DIR}/Obj2.moc) + +# Make sure AUTOGEN file skipping is disabled +set_source_files_properties( + ${CSD}/Obj.hh + ${CBD}/Obj.cpp + ${CSD}/Obj2.hh + ${CBD}/Obj2.cpp + PROPERTIES + SKIP_AUTOGEN OFF + SKIP_AUTOMOC OFF +) + +add_executable(mocCMP0100Old + ${CSD}/main.cpp + ${CSD}/Obj.hh # Manually include Obj.hh + ${CSD}/Obj.cpp + ${CSD}/Obj2.cpp # Let AUTOMOC detect Obj2.hh + ${mocCMP0100OldMoc} +) +target_link_libraries(mocCMP0100Old ${QT_LIBRARIES}) +target_include_directories(mocCMP0100Old PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Tests/QtAutogen/MocCMP0100/Obj.cpp b/Tests/QtAutogen/MocCMP0100/Obj.cpp new file mode 100644 index 0000000..bb6d0a0 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj.cpp @@ -0,0 +1,31 @@ +#include "Obj.hh" + +#include <QObject> + +class ObjPrivate : public QObject +{ + Q_OBJECT +public: + ObjPrivate(); + ~ObjPrivate(); +}; + +ObjPrivate::ObjPrivate() +{ +} + +ObjPrivate::~ObjPrivate() +{ +} + +Obj::Obj() + : d(new ObjPrivate) +{ +} + +Obj::~Obj() +{ + delete d; +} + +#include "Obj.moc" diff --git a/Tests/QtAutogen/MocCMP0100/Obj.hh b/Tests/QtAutogen/MocCMP0100/Obj.hh new file mode 100644 index 0000000..940bfc2 --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj.hh @@ -0,0 +1,20 @@ +#ifndef OBJ_HH +#define OBJ_HH + +#include <QObject> + +// Qt enabled private class +class ObjPrivate; +// Qt enabled class +class Obj : public QObject +{ + Q_OBJECT +public: + Obj(); + ~Obj(); + +private: + ObjPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocCMP0100/Obj2.cpp b/Tests/QtAutogen/MocCMP0100/Obj2.cpp new file mode 100644 index 0000000..8a359ad --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj2.cpp @@ -0,0 +1,31 @@ +#include "Obj2.hh" + +#include <QObject> + +class Obj2Private : public QObject +{ + Q_OBJECT +public: + Obj2Private(); + ~Obj2Private(); +}; + +Obj2Private::Obj2Private() +{ +} + +Obj2Private::~Obj2Private() +{ +} + +Obj2::Obj2() + : d(new Obj2Private) +{ +} + +Obj2::~Obj2() +{ + delete d; +} + +#include "Obj2.moc" diff --git a/Tests/QtAutogen/MocCMP0100/Obj2.hh b/Tests/QtAutogen/MocCMP0100/Obj2.hh new file mode 100644 index 0000000..1c74cdd --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/Obj2.hh @@ -0,0 +1,20 @@ +#ifndef OBJ2_HH +#define OBJ2_HH + +#include <QObject> + +// Qt enabled private class +class Obj2Private; +// Qt enabled class +class Obj2 : public QObject +{ + Q_OBJECT +public: + Obj2(); + ~Obj2(); + +private: + Obj2Private* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocCMP0100/main.cpp b/Tests/QtAutogen/MocCMP0100/main.cpp new file mode 100644 index 0000000..17061da --- /dev/null +++ b/Tests/QtAutogen/MocCMP0100/main.cpp @@ -0,0 +1,9 @@ +#include "Obj.hh" +#include "Obj2.hh" + +int main(int argv, char** args) +{ + Obj obj; + Obj2 obj2; + return 0; +} diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp index e1fdf0b..198ae98 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp @@ -10,7 +10,7 @@ class StyleA : public QStylePlugin Q_OBJECT // Json file in source local directory Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json") - A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg) + A_CUSTOM_MACRO(org.styles.A, "StyleA_Custom.json", AnotherArg) public: QStyle* create(const QString& key); }; diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp index 7550d0c..8ce8d77 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp @@ -10,7 +10,7 @@ class StyleB : public QStylePlugin Q_OBJECT // Json file in source local subdirectory Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json") - A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg) + A_CUSTOM_MACRO(org.styles.B, "jsonIn/StyleB_Custom.json", AnotherArg) public: QStyle* create(const QString& key); }; diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp index ec71bec..53171e3 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp @@ -10,7 +10,7 @@ class StyleC : public QStylePlugin Q_OBJECT // Json file in global root directory Q_PLUGIN_METADATA(IID "org.styles.C" FILE "StyleC.json") - A_CUSTOM_MACRO(SomeArg, "StyleC_Custom.json", AnotherArg) + A_CUSTOM_MACRO(org.styles.C, "StyleC_Custom.json", AnotherArg) public: QStyle* create(const QString& key); }; diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp index 3c093b9..29674f9 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp @@ -10,7 +10,7 @@ class StyleD : public QStylePlugin Q_OBJECT // Json file in global sub director Q_PLUGIN_METADATA(IID "org.styles.D" FILE "sub/StyleD.json") - A_CUSTOM_MACRO(SomeArg, "sub/StyleD_Custom.json", AnotherArg) + A_CUSTOM_MACRO(org.styles.D, "sub/StyleD_Custom.json", AnotherArg) public: QStyle* create(const QString& key); }; diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp index 5f10fb4..7318220 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp @@ -10,7 +10,7 @@ class StyleE : public QStylePlugin Q_OBJECT // Json files in global root directory Q_PLUGIN_METADATA(IID "org.styles.E" FILE "StyleE.json") - A_CUSTOM_MACRO(SomeArg, "StyleE_Custom.json", AnotherArg) + A_CUSTOM_MACRO(org.styles.E, "StyleE_Custom.json", AnotherArg) public: QStyle* create(const QString& key); }; diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp index 53a4284..2f558a8 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp @@ -1,7 +1,7 @@ #ifndef UTILITYMACROS_HPP #define UTILITYMACROS_HPP -// Empty test macro definition -#define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations) +#define A_CUSTOM_MACRO(url, jsonFile, pluginRegistrations) \ + Q_PLUGIN_METADATA(IID #url FILE jsonFile) #endif diff --git a/Tests/QtAutogen/SameName/CMakeLists.txt b/Tests/QtAutogen/SameName/CMakeLists.txt index cd29a2a..4ce8dbd 100644 --- a/Tests/QtAutogen/SameName/CMakeLists.txt +++ b/Tests/QtAutogen/SameName/CMakeLists.txt @@ -1,7 +1,10 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16.0) project(SameName) include("../AutogenGuiTest.cmake") +# Process .hh headers in AUTOMOC +cmake_policy(SET CMP0100 NEW) + # Test AUTOMOC and AUTORCC on source files with the same name # but in different subdirectories @@ -18,6 +21,7 @@ add_executable(sameName ccc/data.qrc item.cpp object.h + object.hh object.h++ object.hpp object.hxx diff --git a/Tests/QtAutogen/SameName/main.cpp b/Tests/QtAutogen/SameName/main.cpp index 19a6f6d..725f4cd 100644 --- a/Tests/QtAutogen/SameName/main.cpp +++ b/Tests/QtAutogen/SameName/main.cpp @@ -6,6 +6,7 @@ #include "item.hpp" #include "object.h" #include "object.h++" +#include "object.hh" #include "object.hpp" #include "object.hxx" #include "object_upper_ext.H" @@ -21,6 +22,7 @@ int main(int argv, char** args) ::ccc::Item ccc_item; // Object instances ::Object_h obj_h; + ::Object_hh obj_hh; ::Object_hplpl obj_hplpl; ::Object_hpp obj_hpp; ::Object_hxx obj_hxx; diff --git a/Tests/QtAutogen/SameName/object.hh b/Tests/QtAutogen/SameName/object.hh new file mode 100644 index 0000000..3e16f83 --- /dev/null +++ b/Tests/QtAutogen/SameName/object.hh @@ -0,0 +1,13 @@ +#ifndef OBJECT_HH +#define OBJECT_HH + +#include <QObject> + +class Object_hh : public QObject +{ + Q_OBJECT + Q_SLOT + void go(){}; +}; + +#endif diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index 2b001d4..a19a9ae 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -32,6 +32,7 @@ ADD_AUTOGEN_TEST(UicSkipSource) if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) + ADD_AUTOGEN_TEST(MocCMP0100) ADD_AUTOGEN_TEST(MocInclude) ADD_AUTOGEN_TEST(MocIncludeSymlink) ADD_AUTOGEN_TEST(MocSkipSource) diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-result.txt b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-stdout.txt b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-stdout.txt new file mode 100644 index 0000000..760ba3c --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-stdout.txt @@ -0,0 +1 @@ +ERROR: Undefined symbol: .AIXNotExported diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicit.cmake b/Tests/RunCMake/AutoExportDll/AIXExportExplicit.cmake new file mode 100644 index 0000000..d23b172 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicit.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF) +add_library(AIXExportExplicitLib SHARED AIXExportExplicitLib.c) +add_executable(AIXExportExplicitMain AIXExportExplicitMain.c) +target_link_options(AIXExportExplicitLib PRIVATE LINKER:-bE:${CMAKE_CURRENT_SOURCE_DIR}/AIXExportExplicitLib.exp) +target_link_libraries(AIXExportExplicitMain PRIVATE AIXExportExplicitLib) diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.c b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.c new file mode 100644 index 0000000..58fd5ac --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.c @@ -0,0 +1,8 @@ +int AIXNotExported(void) +{ + return 0; +} +int AIXExportedSymbol(void) +{ + return 0; +} diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.exp b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.exp new file mode 100644 index 0000000..9eb7bf8 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.exp @@ -0,0 +1 @@ +AIXExportedSymbol diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicitMain.c b/Tests/RunCMake/AutoExportDll/AIXExportExplicitMain.c new file mode 100644 index 0000000..ad9c8ec --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicitMain.c @@ -0,0 +1,7 @@ +extern int AIXNotExported(void); +extern int AIXExportedSymbol(void); + +int main(void) +{ + return AIXNotExported() + AIXExportedSymbol(); +} diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake index 6c9be4b..75130f2 100644 --- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -55,3 +55,14 @@ if(EXPORTS) message(SEND_ERROR "\"${EXPORTS_DEF}\" has been updated.") endif() endif() + +function(run_AIXExportExplicit) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/AIXExpotExplicit-build") + run_cmake(AIXExportExplicit) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + run_cmake_command(AIXExportExplicit-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() +if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + run_AIXExportExplicit() +endif() diff --git a/Tests/RunCMake/BuildDepends/ExternalProject/CMakeLists.txt b/Tests/RunCMake/BuildDepends/ExternalProject/CMakeLists.txt new file mode 100644 index 0000000..57a0f6e --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProject/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.12) +project(External NONE) + +if (DEFINED cache_arg) + message("configured with: ${cache_arg}") +else () + message("cache_arg is undefined") +endif () + +if (DEFINED second_cache_arg) + message("configured again with: ${second_cache_arg}") +else () + message("second_cache_arg is undefined") +endif () diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build1-stdout.txt b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build1-stdout.txt new file mode 100644 index 0000000..fea7fd9 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build1-stdout.txt @@ -0,0 +1,2 @@ +.*configured with: first +.*second_cache_arg is undefined diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build2-stdout.txt b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build2-stdout.txt new file mode 100644 index 0000000..e19e743 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build2-stdout.txt @@ -0,0 +1,2 @@ +.*configured with: first +.*configured again with: second diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.cmake b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.cmake new file mode 100644 index 0000000..fe69426 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.cmake @@ -0,0 +1,19 @@ +include("${CMAKE_CURRENT_BINARY_DIR}/data.cmake") + +include(ExternalProject) +ExternalProject_add(external + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/ExternalProject" + CMAKE_CACHE_ARGS + ${cache_args} + BUILD_COMMAND "" + INSTALL_COMMAND "") + +set(cache_args_path "<TMP_DIR>/external-cache-$<CONFIG>.cmake") +set(cmake_cache_path "<BINARY_DIR>/CMakeCache.txt") +_ep_replace_location_tags(external cache_args_path cmake_cache_path) + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake" CONTENT " +set(check_pairs + \"${cmake_cache_path}|${cache_args_path}\" +) +") diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step1.cmake b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step1.cmake new file mode 100644 index 0000000..57c7ab7 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/data.cmake" + "set(cache_args -Dcache_arg:STRING=first) +") diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step2.cmake b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step2.cmake new file mode 100644 index 0000000..cbb79e1 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/data.cmake" + "set(cache_args -Dsecond_cache_arg:STRING=second) +") diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 14ae243..e4d7177 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -46,6 +46,11 @@ endif() run_BuildDepends(Custom-Symbolic-and-Byproduct) run_BuildDepends(Custom-Always) +set(RunCMake_TEST_OUTPUT_MERGE_save "${RunCMake_TEST_OUTPUT_MERGE}") +set(RunCMake_TEST_OUTPUT_MERGE 1) +run_BuildDepends(ExternalProjectCacheArgs) +set(RunCMake_TEST_OUTPUT_MERGE "${RunCMake_TEST_OUTPUT_MERGE_save}") + # 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") diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake index 98274f0..5952279 100644 --- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -1,5 +1,24 @@ include(RunCMake) +if(RunCMake_GENERATOR MATCHES "^Ninja") + # Detect ninja version so we know what tests can be supported. + execute_process( + COMMAND "${RunCMake_MAKE_PROGRAM}" --version + OUTPUT_VARIABLE ninja_out + ERROR_VARIABLE ninja_out + RESULT_VARIABLE ninja_res + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(ninja_res EQUAL 0 AND "x${ninja_out}" MATCHES "^x[0-9]+\\.[0-9]+") + set(ninja_version "${ninja_out}") + message(STATUS "ninja version: ${ninja_version}") + else() + message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}") + endif() +else() + set(ninja_version "") +endif() + run_cmake(CMP0037-OLD-space) run_cmake(CMP0037-NEW-space) run_cmake(CMP0037-WARN-space) @@ -9,8 +28,10 @@ if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make")) run_cmake(CMP0037-WARN-colon) endif() -run_cmake(CMP0037-WARN-reserved) -run_cmake(CMP0037-OLD-reserved) +if(NOT ninja_version VERSION_GREATER_EQUAL 1.10) + run_cmake(CMP0037-WARN-reserved) + run_cmake(CMP0037-OLD-reserved) +endif() run_cmake(CMP0037-NEW-reserved) run_cmake(NEW-cond) diff --git a/Tests/RunCMake/CMP0068/CMP0068-OLD-stderr.txt b/Tests/RunCMake/CMP0068/CMP0068-OLD-stderr.txt new file mode 100644 index 0000000..a736129 --- /dev/null +++ b/Tests/RunCMake/CMP0068/CMP0068-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0068-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0068 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/CMP0069/CMP0069-OLD-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-OLD-stderr.txt new file mode 100644 index 0000000..f51a6f4 --- /dev/null +++ b/Tests/RunCMake/CMP0069/CMP0069-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0069-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0069 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/CMP0102/CMP0102-Common.cmake b/Tests/RunCMake/CMP0102/CMP0102-Common.cmake new file mode 100644 index 0000000..61fdad6 --- /dev/null +++ b/Tests/RunCMake/CMP0102/CMP0102-Common.cmake @@ -0,0 +1,2 @@ + +mark_as_advanced(CMP0102_TEST_VARIABLE) diff --git a/Tests/RunCMake/CMP0102/CMP0102-NEW.cmake b/Tests/RunCMake/CMP0102/CMP0102-NEW.cmake new file mode 100644 index 0000000..bdf769f --- /dev/null +++ b/Tests/RunCMake/CMP0102/CMP0102-NEW.cmake @@ -0,0 +1,13 @@ + +cmake_policy(SET CMP0102 NEW) + +include (CMP0102-Common.cmake) +get_property(is_type_set CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE SET) +if (is_type_set) + get_property(type CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE) + message(FATAL_ERROR + "There is a cache entry for an undefined variable after " + "`mark_as_advanced`.") +endif () diff --git a/Tests/RunCMake/CMP0102/CMP0102-OLD.cmake b/Tests/RunCMake/CMP0102/CMP0102-OLD.cmake new file mode 100644 index 0000000..5c20dd3 --- /dev/null +++ b/Tests/RunCMake/CMP0102/CMP0102-OLD.cmake @@ -0,0 +1,18 @@ + +cmake_policy(SET CMP0102 OLD) + +include (CMP0102-Common.cmake) +get_property(is_type_set CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE SET) +if (NOT is_type_set) + message(FATAL_ERROR + "There is a cache entry for an undefined variable after " + "`mark_as_advanced`.") +endif () +get_property(type CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE) +if (NOT type STREQUAL "UNINITIALIZED") + message(FATAL_ERROR + "The cache type for CMP0102_TEST_VARIABLE is not " + "UNINITIALIZED") +endif () diff --git a/Tests/RunCMake/CMP0102/CMP0102-WARN-Default.cmake b/Tests/RunCMake/CMP0102/CMP0102-WARN-Default.cmake new file mode 100644 index 0000000..d6ebe4d --- /dev/null +++ b/Tests/RunCMake/CMP0102/CMP0102-WARN-Default.cmake @@ -0,0 +1,16 @@ + +include (CMP0102-Common.cmake) +get_property(is_type_set CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE SET) +if (NOT is_type_set) + message(FATAL_ERROR + "There is a cache entry for an undefined variable after " + "`mark_as_advanced`.") +endif () +get_property(type CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE) +if (NOT type STREQUAL "UNINITIALIZED") + message(FATAL_ERROR + "The cache type for CMP0102_TEST_VARIABLE is not " + "UNINITIALIZED") +endif () diff --git a/Tests/RunCMake/CMP0102/CMP0102-WARN-stderr.txt b/Tests/RunCMake/CMP0102/CMP0102-WARN-stderr.txt new file mode 100644 index 0000000..bb56ec2 --- /dev/null +++ b/Tests/RunCMake/CMP0102/CMP0102-WARN-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at CMP0102-Common.cmake:2 \(mark_as_advanced\): + Policy CMP0102 is not set: The variable named "CMP0102_TEST_VARIABLE" is + not in the cache. This results in an empty cache entry which is no longer + created when policy CMP0102 is set to NEW. Run "cmake --help-policy + CMP0102" for policy details. Use the cmake_policy command to set the + policy and suppress this warning. +Call Stack \(most recent call first\): + CMP0102-WARN.cmake:4 \(include\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0102/CMP0102-WARN.cmake b/Tests/RunCMake/CMP0102/CMP0102-WARN.cmake new file mode 100644 index 0000000..e9a45f1 --- /dev/null +++ b/Tests/RunCMake/CMP0102/CMP0102-WARN.cmake @@ -0,0 +1,18 @@ + +set(CMAKE_POLICY_WARNING_CMP0102 1) + +include (CMP0102-Common.cmake) +get_property(is_type_set CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE SET) +if (NOT is_type_set) + message(FATAL_ERROR + "There is a cache entry for an undefined variable after " + "`mark_as_advanced`.") +endif () +get_property(type CACHE CMP0102_TEST_VARIABLE + PROPERTY TYPE) +if (NOT type STREQUAL "UNINITIALIZED") + message(FATAL_ERROR + "The cache type for CMP0102_TEST_VARIABLE is not " + "UNINITIALIZED") +endif () diff --git a/Tests/RunCMake/CMP0102/CMakeLists.txt b/Tests/RunCMake/CMP0102/CMakeLists.txt new file mode 100644 index 0000000..ef2163c --- /dev/null +++ b/Tests/RunCMake/CMP0102/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0102/RunCMakeTest.cmake b/Tests/RunCMake/CMP0102/RunCMakeTest.cmake new file mode 100644 index 0000000..9b5df74 --- /dev/null +++ b/Tests/RunCMake/CMP0102/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(CMP0102-OLD) +run_cmake(CMP0102-NEW) +run_cmake(CMP0102-WARN) +run_cmake(CMP0102-WARN-Default) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 581a39e..e9f8bca 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -115,6 +115,7 @@ if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) endif() add_RunCMake_test(CMP0069) add_RunCMake_test(CMP0081) +add_RunCMake_test(CMP0102) # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode @@ -125,7 +126,7 @@ endif() if(CMAKE_GENERATOR MATCHES "Make") add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU}) endif() -if(CMAKE_GENERATOR STREQUAL "Ninja") +if(CMAKE_GENERATOR MATCHES "Ninja") set(Ninja_ARGS -DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION} -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} @@ -134,6 +135,16 @@ if(CMAKE_GENERATOR STREQUAL "Ninja") list(APPEND Ninja_ARGS -DTEST_Fortran=1) endif() add_RunCMake_test(Ninja) + set(NinjaMultiConfig_ARGS + -DCYGWIN=${CYGWIN} + ) + if(CMake_TEST_Qt5 AND Qt5Core_FOUND) + list(APPEND NinjaMultiConfig_ARGS -DCMake_TEST_Qt5=1) + endif() + if(DEFINED CMake_TEST_CUDA) + list(APPEND NinjaMultiConfig_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + endif() + add_RunCMake_test(NinjaMultiConfig) endif() add_RunCMake_test(CTest) @@ -189,6 +200,7 @@ add_RunCMake_test(GeneratorToolset) add_RunCMake_test(GetPrerequisites) add_RunCMake_test(GNUInstallDirs -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test +add_RunCMake_test(Graphviz) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) @@ -209,6 +221,7 @@ add_RunCMake_test(ScriptMode) add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER}) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) +add_RunCMake_test(TargetProperties) add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) @@ -271,6 +284,7 @@ add_RunCMake_test(find_package) add_RunCMake_test(find_path) add_RunCMake_test(find_program -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(foreach) +add_RunCMake_test(function) add_RunCMake_test(get_filename_component) add_RunCMake_test(get_property) add_RunCMake_test(if) @@ -278,6 +292,7 @@ add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(include_guard) add_RunCMake_test(list) +add_RunCMake_test(load_cache) add_RunCMake_test(math) add_RunCMake_test(message) add_RunCMake_test(option) @@ -289,6 +304,10 @@ add_RunCMake_test(set_property) add_RunCMake_test(string) add_RunCMake_test(test_include_dirs) add_RunCMake_test(BundleUtilities) +if(APPLE) + add_RunCMake_test(INSTALL_NAME_DIR) + add_RunCMake_test(MacOSVersions) +endif() function(add_RunCMake_test_try_compile) if(CMAKE_VERSION VERSION_LESS 3.9.20170907 AND "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") @@ -335,6 +354,7 @@ add_RunCMake_test(alias_targets) add_RunCMake_test(interface_library) add_RunCMake_test(no_install_prefix) add_RunCMake_test(configure_file) +add_RunCMake_test(CTestTimeout -DTIMEOUT=${CTestTestTimeout_TIME}) add_RunCMake_test(CTestTimeoutAfterMatch) # ctresalloc links against CMakeLib and CTestLib, which means it can't be built @@ -436,12 +456,12 @@ add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_I add_RunCMake_test(target_compile_definitions) add_RunCMake_test(target_compile_features) -add_RunCMake_test(target_compile_options) +add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test(target_include_directories) add_RunCMake_test(target_sources) add_RunCMake_test(CheckModules) add_RunCMake_test(CheckIPOSupported) -add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCYGWIN=${CYGWIN} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) add_RunCMake_test(CommandLineTar) if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)) @@ -454,7 +474,9 @@ add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN} -DCMAK -DCMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN=${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG=${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG} - -DCMAKE_EXECUTABLE_FORMAT=${CMAKE_EXECUTABLE_FORMAT}) + -DCMAKE_EXECUTABLE_FORMAT=${CMAKE_EXECUTABLE_FORMAT} + -DCMake_INSTALL_NAME_TOOL_BUG=${CMake_INSTALL_NAME_TOOL_BUG} + ) add_RunCMake_test(CPackCommandLine) add_RunCMake_test(CPackConfig) @@ -554,6 +576,7 @@ set(cpack_tests DEB.MD5SUMS DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY DEB.DEB_DESCRIPTION + DEB.PROJECT_META RPM.CUSTOM_BINARY_SPEC_FILE RPM.CUSTOM_NAMES @@ -574,6 +597,7 @@ set(cpack_tests RPM.SUGGESTS RPM.SYMLINKS RPM.USER_FILELIST + RPM.PROJECT_META 7Z TBZ2 @@ -584,10 +608,16 @@ set(cpack_tests STGZ External ) +if(APPLE) + list(APPEND cpack_tests DragNDrop) +endif() add_RunCMake_test_group(CPack "${cpack_tests}") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used -add_RunCMake_test(AutoExportDll -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}) +add_RunCMake_test(AutoExportDll + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID} + ) add_RunCMake_test(AndroidMK) diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index f65cb9d..24f54c6 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -75,7 +75,7 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK if(package_target) set(cpack_command_ ${CMAKE_COMMAND} --build "${RunCMake_TEST_BINARY_DIR}" --target package) else() - set(cpack_command_ ${CMAKE_CPACK_COMMAND} ${pack_params_}) + set(cpack_command_ ${CMAKE_CPACK_COMMAND} ${pack_params_} -C Debug) endif() # execute cpack diff --git a/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake b/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake new file mode 100644 index 0000000..023e597 --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/Helpers.cmake @@ -0,0 +1,54 @@ +set(ALL_FILES_GLOB "*.dmg") + +function(getPackageContent FILE RESULT_VAR) + get_filename_component(path_ "${FILE}" DIRECTORY) + file(REMOVE_RECURSE "${path_}/content") + file(MAKE_DIRECTORY "${path_}/content") + execute_process(COMMAND ${HDIUTIL_EXECUTABLE} attach -mountroot ${path_}/content -nobrowse ${FILE} + RESULT_VARIABLE attach_result_ + ERROR_VARIABLE attach_error_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(attach_result_) + message(FATAL_ERROR "Failed to attach DMG: '${attach_result_}';" + " '${attach_error_}'.") + endif() + + file(GLOB_RECURSE package_content_ LIST_DIRECTORIES true RELATIVE + "${path_}/content" "${path_}/content/*") + # Some versions of macOS have .Trashes, others do not. + list(FILTER package_content_ EXCLUDE REGEX "/.Trashes$") + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) + + execute_process(COMMAND ${HDIUTIL_EXECUTABLE} detach ${path_}/content/volume-name + RESULT_VARIABLE detach_result_ + ERROR_VARIABLE detach_error_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(detach_result_) + message(FATAL_ERROR "Failed to detach DMG: '${detach_result_}';" + " '${detach_error_}'.") + endif() +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} "${NAME}-${VERSION}-Darwin${COMPONENT}.dmg" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + getPackageContent("${FILE}" package_content_) + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + set(prefix_ "volume-name") + list(TRANSFORM ${CONTENT_VAR} PREPEND "${prefix_}" OUTPUT_VARIABLE prepared_) + list(APPEND prepared_ "${prefix_}") + + set(${CONTENT_VAR} "${prepared_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/DragNDrop/Prerequirements.cmake b/Tests/RunCMake/CPack/DragNDrop/Prerequirements.cmake new file mode 100644 index 0000000..f0aaf2c --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/Prerequirements.cmake @@ -0,0 +1,8 @@ +function(get_test_prerequirements found_var config_file) + find_program(HDIUTIL_EXECUTABLE hdiutil) + + if(HDIUTIL_EXECUTABLE) + file(WRITE "${config_file}" "set(HDIUTIL_EXECUTABLE \"${HDIUTIL_EXECUTABLE}\")") + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DragNDrop/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/DragNDrop/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..aa6c8ff --- /dev/null +++ b/Tests/RunCMake/CPack/DragNDrop/packaging_COMPONENT_default.cmake @@ -0,0 +1,3 @@ +set(CPACK_COMPONENTS_GROUPING "IGNORE") +set(CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK ON) +set(CPACK_DMG_VOLUME_NAME "volume-name") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index c2382b0..3be1fd0 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -5,7 +5,7 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") # run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM.CUSTOM_BINARY_SPEC_FILE" false "MONOLITHIC;COMPONENT") -run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ" true "COMPONENT") +run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ;DragNDrop" true "COMPONENT") run_cpack_test(DEBUGINFO "RPM.DEBUGINFO;DEB.DEBUGINFO" true "COMPONENT") run_cpack_test_subtests(DEFAULT_PERMISSIONS "CMAKE_var_set;CPACK_var_set;both_set;invalid_CMAKE_var;invalid_CPACK_var" "RPM.DEFAULT_PERMISSIONS;DEB.DEFAULT_PERMISSIONS" false "MONOLITHIC;COMPONENT") run_cpack_test(DEPENDENCIES "RPM.DEPENDENCIES;DEB.DEPENDENCIES" true "COMPONENT") @@ -43,3 +43,4 @@ run_cpack_test_subtests( false "MONOLITHIC;COMPONENT" ) +run_cpack_test(PROJECT_META "RPM.PROJECT_META;DEB.PROJECT_META" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake index 07226df..9ac19e2 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake @@ -12,4 +12,7 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") elseif(GENERATOR_TYPE STREQUAL "TGZ") set(EXPECTED_FILE_2 "second.tar.gz") set(EXPECTED_FILE_3 "pkg_3_abc.tar.gz") +elseif(GENERATOR_TYPE STREQUAL "DragNDrop") + set(EXPECTED_FILE_2 "second.dmg") + set(EXPECTED_FILE_3 "pkg_3_abc.dmg") endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake index 4c20e41..899258e 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake @@ -10,6 +10,9 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") elseif(GENERATOR_TYPE STREQUAL "TGZ") set(CPACK_ARCHIVE_PKG_2_FILE_NAME "second") set(CPACK_ARCHIVE_PKG_3_FILE_NAME "pkg_3_abc") +elseif(GENERATOR_TYPE STREQUAL "DragNDrop") + set(CPACK_DMG_PKG_2_FILE_NAME "second") + set(CPACK_DMG_PKG_3_FILE_NAME "pkg_3_abc") endif() install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake index bfe2059..70ad48b 100644 --- a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake @@ -46,17 +46,7 @@ set(_expected_description [[ Description: This is the summary line . See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description]]) -# ATTENTION The code in `cmCPackGenerator.cxx` to read `CPACK_PACKAGE_DESCRIPTION_FILE` -# has a BUG: it appends the `\n` character to every line of the -# input, even if there was no EOL (e.g. at the last line of the file). -# That is WHY for this sub-test the one more pre-formatted "empty" -# line required! -# NOTE For component based installers content of the file gonna read by -# `CPackDeb` module and the `file(READ...)` command so no the mentioned -# workaround required! -if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION_FILE" AND PACKAGING_TYPE STREQUAL "MONOLITHIC") - string(APPEND _expected_description "\n ." ) -elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_NO_PACKAGE_DESCRIPTION") +if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_NO_PACKAGE_DESCRIPTION") set(_expected_description [[ Description: This is the summary line]]) elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_COMPONENT_COMP_DESCRIPTION") set(_expected_description [[ Description: One line description]]) diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt index 18bf617..ca25b1e 100644 --- a/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt @@ -1,5 +1,6 @@ ^\{ - "componentGroups" :[ ] + ("buildConfig" : "Debug", +)? "componentGroups" :[ ] \{ "f12" :[ ] \{ diff --git a/Tests/RunCMake/CPack/tests/PROJECT_META/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PROJECT_META/ExpectedFiles.cmake new file mode 100644 index 0000000..448ed2b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PROJECT_META/ExpectedFiles.cmake @@ -0,0 +1,9 @@ +if(GENERATOR_TYPE STREQUAL DEB) + set(EXPECTED_FILE_1 "project_meta-1.2.3*.deb") +elseif(GENERATOR_TYPE STREQUAL RPM) + set(EXPECTED_FILE_1 "project_meta-1.2.3*.rpm") +else() + message(FATAL_ERROR "Unexpected CPack generator") +endif() +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake new file mode 100644 index 0000000..b3accb5 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake @@ -0,0 +1,30 @@ +function(checkPackageURL FILE TAG EXPECTED_URL) + getPackageInfo("${FILE}" "_file_info") + string(REPLACE "\n" ";" _file_info "${_file_info}") + + set(_seen_url FALSE) + foreach(_line IN LISTS _file_info) + if(_line MATCHES "${TAG}: (.*)") + set(_seen_url TRUE) + if(NOT CMAKE_MATCH_1 STREQUAL EXPECTED_URL) + message(FATAL_ERROR "Unexpected `Homepage` URL: `${CMAKE_MATCH_1}` != `${EXPECTED_URL}`") + endif() + break() + endif() + endforeach() + if(NOT _seen_url) + message(FATAL_ERROR "The packge `${FILE}` do not have URL as expected") + endif() +endfunction() + +if(GENERATOR_TYPE STREQUAL DEB) + set(_tag " Homepage") # NOTE The leading space +elseif(GENERATOR_TYPE STREQUAL RPM) + set(_tag "URL.*") +else() + message(FATAL_ERROR "Unexpected CPack generator") +endif() + +checkPackageURL("${FOUND_FILE_1}" "${_tag}" "https://meta.test.info") + +# kate: indent-width 2; diff --git a/Tests/RunCMake/CPack/tests/PROJECT_META/test.cmake b/Tests/RunCMake/CPack/tests/PROJECT_META/test.cmake new file mode 100644 index 0000000..9c5266a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PROJECT_META/test.cmake @@ -0,0 +1,11 @@ +project( + MetaInfoTest + VERSION 1.2.3 + DESCRIPTION "This is going to be a summary" + HOMEPAGE_URL "https://meta.test.info" +) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CTest/CMakeCTestArguments-test-check.cmake b/Tests/RunCMake/CTest/CMakeCTestArguments-test-check.cmake new file mode 100644 index 0000000..3e05953 --- /dev/null +++ b/Tests/RunCMake/CTest/CMakeCTestArguments-test-check.cmake @@ -0,0 +1,4 @@ +set(log "${RunCMake_TEST_BINARY_DIR}/output-log.txt") +if(NOT EXISTS "${log}") + set(RunCMake_TEST_FAILED "The expected output log file is missing:\n ${log}") +endif() diff --git a/Tests/RunCMake/CTest/CMakeCTestArguments.cmake b/Tests/RunCMake/CTest/CMakeCTestArguments.cmake new file mode 100644 index 0000000..37f2933 --- /dev/null +++ b/Tests/RunCMake/CTest/CMakeCTestArguments.cmake @@ -0,0 +1,2 @@ +include(CTest) +add_test(NAME CMakeCTestArguments COMMAND ${CMAKE_COMMAND} -E echo CMakeCTestArguments) diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake index 1392240..761224a 100644 --- a/Tests/RunCMake/CTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake @@ -5,3 +5,16 @@ run_cmake(BeforeProject) unset(RunCMake_TEST_OPTIONS) run_cmake(NotOn) + +function(run_CMakeCTestArguments) + run_cmake_with_options(CMakeCTestArguments "-DCMAKE_CTEST_ARGUMENTS=--quiet\\;--output-log\\;output-log.txt") + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMakeCTestArguments-build) + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + set(test "test") + else() + set(test "RUN_TESTS") + endif() + run_cmake_command(CMakeCTestArguments-test ${CMAKE_COMMAND} --build . --config Debug --target "${test}") +endfunction() +run_CMakeCTestArguments() diff --git a/Tests/RunCMake/CTestCommandLine/CMakeLists.txt.in b/Tests/RunCMake/CTestCommandLine/CMakeLists.txt.in new file mode 100644 index 0000000..5437800 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/CMakeLists.txt.in @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.1) +project(CTestCommandLine@CASE_NAME@ NONE) +include(CTest) +add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 6b23162..9b9ae65 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -1,9 +1,33 @@ include(RunCMake) +include(RunCTest) + set(RunCMake_TEST_TIMEOUT 60) unset(ENV{CTEST_PARALLEL_LEVEL}) unset(ENV{CTEST_OUTPUT_ON_FAILURE}) +run_cmake_command(repeat-opt-bad1 + ${CMAKE_CTEST_COMMAND} --repeat until-pass + ) +run_cmake_command(repeat-opt-bad2 + ${CMAKE_CTEST_COMMAND} --repeat until-pass:foo + ) +run_cmake_command(repeat-opt-bad3 + ${CMAKE_CTEST_COMMAND} --repeat until-fail:2 --repeat-until-fail 2 + ) +run_cmake_command(repeat-opt-bad4 + ${CMAKE_CTEST_COMMAND} --repeat-until-fail 2 --repeat until-fail:2 + ) +run_cmake_command(repeat-opt-until-pass + ${CMAKE_CTEST_COMMAND} --repeat until-pass:2 + ) +run_cmake_command(repeat-opt-until-fail + ${CMAKE_CTEST_COMMAND} --repeat until-fail:2 + ) +run_cmake_command(repeat-opt-after-timeout + ${CMAKE_CTEST_COMMAND} --repeat after-timeout:2 + ) + run_cmake_command(repeat-until-fail-bad1 ${CMAKE_CTEST_COMMAND} --repeat-until-fail ) @@ -14,19 +38,39 @@ run_cmake_command(repeat-until-fail-good ${CMAKE_CTEST_COMMAND} --repeat-until-fail 2 ) -function(run_repeat_until_fail_tests) +function(run_repeat_until_pass_tests) # Use a single build tree for a few tests without cleaning. - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/repeat-until-fail-build) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/repeat-until-pass-build) + run_cmake(repeat-until-pass-cmake) set(RunCMake_TEST_NO_CLEAN 1) - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake_command(repeat-until-pass-ctest + ${CMAKE_CTEST_COMMAND} -C Debug --repeat until-pass:3 + ) +endfunction() +run_repeat_until_pass_tests() +function(run_repeat_after_timeout_tests) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/repeat-after-timeout-build) + run_cmake(repeat-after-timeout-cmake) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(repeat-after-timeout-ctest + ${CMAKE_CTEST_COMMAND} -C Debug --repeat after-timeout:3 + ) +endfunction() +run_repeat_after_timeout_tests() + +function(run_repeat_until_fail_tests) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/repeat-until-fail-build) run_cmake(repeat-until-fail-cmake) + set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(repeat-until-fail-ctest - ${CMAKE_CTEST_COMMAND} -C Debug --repeat-until-fail 3 + ${CMAKE_CTEST_COMMAND} -C Debug ${ARGN} ) endfunction() -run_repeat_until_fail_tests() +run_repeat_until_fail_tests(--repeat-until-fail 3) +run_repeat_until_fail_tests(--repeat until-fail:3) function(run_BadCTestTestfile) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BadCTestTestfile) @@ -269,3 +313,35 @@ function(run_ShowOnly) run_cmake_command(show-only_json-v1 ${CMAKE_CTEST_COMMAND} --show-only=json-v1) endfunction() run_ShowOnly() + +function(run_NoTests) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoTests) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "") + run_cmake_command(no-tests_ignore ${CMAKE_CTEST_COMMAND} --no-tests=ignore) + run_cmake_command(no-tests_error ${CMAKE_CTEST_COMMAND} --no-tests=error) + run_cmake_command(no-tests_bad ${CMAKE_CTEST_COMMAND} --no-tests=bad) + run_cmake_command(no-tests_legacy ${CMAKE_CTEST_COMMAND}) + file(WRITE "${RunCMake_TEST_BINARY_DIR}/NoTestsScript.cmake" " + set(CTEST_COMMAND \"${CMAKE_CTEST_COMMAND}\") + set(CTEST_SOURCE_DIRECTORY \"${RunCMake_SOURCE_DIR}\") + set(CTEST_BINARY_DIRECTORY \"${RunCMake_TEST_BINARY_DIR}\") + ctest_start(Experimental) + ctest_test() +") + run_cmake_command( + no-tests-script_ignore ${CMAKE_CTEST_COMMAND} --no-tests=ignore + -S "${RunCMake_TEST_BINARY_DIR}/NoTestsScript.cmake") + run_cmake_command( + no-tests-script_error ${CMAKE_CTEST_COMMAND} --no-tests=error + -S "${RunCMake_TEST_BINARY_DIR}/NoTestsScript.cmake") + run_cmake_command( + no-tests-script_legacy ${CMAKE_CTEST_COMMAND} + -S "${RunCMake_TEST_BINARY_DIR}/NoTestsScript.cmake") +endfunction() +run_NoTests() + +# Check the configuration type variable is passed +run_ctest(check-configuration-type) diff --git a/Tests/RunCMake/CTestCommandLine/check-configuration-type-stderr.txt b/Tests/RunCMake/CTestCommandLine/check-configuration-type-stderr.txt new file mode 100644 index 0000000..b2c1a45 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/check-configuration-type-stderr.txt @@ -0,0 +1,2 @@ +Command line CTEST_CONFIGURATION_TYPE=Debug +set CTEST_CONFIGURATION_TYPE=Release diff --git a/Tests/RunCMake/CTestCommandLine/no-tests-script_error-result.txt b/Tests/RunCMake/CTestCommandLine/no-tests-script_error-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests-script_error-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestCommandLine/no-tests-script_error-stderr.txt b/Tests/RunCMake/CTestCommandLine/no-tests-script_error-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests-script_error-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/no-tests-script_legacy-result.txt b/Tests/RunCMake/CTestCommandLine/no-tests-script_legacy-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests-script_legacy-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestCommandLine/no-tests-script_legacy-stderr.txt b/Tests/RunCMake/CTestCommandLine/no-tests-script_legacy-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests-script_legacy-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/no-tests_bad-result.txt b/Tests/RunCMake/CTestCommandLine/no-tests_bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests_bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/no-tests_bad-stderr.txt b/Tests/RunCMake/CTestCommandLine/no-tests_bad-stderr.txt new file mode 100644 index 0000000..1703539 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests_bad-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--no-tests=' given unknown value 'bad'$ diff --git a/Tests/RunCMake/CTestCommandLine/no-tests_error-result.txt b/Tests/RunCMake/CTestCommandLine/no-tests_error-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests_error-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/CTestCommandLine/no-tests_error-stderr.txt b/Tests/RunCMake/CTestCommandLine/no-tests_error-stderr.txt new file mode 100644 index 0000000..eafba1c --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests_error-stderr.txt @@ -0,0 +1 @@ +No tests were found!!! diff --git a/Tests/RunCMake/CTestCommandLine/no-tests_legacy-stderr.txt b/Tests/RunCMake/CTestCommandLine/no-tests_legacy-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/no-tests_legacy-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-cmake.cmake b/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-cmake.cmake new file mode 100644 index 0000000..873c0bd --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-cmake.cmake @@ -0,0 +1,15 @@ +enable_testing() + +set(TEST_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_output.txt") +add_test(NAME initialization + COMMAND ${CMAKE_COMMAND} + "-DTEST_OUTPUT_FILE=${TEST_OUTPUT_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/init.cmake") +add_test(NAME test1 + COMMAND ${CMAKE_COMMAND} + "-DTEST_OUTPUT_FILE=${TEST_OUTPUT_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/test1-timeout.cmake") +set_tests_properties(test1 PROPERTIES DEPENDS "initialization" TIMEOUT 5) + +add_test(hello ${CMAKE_COMMAND} -E echo hello) +add_test(goodbye ${CMAKE_COMMAND} -E echo goodbye) diff --git a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-ctest-stdout.txt b/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-ctest-stdout.txt new file mode 100644 index 0000000..d0a5487 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-ctest-stdout.txt @@ -0,0 +1,15 @@ +^Test project .*/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-build + Start 1: initialization +1/4 Test #1: initialization ................... Passed +[0-9.]+ sec + Start 2: test1 +2/4 Test #2: test1 ............................\*\*\*Timeout +[0-9.]+ sec + Start 2: test1 + Test #2: test1 ............................ Passed +[0-9.]+ sec + Start 3: hello +3/4 Test #3: hello ............................ Passed +[0-9.]+ sec + Start 4: goodbye +4/4 Test #4: goodbye .......................... Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 4 + +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-after-timeout-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-after-timeout-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-after-timeout-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-stderr.txt new file mode 100644 index 0000000..f6f3241 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--repeat' given invalid value 'until-pass'$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-stderr.txt new file mode 100644 index 0000000..2f9f32a --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--repeat' given invalid value 'until-pass:foo'$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-stderr.txt new file mode 100644 index 0000000..de4e11b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-stderr.txt @@ -0,0 +1 @@ +^CMake Error: At most one '--repeat' option may be used\.$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-stderr.txt new file mode 100644 index 0000000..de4e11b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-stderr.txt @@ -0,0 +1 @@ +^CMake Error: At most one '--repeat' option may be used\.$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-until-fail-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-fail-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-fail-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-until-pass-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-pass-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-pass-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-cmake.cmake b/Tests/RunCMake/CTestCommandLine/repeat-until-pass-cmake.cmake new file mode 100644 index 0000000..d109551 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-pass-cmake.cmake @@ -0,0 +1,15 @@ +enable_testing() + +set(TEST_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_output.txt") +add_test(NAME initialization + COMMAND ${CMAKE_COMMAND} + "-DTEST_OUTPUT_FILE=${TEST_OUTPUT_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/init.cmake") +add_test(NAME test1 + COMMAND ${CMAKE_COMMAND} + "-DTEST_OUTPUT_FILE=${TEST_OUTPUT_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/test1-pass.cmake") +set_tests_properties(test1 PROPERTIES DEPENDS "initialization") + +add_test(hello ${CMAKE_COMMAND} -E echo hello) +add_test(goodbye ${CMAKE_COMMAND} -E echo goodbye) diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-ctest-stdout.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-pass-ctest-stdout.txt new file mode 100644 index 0000000..3745dc2 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-pass-ctest-stdout.txt @@ -0,0 +1,15 @@ +^Test project .*/Tests/RunCMake/CTestCommandLine/repeat-until-pass-build + Start 1: initialization +1/4 Test #1: initialization ................... Passed +[0-9.]+ sec + Start 2: test1 +2/4 Test #2: test1 ............................\*\*\*Failed +[0-9.]+ sec + Start 2: test1 + Test #2: test1 ............................ Passed +[0-9.]+ sec + Start 3: hello +3/4 Test #3: hello ............................ Passed +[0-9.]+ sec + Start 4: goodbye +4/4 Test #4: goodbye .......................... Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 4 + +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/CTestCommandLine/test.cmake.in b/Tests/RunCMake/CTestCommandLine/test.cmake.in new file mode 100644 index 0000000..b82968a --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/test.cmake.in @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.1) + +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_NIGHTLY_START_TIME "01:00:00 UTC") +set(CTEST_COMMAND "@CMAKE_CTEST_COMMAND@") + +if("@CASE_NAME@" MATCHES "^check-configuration-type") + message("Command line CTEST_CONFIGURATION_TYPE=" ${CTEST_CONFIGURATION_TYPE}) + set(CTEST_CONFIGURATION_TYPE "Release") + message("set CTEST_CONFIGURATION_TYPE=" ${CTEST_CONFIGURATION_TYPE}) + + ctest_start(Experimental) +endif() diff --git a/Tests/RunCMake/CTestCommandLine/test1-pass.cmake b/Tests/RunCMake/CTestCommandLine/test1-pass.cmake new file mode 100644 index 0000000..dda8dea --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/test1-pass.cmake @@ -0,0 +1,13 @@ +# This is run by test test1 in repeat-until-pass-cmake.cmake with cmake -P. +# It reads the file TEST_OUTPUT_FILE and increments the number +# found in the file by 1. Unless the number is 2, then the +# code sends out a cmake error causing the test to pass only on +# the second time it is run. +message("TEST_OUTPUT_FILE = ${TEST_OUTPUT_FILE}") +file(READ "${TEST_OUTPUT_FILE}" COUNT) +message("COUNT= ${COUNT}") +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${TEST_OUTPUT_FILE}" "${COUNT}") +if(NOT COUNT EQUAL 2) + message(FATAL_ERROR "this test passes only on the 2nd run") +endif() diff --git a/Tests/RunCMake/CTestCommandLine/test1-timeout.cmake b/Tests/RunCMake/CTestCommandLine/test1-timeout.cmake new file mode 100644 index 0000000..fbf2ccc --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/test1-timeout.cmake @@ -0,0 +1,14 @@ +# This is run by test test1 in repeat-after-timeout-cmake.cmake with cmake -P. +# It reads the file TEST_OUTPUT_FILE and increments the number +# found in the file by 1. Unless the number is 2, then the +# code sends out a cmake error causing the test to not timeout only on +# the second time it is run. +message("TEST_OUTPUT_FILE = ${TEST_OUTPUT_FILE}") +file(READ "${TEST_OUTPUT_FILE}" COUNT) +message("COUNT= ${COUNT}") +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${TEST_OUTPUT_FILE}" "${COUNT}") +if(NOT COUNT EQUAL 2) + message("this test times out except on the 2nd run") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10) +endif() diff --git a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake index 7d63299..ef79dce 100644 --- a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake @@ -1,6 +1,6 @@ function(setup_resource_tests) if(CTEST_RESOURCE_ALLOC_ENABLED) - add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E remove -f "${CMAKE_BINARY_DIR}/ctresalloc.log") + add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E rm -f "${CMAKE_BINARY_DIR}/ctresalloc.log") endif() endfunction() diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt index 41df5af..91d7ef9 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt +++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt @@ -1,4 +1,14 @@ -^Insufficient resources +^Insufficient resources for test Test1: + + Test requested resources of type 'fluxcapacitors' in the following amounts: + 200 slots + but only the following units were available: + 'outatime': 121 slots + +Resource spec file: + + [^ +]*/Tests/RunCMake/CTestResourceAllocation/resspec.json CMake Error at [^ ]*/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res/test\.cmake:[0-9]+ \(message\): Tests did not pass$ diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt index 6c2f554..5c75a3d 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt +++ b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt @@ -1,4 +1,11 @@ -^Insufficient resources +^Insufficient resources for test Test1: + + Test requested resources of type 'terminators' which does not exist + +Resource spec file: + + [^ +]*/Tests/RunCMake/CTestResourceAllocation/resspec.json CMake Error at [^ ]*/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res/test\.cmake:[0-9]+ \(message\): Tests did not pass$ diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt index 82dfdef..4902a19 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt +++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt @@ -1,4 +1,21 @@ -^Insufficient resources +^Insufficient resources for test Test1: + + Test requested resources of type 'widgets' in the following amounts: + 12 slots + but only the following units were available: + '0': 4 slots + '1': 2 slots + '2': 4 slots + '3': 8 slots + '4': 1 slot + '5': 1 slot + '6': 1 slot + '7': 1 slot + +Resource spec file: + + [^ +]*/Tests/RunCMake/CTestResourceAllocation/resspec.json CMake Error at [^ ]*/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res/test\.cmake:[0-9]+ \(message\): Tests did not pass$ diff --git a/Tests/RunCMake/CTestTimeout/Basic-stdout.txt b/Tests/RunCMake/CTestTimeout/Basic-stdout.txt new file mode 100644 index 0000000..db59dbf --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/Basic-stdout.txt @@ -0,0 +1,6 @@ +Test project [^ +]*/Tests/RunCMake/CTestTimeout/Basic-build + Start 1: TestTimeout +1/1 Test #1: TestTimeout ......................\*\*\*Timeout +[1-9][0-9.]* sec ++ +0% tests passed, 1 tests failed out of 1 diff --git a/Tests/RunCMake/CTestTimeout/CMakeLists.txt.in b/Tests/RunCMake/CTestTimeout/CMakeLists.txt.in new file mode 100644 index 0000000..20faa94 --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/CMakeLists.txt.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.16) +project(CTestTest@CASE_NAME@ C) +include(CTest) + +add_executable(TestTimeout TestTimeout.c) + +if(NOT TIMEOUT) + set(TIMEOUT 4) +endif() +target_compile_definitions(TestTimeout PRIVATE TIMEOUT=${TIMEOUT}) + +add_test(NAME TestTimeout COMMAND TestTimeout) +set_property(TEST TestTimeout PROPERTY TIMEOUT ${TIMEOUT}) + +@CASE_CMAKELISTS_SUFFIX_CODE@ diff --git a/Tests/RunCMake/CTestTimeout/Fork-stdout.txt b/Tests/RunCMake/CTestTimeout/Fork-stdout.txt new file mode 100644 index 0000000..2938d8e --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/Fork-stdout.txt @@ -0,0 +1,6 @@ +Test project [^ +]*/Tests/RunCMake/CTestTimeout/Fork-build + Start 1: TestTimeout +1/1 Test #1: TestTimeout ......................\*\*\*Timeout +[1-9][0-9.]* sec ++ +0% tests passed, 1 tests failed out of 1 diff --git a/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake b/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake new file mode 100644 index 0000000..7e96b6d --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake @@ -0,0 +1,22 @@ +include(RunCTest) + +if(NOT TIMEOUT) + # Give the process time to load and start running. + set(TIMEOUT 4) +endif() + +function(run_ctest_timeout CASE_NAME) + configure_file(${RunCMake_SOURCE_DIR}/TestTimeout.c + ${RunCMake_BINARY_DIR}/${CASE_NAME}/TestTimeout.c COPYONLY) + run_ctest(${CASE_NAME}) +endfunction() + +run_ctest_timeout(Basic) + +if(UNIX) + string(CONCAT CASE_CMAKELISTS_SUFFIX_CODE [[ + target_compile_definitions(TestTimeout PRIVATE FORK) +]]) + run_ctest_timeout(Fork) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endif() diff --git a/Tests/RunCMake/CTestTimeout/TestTimeout.c b/Tests/RunCMake/CTestTimeout/TestTimeout.c new file mode 100644 index 0000000..5a008a7 --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/TestTimeout.c @@ -0,0 +1,24 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +#include <stdio.h> + +int main(void) +{ +#ifdef FORK + pid_t pid = fork(); + if (pid != 0) { + return 0; + } +#endif + +#if defined(_WIN32) + Sleep((TIMEOUT + 4) * 1000); +#else + sleep((TIMEOUT + 4)); +#endif + return 0; +} diff --git a/Tests/RunCMake/CTestTimeout/test.cmake.in b/Tests/RunCMake/CTestTimeout/test.cmake.in new file mode 100644 index 0000000..be2625b --- /dev/null +++ b/Tests/RunCMake/CTestTimeout/test.cmake.in @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.16) +@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}") + +ctest_start(Experimental) +ctest_configure(OPTIONS "-DTIMEOUT=@TIMEOUT@") +ctest_build() +ctest_test() diff --git a/Tests/RunCMake/CheckIPOSupported/cmp0069-is-old-stderr.txt b/Tests/RunCMake/CheckIPOSupported/cmp0069-is-old-stderr.txt index f183594..1baa63a 100644 --- a/Tests/RunCMake/CheckIPOSupported/cmp0069-is-old-stderr.txt +++ b/Tests/RunCMake/CheckIPOSupported/cmp0069-is-old-stderr.txt @@ -1,4 +1,15 @@ -^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): +^CMake Deprecation Warning at cmp0069-is-old.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0069 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): Policy CMP0069 set to OLD Call Stack \(most recent call first\): cmp0069-is-old\.cmake:[0-9]+ \(check_ipo_supported\) diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt new file mode 100644 index 0000000..62b963a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Unknown -E rm argument: -rd$ diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake new file mode 100644 index 0000000..b1a29a2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/dir/existing.txt) + set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt new file mode 100644 index 0000000..1ac7dba --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Missing file/directory to remove$ diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake new file mode 100644 index 0000000..6cd4edd --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake @@ -0,0 +1,8 @@ +execute_process( + COMMAND ${CMAKE_COMMAND} -E rm "" + RESULT_VARIABLE actual_result + ) + +if(NOT "${actual_result}" EQUAL "1") + message(SEND_ERROR "cmake -E rm \"\" should have returned 1, got ${actual_result}") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake new file mode 100644 index 0000000..a0a9b20 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt new file mode 100644 index 0000000..05df88a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt @@ -0,0 +1 @@ +^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt new file mode 100644 index 0000000..05df88a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt @@ -0,0 +1 @@ +^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake new file mode 100644 index 0000000..1a976cb --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}) + set(RunCMake_TEST_FAILED "${out} not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt new file mode 100644 index 0000000..1ac7dba --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Missing file/directory to remove$ diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake new file mode 100644 index 0000000..609271e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/d1 OR NOT EXISTS ${out}/d2) + set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 is removed but should not") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt new file mode 100644 index 0000000..33ea2e3 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt @@ -0,0 +1,2 @@ +^Error removing directory ".*/rm_tests/d1" without recursive option\. +Error removing directory ".*/rm_tests/d2" without recursive option\.$ diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake new file mode 100644 index 0000000..5282da7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/d1 OR EXISTS ${out}/d2) + set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 should be removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake new file mode 100644 index 0000000..b1a29a2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/dir/existing.txt) + set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake new file mode 100644 index 0000000..a0a9b20 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index b608d33..8930721 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -254,6 +254,24 @@ function(run_EnvironmentGenerator) endfunction() run_EnvironmentGenerator() +function(run_EnvironmentExportCompileCommands) + set(RunCMake_TEST_SOURCE_DIR ${RunCMake_SOURCE_DIR}/env-export-compile-commands) + + run_cmake(env-export-compile-commands-unset) + + set(ENV{CMAKE_EXPORT_COMPILE_COMMANDS} ON) + run_cmake(env-export-compile-commands-set) + + set(RunCMake_TEST_OPTIONS -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF) + run_cmake(env-export-compile-commands-override) + + unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS}) +endfunction(run_EnvironmentExportCompileCommands) + +if(RunCMake_GENERATOR MATCHES "Unix Makefiles" OR RunCMake_GENERATOR MATCHES "Ninja") + run_EnvironmentExportCompileCommands() +endif() + 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) @@ -370,6 +388,76 @@ endif() unset(out) unset(outfile) +set(out ${RunCMake_BINARY_DIR}/rm_tests) +file(REMOVE_RECURSE "${out}") +file(MAKE_DIRECTORY ${out}) +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_force_existing + ${CMAKE_COMMAND} -E rm -f ${out}/existing.txt) +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_non_force_existing + ${CMAKE_COMMAND} -E rm ${out}/existing.txt) +run_cmake_command(E_rm_file_force_non_existing + ${CMAKE_COMMAND} -E rm -f ${out}/not_existing.txt) +run_cmake_command(E_rm_file_non_force_non_existing + ${CMAKE_COMMAND} -E rm ${out}/not_existing.txt) + +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_recursive_existing + ${CMAKE_COMMAND} -E rm -r ${out}/existing.txt) +run_cmake_command(E_rm_file_recursive_non_existing + ${CMAKE_COMMAND} -E rm -r ${out}/not_existing.txt) + +file(MAKE_DIRECTORY ${out}/d1 ${out}/d2) +run_cmake_command(E_rm_non_recursive_directory-two-directories + ${CMAKE_COMMAND} -E rm ${out}/d1 ${out}/d2) + +run_cmake_command(E_rm_recursive_directory-two-directories + ${CMAKE_COMMAND} -E rm -R ${out}/d1 ${out}/d2) + +run_cmake_command(E_rm_no_file_specified + ${CMAKE_COMMAND} -E rm -rf) + +run_cmake_command(E_rm_empty_file_specified + ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_rm_empty_file_specified.cmake) + +run_cmake_command(E_rm_bad_argument + ${CMAKE_COMMAND} -E rm -rd ${out}/d1 ${out}/d2) + +file(MAKE_DIRECTORY ${out}/d1 ${out}/d2) +file(WRITE ${out}/test.txt "") +run_cmake_command(E_rm_force_recursive_directory_with_files + ${CMAKE_COMMAND} -E rm -rf ${out}/) + +run_cmake_command(E_rm_force_recursive_non_existing_file + ${CMAKE_COMMAND} -E rm -Rf ${out}/test.txt) + +if(NOT WIN32 AND NOT CYGWIN) + file(MAKE_DIRECTORY ${out}) + file(TOUCH ${out}/existing.txt) + file(MAKE_DIRECTORY ${out}/dir) + file(TOUCH ${out}/dir/existing.txt) # add a file in the folder + file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC) + file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC) + file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC) + run_cmake_command(E_rm_file_link_existing + ${CMAKE_COMMAND} -E rm ${out}/existing_file_link.txt) + run_cmake_command(E_rm_directory_link_existing + ${CMAKE_COMMAND} -E rm ${out}/link_dir) + run_cmake_command(E_rm_file_link_non_existing + ${CMAKE_COMMAND} -E rm ${out}/non_existing_file_link.txt) + + file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC) + file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC) + file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC) + run_cmake_command(E_rm_recursive_file_link_existing + ${CMAKE_COMMAND} -E rm -R ${out}/existing_file_link.txt) + run_cmake_command(E_rm_recursive_directory_link_existing + ${CMAKE_COMMAND} -E rm -r ${out}/link_dir) + run_cmake_command(E_rm_recursive_file_link_non_existing + ${CMAKE_COMMAND} -E rm -r ${out}/non_existing_file_link.txt) +endif() +unset(out) run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env) run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1) @@ -519,6 +607,14 @@ set(RunCMake_TEST_OPTIONS --trace-redirect=/no/such/file.txt) run_cmake(trace-redirect-nofile) unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS --trace --trace-format=json-v1 --trace-redirect=${RunCMake_BINARY_DIR}/json-v1.trace) +run_cmake(trace-json-v1) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS --trace-expand --trace-format=json-v1 --trace-redirect=${RunCMake_BINARY_DIR}/json-v1-expand.trace) +run_cmake(trace-json-v1-expand) +unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS -Wno-deprecated --warn-uninitialized) run_cmake(warn-uninitialized) unset(RunCMake_TEST_OPTIONS) @@ -571,3 +667,32 @@ if(CMAKE_HOST_UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "CYGWIN") run_cmake_command(closed_stderr sh -c "\"${CMAKE_COMMAND}\" --version 2>&-") run_cmake_command(closed_stdall sh -c "\"${CMAKE_COMMAND}\" --version <&- >&- 2>&-") endif() + +function(run_llvm_rc) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/llvm_rc-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake_command(llvm_rc_no_args ${CMAKE_COMMAND} -E cmake_llvm_rc) + run_cmake_command(llvm_rc_no_-- ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test") + run_cmake_command(llvm_rc_empty_preprocessor ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp -- ${CMAKE_COMMAND} -E echo "This is a test") + run_cmake_command(llvm_rc_failing_first_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -P FailedProgram.cmake -- ${CMAKE_COMMAND} -E echo "This is a test") + run_cmake_command(llvm_rc_failing_second_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -P FailedProgram.cmake ) + if(EXISTS ${RunCMake_TEST_BINARY_DIR}/test.tmp) + message(SEND_ERROR "${test} - FAILED:\n" + "test.tmp was not deleted") + endif() + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir") + run_cmake_command(llvm_rc_full_run ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -E copy test.tmp SOURCE_DIR/llvmrc.result ) + if(EXISTS ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/test.tmp) + message(SEND_ERROR "${test} - FAILED:\n" + "test.tmp was not deleted") + endif() + file(READ ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/llvmrc.result LLVMRC_RESULT) + if(NOT "${LLVMRC_RESULT}" STREQUAL "This is a test\n") + message(SEND_ERROR "${test} - FAILED:\n" + "llvmrc.result was not created") + endif() + unset(LLVMRC_RESULT) +endfunction() +run_llvm_rc() diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands-override-check.cmake b/Tests/RunCMake/CommandLine/env-export-compile-commands-override-check.cmake new file mode 100644 index 0000000..032a1ae --- /dev/null +++ b/Tests/RunCMake/CommandLine/env-export-compile-commands-override-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json") + set(RunCMake_TEST_FAILED "compile_commands.json generated with CMAKE_EXPORT_COMPILE_COMMANDS overridden") +endif() diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands-set-check.cmake b/Tests/RunCMake/CommandLine/env-export-compile-commands-set-check.cmake new file mode 100644 index 0000000..a749a55 --- /dev/null +++ b/Tests/RunCMake/CommandLine/env-export-compile-commands-set-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json") + set(RunCMake_TEST_FAILED "compile_commands.json not generated with CMAKE_EXPORT_COMPILE_COMMANDS set") +endif() diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands-unset-check.cmake b/Tests/RunCMake/CommandLine/env-export-compile-commands-unset-check.cmake new file mode 100644 index 0000000..c5878f0 --- /dev/null +++ b/Tests/RunCMake/CommandLine/env-export-compile-commands-unset-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json") + set(RunCMake_TEST_FAILED "compile_commands.json generated with CMAKE_EXPORT_COMPILE_COMMANDS unset") +endif() diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands/CMakeLists.txt b/Tests/RunCMake/CommandLine/env-export-compile-commands/CMakeLists.txt new file mode 100644 index 0000000..aa6fbfd --- /dev/null +++ b/Tests/RunCMake/CommandLine/env-export-compile-commands/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.14) +project(env-export-compile-commands C) + +# Add target with a source file to make sure compile_commands.json gets +# generated. +file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/main.c) +add_executable(env-export-compile-commands ${CMAKE_CURRENT_BINARY_DIR}/main.c) diff --git a/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-stderr.txt new file mode 100644 index 0000000..cb69366 --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-stderr.txt @@ -0,0 +1 @@ +Empty preprocessing command diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-stderr.txt new file mode 100644 index 0000000..765b708 --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-stderr.txt @@ -0,0 +1 @@ +CMake Error diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-stderr.txt new file mode 100644 index 0000000..765b708 --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-stderr.txt @@ -0,0 +1 @@ +CMake Error diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_---result.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_---result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_no_---result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_---stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_---stderr.txt new file mode 100644 index 0000000..9c140b7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_no_---stderr.txt @@ -0,0 +1 @@ +Empty resource compilation command diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_args-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_no_args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_args-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_args-stderr.txt new file mode 100644 index 0000000..d66b547 --- /dev/null +++ b/Tests/RunCMake/CommandLine/llvm_rc_no_args-stderr.txt @@ -0,0 +1 @@ +Invalid cmake_llvm_rc arguments diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake new file mode 100644 index 0000000..66af039 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake @@ -0,0 +1,11 @@ +if(PYTHON_EXECUTABLE) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" "${RunCMake_BINARY_DIR}/json-v1.trace" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE output + ) + if(NOT result EQUAL 0) + set(RunCMake_TEST_FAILED "JSON trace validation failed:\n${output}") + endif() +endif() diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py new file mode 100755 index 0000000..e617b76 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +import json +import os +import sys + +if sys.version_info[0] >= 3: + unicode = str + +trace_file = None +expand = False + +for i in sys.argv[1:]: + if trace_file is None and not i.startswith('-'): + trace_file = i + continue + + if i in ['-e', '--expand']: + expand = True + +assert trace_file is not None +assert os.path.exists(trace_file) + +if expand: + msg_args = ['STATUS', 'fff', 'fff;sss; SPACES !!! ', ' 42 space in string!', ' SPACES !!! '] +else: + msg_args = ['STATUS', 'fff', '${ASDF}', ' ${FOO} ${BAR}', ' SPACES !!! '] + +required_traces = [ + { + 'args': ['STATUS', 'JSON-V1 str', 'spaces'], + 'cmd': 'message', + }, + { + 'args': ['ASDF', 'fff', 'sss', ' SPACES !!! '], + 'cmd': 'set', + }, + { + 'args': ['FOO', '42'], + 'cmd': 'set', + }, + { + 'args': ['BAR', ' space in string!'], + 'cmd': 'set', + }, + { + 'args': msg_args, + 'cmd': 'message', + 'frame': 3 if expand else 2 + }, +] + +with open(trace_file, 'r') as fp: + # Check for version (must be the first document) + vers = json.loads(fp.readline()) + assert sorted(vers.keys()) == ['version'] + assert sorted(vers['version'].keys()) == ['major', 'minor'] + assert vers['version']['major'] == 1 + assert vers['version']['minor'] == 0 + + for i in fp.readlines(): + line = json.loads(i) + assert sorted(line.keys()) == ['args', 'cmd', 'file', 'frame', 'line', 'time'] + assert isinstance(line['args'], list) + assert isinstance(line['cmd'], unicode) + assert isinstance(line['file'], unicode) + assert isinstance(line['frame'], int) + assert isinstance(line['line'], int) + assert isinstance(line['time'], float) + + for j in required_traces: + # Compare the subset of required keys with line + if {k: line[k] for k in j} == j: + required_traces.remove(j) + +assert not required_traces diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake new file mode 100644 index 0000000..7916d2e --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake @@ -0,0 +1,11 @@ +if(PYTHON_EXECUTABLE) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" --expand "${RunCMake_BINARY_DIR}/json-v1-expand.trace" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE output + ) + if(NOT result EQUAL 0) + set(RunCMake_TEST_FAILED "JSON trace validation failed:\n${output}") + endif() +endif() diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-expand.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-expand.cmake new file mode 100644 index 0000000..5c190e6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-json-v1-expand.cmake @@ -0,0 +1 @@ +include(trace-json-v1.cmake) diff --git a/Tests/RunCMake/CommandLine/trace-json-v1.cmake b/Tests/RunCMake/CommandLine/trace-json-v1.cmake new file mode 100644 index 0000000..ed0a0f9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-json-v1.cmake @@ -0,0 +1,5 @@ +message(STATUS "JSON-V1 str" "spaces") +set(ASDF fff sss " SPACES !!! ") +set(FOO 42) +set(BAR " space in string!") +message(STATUS fff ${ASDF} " ${FOO} ${BAR}" " SPACES !!! ") diff --git a/Tests/RunCMake/CompilerLauncher/C-common.cmake b/Tests/RunCMake/CompilerLauncher/C-common.cmake new file mode 100644 index 0000000..96b004b --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-common.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.c) diff --git a/Tests/RunCMake/CompilerLauncher/C-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/C-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/C-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/C-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/C-env.cmake b/Tests/RunCMake/CompilerLauncher/C-env.cmake new file mode 100644 index 0000000..09b5167 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-env.cmake @@ -0,0 +1 @@ +include(C-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/C-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/C-launch-env.cmake new file mode 100644 index 0000000..68abcb5 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/C.cmake b/Tests/RunCMake/CompilerLauncher/C.cmake index 67bf7c4..481e74d 100644 --- a/Tests/RunCMake/CompilerLauncher/C.cmake +++ b/Tests/RunCMake/CompilerLauncher/C.cmake @@ -1,4 +1,2 @@ -enable_language(C) set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.c) +include(C-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake new file mode 100644 index 0000000..6f7fc86 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake @@ -0,0 +1,3 @@ +enable_language(CUDA) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cu) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-env.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-env.cmake new file mode 100644 index 0000000..cefbe9e --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-env.cmake @@ -0,0 +1 @@ +include(CUDA-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-launch-env.cmake new file mode 100644 index 0000000..d0d777a --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CUDA-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA.cmake b/Tests/RunCMake/CompilerLauncher/CUDA.cmake index fe5560b..7f1652b 100644 --- a/Tests/RunCMake/CompilerLauncher/CUDA.cmake +++ b/Tests/RunCMake/CompilerLauncher/CUDA.cmake @@ -1,4 +1,2 @@ -enable_language(CUDA) set(CMAKE_CUDA_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.cu) +include(CUDA-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CXX-common.cmake b/Tests/RunCMake/CompilerLauncher/CXX-common.cmake new file mode 100644 index 0000000..3d2ee00 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-common.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/CompilerLauncher/CXX-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CXX-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CXX-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CXX-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CXX-env.cmake b/Tests/RunCMake/CompilerLauncher/CXX-env.cmake new file mode 100644 index 0000000..db36956 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-env.cmake @@ -0,0 +1 @@ +include(CXX-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CXX-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/CXX-launch-env.cmake new file mode 100644 index 0000000..a65cc89 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CXX.cmake b/Tests/RunCMake/CompilerLauncher/CXX.cmake index cdd3478..1f9a12b 100644 --- a/Tests/RunCMake/CompilerLauncher/CXX.cmake +++ b/Tests/RunCMake/CompilerLauncher/CXX.cmake @@ -1,4 +1,2 @@ -enable_language(CXX) set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.cxx) +include(CXX-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-common.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-common.cmake new file mode 100644 index 0000000..e33c2ca --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-common.cmake @@ -0,0 +1,3 @@ +enable_language(Fortran) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.F) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-env.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-env.cmake new file mode 100644 index 0000000..3dc27c3 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-env.cmake @@ -0,0 +1 @@ +include(Fortran-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-launch-env.cmake new file mode 100644 index 0000000..30a196c --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(Fortran-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran.cmake b/Tests/RunCMake/CompilerLauncher/Fortran.cmake index 72cc03e..dc46173 100644 --- a/Tests/RunCMake/CompilerLauncher/Fortran.cmake +++ b/Tests/RunCMake/CompilerLauncher/Fortran.cmake @@ -1,4 +1,2 @@ -enable_language(Fortran) set(CMAKE_Fortran_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.F) +include(Fortran-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-common.cmake b/Tests/RunCMake/CompilerLauncher/OBJC-common.cmake new file mode 100644 index 0000000..7b565f4 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJC-common.cmake @@ -0,0 +1,3 @@ +enable_language(OBJC) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.m) diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJC-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJC-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJC-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJC-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-env.cmake b/Tests/RunCMake/CompilerLauncher/OBJC-env.cmake new file mode 100644 index 0000000..949e88d --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJC-env.cmake @@ -0,0 +1 @@ +include(OBJC-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/OBJC-launch-env.cmake new file mode 100644 index 0000000..1cf13d3 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJC-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(OBJC-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/OBJC.cmake b/Tests/RunCMake/CompilerLauncher/OBJC.cmake index 55c4493..3374e82 100644 --- a/Tests/RunCMake/CompilerLauncher/OBJC.cmake +++ b/Tests/RunCMake/CompilerLauncher/OBJC.cmake @@ -1,4 +1,2 @@ -enable_language(OBJC) set(CMAKE_OBJC_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.m) +include(OBJC-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-common.cmake b/Tests/RunCMake/CompilerLauncher/OBJCXX-common.cmake new file mode 100644 index 0000000..e2ee4eb --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-common.cmake @@ -0,0 +1,3 @@ +enable_language(OBJCXX) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.mm) diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJCXX-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJCXX-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-env.cmake b/Tests/RunCMake/CompilerLauncher/OBJCXX-env.cmake new file mode 100644 index 0000000..3ed966d --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-env.cmake @@ -0,0 +1 @@ +include(OBJCXX-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/OBJCXX-launch-env.cmake new file mode 100644 index 0000000..04c916a --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(OBJCXX-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX.cmake b/Tests/RunCMake/CompilerLauncher/OBJCXX.cmake index e629603..993ec90 100644 --- a/Tests/RunCMake/CompilerLauncher/OBJCXX.cmake +++ b/Tests/RunCMake/CompilerLauncher/OBJCXX.cmake @@ -1,4 +1,2 @@ -enable_language(OBJCXX) set(CMAKE_OBJCXX_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.mm) +include(OBJCXX-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index 4420260..69fff20 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -9,12 +9,19 @@ function(run_compiler_launcher lang) run_cmake(${lang}) set(RunCMake_TEST_OUTPUT_MERGE 1) - if("${RunCMake_GENERATOR}" STREQUAL "Ninja") + if("${RunCMake_GENERATOR}" MATCHES "Ninja") set(verbose_args -- -v) endif() run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() +function(run_compiler_launcher_env lang) + string(REGEX REPLACE "-.*" "" core_lang "${lang}") + set(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER} "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") + run_compiler_launcher(${lang}) + unset(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER}) +endfunction() + set(langs C CXX) if(CMake_TEST_CUDA) list(APPEND langs CUDA) @@ -28,7 +35,9 @@ endif() foreach(lang ${langs}) run_compiler_launcher(${lang}) + run_compiler_launcher_env(${lang}-env) if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") run_compiler_launcher(${lang}-launch) + run_compiler_launcher_env(${lang}-launch-env) endif() endforeach() diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt new file mode 100644 index 0000000..a5d149d --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_CROSS_CONFIGS + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake new file mode 100644 index 0000000..75d0c47 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake @@ -0,0 +1 @@ +set(CMAKE_CROSS_CONFIGS "") diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt new file mode 100644 index 0000000..8aa3ed3 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_DEFAULT_BUILD_TYPE + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake new file mode 100644 index 0000000..64c7feb --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake @@ -0,0 +1 @@ +set(CMAKE_DEFAULT_BUILD_TYPE "") diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt new file mode 100644 index 0000000..040bf4d --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_DEFAULT_CONFIGS + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake new file mode 100644 index 0000000..5b65172 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake @@ -0,0 +1 @@ +set(CMAKE_DEFAULT_CONFIGS "") diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 76d843c..9fd4499 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -50,3 +50,9 @@ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(RemoveCache) file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") run_cmake(RemoveCache) + +if(NOT RunCMake_GENERATOR MATCHES "^Ninja Multi-Config$") + run_cmake(NoCMAKE_CROSS_CONFIGS) + run_cmake(NoCMAKE_DEFAULT_BUILD_TYPE) + run_cmake(NoCMAKE_DEFAULT_CONFIGS) +endif() diff --git a/Tests/RunCMake/FPHSA/FindNameMismatch.cmake b/Tests/RunCMake/FPHSA/FindNameMismatch.cmake new file mode 100644 index 0000000..540aa67 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatch.cmake @@ -0,0 +1,4 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NAMEMISMATCH REQUIRED_VARS "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchOld.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchOld.cmake new file mode 100644 index 0000000..d155ea7 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchOld.cmake @@ -0,0 +1,4 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NAMEMISMATCH "old signature" "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchSuppressed.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressed.cmake new file mode 100644 index 0000000..042a59a --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressed.cmake @@ -0,0 +1,6 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +set(FPHSA_NAME_MISMATCHED 1) +find_package_handle_standard_args(NAMEMISMATCH "old signature" "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +unset(FPHSA_NAME_MISMATCHED) +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedArg.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedArg.cmake new file mode 100644 index 0000000..6a0e964 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedArg.cmake @@ -0,0 +1,4 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NAMEMISMATCH NAME_MISMATCHED REQUIRED_VARS "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedCompat.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedCompat.cmake new file mode 100644 index 0000000..791cfee --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedCompat.cmake @@ -0,0 +1,6 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +set(FPHSA_NAME_MISMATCHED 1) +find_package_handle_standard_args(NAMEMISMATCH REQUIRED_VARS "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +unset(FPHSA_NAME_MISMATCHED) +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt b/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt new file mode 100644 index 0000000..722b50b --- /dev/null +++ b/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt @@ -0,0 +1,23 @@ +CMake Warning \(dev\) at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + The package name passed to `find_package_handle_standard_args` + \(NAMEMISMATCH\) does not match the name of the calling package + \(NameMismatch\). This can lead to problems in calling code that expects + `find_package` result variables \(e.g., `_FOUND`\) to follow a certain + pattern. +Call Stack \(most recent call first\): + FindNameMismatch.cmake:3 \(find_package_handle_standard_args\) + NameMismatch.cmake:3 \(find_package\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\) at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + The package name passed to `find_package_handle_standard_args` + \(NAMEMISMATCH\) does not match the name of the calling package + \(NameMismatchOld\). This can lead to problems in calling code that expects + `find_package` result variables \(e.g., `_FOUND`\) to follow a certain + pattern. +Call Stack \(most recent call first\): + FindNameMismatchOld.cmake:3 \(find_package_handle_standard_args\) + NameMismatch.cmake:4 \(find_package\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/FPHSA/NameMismatch.cmake b/Tests/RunCMake/FPHSA/NameMismatch.cmake new file mode 100644 index 0000000..9ca3cc6 --- /dev/null +++ b/Tests/RunCMake/FPHSA/NameMismatch.cmake @@ -0,0 +1,7 @@ +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +find_package(NameMismatch REQUIRED) +find_package(NameMismatchOld REQUIRED) +find_package(NameMismatchSuppressed REQUIRED) +find_package(NameMismatchSuppressedCompat REQUIRED) +find_package(NameMismatchSuppressedArg REQUIRED) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index f3e6c3e..286915d 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -1,6 +1,7 @@ include(RunCMake) run_cmake(BadFoundVar) +run_cmake(NameMismatch) # The pseudo module will "find" a package with the given version. Check if the # version selection code in FPHSA works correctly. diff --git a/Tests/RunCMake/FileAPI/RunCMakeTest.cmake b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake index f8adb64..8cdc00c 100644 --- a/Tests/RunCMake/FileAPI/RunCMakeTest.cmake +++ b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake @@ -34,6 +34,10 @@ function(check_python case) endif() endfunction() +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo") +endif() + run_cmake(Nothing) run_cmake(Empty) run_cmake(EmptyClient) diff --git a/Tests/RunCMake/FileAPI/check_index.py b/Tests/RunCMake/FileAPI/check_index.py index cda7234..20243c0 100644 --- a/Tests/RunCMake/FileAPI/check_index.py +++ b/Tests/RunCMake/FileAPI/check_index.py @@ -109,10 +109,11 @@ def check_cmake_generator(g): name = g.get("name", None) assert is_string(name) if name.startswith("Visual Studio"): - assert sorted(g.keys()) == ["name", "platform"] + assert sorted(g.keys()) == ["multiConfig", "name", "platform"] assert is_string(g["platform"]) else: - assert sorted(g.keys()) == ["name"] + assert sorted(g.keys()) == ["multiConfig", "name"] + assert is_bool(g["multiConfig"], matches(name, "^(Visual Studio |Xcode$|Ninja Multi-Config$)")) def check_index_object(indexEntry, kind, major, minor, check): assert is_dict(indexEntry) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 66c559d..de6253f 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -621,12 +621,12 @@ def gen_check_directories(c, g): }, ] - if matches(g, "^Visual Studio "): + if matches(g["name"], "^Visual Studio "): for e in expected: if e["parentSource"] is not None: e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^ZERO_CHECK"), e["targetIds"]) - elif g == "Xcode": + elif g["name"] == "Xcode": if ';' in os.environ.get("CMAKE_OSX_ARCHITECTURES", ""): for e in expected: e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^(link_imported_object_exe)"), e["targetIds"]) @@ -5087,13 +5087,13 @@ def gen_check_targets(c, g, inSource): for s in e["sources"]: s["path"] = s["path"].replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) if e["sourceGroups"] is not None: - for g in e["sourceGroups"]: - g["sourcePaths"] = [p.replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) for p in g["sourcePaths"]] + for group in e["sourceGroups"]: + group["sourcePaths"] = [p.replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) for p in group["sourcePaths"]] if e["compileGroups"] is not None: - for g in e["compileGroups"]: - g["sourcePaths"] = [p.replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) for p in g["sourcePaths"]] + for group in e["compileGroups"]: + group["sourcePaths"] = [p.replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) for p in group["sourcePaths"]] - if matches(g, "^Visual Studio "): + if matches(g["name"], "^Visual Studio "): expected = filter_list(lambda e: e["name"] not in ("ZERO_CHECK") or e["id"] == "^ZERO_CHECK::@6890427a1f51a3e7e1df$", expected) for e in expected: if e["type"] == "UTILITY": @@ -5130,7 +5130,7 @@ def gen_check_targets(c, g, inSource): if matches(d["id"], "^\\^ZERO_CHECK::@"): d["id"] = "^ZERO_CHECK::@6890427a1f51a3e7e1df$" - elif g == "Xcode": + elif g["name"] == "Xcode": if ';' in os.environ.get("CMAKE_OSX_ARCHITECTURES", ""): expected = filter_list(lambda e: e["name"] not in ("link_imported_object_exe"), expected) for e in expected: @@ -5286,12 +5286,12 @@ def gen_check_projects(c, g): }, ] - if matches(g, "^Visual Studio "): + if matches(g["name"], "^Visual Studio "): for e in expected: if e["parentName"] is not None: e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^ZERO_CHECK"), e["targetIds"]) - elif g == "Xcode": + elif g["name"] == "Xcode": if ';' in os.environ.get("CMAKE_OSX_ARCHITECTURES", ""): for e in expected: e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^(link_imported_object_exe)"), e["targetIds"]) @@ -5327,7 +5327,7 @@ def check_object_codemodel(g): inSource = os.path.dirname(o["paths"]["build"]) == o["paths"]["source"] - if matches(g, "^(Visual Studio |Xcode$)"): + if g["multiConfig"]: assert sorted([c["name"] for c in o["configurations"]]) == ["Debug", "MinSizeRel", "RelWithDebInfo", "Release"] else: assert len(o["configurations"]) == 1 @@ -5339,4 +5339,4 @@ def check_object_codemodel(g): assert is_dict(index) assert sorted(index.keys()) == ["cmake", "objects", "reply"] -check_objects(index["objects"], index["cmake"]["generator"]["name"]) +check_objects(index["objects"], index["cmake"]["generator"]) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index 62bb5de..d697fc6 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -99,6 +99,7 @@ file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc Description: Dummy package for FindPkgConfig IMPORTED_TARGET INTERFACE_LINK_OPTIONS test Version: 1.2.3 Libs: -e dummy_main +Cflags: -I/special -isystem /other -isystem/more -DA-isystem/foo ") set(expected_link_options -e dummy_main) @@ -109,7 +110,26 @@ 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" + "Additional link options not present in INTERFACE_LINK_OPTIONS property\n" "expected: \"${expected_link_options}\", but got \"${link_options}\"" ) endif() + +get_target_property(inc_dirs PkgConfig::FakeLinkOptionsPackage INTERFACE_INCLUDE_DIRECTORIES) +set(expected_inc_dirs "/special" "/other" "/more") + +if (NOT inc_dirs STREQUAL expected_inc_dirs) + message(FATAL_ERROR + "Additional include directories not correctly present in INTERFACE_INCLUDE_DIRECTORIES property\n" + "expected: \"${expected_inc_dirs}\", got \"${inc_dirs}\"" + ) +endif () + +get_target_property(c_opts PkgConfig::FakeLinkOptionsPackage INTERFACE_COMPILE_OPTIONS) +set(expected_c_opts "-DA-isystem/foo") # this is an invalid option, but a good testcase +if (NOT c_opts STREQUAL expected_c_opts) + message(FATAL_ERROR + "Additional compile options not present in INTERFACE_COMPILE_OPTIONS property\n" + "expected: \"${expected_c_opts}\", got \"${c_opts}\"" + ) +endif () diff --git a/Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt b/Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt new file mode 100644 index 0000000..36f064c --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/NoSystem-stderr.txt @@ -0,0 +1,8 @@ +^CMake Warning \(dev\) at .*/Modules/GNUInstallDirs.cmake:[0-9]+ \(message\): + Unable to determine default CMAKE_INSTALL_LIBDIR directory because no + target architecture is known. Please enable at least one language before + including GNUInstallDirs. +Call Stack \(most recent call first\): + NoSystem.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/GNUInstallDirs/NoSystem.cmake b/Tests/RunCMake/GNUInstallDirs/NoSystem.cmake new file mode 100644 index 0000000..19cf7be --- /dev/null +++ b/Tests/RunCMake/GNUInstallDirs/NoSystem.cmake @@ -0,0 +1,2 @@ +unset(CMAKE_SYSTEM_NAME) +include(GNUInstallDirs) diff --git a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake index d671ee0..eb2c1a2 100644 --- a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake +++ b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake @@ -16,4 +16,7 @@ foreach(case ) set(RunCMake-stderr-file ${case}${variant}-stderr.txt) run_cmake(${case}) + unset(RunCMake-stderr-file) endforeach() + +run_cmake(NoSystem) diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index ae75561..bb22841 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -30,6 +30,8 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x86") run_cmake(BadToolsetHostArchTwice) if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[56]") + set(RunCMake_GENERATOR_TOOLSET "VCTargetsPath=Test Path") + run_cmake(TestToolsetVCTargetsPathOnly) set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Test Toolset Version") run_cmake(TestToolsetVersionBoth) set(RunCMake_GENERATOR_TOOLSET ",version=Test Toolset Version") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetVCTargetsPathOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetVCTargetsPathOnly-stdout.txt new file mode 100644 index 0000000..c46373f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetVCTargetsPathOnly-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+' +-- CMAKE_VS_PLATFORM_TOOLSET_VCTARGETS_CUSTOM_DIR='Test Path' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetVCTargetsPathOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetVCTargetsPathOnly.cmake new file mode 100644 index 0000000..c20a303 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetVCTargetsPathOnly.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_VCTARGETS_CUSTOM_DIR='${CMAKE_VS_PLATFORM_TOOLSET_VCTARGETS_CUSTOM_DIR}'") diff --git a/Tests/RunCMake/Graphviz/CMakeGraphVizOptions.cmake.in b/Tests/RunCMake/Graphviz/CMakeGraphVizOptions.cmake.in new file mode 100644 index 0000000..8a1c3d0 --- /dev/null +++ b/Tests/RunCMake/Graphviz/CMakeGraphVizOptions.cmake.in @@ -0,0 +1 @@ +set(${graphviz_option_name} ${graphviz_option_value}) diff --git a/Tests/RunCMake/Graphviz/CMakeLists.txt b/Tests/RunCMake/Graphviz/CMakeLists.txt new file mode 100644 index 0000000..d23d4cf --- /dev/null +++ b/Tests/RunCMake/Graphviz/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.15) +project(${RunCMake_TEST} C) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake b/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake new file mode 100644 index 0000000..772f312 --- /dev/null +++ b/Tests/RunCMake/Graphviz/GraphvizTestProject.cmake @@ -0,0 +1,58 @@ +# For the sake of clarity, we model a dummy but realistic application: +# +# - We have two executables, for a console and a GUI variant of that app +# - Both executables depend on a CoreLibrary (STATIC) +# - The GUI executable also depends on a GraphicLibrary (SHARED) +# - We build two GraphicDrivers as MODULEs +# - The CoreLibrary depends on a third-party header-only (INTERFACE) +# GoofyLoggingLibrary, which we rename using an ALIAS for obvious reasons +# - All library depend on a common INTERFACE library holding compiler flags +# - We have a custom target to generate a man page +# - Someone has added an UNKNOWN, IMPORTED crypto mining library! + +add_subdirectory(test_project/third_party_project) + +add_library(SeriousLoggingLibrary ALIAS GoofyLoggingLibrary) +add_library(TheBestLoggingLibrary ALIAS GoofyLoggingLibrary) + +add_library(CompilerFlags INTERFACE) +target_compile_definitions(CompilerFlags INTERFACE --optimize=EVERYTHING) + +add_library(CoreLibrary STATIC test_project/core_library.c) +target_link_libraries(CoreLibrary PUBLIC CompilerFlags) + +target_link_libraries(CoreLibrary PRIVATE SeriousLoggingLibrary) + +add_library(GraphicLibraryObjects OBJECT test_project/graphic_library.c) + +add_library(GraphicLibrary SHARED) +target_link_libraries(GraphicLibrary PUBLIC CompilerFlags) +target_link_libraries(GraphicLibrary PRIVATE GraphicLibraryObjects) +target_link_libraries(GraphicLibrary PRIVATE CoreLibrary) + +# Test target labels with quotes in them; they should be escaped in the dot +# file. +# See https://gitlab.kitware.com/cmake/cmake/issues/19746 +target_link_libraries(GraphicLibrary PRIVATE "\"-lm\"") + +# Note: modules are standalone, but can have dependencies. +add_library(GraphicDriverOpenGL MODULE test_project/module.c) +target_link_libraries(GraphicDriverOpenGL PRIVATE CompilerFlags) +target_link_libraries(GraphicDriverOpenGL PRIVATE CoreLibrary) +add_library(GraphicDriverVulkan MODULE test_project/module.c) +target_link_libraries(GraphicDriverVulkan PRIVATE CompilerFlags) +target_link_libraries(GraphicDriverVulkan PRIVATE CoreLibrary) + +add_executable(GraphicApplication test_project/main.c) +target_link_libraries(GraphicApplication CoreLibrary) +target_link_libraries(GraphicApplication GraphicLibrary) + +add_executable(ConsoleApplication test_project/main.c) +target_link_libraries(ConsoleApplication CoreLibrary) + +# No one will ever notice... +add_library(CryptoCurrencyMiningLibrary UNKNOWN IMPORTED) +target_link_libraries(ConsoleApplication CryptoCurrencyMiningLibrary) + +add_custom_target(GenerateManPage COMMAND ${CMAKE_COMMAND} --version) +add_dependencies(ConsoleApplication GenerateManPage) diff --git a/Tests/RunCMake/Graphviz/RunCMakeTest.cmake b/Tests/RunCMake/Graphviz/RunCMakeTest.cmake new file mode 100644 index 0000000..c0cea10 --- /dev/null +++ b/Tests/RunCMake/Graphviz/RunCMakeTest.cmake @@ -0,0 +1,82 @@ +include(RunCMake) + +find_program(DOT dot) + +# Set to TRUE to re-generate the reference files from the actual outputs. +# Make sure you verify them! +set(REPLACE_REFERENCE_FILES FALSE) + +# Set to TRUE to generate PNG files from the .dot files, using Graphviz (dot). +# Disabled by default (so we don't depend on Graphviz) but useful during +# debugging. +set(GENERATE_PNG_FILES FALSE) + +# 1. Generate the Graphviz (.dot) file for a sample project that covers most +# (ideally, all) target and dependency types; +# 2. Compare that generated file with a reference file. +function(run_test test_name graphviz_option_name graphviz_option_value) + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test_name}) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + # Set ${graphviz_option_name} to ${graphviz_option_value}. + if(graphviz_option_name) + configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeGraphVizOptions.cmake.in + ${RunCMake_TEST_BINARY_DIR}/CMakeGraphVizOptions.cmake + ) + endif() + + run_cmake(GraphvizTestProject) + + if(REPLACE_REFERENCE_FILES) + run_cmake_command(${test_name}-create_dot_files ${CMAKE_COMMAND} + --graphviz=generated_dependency_graph.dot . + ) + + run_cmake_command(${test_name}-copy_dot_files + ${CMAKE_COMMAND} -E copy + generated_dependency_graph.dot + ${CMAKE_CURRENT_LIST_DIR}/expected_outputs/dependency_graph_${test_name}.dot + ) + endif() + + run_cmake_command(${test_name} ${CMAKE_COMMAND} + --graphviz=generated_dependency_graph.dot . + ) + + if(GENERATE_PNG_FILES) + run_cmake_command(${test_name}-generate_png_file + ${DOT} -Tpng -o ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.png + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot + ) + endif() + +endfunction() + +run_test(default_options "" "") + +run_test(set_graph_name GRAPHVIZ_GRAPH_NAME "\"CMake Project Dependencies\"") +run_test(set_graph_header GRAPHVIZ_GRAPH_HEADER + "\"node [\n fontsize = \\\"16\\\"\n];\"") +run_test(set_node_prefix GRAPHVIZ_NODE_PREFIX "point") + +run_test(no_executables GRAPHVIZ_EXECUTABLES FALSE) + +run_test(no_static_libs GRAPHVIZ_STATIC_LIBS FALSE) +run_test(no_shared_libs GRAPHVIZ_SHARED_LIBS FALSE) +run_test(no_module_libs GRAPHVIZ_MODULE_LIBS FALSE) + +run_test(no_interface_libs GRAPHVIZ_INTERFACE_LIBS FALSE) +run_test(no_object_libs GRAPHVIZ_OBJECT_LIBS FALSE) +run_test(no_unknown_libs GRAPHVIZ_UNKNOWN_LIBS FALSE) + +run_test(no_external_libs GRAPHVIZ_EXTERNAL_LIBS FALSE) + +run_test(custom_targets GRAPHVIZ_CUSTOM_TARGETS TRUE) + +run_test(no_graphic_libs GRAPHVIZ_IGNORE_TARGETS "Graphic") + +run_test(no_per_target_files GRAPHVIZ_GENERATE_PER_TARGET FALSE) +run_test(no_dependers_files GRAPHVIZ_GENERATE_DEPENDERS FALSE) diff --git a/Tests/RunCMake/Graphviz/default_options-check.cmake b/Tests/RunCMake/Graphviz/default_options-check.cmake new file mode 100644 index 0000000..c9a7562 --- /dev/null +++ b/Tests/RunCMake/Graphviz/default_options-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_default_options.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot new file mode 100644 index 0000000..8b0365a --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot @@ -0,0 +1,52 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GenerateManPage", shape = box ]; + "node1" -> "node5" // ConsoleApplication -> GenerateManPage + "node6" [ label = "GraphicApplication", shape = egg ]; + "node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node7" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node8" [ label = "\"-lm\"", shape = septagon ]; + "node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm" + "node7" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node9" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot new file mode 100644 index 0000000..1bbf25a --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot @@ -0,0 +1,50 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot new file mode 100644 index 0000000..1bbf25a --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot @@ -0,0 +1,50 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_executables.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_executables.dot new file mode 100644 index 0000000..558a470 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_executables.dot @@ -0,0 +1,44 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "CoreLibrary", shape = octagon ]; + "node1" -> "node0" // CoreLibrary -> CompilerFlags + "node2" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node1" -> "node2" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node3" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node4" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node5" [ label = "\"-lm\"", shape = septagon ]; + "node4" -> "node5" [ style = dotted ] // GraphicLibrary -> "-lm" + "node4" -> "node0" // GraphicLibrary -> CompilerFlags + "node4" -> "node1" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node6" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node4" -> "node6" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node7" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node7" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node7" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node8" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node8" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot new file mode 100644 index 0000000..660af37 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot @@ -0,0 +1,46 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "GraphicApplication", shape = egg ]; + "node4" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node5" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node5" -> "node0" // GraphicLibrary -> CompilerFlags + "node5" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node6" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node5" -> "node6" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node4" -> "node5" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node7" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node7" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node7" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node8" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node8" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot new file mode 100644 index 0000000..5af7fec --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot @@ -0,0 +1,35 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "\"-lm\"", shape = septagon ]; +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot new file mode 100644 index 0000000..94ec41c --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot @@ -0,0 +1,43 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "ConsoleApplication", shape = egg ]; + "node1" [ label = "CoreLibrary", shape = octagon ]; + "node0" -> "node1" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node2" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node0" -> "node2" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node3" [ label = "GraphicApplication", shape = egg ]; + "node3" -> "node1" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node4" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node5" [ label = "\"-lm\"", shape = septagon ]; + "node4" -> "node5" [ style = dotted ] // GraphicLibrary -> "-lm" + "node4" -> "node1" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node6" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node4" -> "node6" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node3" -> "node4" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node7" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node7" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node8" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node8" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot new file mode 100644 index 0000000..65b7a71 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot @@ -0,0 +1,44 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot new file mode 100644 index 0000000..8116bc9 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot @@ -0,0 +1,48 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node8" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot new file mode 100644 index 0000000..1bbf25a --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot @@ -0,0 +1,50 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot new file mode 100644 index 0000000..439d1f7 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot @@ -0,0 +1,44 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "\"-lm\"", shape = septagon ]; + "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node8" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot new file mode 100644 index 0000000..81199a2 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot @@ -0,0 +1,42 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node3" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node3" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node4" [ label = "GraphicApplication", shape = egg ]; + "node5" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node6" [ label = "\"-lm\"", shape = septagon ]; + "node5" -> "node6" [ style = dotted ] // GraphicLibrary -> "-lm" + "node5" -> "node0" // GraphicLibrary -> CompilerFlags + "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node5" -> "node7" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node4" -> "node5" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot new file mode 100644 index 0000000..1be6550 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot @@ -0,0 +1,48 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "GraphicApplication", shape = egg ]; + "node4" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node5" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node6" [ label = "\"-lm\"", shape = septagon ]; + "node5" -> "node6" [ style = dotted ] // GraphicLibrary -> "-lm" + "node5" -> "node0" // GraphicLibrary -> CompilerFlags + "node5" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node7" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node5" -> "node7" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node4" -> "node5" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node8" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node8" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot new file mode 100644 index 0000000..1cfbe0f --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot @@ -0,0 +1,50 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "16" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot new file mode 100644 index 0000000..9653c33 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot @@ -0,0 +1,50 @@ +digraph "CMake Project Dependencies" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "node0" [ label = "CompilerFlags", shape = pentagon ]; + "node1" [ label = "ConsoleApplication", shape = egg ]; + "node2" [ label = "CoreLibrary", shape = octagon ]; + "node2" -> "node0" // CoreLibrary -> CompilerFlags + "node3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "node4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "node1" -> "node4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "node5" [ label = "GraphicApplication", shape = egg ]; + "node5" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "node6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "node7" [ label = "\"-lm\"", shape = septagon ]; + "node6" -> "node7" [ style = dotted ] // GraphicLibrary -> "-lm" + "node6" -> "node0" // GraphicLibrary -> CompilerFlags + "node6" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "node8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "node6" -> "node8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "node5" -> "node6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "node9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "node9" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "node9" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot new file mode 100644 index 0000000..82d96d0 --- /dev/null +++ b/Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot @@ -0,0 +1,50 @@ +digraph "GraphvizTestProject" { +node [ + fontsize = "12" +]; +subgraph clusterLegend { + label = "Legend"; + color = black; + edge [ style = invis ]; + legendNode0 [ label = "Executable", shape = egg ]; + legendNode1 [ label = "Static Library", shape = octagon ]; + legendNode2 [ label = "Shared Library", shape = doubleoctagon ]; + legendNode3 [ label = "Module Library", shape = tripleoctagon ]; + legendNode4 [ label = "Interface Library", shape = pentagon ]; + legendNode5 [ label = "Object Library", shape = hexagon ]; + legendNode6 [ label = "Unknown Library", shape = septagon ]; + legendNode7 [ label = "Custom Target", shape = box ]; + legendNode0 -> legendNode1 [ style = solid ]; + legendNode0 -> legendNode2 [ style = solid ]; + legendNode0 -> legendNode3; + legendNode1 -> legendNode4 [ label = "Interface", style = dashed ]; + legendNode2 -> legendNode5 [ label = "Private", style = dotted ]; + legendNode3 -> legendNode6 [ style = solid ]; + legendNode0 -> legendNode7; +} + "point0" [ label = "CompilerFlags", shape = pentagon ]; + "point1" [ label = "ConsoleApplication", shape = egg ]; + "point2" [ label = "CoreLibrary", shape = octagon ]; + "point2" -> "point0" // CoreLibrary -> CompilerFlags + "point3" [ label = "GoofyLoggingLibrary\n(SeriousLoggingLibrary)\n(TheBestLoggingLibrary)", shape = pentagon ]; + "point2" -> "point3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary + "point1" -> "point2" [ style = dotted ] // ConsoleApplication -> CoreLibrary + "point4" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ]; + "point1" -> "point4" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary + "point5" [ label = "GraphicApplication", shape = egg ]; + "point5" -> "point2" [ style = dotted ] // GraphicApplication -> CoreLibrary + "point6" [ label = "GraphicLibrary", shape = doubleoctagon ]; + "point7" [ label = "\"-lm\"", shape = septagon ]; + "point6" -> "point7" [ style = dotted ] // GraphicLibrary -> "-lm" + "point6" -> "point0" // GraphicLibrary -> CompilerFlags + "point6" -> "point2" [ style = dotted ] // GraphicLibrary -> CoreLibrary + "point8" [ label = "GraphicLibraryObjects", shape = hexagon ]; + "point6" -> "point8" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects + "point5" -> "point6" [ style = dotted ] // GraphicApplication -> GraphicLibrary + "point9" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ]; + "point9" -> "point0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags + "point9" -> "point2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary + "point10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ]; + "point10" -> "point0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags + "point10" -> "point2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary +} diff --git a/Tests/RunCMake/Graphviz/no_dependers_files-check.cmake b/Tests/RunCMake/Graphviz/no_dependers_files-check.cmake new file mode 100644 index 0000000..f4a43b6 --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_dependers_files-check.cmake @@ -0,0 +1,4 @@ +file(GLOB dependers_files ${RunCMake_TEST_BINARY_DIR}/*.dependers) +if(${dependers_files}) + set(RunCMake_TEST_FAILED "Found *.dependers files despite GRAPHVIZ_GENERATE_DEPENDERS set to FALSE.") +endif() diff --git a/Tests/RunCMake/Graphviz/no_executables-check.cmake b/Tests/RunCMake/Graphviz/no_executables-check.cmake new file mode 100644 index 0000000..be29a4f --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_executables-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_executables.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_external_libs-check.cmake b/Tests/RunCMake/Graphviz/no_external_libs-check.cmake new file mode 100644 index 0000000..518ef7b --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_external_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_external_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_graphic_libs-check.cmake b/Tests/RunCMake/Graphviz/no_graphic_libs-check.cmake new file mode 100644 index 0000000..0f5aa47 --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_graphic_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_graphic_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_interface_libs-check.cmake b/Tests/RunCMake/Graphviz/no_interface_libs-check.cmake new file mode 100644 index 0000000..018fef0 --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_interface_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_interface_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_module_libs-check.cmake b/Tests/RunCMake/Graphviz/no_module_libs-check.cmake new file mode 100644 index 0000000..e185cb1 --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_module_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_module_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_object_libs-check.cmake b/Tests/RunCMake/Graphviz/no_object_libs-check.cmake new file mode 100644 index 0000000..90e7ecb --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_object_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_object_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_per_target_files-check.cmake b/Tests/RunCMake/Graphviz/no_per_target_files-check.cmake new file mode 100644 index 0000000..95d05a1 --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_per_target_files-check.cmake @@ -0,0 +1,5 @@ +file(GLOB per_target_files ${RunCMake_TEST_BINARY_DIR}/*.dot.*) +list(FILTER per_target_files EXCLUDE REGEX ".*\\.dependers$") +if(per_target_files) + set(RunCMake_TEST_FAILED "Found per-target .dot files despite GRAPHVIZ_GENERATE_PER_TARGET set to FALSE.") +endif() diff --git a/Tests/RunCMake/Graphviz/no_shared_libs-check.cmake b/Tests/RunCMake/Graphviz/no_shared_libs-check.cmake new file mode 100644 index 0000000..b45da2e --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_shared_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_shared_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_static_libs-check.cmake b/Tests/RunCMake/Graphviz/no_static_libs-check.cmake new file mode 100644 index 0000000..befc11b --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_static_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_static_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/no_unknown_libs-check.cmake b/Tests/RunCMake/Graphviz/no_unknown_libs-check.cmake new file mode 100644 index 0000000..95286bc --- /dev/null +++ b/Tests/RunCMake/Graphviz/no_unknown_libs-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_no_unknown_libs.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/set_graph_header-check.cmake b/Tests/RunCMake/Graphviz/set_graph_header-check.cmake new file mode 100644 index 0000000..1396484 --- /dev/null +++ b/Tests/RunCMake/Graphviz/set_graph_header-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_set_graph_header.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/set_graph_name-check.cmake b/Tests/RunCMake/Graphviz/set_graph_name-check.cmake new file mode 100644 index 0000000..0c522e9 --- /dev/null +++ b/Tests/RunCMake/Graphviz/set_graph_name-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_set_graph_name.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/set_node_prefix-check.cmake b/Tests/RunCMake/Graphviz/set_node_prefix-check.cmake new file mode 100644 index 0000000..61e9b24 --- /dev/null +++ b/Tests/RunCMake/Graphviz/set_node_prefix-check.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +ensure_files_match( + ${RunCMake_TEST_SOURCE_DIR}/expected_outputs/dependency_graph_set_node_prefix.dot + ${RunCMake_TEST_BINARY_DIR}/generated_dependency_graph.dot) diff --git a/Tests/RunCMake/Graphviz/test_project/core_library.c b/Tests/RunCMake/Graphviz/test_project/core_library.c new file mode 100644 index 0000000..e8a8844 --- /dev/null +++ b/Tests/RunCMake/Graphviz/test_project/core_library.c @@ -0,0 +1,3 @@ +void log_something() +{ +} diff --git a/Tests/RunCMake/Graphviz/test_project/graphic_library.c b/Tests/RunCMake/Graphviz/test_project/graphic_library.c new file mode 100644 index 0000000..958c8ab --- /dev/null +++ b/Tests/RunCMake/Graphviz/test_project/graphic_library.c @@ -0,0 +1,3 @@ +void initialize_graphics() +{ +} diff --git a/Tests/RunCMake/Graphviz/test_project/main.c b/Tests/RunCMake/Graphviz/test_project/main.c new file mode 100644 index 0000000..d123e09 --- /dev/null +++ b/Tests/RunCMake/Graphviz/test_project/main.c @@ -0,0 +1,4 @@ +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/RunCMake/Graphviz/test_project/module.c b/Tests/RunCMake/Graphviz/test_project/module.c new file mode 100644 index 0000000..a508b09 --- /dev/null +++ b/Tests/RunCMake/Graphviz/test_project/module.c @@ -0,0 +1,3 @@ +static void some_function() +{ +} diff --git a/Tests/RunCMake/Graphviz/test_project/third_party_project/CMakeLists.txt b/Tests/RunCMake/Graphviz/test_project/third_party_project/CMakeLists.txt new file mode 100644 index 0000000..e381750 --- /dev/null +++ b/Tests/RunCMake/Graphviz/test_project/third_party_project/CMakeLists.txt @@ -0,0 +1,3 @@ +project(ThirdPartyProject) + +add_library(GoofyLoggingLibrary INTERFACE) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/CMakeLists.txt b/Tests/RunCMake/INSTALL_NAME_DIR/CMakeLists.txt new file mode 100644 index 0000000..5253d34 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${CMAKE_CURRENT_LIST_DIR}/INSTALL_NAME_DIR.cmake) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/INSTALL_NAME_DIR.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/INSTALL_NAME_DIR.cmake new file mode 100644 index 0000000..eaa0b45 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/INSTALL_NAME_DIR.cmake @@ -0,0 +1,15 @@ +function(add_install_name_dir_libraries install_name_dir) + add_library(build_dir SHARED test.c) + add_library(install_dir SHARED test.c) + if(NOT install_name_dir STREQUAL "NONE") + set_target_properties(build_dir install_dir PROPERTIES + INSTALL_NAME_DIR "${install_name_dir}" + ) + endif() + set_target_properties(install_dir PROPERTIES + BUILD_WITH_INSTALL_NAME_DIR TRUE + ) + install(TARGETS build_dir install_dir EXPORT InstallNameDirTest DESTINATION lib) + install(EXPORT InstallNameDirTest DESTINATION lib/cmake/InstallNameDirTest FILE InstallNameDirTest-targets.cmake) + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/targets.txt" CONTENT "$<TARGET_FILE:build_dir>\n$<TARGET_FILE:install_dir>\n" CONDITION $<CONFIG:Debug>) +endfunction() diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/RunCMakeTest.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/RunCMakeTest.cmake new file mode 100644 index 0000000..2aa03dd --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/RunCMakeTest.cmake @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.16) + +include(RunCMake) + +function(run_install_test case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE:STRING=Debug "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/fake_install") + 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 . --config Debug) + run_cmake_command(${case}-install ${CMAKE_COMMAND} --install . --config Debug --prefix "${RunCMake_TEST_BINARY_DIR}/real_install") +endfunction() + +find_program(OTOOL_COMMAND otool) + +function(check_install_name_dir file expected) + execute_process(COMMAND ${OTOOL_COMMAND} -l ${file} RESULT_VARIABLE _result OUTPUT_VARIABLE _output) + if(_result) + string(APPEND RunCMake_TEST_FAILED "Could not run otool on ${file}\n") + elseif(_output MATCHES "cmd LC_ID_DYLIB\n[^\n]*\n *name ([^\n]*) \\(offset [0-9]+\\)\n") + set(_install_name "${CMAKE_MATCH_1}") + if(NOT _install_name MATCHES "${expected}") + string(APPEND RunCMake_TEST_FAILED "Install name of ${file} did not match ${expected} (actual: ${_install_name})\n") + endif() + else() + string(APPEND RunCMake_TEST_FAILED "otool did not print install name for ${file}\n") + endif() + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +function(check_imported_soname contents target expected) + if(contents MATCHES "set_target_properties\\(${target} PROPERTIES\n[^\n]*\n *IMPORTED_SONAME_DEBUG \"([^\n]*)\"\n") + set(_soname "${CMAKE_MATCH_1}") + set(_regex "^${expected}lib${target}\\.dylib$") + if(NOT _soname MATCHES "${_regex}") + string(APPEND RunCMake_TEST_FAILED "Target ${target}'s IMPORTED_SONAME_DEBUG did not match ${_regex} (actual: ${_soname})\n") + endif() + else() + string(APPEND RunCMake_TEST_FAILED "Could not find IMPORTED_SONAME_DEBUG for target ${target} in package config file\n") + endif() + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +function(check_libraries fake_install real_install soname_prefix) + file(STRINGS "${RunCMake_TEST_BINARY_DIR}/targets.txt" _targets) + list(GET _targets 0 _build_dir) + list(GET _targets 1 _install_dir) + check_install_name_dir("${_build_dir}" "^@rpath/libbuild_dir\\.dylib$") + check_install_name_dir("${_install_dir}" "^${fake_install}libinstall_dir\\.dylib$") + check_install_name_dir("${RunCMake_TEST_BINARY_DIR}/real_install/lib/libbuild_dir.dylib" "^${real_install}libbuild_dir\\.dylib$") + check_install_name_dir("${RunCMake_TEST_BINARY_DIR}/real_install/lib/libinstall_dir.dylib" "^${real_install}libinstall_dir\\.dylib$") + + file(READ "${RunCMake_TEST_BINARY_DIR}/real_install/lib/cmake/InstallNameDirTest/InstallNameDirTest-targets-debug.cmake" _targets) + check_imported_soname("${_targets}" build_dir "${soname_prefix}") + check_imported_soname("${_targets}" install_dir "${soname_prefix}") + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +run_install_test(none) +run_install_test(empty) +run_install_test(simple) +run_install_test(simple_genex) +run_install_test(prefix_genex) +run_install_test(empty_genex) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/empty-install-check.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/empty-install-check.cmake new file mode 100644 index 0000000..db87d2c --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/empty-install-check.cmake @@ -0,0 +1 @@ +check_libraries("" "" "") diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/empty.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/empty.cmake new file mode 100644 index 0000000..0cde4d1 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/empty.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_install_name_dir_libraries("") diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/empty_genex-install-check.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/empty_genex-install-check.cmake new file mode 100644 index 0000000..db87d2c --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/empty_genex-install-check.cmake @@ -0,0 +1 @@ +check_libraries("" "" "") diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/empty_genex.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/empty_genex.cmake new file mode 100644 index 0000000..321c8d1 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/empty_genex.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_install_name_dir_libraries($<0:/usr/local/lib>) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/none-install-check.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/none-install-check.cmake new file mode 100644 index 0000000..c3e7ac4 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/none-install-check.cmake @@ -0,0 +1 @@ +check_libraries(@rpath/ @rpath/ @rpath/) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/none.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/none.cmake new file mode 100644 index 0000000..79c5e7d --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/none.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_install_name_dir_libraries(NONE) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex-install-check.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex-install-check.cmake new file mode 100644 index 0000000..8cf7db8 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex-install-check.cmake @@ -0,0 +1,6 @@ +check_libraries( + ".*/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex-build/fake_install/lib/" + ".*/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex-build/real_install/lib/" + # "$" has to be escaped twice because of its significance in regexes. + "\\\${_IMPORT_PREFIX}/lib/" + ) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex.cmake new file mode 100644 index 0000000..7e26208 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/prefix_genex.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_install_name_dir_libraries($<1:$<INSTALL_PREFIX>/lib>) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/simple-install-check.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/simple-install-check.cmake new file mode 100644 index 0000000..5f737cb --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/simple-install-check.cmake @@ -0,0 +1 @@ +check_libraries(/usr/local/lib/ /usr/local/lib/ /usr/local/lib/) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/simple.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/simple.cmake new file mode 100644 index 0000000..d019875 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/simple.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_install_name_dir_libraries(/usr/local/lib) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/simple_genex-install-check.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/simple_genex-install-check.cmake new file mode 100644 index 0000000..5f737cb --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/simple_genex-install-check.cmake @@ -0,0 +1 @@ +check_libraries(/usr/local/lib/ /usr/local/lib/ /usr/local/lib/) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/simple_genex.cmake b/Tests/RunCMake/INSTALL_NAME_DIR/simple_genex.cmake new file mode 100644 index 0000000..1e729e8 --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/simple_genex.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_install_name_dir_libraries($<1:/usr/local/lib>) diff --git a/Tests/RunCMake/INSTALL_NAME_DIR/test.c b/Tests/RunCMake/INSTALL_NAME_DIR/test.c new file mode 100644 index 0000000..c2db61c --- /dev/null +++ b/Tests/RunCMake/INSTALL_NAME_DIR/test.c @@ -0,0 +1,3 @@ +void test(void) +{ +} diff --git a/Tests/RunCMake/MacOSVersions/CMakeLists.txt b/Tests/RunCMake/MacOSVersions/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake b/Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake new file mode 100644 index 0000000..c4faa8b --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake @@ -0,0 +1,27 @@ +set(cfg_dir) +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(cfg_dir /Debug) +endif() + +set(lib "${RunCMake_TEST_BINARY_DIR}${cfg_dir}/libfoo.1.0.dylib") +if(NOT EXISTS "${lib}") + set(RunCMake_TEST_FAILED "Library file is missing:\n ${lib}") + return() +endif() + +execute_process(COMMAND otool -l "${lib}" OUTPUT_VARIABLE out ERROR_VARIABLE err RESULT_VARIABLE res) +if(NOT res EQUAL 0) + string(REPLACE "\n" "\n " err " ${err}") + set(RunCMake_TEST_FAILED "Running 'otool -l' on file:\n ${lib}\nfailed:\n${err}") + return() +endif() + +foreach(ver + [[current version 3\.2\.1]] + [[compatibility version 2\.1\.0]] + ) + if(NOT "${out}" MATCHES "( |\n)${ver}( |\n)") + set(RunCMake_TEST_FAILED "Library file:\n ${lib}\ndoes not contain '${ver}'") + return() + endif() +endforeach() diff --git a/Tests/RunCMake/MacOSVersions/MacOSVersions.cmake b/Tests/RunCMake/MacOSVersions/MacOSVersions.cmake new file mode 100644 index 0000000..fc51bd8 --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/MacOSVersions.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +add_library(foo SHARED foo.c) +set_target_properties(foo PROPERTIES + VERSION 1.0 + SOVERSION 1 + MACHO_COMPATIBILITY_VERSION 2.1.0 + MACHO_CURRENT_VERSION 3.2.1 + ) diff --git a/Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake b/Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake new file mode 100644 index 0000000..eb7ca48 --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) + +function(run_MacOSVersions) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MacOSVersions-build) + run_cmake(MacOSVersions) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(MacOSVersions-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() + +run_MacOSVersions() diff --git a/Tests/RunCMake/MacOSVersions/foo.c b/Tests/RunCMake/MacOSVersions/foo.c new file mode 100644 index 0000000..c83d856 --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/foo.c @@ -0,0 +1,4 @@ +int foo(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index 82db6b7..6b2721c 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -26,10 +26,13 @@ function(run_VerboseBuild) endif() run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first) unset(RunCMake-stdout-file) + set(_backup_lang "$ENV{LANG}") if(MAKE_IS_GNU) set(RunCMake-stdout-file VerboseBuild-nowork-gnu-stdout.txt) + set(ENV{LANG} "C") endif() run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose) + set(ENV{LANG} "${_backup_lang}") endfunction() run_VerboseBuild() diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt index 4dddc96..07deee2 100644 --- a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt @@ -1,6 +1,6 @@ [0-9]+ -CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): +CMake Error at .*/variable_watch\.cmake:[0-9]+ \(update_x\): Maximum recursion depth of [0-9]+ exceeded Call Stack \(most recent call first\): .*/variable_watch\.cmake:5 \(set\) - .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:[0-9]+ \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt index a8b4756..b2395b3 100644 --- a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt @@ -1,6 +1,6 @@ [0-9]+ -CMake Error at variable_watch\.cmake:9999 \(update_x\): +CMake Error at variable_watch\.cmake:[0-9]+ \(update_x\): Maximum recursion depth of [0-9]+ exceeded Call Stack \(most recent call first\): variable_watch\.cmake:5 \(set\) - variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:[0-9]+ \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt index 4dddc96..07deee2 100644 --- a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt @@ -1,6 +1,6 @@ [0-9]+ -CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): +CMake Error at .*/variable_watch\.cmake:[0-9]+ \(update_x\): Maximum recursion depth of [0-9]+ exceeded Call Stack \(most recent call first\): .*/variable_watch\.cmake:5 \(set\) - .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:[0-9]+ \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt index a8b4756..b2395b3 100644 --- a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt @@ -1,6 +1,6 @@ [0-9]+ -CMake Error at variable_watch\.cmake:9999 \(update_x\): +CMake Error at variable_watch\.cmake:[0-9]+ \(update_x\): Maximum recursion depth of [0-9]+ exceeded Call Stack \(most recent call first\): variable_watch\.cmake:5 \(set\) - variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:[0-9]+ \(update_x\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt index 00b2b3c..52fedd3 100644 --- a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt @@ -2,17 +2,17 @@ 6 8 10 -CMake Error at .*/variable_watch\.cmake:9999 \(update_x\): +CMake Error at .*/variable_watch\.cmake:[0-9]+ \(update_x\): Maximum recursion depth of 10 exceeded Call Stack \(most recent call first\): .*/variable_watch\.cmake:5 \(set\) - .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:[0-9]+ \(update_x\) .*/variable_watch\.cmake:5 \(set\) - .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:[0-9]+ \(update_x\) .*/variable_watch\.cmake:5 \(set\) - .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:[0-9]+ \(update_x\) .*/variable_watch\.cmake:5 \(set\) - .*/variable_watch\.cmake:9999 \(update_x\) + .*/variable_watch\.cmake:[0-9]+ \(update_x\) .*/variable_watch\.cmake:9 \(set\) .*/CMakeLists\.txt:5 \(include\) diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt index 8f27bf1..1427f1d 100644 --- a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt +++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt @@ -2,17 +2,17 @@ 6 8 10 -CMake Error at variable_watch\.cmake:9999 \(update_x\): +CMake Error at variable_watch\.cmake:[0-9]+ \(update_x\): Maximum recursion depth of 10 exceeded Call Stack \(most recent call first\): variable_watch\.cmake:5 \(set\) - variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:[0-9]+ \(update_x\) variable_watch\.cmake:5 \(set\) - variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:[0-9]+ \(update_x\) variable_watch\.cmake:5 \(set\) - variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:[0-9]+ \(update_x\) variable_watch\.cmake:5 \(set\) - variable_watch\.cmake:9999 \(update_x\) + variable_watch\.cmake:[0-9]+ \(update_x\) variable_watch\.cmake:9 \(set\) CMakeLists\.txt:5 \(include\) diff --git a/Tests/RunCMake/Ninja/ChangeBuildType.cmake b/Tests/RunCMake/Ninja/ChangeBuildType.cmake new file mode 100644 index 0000000..80405a8 --- /dev/null +++ b/Tests/RunCMake/Ninja/ChangeBuildType.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +function(change_build_type_subdir) + set(CMAKE_BUILD_TYPE Release) + add_subdirectory(SubDirPrefix) +endfunction() + +change_build_type_subdir() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +add_executable(hello hello_sub_greeting.c) +target_link_libraries(hello greeting) diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake index 1e36e65..a96802a 100644 --- a/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake +++ b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake @@ -1,3 +1,4 @@ +set_property(GLOBAL PROPERTY JOB_POOLS custom_command_pool=2 custom_target_pool=2) add_custom_command( OUTPUT hello.copy.c COMMAND "${CMAKE_COMMAND}" -E copy diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 808a872..0eada08 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -1,5 +1,8 @@ include(RunCMake) +set(RunCMake_GENERATOR "Ninja") +set(RunCMake_GENERATOR_IS_MULTI_CONFIG 0) + # Detect ninja version so we know what tests can be supported. execute_process( COMMAND "${RunCMake_MAKE_PROGRAM}" --version @@ -304,3 +307,12 @@ function (run_PreventConfigureFileDupBuildRule) run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err) endfunction() run_PreventConfigureFileDupBuildRule() + +function (run_ChangeBuildType) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeBuildType-build) + set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE:STRING=Debug") + run_cmake(ChangeBuildType) + unset(RunCMake_TEST_OPTIONS) + run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err) +endfunction() +run_ChangeBuildType() diff --git a/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-all-clean-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-all-clean-ninja-check.cmake new file mode 100644 index 0000000..012dc2f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-all-clean-ninja-check.cmake @@ -0,0 +1,4 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + # Intentionally empty + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-check.cmake b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-check.cmake new file mode 100644 index 0000000..77412f1 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-check.cmake @@ -0,0 +1,8 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${RunCMake_TEST_BINARY_DIR}/global.txt + ${RunCMake_TEST_BINARY_DIR}/Debug.txt + ${RunCMake_TEST_BINARY_DIR}/Release.txt + ${RunCMake_TEST_BINARY_DIR}/MinSizeRel.txt + ${RunCMake_TEST_BINARY_DIR}/RelWithDebInfo.txt + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-release-clean-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-release-clean-build-check.cmake new file mode 100644 index 0000000..f211223 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles-release-clean-build-check.cmake @@ -0,0 +1,6 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${RunCMake_TEST_BINARY_DIR}/Debug.txt + ${RunCMake_TEST_BINARY_DIR}/MinSizeRel.txt + ${RunCMake_TEST_BINARY_DIR}/RelWithDebInfo.txt + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles.cmake b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles.cmake new file mode 100644 index 0000000..983a494 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/AdditionalCleanFiles.cmake @@ -0,0 +1,3 @@ +file(GENERATE OUTPUT $<CONFIG>.txt CONTENT "$<CONFIG>\n") +file(TOUCH ${CMAKE_BINARY_DIR}/global.txt) +set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "$<CONFIG>.txt;global.txt") diff --git a/Tests/RunCMake/NinjaMultiConfig/AutoMocExecutable.cmake b/Tests/RunCMake/NinjaMultiConfig/AutoMocExecutable.cmake new file mode 100644 index 0000000..950e18e --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/AutoMocExecutable.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +add_executable(badmoc badmoc.c) +target_compile_definitions(badmoc PRIVATE "CONFIG=\"$<CONFIG>\"") + +add_executable(exe main.c) +set_target_properties(exe PROPERTIES + AUTOMOC ON + AUTOMOC_EXECUTABLE $<TARGET_FILE:badmoc> + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CMakeLists.txt b/Tests/RunCMake/NinjaMultiConfig/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/NinjaMultiConfig/Clean-release-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Clean-release-build-check.cmake new file mode 100644 index 0000000..cfe6984 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Clean-release-build-check.cmake @@ -0,0 +1,16 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ${TARGET_SONAME_FILE_mylib_Release} + ${TARGET_OBJECT_FILES_mylib_Release} + + ${TARGET_OBJECT_FILES_myobj_Release} + + ${TARGET_FILE_exeall_Release} + ${TARGET_EXE_FILE_exeall_Release} + ${TARGET_OBJECT_FILES_exeall_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_exenotall_Release} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Clean-release-clean-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Clean-release-clean-build-check.cmake new file mode 100644 index 0000000..06b3fb6 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Clean-release-clean-build-check.cmake @@ -0,0 +1,7 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + EXCLUDE + ${TARGET_OBJECT_FILES_exeall_Release} + ${TARGET_OBJECT_FILES_exenotall_Release} + ${TARGET_OBJECT_FILES_mylib_Release} + ${TARGET_OBJECT_FILES_myobj_Release} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Clean-release-notall-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Clean-release-notall-ninja-check.cmake new file mode 100644 index 0000000..42d6a78 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Clean-release-notall-ninja-check.cmake @@ -0,0 +1,16 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ${TARGET_SONAME_FILE_mylib_Release} + ${TARGET_OBJECT_FILES_mylib_Release} + + ${TARGET_OBJECT_FILES_myobj_Release} + + ${TARGET_FILE_exeall_Release} + ${TARGET_EXE_FILE_exeall_Release} + ${TARGET_OBJECT_FILES_exeall_Release} + + ${TARGET_FILE_exenotall_Release} + ${TARGET_OBJECT_FILES_exenotall_Release} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Clean.cmake b/Tests/RunCMake/NinjaMultiConfig/Clean.cmake new file mode 100644 index 0000000..2258d2b --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Clean.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +add_executable(exeall main.c) +set_target_properties(exeall PROPERTIES VERSION 1.0.0) +add_executable(exenotall main.c) +set_target_properties(exenotall PROPERTIES EXCLUDE_FROM_ALL TRUE) + +add_library(mylib SHARED simplelib.c) +set_target_properties(mylib PROPERTIES + VERSION 1.0.0 + SOVERSION 1 + ) + +add_library(myobj OBJECT simplelib.c) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(exeall exenotall mylib myobj) diff --git a/Tests/RunCMake/NinjaMultiConfig/Common.cmake b/Tests/RunCMake/NinjaMultiConfig/Common.cmake new file mode 100644 index 0000000..6c0d82a --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Common.cmake @@ -0,0 +1,62 @@ +function(generate_output_files) + set(content) + foreach(tgt IN LISTS ARGN) + get_property(type TARGET ${tgt} PROPERTY TYPE) + + if(NOT type STREQUAL "OBJECT_LIBRARY") + set(file " [==[$<TARGET_FILE:${tgt}>]==]") + set(filename " [==[$<TARGET_FILE_NAME:${tgt}>]==]") + else() + set(file) + set(filename) + endif() + string(APPEND content "set(TARGET_FILE_${tgt}_$<CONFIG>${file})\n") + string(APPEND content "set(TARGET_FILE_NAME_${tgt}_$<CONFIG>${filename})\n") + + if(type MATCHES "^(STATIC|MODULE|SHARED)_LIBRARY$") + set(linker_file " [==[$<TARGET_LINKER_FILE:${tgt}>]==]") + set(linker_filename " [==[$<TARGET_LINKER_FILE_NAME:${tgt}>]==]") + else() + set(linker_file) + set(linker_filename) + endif() + string(APPEND content "set(TARGET_LINKER_FILE_${tgt}_$<CONFIG>${linker_file})\n") + string(APPEND content "set(TARGET_LINKER_FILE_NAME_${tgt}_$<CONFIG>${linker_filename})\n") + + if(NOT WIN32 AND NOT CYGWIN AND type MATCHES "^(SHARED_LIBRARY)$") + set(soname_file " [==[$<TARGET_SONAME_FILE:${tgt}>]==]") + set(soname_filename " [==[$<TARGET_SONAME_FILE_NAME:${tgt}>]==]") + else() + set(soname_file) + set(soname_filename) + endif() + string(APPEND content "set(TARGET_SONAME_FILE_${tgt}_$<CONFIG>${soname_file})\n") + string(APPEND content "set(TARGET_SONAME_FILE_NAME_${tgt}_$<CONFIG>${soname_filename})\n") + + if(type MATCHES "^(EXECUTABLE)$") + set(exe_file " [==[$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>$<TARGET_FILE_SUFFIX:${tgt}>]==]") + set(exe_filename " [==[$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>$<TARGET_FILE_SUFFIX:${tgt}>]==]") + + if(WIN32) + set(exe_lib_file " [==[$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>.lib]==]") + string(APPEND content "set(TARGET_EXE_LIB_FILE_${tgt}_$<CONFIG>${exe_lib_file})\n") + endif() + else() + set(exe_file) + set(exe_filename) + endif() + string(APPEND content "set(TARGET_EXE_FILE_${tgt}_$<CONFIG>${exe_file})\n") + string(APPEND content "set(TARGET_EXE_FILE_NAME_${tgt}_$<CONFIG>${exe_filename})\n") + + string(APPEND content "set(TARGET_OBJECT_FILES_${tgt}_$<CONFIG> [==[$<TARGET_OBJECTS:${tgt}>]==])\n") + endforeach() + + file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/target_files_$<CONFIG>.cmake" CONTENT "${content}") + + set(content) + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) + string(APPEND content "include(\${CMAKE_CURRENT_LIST_DIR}/target_files_${config}.cmake)\n") + endforeach() + + file(WRITE "${CMAKE_BINARY_DIR}/target_files.cmake" "${content}") +endfunction() diff --git a/Tests/RunCMake/NinjaMultiConfig/CudaSimple-all-clean-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CudaSimple-all-clean-build-check.cmake new file mode 100644 index 0000000..45f684b --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CudaSimple-all-clean-build-check.cmake @@ -0,0 +1,21 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplecudaexe_Debug} + ${TARGET_OBJECT_FILES_simplecudashared_Debug} + ${TARGET_OBJECT_FILES_simplecudaobj_Debug} + + ${TARGET_OBJECT_FILES_simplecudaexe_Release} + ${TARGET_OBJECT_FILES_simplecudashared_Release} + ${TARGET_OBJECT_FILES_simplecudaobj_Release} + + ${TARGET_OBJECT_FILES_simplecudaexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simplecudashared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplecudaobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplecudaexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplecudashared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplecudaobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CudaSimple-debug-target-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CudaSimple-debug-target-build-check.cmake new file mode 100644 index 0000000..39db5ff --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CudaSimple-debug-target-build-check.cmake @@ -0,0 +1,28 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simplecudaexe_Debug} + ${TARGET_EXE_LIB_FILE_simplecudaexe_Debug} + ${TARGET_OBJECT_FILES_simplecudaexe_Debug} + + ${TARGET_FILE_simplecudashared_Debug} + ${TARGET_LINKER_FILE_simplecudashared_Debug} + ${TARGET_OBJECT_FILES_simplecudashared_Debug} + + ${TARGET_OBJECT_FILES_simplecudaobj_Debug} + + EXCLUDE + + ${TARGET_OBJECT_FILES_simplecudaexe_Release} + ${TARGET_OBJECT_FILES_simplecudashared_Release} + ${TARGET_OBJECT_FILES_simplecudaobj_Release} + + ${TARGET_OBJECT_FILES_simplecudaexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simplecudashared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplecudaobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplecudaexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplecudashared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplecudaobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake new file mode 100644 index 0000000..2e9b1cb --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake @@ -0,0 +1,21 @@ +enable_language(CUDA) +file(TOUCH ${CMAKE_BINARY_DIR}/empty.cmake) + +add_library(simplecudaobj OBJECT simplelib.cu) +set_target_properties(simplecudaobj + PROPERTIES + POSITION_INDEPENDENT_CODE ON) + +add_library(simplecudashared SHARED ) +target_link_libraries(simplecudashared PRIVATE simplecudaobj) +set_target_properties(simplecudaobj simplecudashared + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) + +add_executable(simplecudaexe main.cu ) +target_link_libraries(simplecudaexe PRIVATE simplecudashared) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(simplecudaexe simplecudashared simplecudaobj) + +file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(GENERATED_FILES [==[${CMAKE_BINARY_DIR}/empty.cmake]==])\n") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake new file mode 100644 index 0000000..c595b10 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake @@ -0,0 +1,5 @@ +set(log "${RunCMake_BINARY_DIR}/CustomCommandDepfile-build/CMakeFiles/impl-Debug.ninja") +file(READ "${log}" build_file) +if(NOT "${build_file}" MATCHES "depfile = test\\.d") + set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: depfile = test.d") +endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake new file mode 100644 index 0000000..1a42670 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake @@ -0,0 +1,9 @@ +add_custom_command( + OUTPUT main.copy.c + COMMAND "${CMAKE_COMMAND}" -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/main.c" + main.copy.c + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + DEPFILE "test.d" + ) +add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/main.copy.c") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-build-check.cmake new file mode 100644 index 0000000..2abdb43 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-build-check.cmake @@ -0,0 +1,38 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${CONFIG_FILES} + ${GENERATED_FILES} + + ${TARGET_FILE_generator_Debug} + ${TARGET_OBJECT_FILES_generator_Debug} + + ${TARGET_FILE_generated_Debug} + ${TARGET_OBJECT_FILES_generated_Debug} + + ${TARGET_FILE_generatorlib_Debug} + ${TARGET_LINKER_FILE_generatorlib_Debug} + ${TARGET_OBJECT_FILES_generatorlib_Debug} + + ${TARGET_OBJECT_FILES_generatorobj_Debug} + + ${TARGET_OBJECT_FILES_emptyobj_Debug} + + EXCLUDE + ${TARGET_OBJECT_FILES_generator_Release} + ${TARGET_OBJECT_FILES_generated_Release} + ${TARGET_OBJECT_FILES_generatorlib_Release} + ${TARGET_OBJECT_FILES_generatorobj_Release} + ${TARGET_OBJECT_FILES_emptyobj_Release} + + ${TARGET_OBJECT_FILES_generator_MinSizeRel} + ${TARGET_OBJECT_FILES_generated_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorlib_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorobj_MinSizeRel} + ${TARGET_OBJECT_FILES_emptyobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_generator_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generated_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorlib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorobj_RelWithDebInfo} + ${TARGET_OBJECT_FILES_emptyobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-clean-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-clean-ninja-check.cmake new file mode 100644 index 0000000..aff42c3 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-clean-ninja-check.cmake @@ -0,0 +1,37 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${CONFIG_FILES} + + ${TARGET_FILE_generator_Release} + ${TARGET_OBJECT_FILES_generator_Release} + + ${TARGET_FILE_generated_Release} + ${TARGET_OBJECT_FILES_generated_Release} + + ${TARGET_FILE_generatorlib_Release} + ${TARGET_LINKER_FILE_generatorlib_Release} + ${TARGET_OBJECT_FILES_generatorlib_Release} + + ${TARGET_OBJECT_FILES_generatorobj_Release} + + ${TARGET_OBJECT_FILES_emptyobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_generator_Debug} + ${TARGET_OBJECT_FILES_generated_Debug} + ${TARGET_OBJECT_FILES_generatorlib_Debug} + ${TARGET_OBJECT_FILES_generatorobj_Debug} + ${TARGET_OBJECT_FILES_emptyobj_Debug} + + ${TARGET_OBJECT_FILES_generator_MinSizeRel} + ${TARGET_OBJECT_FILES_generated_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorlib_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorobj_MinSizeRel} + ${TARGET_OBJECT_FILES_emptyobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_generator_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generated_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorlib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorobj_RelWithDebInfo} + ${TARGET_OBJECT_FILES_emptyobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-generated-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-generated-stdout.txt new file mode 100644 index 0000000..765d486 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-generated-stdout.txt @@ -0,0 +1,12 @@ +^Generator genex config definition: Debug +Generator genex config include dir: Debug +Generator library genex config definition: Debug +Generator library genex config include dir: Debug +Generator object genex config definition: Debug +Generator object genex config include dir: Debug +Generated genex config definition: Debug +Generated genex config include dir: Debug +Generated library genex config definition: Debug +Generated library genex config include dir: Debug +Generated object genex config definition: Debug +Generated object genex config include dir: Debug$ diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-build-check.cmake new file mode 100644 index 0000000..167f5b9 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-build-check.cmake @@ -0,0 +1,43 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${CONFIG_FILES} + ${GENERATED_FILES} + + ${TARGET_FILE_generated_Debug} + ${TARGET_OBJECT_FILES_generated_Debug} + + ${TARGET_FILE_generatorlib_Debug} + ${TARGET_LINKER_FILE_generatorlib_Debug} + ${TARGET_OBJECT_FILES_generatorlib_Debug} + + ${TARGET_OBJECT_FILES_generatorobj_Debug} + + ${TARGET_OBJECT_FILES_emptyobj_Debug} + + ${TARGET_FILE_generator_Release} + ${TARGET_OBJECT_FILES_generator_Release} + + ${TARGET_FILE_generatorlib_Release} + ${TARGET_LINKER_FILE_generatorlib_Release} + ${TARGET_OBJECT_FILES_generatorlib_Release} + + ${TARGET_OBJECT_FILES_generatorobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_generator_Debug} + + ${TARGET_OBJECT_FILES_generated_Release} + ${TARGET_OBJECT_FILES_emptyobj_Release} + + ${TARGET_OBJECT_FILES_generator_MinSizeRel} + ${TARGET_OBJECT_FILES_generated_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorlib_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorobj_MinSizeRel} + ${TARGET_OBJECT_FILES_emptyobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_generator_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generated_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorlib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorobj_RelWithDebInfo} + ${TARGET_OBJECT_FILES_emptyobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-clean-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-clean-ninja-check.cmake new file mode 100644 index 0000000..1e4cbe1 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-clean-ninja-check.cmake @@ -0,0 +1,35 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${CONFIG_FILES} + + ${TARGET_FILE_generator_Release} + ${TARGET_OBJECT_FILES_generator_Release} + + ${TARGET_FILE_generatorlib_Release} + ${TARGET_LINKER_FILE_generatorlib_Release} + ${TARGET_OBJECT_FILES_generatorlib_Release} + + ${TARGET_OBJECT_FILES_generatorobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_generator_Debug} + ${TARGET_OBJECT_FILES_generated_Debug} + ${TARGET_OBJECT_FILES_generatorlib_Debug} + ${TARGET_OBJECT_FILES_generatorobj_Debug} + ${TARGET_OBJECT_FILES_emptyobj_Debug} + + ${TARGET_OBJECT_FILES_generated_Release} + ${TARGET_OBJECT_FILES_emptyobj_Release} + + ${TARGET_OBJECT_FILES_generator_MinSizeRel} + ${TARGET_OBJECT_FILES_generated_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorlib_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorobj_MinSizeRel} + ${TARGET_OBJECT_FILES_emptyobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_generator_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generated_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorlib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorobj_RelWithDebInfo} + ${TARGET_OBJECT_FILES_emptyobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-generated-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-generated-stdout.txt new file mode 100644 index 0000000..1c9abef --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-debug-in-release-graph-generated-stdout.txt @@ -0,0 +1,12 @@ +^Generator genex config definition: Release +Generator genex config include dir: Release +Generator library genex config definition: Release +Generator library genex config include dir: Release +Generator object genex config definition: Release +Generator object genex config include dir: Release +Generated genex config definition: Debug +Generated genex config include dir: Debug +Generated library genex config definition: Debug +Generated library genex config include dir: Debug +Generated object genex config definition: Debug +Generated object genex config include dir: Debug$ diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-clean-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-clean-build-check.cmake new file mode 100644 index 0000000..8ba6d68 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-clean-build-check.cmake @@ -0,0 +1,29 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${CONFIG_FILES} + + EXCLUDE + ${TARGET_OBJECT_FILES_generator_Debug} + ${TARGET_OBJECT_FILES_generated_Debug} + ${TARGET_OBJECT_FILES_generatorlib_Debug} + ${TARGET_OBJECT_FILES_generatorobj_Debug} + ${TARGET_OBJECT_FILES_emptyobj_Debug} + + ${TARGET_OBJECT_FILES_generator_Release} + ${TARGET_OBJECT_FILES_generated_Release} + ${TARGET_OBJECT_FILES_generatorlib_Release} + ${TARGET_OBJECT_FILES_generatorobj_Release} + ${TARGET_OBJECT_FILES_emptyobj_Release} + + ${TARGET_OBJECT_FILES_generator_MinSizeRel} + ${TARGET_OBJECT_FILES_generated_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorlib_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorobj_MinSizeRel} + ${TARGET_OBJECT_FILES_emptyobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_generator_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generated_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorlib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorobj_RelWithDebInfo} + ${TARGET_OBJECT_FILES_emptyobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-generated-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-generated-stdout.txt new file mode 100644 index 0000000..576ec51 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-generated-stdout.txt @@ -0,0 +1,12 @@ +^Generator genex config definition: Release +Generator genex config include dir: Release +Generator library genex config definition: Release +Generator library genex config include dir: Release +Generator object genex config definition: Release +Generator object genex config include dir: Release +Generated genex config definition: Release +Generated genex config include dir: Release +Generated library genex config definition: Release +Generated library genex config include dir: Release +Generated object genex config definition: Release +Generated object genex config include dir: Release$ diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-in-debug-graph-generated-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-in-debug-graph-generated-stdout.txt new file mode 100644 index 0000000..25392af --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-in-debug-graph-generated-stdout.txt @@ -0,0 +1,12 @@ +^Generator genex config definition: Debug +Generator genex config include dir: Debug +Generator library genex config definition: Debug +Generator library genex config include dir: Debug +Generator object genex config definition: Debug +Generator object genex config include dir: Debug +Generated genex config definition: Release +Generated genex config include dir: Release +Generated library genex config definition: Release +Generated library genex config include dir: Release +Generated object genex config definition: Release +Generated object genex config include dir: Release$ diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-in-debug-graph-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-in-debug-graph-ninja-check.cmake new file mode 100644 index 0000000..faf392e --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-in-debug-graph-ninja-check.cmake @@ -0,0 +1,44 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${CONFIG_FILES} + ${GENERATED_FILES} + + ${TARGET_FILE_generator_Debug} + ${TARGET_OBJECT_FILES_generator_Debug} + + ${TARGET_FILE_generatorlib_Debug} + ${TARGET_LINKER_FILE_generatorlib_Debug} + ${TARGET_OBJECT_FILES_generatorlib_Debug} + + ${TARGET_OBJECT_FILES_generatorobj_Debug} + + ${TARGET_FILE_generator_Release} + ${TARGET_OBJECT_FILES_generator_Release} + + ${TARGET_FILE_generated_Release} + ${TARGET_OBJECT_FILES_generated_Release} + + ${TARGET_FILE_generatorlib_Release} + ${TARGET_LINKER_FILE_generatorlib_Release} + ${TARGET_OBJECT_FILES_generatorlib_Release} + + ${TARGET_OBJECT_FILES_generatorobj_Release} + + ${TARGET_OBJECT_FILES_emptyobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_generated_Debug} + ${TARGET_OBJECT_FILES_emptyobj_Debug} + + ${TARGET_OBJECT_FILES_generator_MinSizeRel} + ${TARGET_OBJECT_FILES_generated_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorlib_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorobj_MinSizeRel} + ${TARGET_OBJECT_FILES_emptyobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_generator_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generated_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorlib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorobj_RelWithDebInfo} + ${TARGET_OBJECT_FILES_emptyobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-ninja-check.cmake new file mode 100644 index 0000000..b51a6a7 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator-release-ninja-check.cmake @@ -0,0 +1,46 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${CONFIG_FILES} + ${GENERATED_FILES} + + ${TARGET_FILE_generator_Debug} + ${TARGET_OBJECT_FILES_generator_Debug} + + ${TARGET_FILE_generated_Debug} + ${TARGET_OBJECT_FILES_generated_Debug} + + ${TARGET_FILE_generatorlib_Debug} + ${TARGET_LINKER_FILE_generatorlib_Debug} + ${TARGET_OBJECT_FILES_generatorlib_Debug} + + ${TARGET_OBJECT_FILES_generatorobj_Debug} + + ${TARGET_OBJECT_FILES_emptyobj_Debug} + + ${TARGET_FILE_generator_Release} + ${TARGET_OBJECT_FILES_generator_Release} + + ${TARGET_FILE_generated_Release} + ${TARGET_OBJECT_FILES_generated_Release} + + ${TARGET_FILE_generatorlib_Release} + ${TARGET_LINKER_FILE_generatorlib_Release} + ${TARGET_OBJECT_FILES_generatorlib_Release} + + ${TARGET_OBJECT_FILES_generatorobj_Release} + + ${TARGET_OBJECT_FILES_emptyobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_generator_MinSizeRel} + ${TARGET_OBJECT_FILES_generated_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorlib_MinSizeRel} + ${TARGET_OBJECT_FILES_generatorobj_MinSizeRel} + ${TARGET_OBJECT_FILES_emptyobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_generator_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generated_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorlib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_generatorobj_RelWithDebInfo} + ${TARGET_OBJECT_FILES_emptyobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator.cmake new file mode 100644 index 0000000..f4aca5e --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandGenerator.cmake @@ -0,0 +1,56 @@ +enable_language(C) + +add_library(generatorlib STATIC generatorlib.c) +add_library(generatorobj OBJECT generatorobj.c) +add_library(emptyobj OBJECT empty.c) +add_library(emptyobj2 OBJECT empty.c) + +add_executable(generator generator.c $<TARGET_OBJECTS:generatorobj>) +target_link_libraries(generator PRIVATE generatorlib) + +add_custom_command(OUTPUT generated.c COMMAND generator generated.c) +add_executable(generated ${CMAKE_BINARY_DIR}/generated.c $<TARGET_OBJECTS:generatorobj> $<TARGET_OBJECTS:emptyobj>) +target_link_libraries(generated PRIVATE generatorlib) + +file(GENERATE OUTPUT include/genex/$<CONFIG>/genex_config.h CONTENT +"#ifndef GENEX_CONFIG_H +#define GENEX_CONFIG_H + +#define GENEX_CONFIG_INCLUDE_DIR \"$<CONFIG>\" + +#endif /* GENEX_CONFIG_H */ +") +file(GENERATE OUTPUT include/intdir/$<CONFIG>/intdir_config.h CONTENT +"#ifndef INTDIR_CONFIG_H +#define INTDIR_CONFIG_H + +#define INTDIR_CONFIG_INCLUDE_DIR \"$<CONFIG>\" + +#endif /* INTDIR_CONFIG_H */ +") + +foreach(g generatorlib generatorobj generator generated) + target_compile_definitions(${g} PRIVATE + "GENEX_CONFIG_DEFINITION=\"$<CONFIG>\"" + # FIXME Get this working + # "INTDIR_CONFIG_DEFINITION=\"${CMAKE_CFG_INTDIR}\"" + ) + target_include_directories(${g} PRIVATE + "${CMAKE_BINARY_DIR}/include/genex/$<CONFIG>" + # FIXME Get this working + # "${CMAKE_BINARY_DIR}/include/intdir/${CMAKE_CFG_INTDIR}" + ) +endforeach() + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(generatorlib generatorobj emptyobj generator generated) + +file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(GENERATED_FILES [==[${CMAKE_BINARY_DIR}/generated.c]==])\n") +set(genfiles) +foreach(cfg Debug Release MinSizeRel RelWithDebInfo) + list(APPEND genfiles + ${CMAKE_BINARY_DIR}/include/genex/${cfg}/genex_config.h + ${CMAKE_BINARY_DIR}/include/intdir/${cfg}/intdir_config.h + ) +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(CONFIG_FILES [==[${genfiles}]==])\n") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-command-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-command-ninja-check.cmake new file mode 100644 index 0000000..f5c4020 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-command-ninja-check.cmake @@ -0,0 +1,6 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ${TARGET_DEPENDS_TopCommand} + ) +check_file_contents("${TARGET_DEPENDS_TopCommand}" "^Genex config: Debug\nINTDIR config: Debug\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-in-release-graph-postbuild-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-in-release-graph-postbuild-build-check.cmake new file mode 100644 index 0000000..05861b2 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-in-release-graph-postbuild-build-check.cmake @@ -0,0 +1,8 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ${TARGET_DEPENDS_TopCommand} + ${TARGET_BYPRODUCTS_SubdirTarget} + ${TARGET_BYPRODUCTS_TopTarget} + ${TARGET_FILE_SubdirPostBuild_Debug} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-target-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-target-build-check.cmake new file mode 100644 index 0000000..52895b2 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-target-build-check.cmake @@ -0,0 +1,8 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ${TARGET_DEPENDS_TopCommand} + ${TARGET_BYPRODUCTS_SubdirTarget} + ${TARGET_BYPRODUCTS_TopTarget} + ) +check_file_contents("${TARGET_BYPRODUCTS_TopTarget}" "^Genex config: Debug\nINTDIR config: Debug\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-targetpostbuild-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-targetpostbuild-build-check.cmake new file mode 100644 index 0000000..80439ea --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-debug-targetpostbuild-build-check.cmake @@ -0,0 +1,12 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ${TARGET_DEPENDS_TopCommand} + ${TARGET_BYPRODUCTS_SubdirTarget} + ${TARGET_BYPRODUCTS_TopTarget} + ${TARGET_FILE_SubdirPostBuild_Debug} + ${TARGET_FILE_SubdirPostBuild_Release} + ${TARGET_BYPRODUCTS_SubdirPostBuild} + ${TARGET_BYPRODUCTS_TopTargetPostBuild} + ) +check_file_contents("${TARGET_BYPRODUCTS_TopTargetPostBuild}" "^Genex config: Debug\nINTDIR config: Debug\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-minsizerel-command-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-minsizerel-command-ninja-check.cmake new file mode 100644 index 0000000..2813f02 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-minsizerel-command-ninja-check.cmake @@ -0,0 +1,5 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ) +check_file_contents("${TARGET_DEPENDS_SubdirCommand}" "^Genex config: MinSizeRel\nINTDIR config: MinSizeRel\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-command-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-command-build-check.cmake new file mode 100644 index 0000000..2da9735 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-command-build-check.cmake @@ -0,0 +1,5 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ) +check_file_contents("${TARGET_DEPENDS_SubdirCommand}" "^Genex config: Release\nINTDIR config: Release\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-postbuild-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-postbuild-ninja-check.cmake new file mode 100644 index 0000000..0916b90 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-postbuild-ninja-check.cmake @@ -0,0 +1,11 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ${TARGET_DEPENDS_TopCommand} + ${TARGET_BYPRODUCTS_SubdirTarget} + ${TARGET_BYPRODUCTS_TopTarget} + ${TARGET_FILE_SubdirPostBuild_Debug} + ${TARGET_FILE_SubdirPostBuild_Release} + ${TARGET_BYPRODUCTS_SubdirPostBuild} + ) +check_file_contents("${TARGET_BYPRODUCTS_SubdirPostBuild}" "^Genex config: Release\nINTDIR config: Release\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-target-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-target-ninja-check.cmake new file mode 100644 index 0000000..87e78b4 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-target-ninja-check.cmake @@ -0,0 +1,7 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ${TARGET_DEPENDS_TopCommand} + ${TARGET_BYPRODUCTS_SubdirTarget} + ) +check_file_contents("${TARGET_BYPRODUCTS_SubdirTarget}" "^Genex config: Release\nINTDIR config: Release\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-targetpostbuild-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-targetpostbuild-ninja-check.cmake new file mode 100644 index 0000000..f67d5be --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-targetpostbuild-ninja-check.cmake @@ -0,0 +1,13 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_DEPENDS_SubdirCommand} + ${TARGET_DEPENDS_TopCommand} + ${TARGET_BYPRODUCTS_SubdirTarget} + ${TARGET_BYPRODUCTS_TopTarget} + ${TARGET_FILE_SubdirPostBuild_Debug} + ${TARGET_FILE_SubdirPostBuild_Release} + ${TARGET_BYPRODUCTS_SubdirPostBuild} + ${TARGET_BYPRODUCTS_TopTargetPostBuild} + ${TARGET_BYPRODUCTS_SubdirTargetPostBuild} + ) +check_file_contents("${TARGET_BYPRODUCTS_SubdirTargetPostBuild}" "^Genex config: Release\nINTDIR config: Release\n$") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake new file mode 100644 index 0000000..b2b24e8 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake @@ -0,0 +1,39 @@ +enable_language(C) + +file(REMOVE "${CMAKE_BINARY_DIR}/target_files_custom.cmake") + +function(get_write_file_command var filename) + set(${var} ${CMAKE_COMMAND} -DOUTPUT_FILE=${filename} -DGENEX_CONFIG=$<CONFIG> -DINTDIR_CONFIG=${CMAKE_CFG_INTDIR} -P ${CMAKE_SOURCE_DIR}/WriteFile.cmake PARENT_SCOPE) +endfunction() + +function(create_targets prefix) + get_write_file_command(cmd ${prefix}Command.txt) + add_custom_command(OUTPUT ${prefix}Command.txt COMMAND ${cmd}) + add_custom_target(${prefix}Command DEPENDS ${prefix}Command.txt) + + get_write_file_command(cmd ${prefix}Target.txt) + add_custom_target(${prefix}Target COMMAND ${cmd} BYPRODUCTS ${prefix}Target.txt) + + get_write_file_command(cmd ${prefix}PostBuild.txt) + add_executable(${prefix}PostBuild ${CMAKE_SOURCE_DIR}/main.c) + add_custom_command(TARGET ${prefix}PostBuild COMMAND ${cmd} BYPRODUCTS ${prefix}PostBuild.txt) + + get_write_file_command(cmd ${prefix}TargetPostBuild.txt) + add_custom_target(${prefix}TargetPostBuild) + add_custom_command(TARGET ${prefix}TargetPostBuild COMMAND ${cmd} BYPRODUCTS ${prefix}TargetPostBuild.txt) + + file(APPEND "${CMAKE_BINARY_DIR}/target_files_custom.cmake" +"set(TARGET_DEPENDS_${prefix}Command [==[${CMAKE_CURRENT_BINARY_DIR}/${prefix}Command.txt]==]) +set(TARGET_BYPRODUCTS_${prefix}Target [==[${CMAKE_CURRENT_BINARY_DIR}/${prefix}Target.txt]==]) +set(TARGET_BYPRODUCTS_${prefix}PostBuild [==[${CMAKE_CURRENT_BINARY_DIR}/${prefix}PostBuild.txt]==]) +set(TARGET_BYPRODUCTS_${prefix}TargetPostBuild [==[${CMAKE_CURRENT_BINARY_DIR}/${prefix}TargetPostBuild.txt]==]) +") +endfunction() + +add_subdirectory(CustomCommandsAndTargetsSubdir) + +create_targets(Top) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(TopPostBuild SubdirPostBuild) +file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "include(\${CMAKE_CURRENT_LIST_DIR}/target_files_custom.cmake)\n") diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargetsSubdir/CMakeLists.txt b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargetsSubdir/CMakeLists.txt new file mode 100644 index 0000000..894e3ed --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargetsSubdir/CMakeLists.txt @@ -0,0 +1 @@ +create_targets(Subdir) diff --git a/Tests/RunCMake/NinjaMultiConfig/DefaultBuildFileConfig.cmake b/Tests/RunCMake/NinjaMultiConfig/DefaultBuildFileConfig.cmake new file mode 100644 index 0000000..bb7b160 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/DefaultBuildFileConfig.cmake @@ -0,0 +1 @@ +# Intentionally empty diff --git a/Tests/RunCMake/NinjaMultiConfig/Framework.cmake b/Tests/RunCMake/NinjaMultiConfig/Framework.cmake new file mode 100644 index 0000000..b4c35f6 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Framework.cmake @@ -0,0 +1,22 @@ +enable_language(C) + +set(header "${CMAKE_CURRENT_BINARY_DIR}/header.h") +file(GENERATE + OUTPUT "${header}" + CONTENT "/* foo */" + CONDITION "$<CONFIG:Release>" + ) +add_library(framework SHARED "${header}" empty.c) + +set_property(TARGET framework PROPERTY FRAMEWORK ON) +set_property(TARGET framework APPEND PROPERTY PUBLIC_HEADER ${header}) + +set_target_properties(framework PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "lib" + LIBRARY_OUTPUT_DIRECTORY_DEBUG "lib" + LIBRARY_OUTPUT_DIRECTORY_RELEASE "lib" + DEBUG_POSTFIX "_debug" + ) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(framework) diff --git a/Tests/RunCMake/NinjaMultiConfig/FrameworkDependencyAutogen.cmake b/Tests/RunCMake/NinjaMultiConfig/FrameworkDependencyAutogen.cmake new file mode 100644 index 0000000..75e21b9 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/FrameworkDependencyAutogen.cmake @@ -0,0 +1,20 @@ +enable_language(C) + +set(CMAKE_LINK_DEPENDS_NO_SHARED ON) + +set(QT_VERSION_MAJOR 6) +set(fake_moc_path "${CMAKE_CURRENT_BINARY_DIR}/fake_moc") +file(WRITE "${fake_moc_path}" "") + +add_library(test1 SHARED simplelib.c) +add_library(test2 SHARED empty.c) +target_link_libraries(test2 test1) + +set_target_properties(test1 test2 PROPERTIES + FRAMEWORK ON + AUTOMOC ON + AUTOMOC_EXECUTABLE "${fake_moc_path}" + ) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(test1 test2) diff --git a/Tests/RunCMake/NinjaMultiConfig/Install-all-install-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Install-all-install-ninja-check.cmake new file mode 100644 index 0000000..c588aac --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Install-all-install-ninja-check.cmake @@ -0,0 +1,39 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_exe_Debug} + ${TARGET_OBJECT_FILES_exe_Debug} + + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Debug} + ${TARGET_OBJECT_FILES_mylib_Debug} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/Debug/${TARGET_FILE_NAME_exe_Debug} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_FILE_NAME_mylib_Debug} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_LINKER_FILE_NAME_mylib_Debug} + + ${TARGET_FILE_exe_Release} + ${TARGET_OBJECT_FILES_exe_Release} + + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ${TARGET_OBJECT_FILES_mylib_Release} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/Release/${TARGET_FILE_NAME_exe_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_FILE_NAME_mylib_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_LINKER_FILE_NAME_mylib_Release} + + ${TARGET_FILE_exe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_exe_RelWithDebInfo} + + ${TARGET_FILE_mylib_RelWithDebInfo} + ${TARGET_LINKER_FILE_mylib_RelWithDebInfo} + ${TARGET_OBJECT_FILES_mylib_RelWithDebInfo} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/RelWithDebInfo/${TARGET_FILE_NAME_exe_RelWithDebInfo} + ${RunCMake_TEST_BINARY_DIR}/install/lib/RelWithDebInfo/${TARGET_FILE_NAME_mylib_RelWithDebInfo} + ${RunCMake_TEST_BINARY_DIR}/install/lib/RelWithDebInfo/${TARGET_LINKER_FILE_NAME_mylib_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_exe_MinSizeRel} + ${TARGET_OBJECT_FILES_mylib_MinSizeRel} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Install-debug-in-release-graph-install-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Install-debug-in-release-graph-install-ninja-check.cmake new file mode 100644 index 0000000..bc15a25 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Install-debug-in-release-graph-install-ninja-check.cmake @@ -0,0 +1,31 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_exe_Debug} + ${TARGET_OBJECT_FILES_exe_Debug} + + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Debug} + ${TARGET_OBJECT_FILES_mylib_Debug} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/Debug/${TARGET_FILE_NAME_exe_Debug} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_FILE_NAME_mylib_Debug} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_LINKER_FILE_NAME_mylib_Debug} + + ${TARGET_FILE_exe_Release} + ${TARGET_OBJECT_FILES_exe_Release} + + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ${TARGET_OBJECT_FILES_mylib_Release} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/Release/${TARGET_FILE_NAME_exe_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_FILE_NAME_mylib_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_LINKER_FILE_NAME_mylib_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_exe_MinSizeRel} + ${TARGET_OBJECT_FILES_mylib_MinSizeRel} + + ${TARGET_OBJECT_FILES_exe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_mylib_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Install-default-install-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Install-default-install-ninja-check.cmake new file mode 100644 index 0000000..bc15a25 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Install-default-install-ninja-check.cmake @@ -0,0 +1,31 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_exe_Debug} + ${TARGET_OBJECT_FILES_exe_Debug} + + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Debug} + ${TARGET_OBJECT_FILES_mylib_Debug} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/Debug/${TARGET_FILE_NAME_exe_Debug} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_FILE_NAME_mylib_Debug} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_LINKER_FILE_NAME_mylib_Debug} + + ${TARGET_FILE_exe_Release} + ${TARGET_OBJECT_FILES_exe_Release} + + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ${TARGET_OBJECT_FILES_mylib_Release} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/Release/${TARGET_FILE_NAME_exe_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_FILE_NAME_mylib_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_LINKER_FILE_NAME_mylib_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_exe_MinSizeRel} + ${TARGET_OBJECT_FILES_mylib_MinSizeRel} + + ${TARGET_OBJECT_FILES_exe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_mylib_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Install-release-install-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Install-release-install-build-check.cmake new file mode 100644 index 0000000..3280c89 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Install-release-install-build-check.cmake @@ -0,0 +1,23 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_exe_Release} + ${TARGET_OBJECT_FILES_exe_Release} + + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ${TARGET_OBJECT_FILES_mylib_Release} + + ${RunCMake_TEST_BINARY_DIR}/install/bin/Release/${TARGET_FILE_NAME_exe_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_FILE_NAME_mylib_Release} + ${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_LINKER_FILE_NAME_mylib_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_exe_Debug} + ${TARGET_OBJECT_FILES_mylib_Debug} + + ${TARGET_OBJECT_FILES_exe_MinSizeRel} + ${TARGET_OBJECT_FILES_mylib_MinSizeRel} + + ${TARGET_OBJECT_FILES_exe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_mylib_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Install.cmake b/Tests/RunCMake/NinjaMultiConfig/Install.cmake new file mode 100644 index 0000000..e26e3e0 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Install.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +add_executable(exe main.c) +add_library(mylib STATIC simplelib.c) + +install(TARGETS exe DESTINATION bin/$<CONFIG>) +install(TARGETS mylib DESTINATION lib/$<CONFIG>) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(exe mylib) diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-result.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt new file mode 100644 index 0000000..76c5ecf --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error: + CMAKE_CROSS_CONFIGS is not a subset of CMAKE_CONFIGURATION_TYPES + + +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs.cmake b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs.cmake diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-result.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt new file mode 100644 index 0000000..5aa9038 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error: + The configuration specified by CMAKE_DEFAULT_BUILD_TYPE \(RelWithDebInfo\) is + not present in CMAKE_CONFIGURATION_TYPES + + +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig.cmake b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig.cmake diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-result.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt new file mode 100644 index 0000000..6c2df86 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error: + CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS + + +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross.cmake b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross.cmake diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-result.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt new file mode 100644 index 0000000..5d090a0 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error: + CMAKE_DEFAULT_CONFIGS cannot be used without CMAKE_DEFAULT_BUILD_TYPE or + CMAKE_CROSS_CONFIGS + + +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross.cmake b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross.cmake diff --git a/Tests/RunCMake/NinjaMultiConfig/NoUnusedVariables.cmake b/Tests/RunCMake/NinjaMultiConfig/NoUnusedVariables.cmake new file mode 100644 index 0000000..bb7b160 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/NoUnusedVariables.cmake @@ -0,0 +1 @@ +# Intentionally empty diff --git a/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation-debug-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation-debug-in-release-graph-build-check.cmake new file mode 100644 index 0000000..3657b5b --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation-debug-in-release-graph-build-check.cmake @@ -0,0 +1,7 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ${TARGET_FILE_mylib_Debug} + ${TARGET_LINKER_FILE_mylib_Debug} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation-release-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation-release-in-release-graph-build-check.cmake new file mode 100644 index 0000000..3345ee8 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation-release-in-release-graph-build-check.cmake @@ -0,0 +1,5 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${TARGET_FILE_mylib_Release} + ${TARGET_LINKER_FILE_mylib_Release} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation.cmake b/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation.cmake new file mode 100644 index 0000000..abef3c8 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/PostfixAndLocation.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +set(CMAKE_DEBUG_POSTFIX "_debug") + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/lib) + +add_library(mylib SHARED simplelib.c) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(mylib) diff --git a/Tests/RunCMake/NinjaMultiConfig/Qt5-debug-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Qt5-debug-in-release-graph-build-check.cmake new file mode 100644 index 0000000..2d8df13 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Qt5-debug-in-release-graph-build-check.cmake @@ -0,0 +1,7 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${AUTOGEN_FILES} + + ${TARGET_FILE_exe_Debug} + ${TARGET_OBJECT_FILES_exe_Debug} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake b/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake new file mode 100644 index 0000000..3a1c7f5 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake @@ -0,0 +1,30 @@ +enable_language(CXX) + +find_package(Qt5Core REQUIRED) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOMOC_COMPILER_PREDEFINES OFF) + +add_executable(exe qt5.cxx) +target_link_libraries(exe PRIVATE Qt5::Core) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(exe) + +set(moc_writes_depfiles 0) +if(Qt5Core_VERSION VERSION_GREATER_EQUAL "5.15.0") + set(moc_writes_depfiles 1) +endif() + +set(autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation.cpp") +if(moc_writes_depfiles) + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/deps") + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/timestamp") +endif() +foreach(c IN LISTS CMAKE_CONFIGURATION_TYPES) + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp") + if(moc_writes_depfiles) + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp.d") + endif() +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(AUTOGEN_FILES [==[${autogen_files}]==])\n") diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake new file mode 100644 index 0000000..d4a08a9 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -0,0 +1,307 @@ +cmake_minimum_required(VERSION 3.16) + +include(RunCMake) + +set(RunCMake_GENERATOR "Ninja Multi-Config") +set(RunCMake_GENERATOR_IS_MULTI_CONFIG 1) + +function(check_files dir) + cmake_parse_arguments(_check_files "" "" "INCLUDE;EXCLUDE" ${ARGN}) + + set(expected ${_check_files_INCLUDE}) + list(FILTER expected EXCLUDE REGEX "^$") + list(REMOVE_DUPLICATES expected) + list(SORT expected) + + file(GLOB_RECURSE actual "${dir}/*") + list(FILTER actual EXCLUDE REGEX "/CMakeFiles/|\\.ninja$|/CMakeCache\\.txt$|/target_files[^/]*\\.cmake$|/\\.ninja_[^/]*$|/cmake_install\\.cmake$|\\.ilk$|\\.manifest$|\\.pdb$|\\.exp$|/install_manifest\\.txt$") + foreach(f IN LISTS _check_files_INCLUDE _check_files_EXCLUDE) + if(EXISTS ${f}) + list(APPEND actual ${f}) + endif() + endforeach() + list(REMOVE_DUPLICATES actual) + list(SORT actual) + + if(NOT "${expected}" STREQUAL "${actual}") + string(REPLACE ";" "\n " expected_formatted "${expected}") + string(REPLACE ";" "\n " actual_formatted "${actual}") + string(APPEND RunCMake_TEST_FAILED "Actual files did not match expected\nExpected:\n ${expected_formatted}\nActual:\n ${actual_formatted}\n") + endif() + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +function(check_file_contents filename expected) + if(NOT EXISTS "${filename}") + string(APPEND RunCMake_TEST_FAILED "File ${filename} does not exist\n") + else() + file(READ "${filename}" actual) + if(NOT actual MATCHES "${expected}") + string(REPLACE "\n" "\n " expected_formatted "${expected}") + string(REPLACE "\n" "\n " actual_formatted "${actual}") + string(APPEND RunCMake_TEST_FAILED "Contents of ${filename} do not match expected\nExpected:\n ${expected_formatted}\nActual:\n ${actual_formatted}\n") + endif() + endif() + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction() + +function(run_cmake_configure case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${case}) +endfunction() + +function(run_cmake_build case suffix config) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(tgts) + foreach(tgt IN LISTS ARGN) + list(APPEND tgts --target ${tgt}) + endforeach() + if(config) + set(config_arg --config ${config}) + else() + set(config_arg) + endif() + run_cmake_command(${case}-${suffix}-build "${CMAKE_COMMAND}" --build . ${config_arg} ${tgts}) +endfunction() + +function(run_ninja case suffix file) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${case}-${suffix}-ninja "${RunCMake_MAKE_PROGRAM}" -f "${file}" ${ARGN}) +endfunction() + +############################################################################### + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Simple-build) +# IMPORTANT: Setting RelWithDebInfo as the first item in CMAKE_CONFIGURATION_TYPES +# generates a build.ninja file with that configuration +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo\\;Debug\\;Release\\;MinSizeRel;-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(Simple) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(Simple debug-target Debug simpleexe) +run_ninja(Simple debug-target build-Debug.ninja simplestatic) +get_filename_component(simpleshared_Release "${TARGET_FILE_simpleshared_Release}" NAME) +run_cmake_build(Simple release-filename Release ${simpleshared_Release}) +file(RELATIVE_PATH simpleexe_Release "${RunCMake_TEST_BINARY_DIR}" "${TARGET_FILE_simpleexe_Release}") +run_ninja(Simple release-file build-Release.ninja ${simpleexe_Release}) +run_cmake_build(Simple all-configs Release simplestatic:all) +run_ninja(Simple default-build-file build.ninja simpleexe) +run_cmake_build(Simple all-clean Release clean:all) +run_cmake_build(Simple debug-subdir Debug SimpleSubdir/all) +run_ninja(Simple release-in-minsizerel-graph-subdir build-MinSizeRel.ninja SimpleSubdir/all:Release) +run_cmake_build(Simple all-subdir Release SimpleSubdir/all:all) +run_ninja(Simple minsizerel-top build-MinSizeRel.ninja all) +run_cmake_build(Simple debug-in-release-graph-top Release all:Debug) +run_ninja(Simple all-clean-again build-Debug.ninja clean:all) +run_ninja(Simple all-top build-RelWithDebInfo.ninja all:all) +# Leave enough time for the timestamp to change on second-resolution systems +execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) +file(TOUCH "${RunCMake_TEST_BINARY_DIR}/empty.cmake") +run_ninja(Simple reconfigure-config build-Release.ninja simpleexe) +execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) +file(TOUCH "${RunCMake_TEST_BINARY_DIR}/empty.cmake") +run_ninja(Simple reconfigure-noconfig build.ninja simpleexe) +run_ninja(Simple default-build-file-clean build.ninja clean) +run_ninja(Simple default-build-file-clean-minsizerel build.ninja clean:MinSizeRel) +run_ninja(Simple default-build-file-all build.ninja all) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAlias-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=all;-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(SimpleDefaultBuildAlias) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_ninja(SimpleDefaultBuildAlias target build.ninja simpleexe) +run_ninja(SimpleDefaultBuildAlias all build.ninja all) +run_ninja(SimpleDefaultBuildAlias clean build.ninja clean) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAliasList-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(SimpleDefaultBuildAliasList) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_ninja(SimpleDefaultBuildAliasList target-configs build.ninja simpleexe) +# IMPORTANT: This tests cmake --build . with no config using build.ninja +run_cmake_build(SimpleDefaultBuildAliasList all-configs "" all) +run_ninja(SimpleDefaultBuildAliasList all-relwithdebinfo build.ninja all:RelWithDebInfo) +run_ninja(SimpleDefaultBuildAliasList clean-configs build.ninja clean) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAliasListCross-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo;-DCMAKE_DEFAULT_CONFIGS=all;-DCMAKE_CROSS_CONFIGS=Debug\\;Release") +run_cmake_configure(SimpleDefaultBuildAliasListCross) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_ninja(SimpleDefaultBuildAliasListCross target-configs build.ninja simpleexe) + +unset(RunCMake_TEST_BINARY_DIR) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=Debug\\;Release\\;RelWithDebInfo") +run_cmake(InvalidCrossConfigs) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo") +run_cmake(InvalidDefaultBuildFileConfig) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release\\;RelWithDebInfo") +run_cmake(InvalidDefaultConfigsCross) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=all") +run_cmake(InvalidDefaultConfigsNoCross) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release") +run_cmake(DefaultBuildFileConfig) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleNoCross-build) +run_cmake_configure(SimpleNoCross) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(SimpleNoCross debug-target Debug simpleexe) +run_ninja(SimpleNoCross debug-target build-Debug.ninja simplestatic:Debug) +run_ninja(SimpleNoCross relwithdebinfo-in-release-graph-target build-Release.ninja simplestatic:RelWithDebInfo) +run_cmake_build(SimpleNoCross relwithdebinfo-in-release-graph-all Release all:RelWithDebInfo) +run_cmake_build(SimpleNoCross relwithdebinfo-in-release-graph-clean Release clean:RelWithDebInfo) +run_ninja(SimpleNoCross all-target build-Debug.ninja simplestatic:all) +run_ninja(SimpleNoCross all-all build-Debug.ninja all:all) +run_cmake_build(SimpleNoCross all-clean Debug clean:all) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleCrossConfigs-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release") +run_cmake_configure(SimpleCrossConfigs) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_ninja(SimpleCrossConfigs release-in-release-graph build-Release.ninja simpleexe) +run_cmake_build(SimpleCrossConfigs debug-in-release-graph Release simpleexe:Debug) +run_cmake_build(SimpleCrossConfigs relwithdebinfo-in-release-graph Release simpleexe:RelWithDebInfo) +run_ninja(SimpleCrossConfigs relwithdebinfo-in-relwithdebinfo-graph build-RelWithDebInfo.ninja simpleexe:RelWithDebInfo) +run_ninja(SimpleCrossConfigs release-in-relwithdebinfo-graph build-RelWithDebInfo.ninja simplestatic:Release) +run_cmake_build(SimpleCrossConfigs all-in-relwithdebinfo-graph RelWithDebInfo simplestatic:all) +run_ninja(SimpleCrossConfigs clean-all-in-release-graph build-Release.ninja clean:all) +run_cmake_build(SimpleCrossConfigs all-all-in-release-graph Release all:all) +run_cmake_build(SimpleCrossConfigs all-relwithdebinfo-in-release-graph Release all:RelWithDebInfo) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Framework-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(Framework) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(Framework framework Debug all) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/FrameworkDependencyAutogen-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(FrameworkDependencyAutogen) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(FrameworkDependencyAutogen framework Release test2:Debug) + +set(RunCMake_TEST_NO_CLEAN 1) +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandGenerator-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(CustomCommandGenerator) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(CustomCommandGenerator debug Debug generated) +run_cmake_command(CustomCommandGenerator-debug-generated "${TARGET_FILE_generated_Debug}") +run_ninja(CustomCommandGenerator release build-Release.ninja generated) +run_cmake_command(CustomCommandGenerator-release-generated "${TARGET_FILE_generated_Release}") +run_ninja(CustomCommandGenerator debug-clean build-Debug.ninja clean) +run_cmake_build(CustomCommandGenerator release-clean Release clean) +run_cmake_build(CustomCommandGenerator debug-in-release-graph Release generated:Debug) +run_cmake_command(CustomCommandGenerator-debug-in-release-graph-generated "${TARGET_FILE_generated_Debug}") +run_ninja(CustomCommandGenerator debug-in-release-graph-clean build-Debug.ninja clean:Debug) +run_ninja(CustomCommandGenerator release-in-debug-graph build-Debug.ninja generated:Release) +run_cmake_command(CustomCommandGenerator-release-in-debug-graph-generated "${TARGET_FILE_generated_Release}") +unset(RunCMake_TEST_NO_CLEAN) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandsAndTargets-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(CustomCommandsAndTargets) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(CustomCommandsAndTargets release-command Release SubdirCommand) +#FIXME Get this working +#run_ninja(CustomCommandsAndTargets minsizerel-command build-MinSizeRel.ninja CustomCommandsAndTargetsSubdir/SubdirCommand) +run_ninja(CustomCommandsAndTargets debug-command build-Debug.ninja TopCommand) +run_ninja(CustomCommandsAndTargets release-target build-Release.ninja SubdirTarget) +run_cmake_build(CustomCommandsAndTargets debug-target Debug TopTarget) +run_cmake_build(CustomCommandsAndTargets debug-in-release-graph-postbuild Release SubdirPostBuild:Debug) +run_ninja(CustomCommandsAndTargets release-postbuild build-Release.ninja SubdirPostBuild) +run_cmake_build(CustomCommandsAndTargets debug-targetpostbuild Debug TopTargetPostBuild) +run_ninja(CustomCommandsAndTargets release-targetpostbuild build-Release.ninja SubdirTargetPostBuild) + +unset(RunCMake_TEST_BINARY_DIR) + +run_cmake(CustomCommandDepfile) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PostfixAndLocation-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(PostfixAndLocation) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(PostfixAndLocation release-in-release-graph Release mylib:Release) +run_cmake_build(PostfixAndLocation debug-in-release-graph Release mylib:Debug) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Clean-build) +run_cmake_configure(Clean) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(Clean release Release) +run_ninja(Clean release-notall build-Release.ninja exenotall) +run_cmake_build(Clean release-clean Release clean) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AdditionalCleanFiles-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all") +run_cmake_configure(AdditionalCleanFiles) +unset(RunCMake_TEST_OPTIONS) +run_cmake_build(AdditionalCleanFiles release-clean Release clean) +run_ninja(AdditionalCleanFiles all-clean build-Debug.ninja clean:all) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Install-build) +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_CROSS_CONFIGS=all;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release") +run_cmake_configure(Install) +unset(RunCMake_TEST_OPTIONS) +include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_cmake_build(Install release-install Release install) +run_ninja(Install debug-in-release-graph-install build-Release.ninja install:Debug) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/install") +run_ninja(Install default-install build.ninja install) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/install") +run_ninja(Install all-install build.ninja install:all) + +# FIXME Get this working +#set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutoMocExecutable-build) +#run_cmake_configure(AutoMocExecutable) +#run_cmake_build(AutoMocExecutable debug-in-release-graph Release exe) + +# Need to test this manually because run_cmake() adds --no-warn-unused-cli +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoUnusedVariables-build) +run_cmake_command(NoUnusedVariables ${CMAKE_COMMAND} ${CMAKE_CURRENT_LIST_DIR} + -G "Ninja Multi-Config" + "-DRunCMake_TEST=NoUnusedVariables" + "-DCMAKE_CROSS_CONFIGS=all" + "-DCMAKE_DEFAULT_BUILD_TYPE=Debug" + "-DCMAKE_DEFAULT_CONFIGS=all" + ) + +if(CMake_TEST_CUDA) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CudaSimple-build) + run_cmake_configure(CudaSimple) + include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) + run_cmake_build(CudaSimple debug-target Debug simplecudaexe) + run_ninja(CudaSimple all-clean build-Debug.ninja clean:Debug) +endif() + +if(CMake_TEST_Qt5) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5-build) + set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") + run_cmake_configure(Qt5) + unset(RunCMake_TEST_OPTIONS) + include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) + run_cmake_build(Qt5 debug-in-release-graph Release exe:Debug) +endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-all-clean-again-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-all-clean-again-ninja-check.cmake new file mode 100644 index 0000000..0f919df --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-all-clean-again-ninja-check.cmake @@ -0,0 +1,25 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-all-clean-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-all-clean-build-check.cmake new file mode 100644 index 0000000..0f919df --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-all-clean-build-check.cmake @@ -0,0 +1,25 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-all-configs-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-all-configs-build-check.cmake new file mode 100644 index 0000000..170a0e8 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-all-configs-build-check.cmake @@ -0,0 +1,47 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_LINKER_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simplestatic_MinSizeRel} + ${TARGET_LINKER_FILE_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_FILE_simplestatic_RelWithDebInfo} + ${TARGET_LINKER_FILE_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-all-subdir-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-all-subdir-build-check.cmake new file mode 100644 index 0000000..de4505c --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-all-subdir-build-check.cmake @@ -0,0 +1,49 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + + ${TARGET_FILE_simpleshared_MinSizeRel} + ${TARGET_LINKER_FILE_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-all-top-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-all-top-ninja-check.cmake new file mode 100644 index 0000000..c171e3d --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-all-top-ninja-check.cmake @@ -0,0 +1,56 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_LINKER_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + + ${TARGET_FILE_simpleshared_MinSizeRel} + ${TARGET_LINKER_FILE_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + + ${TARGET_FILE_simplestatic_MinSizeRel} + ${TARGET_LINKER_FILE_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_FILE_simplestatic_RelWithDebInfo} + ${TARGET_LINKER_FILE_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-debug-in-release-graph-top-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-in-release-graph-top-build-check.cmake new file mode 100644 index 0000000..fe980fe --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-in-release-graph-top-build-check.cmake @@ -0,0 +1,53 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + + ${TARGET_FILE_simpleshared_MinSizeRel} + ${TARGET_LINKER_FILE_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + + ${TARGET_FILE_simplestatic_MinSizeRel} + ${TARGET_LINKER_FILE_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-debug-subdir-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-subdir-build-check.cmake new file mode 100644 index 0000000..6bb7773 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-subdir-build-check.cmake @@ -0,0 +1,31 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-debug-target-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-target-build-check.cmake new file mode 100644 index 0000000..6bb7773 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-target-build-check.cmake @@ -0,0 +1,31 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-debug-target-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-target-ninja-check.cmake new file mode 100644 index 0000000..f9c1e92 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-debug-target-ninja-check.cmake @@ -0,0 +1,33 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-all-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-all-ninja-check.cmake new file mode 100644 index 0000000..4e6e654 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-all-ninja-check.cmake @@ -0,0 +1,49 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_LINKER_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_FILE_simplestatic_RelWithDebInfo} + ${TARGET_LINKER_FILE_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-minsizerel-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-minsizerel-ninja-check.cmake new file mode 100644 index 0000000..c09ae65 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-minsizerel-ninja-check.cmake @@ -0,0 +1,41 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_LINKER_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-ninja-check.cmake new file mode 100644 index 0000000..43213dd --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-ninja-check.cmake @@ -0,0 +1,49 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_LINKER_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + + ${TARGET_FILE_simpleshared_MinSizeRel} + ${TARGET_LINKER_FILE_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + + ${TARGET_FILE_simplestatic_MinSizeRel} + ${TARGET_LINKER_FILE_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-ninja-check.cmake new file mode 100644 index 0000000..dae1f4d --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-ninja-check.cmake @@ -0,0 +1,51 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_LINKER_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simplestatic_MinSizeRel} + ${TARGET_LINKER_FILE_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_FILE_simplestatic_RelWithDebInfo} + ${TARGET_LINKER_FILE_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-minsizerel-top-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-minsizerel-top-ninja-check.cmake new file mode 100644 index 0000000..bf4be49 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-minsizerel-top-ninja-check.cmake @@ -0,0 +1,51 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + + ${TARGET_FILE_simpleshared_MinSizeRel} + ${TARGET_LINKER_FILE_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + + ${TARGET_FILE_simplestatic_MinSizeRel} + ${TARGET_LINKER_FILE_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-reconfigure-config-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-reconfigure-config-ninja-stdout.txt new file mode 100644 index 0000000..8877451 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-reconfigure-config-ninja-stdout.txt @@ -0,0 +1,4 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: [^ +]*/Tests/RunCMake/NinjaMultiConfig/Simple-build diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-reconfigure-noconfig-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-reconfigure-noconfig-ninja-stdout.txt new file mode 100644 index 0000000..8877451 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-reconfigure-noconfig-ninja-stdout.txt @@ -0,0 +1,4 @@ +-- Configuring done +-- Generating done +-- Build files have been written to: [^ +]*/Tests/RunCMake/NinjaMultiConfig/Simple-build diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-release-file-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-release-file-ninja-check.cmake new file mode 100644 index 0000000..6e63aae --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-release-file-ninja-check.cmake @@ -0,0 +1,39 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-release-filename-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-release-filename-build-check.cmake new file mode 100644 index 0000000..a9bf42c --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-release-filename-build-check.cmake @@ -0,0 +1,36 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-release-in-minsizerel-graph-subdir-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-release-in-minsizerel-graph-subdir-ninja-check.cmake new file mode 100644 index 0000000..b6c77ab --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-release-in-minsizerel-graph-subdir-ninja-check.cmake @@ -0,0 +1,37 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple.cmake new file mode 100644 index 0000000..a32f551 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +file(TOUCH ${CMAKE_BINARY_DIR}/empty.cmake) +include(${CMAKE_BINARY_DIR}/empty.cmake) + +add_subdirectory(SimpleSubdir) + +add_library(simplestatic STATIC simplelib.c) + +include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) +generate_output_files(simpleexe simpleshared simplestatic simpleobj) + +file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(GENERATED_FILES [==[${CMAKE_BINARY_DIR}/empty.cmake]==])\n") diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-all-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-all-in-release-graph-build-check.cmake new file mode 100644 index 0000000..fee5951 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-all-in-release-graph-build-check.cmake @@ -0,0 +1,45 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-in-relwithdebinfo-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-in-relwithdebinfo-graph-build-check.cmake new file mode 100644 index 0000000..fee5951 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-in-relwithdebinfo-graph-build-check.cmake @@ -0,0 +1,45 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-check.cmake new file mode 100644 index 0000000..fee5951 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-check.cmake @@ -0,0 +1,45 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-stderr.txt new file mode 100644 index 0000000..fa8b462 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-all-relwithdebinfo-in-release-graph-build-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'all:RelWithDebInfo'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-clean-all-in-release-graph-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-clean-all-in-release-graph-ninja-check.cmake new file mode 100644 index 0000000..6c94369 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-clean-all-in-release-graph-ninja-check.cmake @@ -0,0 +1,31 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-debug-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-debug-in-release-graph-build-check.cmake new file mode 100644 index 0000000..b6c77ab --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-debug-in-release-graph-build-check.cmake @@ -0,0 +1,37 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-release-in-release-graph-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-release-in-release-graph-ninja-check.cmake new file mode 100644 index 0000000..d8b5218 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-release-in-release-graph-ninja-check.cmake @@ -0,0 +1,31 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-release-in-relwithdebinfo-graph-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-release-in-relwithdebinfo-graph-ninja-check.cmake new file mode 100644 index 0000000..1a37aa3 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-release-in-relwithdebinfo-graph-ninja-check.cmake @@ -0,0 +1,44 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-check.cmake new file mode 100644 index 0000000..b6c77ab --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-check.cmake @@ -0,0 +1,37 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-stderr.txt new file mode 100644 index 0000000..f3a825c --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-release-graph-build-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'simpleexe:RelWithDebInfo'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-relwithdebinfo-graph-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-relwithdebinfo-graph-ninja-check.cmake new file mode 100644 index 0000000..7eddb2f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs-relwithdebinfo-in-relwithdebinfo-graph-ninja-check.cmake @@ -0,0 +1,43 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs.cmake new file mode 100644 index 0000000..2a5b708 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleCrossConfigs.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/Simple.cmake") diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-all-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-all-ninja-check.cmake new file mode 100644 index 0000000..c171e3d --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-all-ninja-check.cmake @@ -0,0 +1,56 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_LINKER_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_LINKER_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + + ${TARGET_FILE_simpleshared_MinSizeRel} + ${TARGET_LINKER_FILE_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + + ${TARGET_FILE_simplestatic_MinSizeRel} + ${TARGET_LINKER_FILE_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_FILE_simplestatic_RelWithDebInfo} + ${TARGET_LINKER_FILE_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-clean-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-clean-ninja-check.cmake new file mode 100644 index 0000000..0f919df --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-clean-ninja-check.cmake @@ -0,0 +1,25 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-target-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-target-ninja-check.cmake new file mode 100644 index 0000000..de4505c --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias-target-ninja-check.cmake @@ -0,0 +1,49 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + + ${TARGET_FILE_simpleshared_MinSizeRel} + ${TARGET_LINKER_FILE_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias.cmake new file mode 100644 index 0000000..2a5b708 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAlias.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/Simple.cmake") diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-all-configs-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-all-configs-build-check.cmake new file mode 100644 index 0000000..8ffdd20 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-all-configs-build-check.cmake @@ -0,0 +1,39 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-all-relwithdebinfo-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-all-relwithdebinfo-ninja-check.cmake new file mode 100644 index 0000000..9e5baf9 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-all-relwithdebinfo-ninja-check.cmake @@ -0,0 +1,46 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_FILE_simplestatic_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_FILE_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-clean-configs-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-clean-configs-ninja-check.cmake new file mode 100644 index 0000000..3829d3e --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-clean-configs-ninja-check.cmake @@ -0,0 +1,32 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + + ${TARGET_FILE_simpleshared_RelWithDebInfo} + ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + + ${TARGET_FILE_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-target-configs-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-target-configs-ninja-check.cmake new file mode 100644 index 0000000..b6c77ab --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList-target-configs-ninja-check.cmake @@ -0,0 +1,37 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList.cmake new file mode 100644 index 0000000..2a5b708 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasList.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/Simple.cmake") diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross-target-configs-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross-target-configs-ninja-check.cmake new file mode 100644 index 0000000..b6c77ab --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross-target-configs-ninja-check.cmake @@ -0,0 +1,37 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + ${TARGET_FILE_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleexe_Release} + + ${TARGET_FILE_simpleshared_Release} + ${TARGET_LINKER_FILE_simpleshared_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + + ${TARGET_OBJECT_FILES_simpleobj_Release} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simplestatic_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross.cmake new file mode 100644 index 0000000..2a5b708 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/Simple.cmake") diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-all-ninja-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-all-ninja-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-all-ninja-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-all-ninja-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-all-ninja-stderr.txt new file mode 100644 index 0000000..905a355 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-all-ninja-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'all:all'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-clean-build-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-clean-build-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-clean-build-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-clean-build-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-clean-build-stderr.txt new file mode 100644 index 0000000..43528de --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-clean-build-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'clean:all'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-stderr.txt new file mode 100644 index 0000000..6db4bcc --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'simplestatic:all'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-debug-target-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-debug-target-build-check.cmake new file mode 100644 index 0000000..6bb7773 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-debug-target-build-check.cmake @@ -0,0 +1,31 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + EXCLUDE + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-debug-target-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-debug-target-ninja-check.cmake new file mode 100644 index 0000000..c8a735a --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-debug-target-ninja-check.cmake @@ -0,0 +1,32 @@ +check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + ${GENERATED_FILES} + + ${TARGET_FILE_simpleexe_Debug} + ${TARGET_OBJECT_FILES_simpleexe_Debug} + + ${TARGET_FILE_simpleshared_Debug} + ${TARGET_LINKER_FILE_simpleshared_Debug} + ${TARGET_OBJECT_FILES_simpleshared_Debug} + + ${TARGET_FILE_simplestatic_Debug} + ${TARGET_OBJECT_FILES_simplestatic_Debug} + + ${TARGET_OBJECT_FILES_simpleobj_Debug} + + EXCLUDE + ${TARGET_OBJECT_FILES_simpleexe_Release} + ${TARGET_OBJECT_FILES_simpleshared_Release} + ${TARGET_OBJECT_FILES_simplestatic_Release} + ${TARGET_OBJECT_FILES_simpleobj_Release} + + ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel} + ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel} + ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel} + + ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo} + ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo} + ) diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-all-build-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-all-build-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-all-build-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-all-build-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-all-build-stderr.txt new file mode 100644 index 0000000..fa8b462 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-all-build-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'all:RelWithDebInfo'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-clean-build-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-clean-build-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-clean-build-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-clean-build-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-clean-build-stderr.txt new file mode 100644 index 0000000..70eef2f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-clean-build-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'clean:RelWithDebInfo'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-target-ninja-result.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-target-ninja-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-target-ninja-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-target-ninja-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-target-ninja-stderr.txt new file mode 100644 index 0000000..1a1fe9e --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-relwithdebinfo-in-release-graph-target-ninja-stderr.txt @@ -0,0 +1 @@ +^ninja: error: unknown target 'simplestatic:RelWithDebInfo'$ diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross.cmake new file mode 100644 index 0000000..2a5b708 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/Simple.cmake") diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleSubdir/CMakeLists.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleSubdir/CMakeLists.txt new file mode 100644 index 0000000..7e754a3 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleSubdir/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(simpleobj OBJECT ../empty.c) +add_executable(simpleexe ../main.c $<TARGET_OBJECTS:simpleobj>) +add_library(simpleshared SHARED ../simplelib.c) +target_link_libraries(simpleexe PRIVATE simpleshared) diff --git a/Tests/RunCMake/NinjaMultiConfig/WriteFile.cmake b/Tests/RunCMake/NinjaMultiConfig/WriteFile.cmake new file mode 100644 index 0000000..82681a2 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/WriteFile.cmake @@ -0,0 +1 @@ +file(WRITE "${OUTPUT_FILE}" "Genex config: ${GENEX_CONFIG}\nINTDIR config: ${INTDIR_CONFIG}\n") diff --git a/Tests/RunCMake/NinjaMultiConfig/badmoc.c b/Tests/RunCMake/NinjaMultiConfig/badmoc.c new file mode 100644 index 0000000..aec8dc3 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/badmoc.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(void) +{ + printf("BadMoc Configuration: " CONFIG "\n"); + return 1; +} diff --git a/Tests/RunCMake/NinjaMultiConfig/empty.c b/Tests/RunCMake/NinjaMultiConfig/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/empty.c diff --git a/Tests/RunCMake/NinjaMultiConfig/generator.c b/Tests/RunCMake/NinjaMultiConfig/generator.c new file mode 100644 index 0000000..465ee2f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/generator.c @@ -0,0 +1,101 @@ +#include <genex_config.h> +#include <stdio.h> +/* FIXME Get this working */ +/*#include <intdir_config.h>*/ + +const char* generatorlib_genex_config_definition(void); +const char* generatorlib_genex_config_include_dir(void); +const char* generatorobj_genex_config_definition(void); +const char* generatorobj_genex_config_include_dir(void); + +static const char contents[] = + /* clang-format off */ +"#include <stdio.h>\n" +"\n" +"#include <genex_config.h>\n" +/* FIXME Get this working */ +/*"#include <intdir_config.h>\n"*/ +"\n" +"const char* generatorlib_genex_config_definition(void);\n" +"const char* generatorlib_genex_config_include_dir(void);\n" +"const char* generatorobj_genex_config_definition(void);\n" +"const char* generatorobj_genex_config_include_dir(void);\n" +"\n" +"int main(void)\n" +"{\n" +" printf(\n" +" \"Generator genex config definition: " + GENEX_CONFIG_DEFINITION "\\n\"\n" +/* FIXME Get this working */ +/*" \"Generator INTDIR config definition: " + INTDIR_CONFIG_DEFINITION "\\n\"\n"*/ +" \"Generator genex config include dir: " + GENEX_CONFIG_INCLUDE_DIR "\\n\"\n" +/* FIXME Get this working */ +/*" \"Generator INTDIR config include dir: " + INTDIR_CONFIG_INCLUDE_DIR "\\n\"\n"*/ +" \"Generator library genex config definition: %s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generator library INTDIR config definition: %s\\n\"\n"*/ +" \"Generator library genex config include dir: %s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generator library INTDIR config include dir: %s\\n\"\n"*/ +" \"Generator object genex config definition: %s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generator object INTDIR config definition: %s\\n\"\n"*/ +" \"Generator object genex config include dir: %s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generator object INTDIR config include dir: %s\\n\"\n"*/ +" \"Generated genex config definition: \"" + " GENEX_CONFIG_DEFINITION \"\\n\"\n" +/* FIXME Get this working */ +/*" \"Generated INTDIR config definition: \"" + " INTDIR_CONFIG_DEFINITION \"\\n\"\n"*/ +" \"Generated genex config include dir: \"" + " GENEX_CONFIG_INCLUDE_DIR \"\\n\"\n" +/* FIXME Get this working */ +/*" \"Generated INTDIR config include dir: \"" + " INTDIR_CONFIG_INCLUDE_DIR \"\\n\"\n"*/ +" \"Generated library genex config definition: %%s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generated library INTDIR config definition: %%s\\n\"\n"*/ +" \"Generated library genex config include dir: %%s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generated library INTDIR config include dir: %%s\\n\"\n"*/ +" \"Generated object genex config definition: %%s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generated object INTDIR config definition: %%s\\n\"\n"*/ +" \"Generated object genex config include dir: %%s\\n\"\n" +/* FIXME Get this working */ +/*" \"Generated object INTDIR config include dir: %%s\\n\"\n"*/ +" , generatorlib_genex_config_definition()\n" +" , generatorlib_genex_config_include_dir()\n" +" , generatorobj_genex_config_definition()\n" +" , generatorobj_genex_config_include_dir());\n" +" return 0;\n" +"}\n"; +/* clang-format on */ + +int main(int argc, char** argv) +{ + const char* filename; + FILE* fout; + + if (argc < 2) { + fprintf(stderr, "Usage: %s <filename>\n", argv[0]); + return 1; + } + + filename = argv[1]; + if (!(fout = fopen(filename, "w"))) { + fprintf(stderr, "Could not open %s for writing\n", filename); + return 1; + } + fprintf(fout, contents, generatorlib_genex_config_definition(), + generatorlib_genex_config_include_dir(), + generatorobj_genex_config_definition(), + generatorobj_genex_config_include_dir()); + fclose(fout); + + return 0; +} diff --git a/Tests/RunCMake/NinjaMultiConfig/generatorlib.c b/Tests/RunCMake/NinjaMultiConfig/generatorlib.c new file mode 100644 index 0000000..de5c8f3 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/generatorlib.c @@ -0,0 +1,24 @@ +#include <genex_config.h> +/* FIXME Get this working */ +/*#include <intdir_config.h>*/ + +const char* generatorlib_genex_config_definition(void) +{ + return GENEX_CONFIG_DEFINITION; +} + +const char* generatorlib_genex_config_include_dir(void) +{ + return GENEX_CONFIG_INCLUDE_DIR; +} + +/* FIXME Get this working */ +/*const char* generatorlib_intdir_config_definition(void) +{ + return INTDIR_CONFIG_DEFINITION; +} + +const char* generatorlib_intdir_config_include_dir(void) +{ + return INTDIR_CONFIG_INCLUDE_DIR; +}*/ diff --git a/Tests/RunCMake/NinjaMultiConfig/generatorobj.c b/Tests/RunCMake/NinjaMultiConfig/generatorobj.c new file mode 100644 index 0000000..7bb5aa6 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/generatorobj.c @@ -0,0 +1,24 @@ +#include <genex_config.h> +/* FIXME Get this working */ +/*#include <intdir_config.h>*/ + +const char* generatorobj_genex_config_definition(void) +{ + return GENEX_CONFIG_DEFINITION; +} + +const char* generatorobj_genex_config_include_dir(void) +{ + return GENEX_CONFIG_INCLUDE_DIR; +} + +/* FIXME Get this working */ +/*const char* generatorobj_intdir_config_definition(void) +{ + return INTDIR_CONFIG_DEFINITION; +} + +const char* generatorobj_intdir_config_include_dir(void) +{ + return INTDIR_CONFIG_INCLUDE_DIR; +}*/ diff --git a/Tests/RunCMake/NinjaMultiConfig/main.c b/Tests/RunCMake/NinjaMultiConfig/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/NinjaMultiConfig/main.cu b/Tests/RunCMake/NinjaMultiConfig/main.cu new file mode 100644 index 0000000..563b9b2 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/main.cu @@ -0,0 +1,15 @@ + +#include <cuda.h> + +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +#else +# define IMPORT +#endif + +IMPORT int simplelib(); + +int main(void) +{ + return simplelib(); +} diff --git a/Tests/RunCMake/NinjaMultiConfig/qt5.cxx b/Tests/RunCMake/NinjaMultiConfig/qt5.cxx new file mode 100644 index 0000000..972227f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/qt5.cxx @@ -0,0 +1,9 @@ +#include <QCoreApplication> + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + return app.exec(); +} + +#include "moc_qt5.cpp" diff --git a/Tests/RunCMake/NinjaMultiConfig/qt5.h b/Tests/RunCMake/NinjaMultiConfig/qt5.h new file mode 100644 index 0000000..b365b92 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/qt5.h @@ -0,0 +1,5 @@ +#include <QObject> +class QBuffer : public QObject +{ + Q_OBJECT +}; diff --git a/Tests/RunCMake/NinjaMultiConfig/simplelib.c b/Tests/RunCMake/NinjaMultiConfig/simplelib.c new file mode 100644 index 0000000..76ff921 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/simplelib.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void simplelib(void) +{ +} diff --git a/Tests/RunCMake/NinjaMultiConfig/simplelib.cu b/Tests/RunCMake/NinjaMultiConfig/simplelib.cu new file mode 100644 index 0000000..7fc0812 --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/simplelib.cu @@ -0,0 +1,9 @@ +#include <cuda.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif + int simplelib() +{ + return 0; +} diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input index 81e9ee0..b1c4ce0 100644 --- a/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input +++ b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input @@ -53,7 +53,7 @@ LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586' Linking C executable cmTC_ab097.exe "C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_ab097.dir\link.txt --verbose=1 -"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_ab097.dir/objects.a +"C:\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_ab097.dir/objects.a C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_ab097.dir/objects.a @CMakeFiles\cmTC_ab097.dir\objects1.rsp C:\DoesNotExist\MinGW\bin\gcc.exe -v -Wl,--whole-archive CMakeFiles\cmTC_ab097.dir/objects.a -Wl,--no-whole-archive -o cmTC_ab097.exe -Wl,--out-implib,libcmTC_ab097.dll.a -Wl,--major-image-version,0,--minor-image-version,0 Using built-in specs. diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input index cd77340..aae67bb 100644 --- a/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input +++ b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input @@ -59,7 +59,7 @@ LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586' Linking CXX executable cmTC_2b790.exe "C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_2b790.dir\link.txt --verbose=1 -"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_2b790.dir/objects.a +"C:\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_2b790.dir/objects.a C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_2b790.dir/objects.a @CMakeFiles\cmTC_2b790.dir\objects1.rsp C:\DoesNotExist\MinGW\bin\g++.exe -v -Wl,--whole-archive CMakeFiles\cmTC_2b790.dir/objects.a -Wl,--no-whole-archive -o cmTC_2b790.exe -Wl,--out-implib,libcmTC_2b790.dll.a -Wl,--major-image-version,0,--minor-image-version,0 Using built-in specs. diff --git a/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake index 494bcf7..cc719be 100644 --- a/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake @@ -1,4 +1,7 @@ set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/Debug/cmake_pch.h") +endif() set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") if (NOT EXISTS ${foo_pch_header}) diff --git a/Tests/RunCMake/PrecompileHeaders/PchDebugGenex-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchDebugGenex-check.cmake new file mode 100644 index 0000000..cb94ee5 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchDebugGenex-check.cmake @@ -0,0 +1,17 @@ +if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + return() +endif() + +set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/Debug/cmake_pch.h") + +if (NOT EXISTS ${foo_pch_header}) + set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist") + return() +endif() + +file(STRINGS ${foo_pch_header} foo_pch_header_strings) + +if (NOT foo_pch_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo.h\";#include <stdio.h>(;|$)") + set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foo_pch_header}\nhas bad content:\n ${foo_pch_header_strings}") + return() +endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchDebugGenex.cmake b/Tests/RunCMake/PrecompileHeaders/PchDebugGenex.cmake new file mode 100644 index 0000000..854689f --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchDebugGenex.cmake @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +project(PchDebugGenex C) + +add_library(foo foo.c) +target_include_directories(foo PUBLIC include) +target_precompile_headers(foo PUBLIC + "$<$<CONFIG:Debug>:${CMAKE_CURRENT_SOURCE_DIR}/include/foo.h>" + <stdio.h> +) diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake index 4e62b81..28c6ba4 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake @@ -1,5 +1,9 @@ set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/Debug/cmake_pch.h") + set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/Debug/cmake_pch.h") +endif() if (NOT EXISTS ${foo_pch_header}) set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist") diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake index a1e0792..aab20d8 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake @@ -9,6 +9,9 @@ target_precompile_headers(foo PUBLIC <stdio.h> \"string.h\" ) +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + set_property(SOURCE foo.c APPEND PROPERTY COMPILE_OPTIONS "-WX-") +endif() add_library(bar INTERFACE) target_include_directories(bar INTERFACE include) diff --git a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake index cc01ecb..3119341 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake @@ -1,5 +1,9 @@ set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.hxx") +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/Debug/cmake_pch.h") + set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/Debug/cmake_pch.hxx") +endif() if (NOT EXISTS ${foobar_pch_h_header}) set(RunCMake_TEST_FAILED "Generated foobar C pch header ${foobar_pch_h_header} does not exist") @@ -13,14 +17,14 @@ endif() file(STRINGS ${foobar_pch_h_header} foobar_pch_h_header_strings) -if (NOT foobar_pch_h_header_strings MATCHES ";#include <stddef.h>(;|$)") +if (NOT foobar_pch_h_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo_C.h\";#include <stddef.h>(;|$)") set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foobar_pch_h_header}\nhas bad content:\n ${foobar_pch_h_header_strings}") return() endif() file(STRINGS ${foobar_pch_hxx_header} foobar_pch_hxx_header_strings) -if (NOT foobar_pch_hxx_header_strings MATCHES ";#include <cstddef>(;|$)") +if (NOT foobar_pch_hxx_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo_CXX.h\";#include <cstddef>(;|$)") set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foobar_pch_hxx_header}\nhas bad content:\n ${foobar_pch_hxx_header_strings}") return() endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake index cdc42b2..bb18a64 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake @@ -7,6 +7,8 @@ add_executable(foobar ) target_include_directories(foobar PUBLIC include) target_precompile_headers(foobar PRIVATE + "$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/include/foo_C.h>" + "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/include/foo_CXX.h>" "$<$<COMPILE_LANGUAGE:C>:<stddef.h$<ANGLE-R>>" "$<$<COMPILE_LANGUAGE:CXX>:<cstddef$<ANGLE-R>>" ) diff --git a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake index 9018664..f1504a7 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake @@ -1,4 +1,7 @@ set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/cmake_pch.hxx") +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/Debug/cmake_pch.hxx") +endif() file(STRINGS ${main_pch_header} main_pch_header_strings) string(REGEX MATCH "#pragma warning\\(push, 0\\).*#include.*pch.h.*#pragma warning\\(pop\\)" matched_code ${main_pch_header_strings}) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index 8d2f4f9..f587c7d 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -13,6 +13,7 @@ function(run_test name) endfunction() run_cmake(DisabledPch) +run_cmake(PchDebugGenex) run_test(PchInterface) run_cmake(PchPrologueEpilogue) run_test(SkipPrecompileHeaders) diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo_C.h b/Tests/RunCMake/PrecompileHeaders/include/foo_C.h new file mode 100644 index 0000000..f4de601 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/include/foo_C.h @@ -0,0 +1 @@ +#include "foo.h" diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo_CXX.h b/Tests/RunCMake/PrecompileHeaders/include/foo_CXX.h new file mode 100644 index 0000000..f4de601 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/include/foo_CXX.h @@ -0,0 +1 @@ +#include "foo.h" diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index da4d1e5..cb20fb1 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -146,6 +146,12 @@ function(run_cmake test) "|clang[^:]*: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled:" "|Error kstat returned" "|Hit xcodebuild bug" + + "|LICENSE WARNING:" + "|Your license to use PGI[^\n]*expired" + "|Please obtain a new version at" + "|contact PGI Sales at" + "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" "|[^\n]*is a member of multiple groups" "|[^\n]*from Time Machine by path" @@ -204,5 +210,28 @@ function(run_cmake_with_options test) run_cmake(${test}) endfunction() +function(ensure_files_match expected_file actual_file) + if(NOT EXISTS "${expected_file}") + message(FATAL_ERROR "Expected file does not exist:\n ${expected_file}") + endif() + if(NOT EXISTS "${actual_file}") + message(FATAL_ERROR "Actual file does not exist:\n ${actual_file}") + endif() + file(READ "${expected_file}" expected_file_content) + file(READ "${actual_file}" actual_file_content) + if(NOT "${expected_file_content}" STREQUAL "${actual_file_content}") + message(FATAL_ERROR "Actual file content does not match expected:\n + \n + expected file: ${expected_file}\n + expected content:\n + ${expected_file_content}\n + \n + actual file: ${actual_file}\n + actual content:\n + ${actual_file_content}\n + ") + endif() +endfunction() + # Protect RunCMake tests from calling environment. unset(ENV{MAKEFLAGS}) diff --git a/Tests/RunCMake/RuntimePath/Relative.cmake b/Tests/RunCMake/RuntimePath/Relative.cmake index 203241f..80ed189 100644 --- a/Tests/RunCMake/RuntimePath/Relative.cmake +++ b/Tests/RunCMake/RuntimePath/Relative.cmake @@ -1,5 +1,12 @@ enable_language(C) +set(cfg_up) +set(cfg_slash /) +if(cfg_dir) + set(cfg_up /..) + set(cfg_slash) +endif() + if(NOT CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN) if(CMAKE_C_PLATFORM_ID STREQUAL "Linux") # Sanity check for platform that is definitely known to support $ORIGIN. @@ -45,25 +52,25 @@ CheckRpath(main "\$ORIGIN") add_executable(main-norel main.c) target_link_libraries(main-norel utils) set_property(TARGET main-norel PROPERTY BUILD_RPATH_USE_ORIGIN OFF) -CheckRpath(main-norel "${CMAKE_CURRENT_BINARY_DIR}") +CheckRpath(main-norel "${CMAKE_CURRENT_BINARY_DIR}${cfg_dir}") add_executable(mainsub main.c) target_link_libraries(mainsub utils) set_property(TARGET mainsub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) -CheckRpath(mainsub "\$ORIGIN/../") +CheckRpath(mainsub "\$ORIGIN${cfg_up}/..${cfg_dir}${cfg_slash}") add_executable(main-sub main.c) target_link_libraries(main-sub utils-sub) -CheckRpath(main-sub "\$ORIGIN/libs") +CheckRpath(main-sub "\$ORIGIN${cfg_up}/libs${cfg_dir}") add_executable(mainsub-sub main.c) target_link_libraries(mainsub-sub utils-sub) set_property(TARGET mainsub-sub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) -CheckRpath(mainsub-sub "\$ORIGIN/../libs") +CheckRpath(mainsub-sub "\$ORIGIN${cfg_up}/../libs${cfg_dir}") if(externDir) # Binaries linking to libraries outside the build tree should have an absolute RPATH. add_executable(main-extern main.c) target_link_libraries(main-extern utils-extern) - CheckRpath(main-extern "${externDir}") + CheckRpath(main-extern "${externDir}${cfg_dir}") endif() diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake index 4c9ddcd..ad446e9 100644 --- a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake +++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake @@ -6,7 +6,9 @@ function(run_RuntimePath name) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) set(RunCMake_TEST_NO_CLEAN 1) if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + set(RunCMake_TEST_OPTIONS -Dcfg_dir= -DCMAKE_BUILD_TYPE=Debug) + else() + set(RunCMake_TEST_OPTIONS -Dcfg_dir=/$<CONFIG>) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -14,12 +16,16 @@ function(run_RuntimePath name) run_cmake_command(${name}-build ${CMAKE_COMMAND} --build . --config Debug) endfunction() +set(cfg_dir) +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(cfg_dir /Debug) +endif() + run_RuntimePath(SymlinkImplicit) run_cmake_command(SymlinkImplicitCheck - ${CMAKE_COMMAND} -Ddir=${RunCMake_BINARY_DIR}/SymlinkImplicit-build -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake) + ${CMAKE_COMMAND} -Ddir=${RunCMake_BINARY_DIR}/SymlinkImplicit-build -Dcfg_dir=${cfg_dir} -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake) run_RuntimePath(Relative) -# FIXME: Run RelativeCheck (appears to be broken currently) run_RuntimePath(Genex) run_cmake_command(GenexCheck diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake index d34742e..4f50d4b 100644 --- a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake +++ b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake @@ -1,2 +1,2 @@ -file(COPY ${dir}/bin/exe DESTINATION ${dir}) +file(COPY ${dir}/bin${cfg_dir}/exe DESTINATION ${dir}) file(RPATH_CHANGE FILE "${dir}/exe" OLD_RPATH "${dir}/libLink" NEW_RPATH "old-should-not-exist") diff --git a/Tests/RunCMake/Swift/L.swift b/Tests/RunCMake/Swift/L.swift new file mode 100644 index 0000000..79ff87e --- /dev/null +++ b/Tests/RunCMake/Swift/L.swift @@ -0,0 +1 @@ +public let ThirtyTwo: Int = 32 diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index 4817045..1db202e 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -7,6 +7,16 @@ if(RunCMake_GENERATOR STREQUAL Xcode) elseif(RunCMake_GENERATOR STREQUAL Ninja) if(CMAKE_Swift_COMPILER) run_cmake(Win32ExecutableDisallowed) + + set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Darwin) + run_cmake(SwiftMultiArch) + unset(RunCMake_TEST_OPTIONS) + endif() +elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config") + if(CMAKE_Swift_COMPILER) + set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release") + run_cmake(SwiftSimple) + unset(RunCMake_TEST_OPTIONS) endif() else() run_cmake(NotSupported) diff --git a/Tests/RunCMake/Swift/SwiftMultiArch-result.txt b/Tests/RunCMake/Swift/SwiftMultiArch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Swift/SwiftMultiArch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Swift/SwiftMultiArch-stderr.txt b/Tests/RunCMake/Swift/SwiftMultiArch-stderr.txt new file mode 100644 index 0000000..874bdc7 --- /dev/null +++ b/Tests/RunCMake/Swift/SwiftMultiArch-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SwiftMultiArch.cmake:3 \(project\): + multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift +Call Stack \(most recent call first\): + CMakeLists.txt:3 diff --git a/Tests/RunCMake/Swift/SwiftMultiArch.cmake b/Tests/RunCMake/Swift/SwiftMultiArch.cmake new file mode 100644 index 0000000..5fdb688 --- /dev/null +++ b/Tests/RunCMake/Swift/SwiftMultiArch.cmake @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.15.1) +set(CMAKE_OSX_ARCHITECTURES "armv7;arm64;i386;x86_64") +project(SwiftMultiArch + LANGUAGES Swift) diff --git a/Tests/RunCMake/Swift/SwiftSimple.cmake b/Tests/RunCMake/Swift/SwiftSimple.cmake new file mode 100644 index 0000000..1f2702d --- /dev/null +++ b/Tests/RunCMake/Swift/SwiftSimple.cmake @@ -0,0 +1,2 @@ +enable_language(Swift) +add_library(L L.swift) diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 6d72fac..9a1e027 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -28,6 +28,7 @@ \* CMP0081 \* CMP0083 \* CMP0095 + \* CMP0099 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetProperties/CMakeLists.txt b/Tests/RunCMake/TargetProperties/CMakeLists.txt new file mode 100644 index 0000000..be9d403 --- /dev/null +++ b/Tests/RunCMake/TargetProperties/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST}) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetProperties/Deprecation-stderr.txt b/Tests/RunCMake/TargetProperties/Deprecation-stderr.txt new file mode 100644 index 0000000..11a4cd8 --- /dev/null +++ b/Tests/RunCMake/TargetProperties/Deprecation-stderr.txt @@ -0,0 +1,9 @@ +^CMake Warning \(dev\) at Deprecation\.cmake:[0-9]+ \(target_link_libraries\): + The library that is being linked to, testLibDeprecation, is marked as being + deprecated by the owner\. The message provided by the developer is: + + Deprecated version\. Please use latest version + +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/TargetProperties/Deprecation.cmake b/Tests/RunCMake/TargetProperties/Deprecation.cmake new file mode 100644 index 0000000..9361273 --- /dev/null +++ b/Tests/RunCMake/TargetProperties/Deprecation.cmake @@ -0,0 +1,5 @@ +add_library(testLibDeprecation STATIC empty.cpp) +set_property(TARGET testLibDeprecation PROPERTY DEPRECATION "Deprecated version. Please use latest version") + +add_executable(testExe1 empty.cpp) +target_link_libraries(testExe1 testLibDeprecation) diff --git a/Tests/RunCMake/TargetProperties/RunCMakeTest.cmake b/Tests/RunCMake/TargetProperties/RunCMakeTest.cmake new file mode 100644 index 0000000..5af31da --- /dev/null +++ b/Tests/RunCMake/TargetProperties/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(Deprecation) diff --git a/Tests/RunCMake/TargetProperties/empty.cpp b/Tests/RunCMake/TargetProperties/empty.cpp new file mode 100644 index 0000000..4086dcc --- /dev/null +++ b/Tests/RunCMake/TargetProperties/empty.cpp @@ -0,0 +1,4 @@ +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index bee8c4e..0d462ba 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -1,6 +1,6 @@ include(RunCMake) -if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") +if(RunCMake_GENERATOR STREQUAL "Xcode") run_cmake(ConfigNotAllowed) endif() diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 44ccd6b..8a04f78 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,3 +1,5 @@ +cmake_policy(SET CMP0057 NEW) + include(RunCMake) cmake_policy(SET CMP0054 NEW) @@ -15,6 +17,7 @@ run_cmake(VsDebuggerCommand) run_cmake(VsDebuggerCommandArguments) run_cmake(VsDebuggerEnvironment) run_cmake(VsCSharpCustomTags) +run_cmake(VsCSharpDocumentationFile) run_cmake(VsCSharpReferenceProps) run_cmake(VsCSharpWithoutSources) run_cmake(VsCSharpDeployFiles) @@ -28,6 +31,12 @@ run_cmake(VsDpiAwareBadParam) run_cmake(VsPrecompileHeaders) run_cmake(VsPrecompileHeadersReuseFromCompilePDBName) +run_cmake(VsWinRTByDefault) + +set(RunCMake_GENERATOR_TOOLSET "VCTargetsPath=$(VCTargetsPath)") +run_cmake(VsVCTargetsPath) +unset(RunCMake_GENERATOR_TOOLSET) + if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) run_cmake(VsJustMyCode) endif() @@ -44,3 +53,6 @@ if (RunCMake_GENERATOR MATCHES "Visual Studio 1[0-4] 201[0-5]" OR else() run_cmake(UnityBuildNative) endif() + +run_cmake(VsDotnetTargetFramework) +run_cmake(VsDotnetTargetFrameworkVersion) diff --git a/Tests/RunCMake/VS10Project/VSDotnetTargetFrameworkVersion.cmake b/Tests/RunCMake/VS10Project/VSDotnetTargetFrameworkVersion.cmake new file mode 100644 index 0000000..8e0e0b4 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VSDotnetTargetFrameworkVersion.cmake @@ -0,0 +1,10 @@ +enable_language(CSharp) +if(NOT CMAKE_CSharp_COMPILER) + return() +endif() + +set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1") +add_library(foo SHARED foo.cs) + +set(CMAKE_DOTNET_TARGET_FRAMEWORK "netcoreapp3.1") +add_library(bar SHARED foo.cs) diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake index 152bf9c..631abac 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake @@ -27,15 +27,15 @@ foreach(line IN LISTS lines) elseif(inDebug AND (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$") AND - (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND - (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$")) + (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$")) AND + (NOT (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$")) ) set(debugOK TRUE) elseif(inRelease AND (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$") AND - (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND - (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$")) + (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$")) AND + (NOT (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$")) ) set(releaseOK TRUE) endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpDocumentationFile-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDocumentationFile-check.cmake new file mode 100644 index 0000000..0393362 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpDocumentationFile-check.cmake @@ -0,0 +1,26 @@ +# +# Check C# VS project for required elements +# +set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj") +if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() +endif() + +file(STRINGS "${csProjectFile}" lines) + +set(HAVE_DocumentationFile 0) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<DocumentationFile>([^<>]+)</DocumentationFile>") + if(HAVE_DocumentationFile) + set(RunCMake_TEST_FAILED "Documentation node has been generated more than once for\n ${csProjectFile}") + return() + endif() + set(HAVE_DocumentationFile 1) + endif() +endforeach() + +if(NOT HAVE_DocumentationFile) + set(RunCMake_TEST_FAILED "Documentation node has not been generated for\n ${csProjectFile}") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpDocumentationFile.cmake b/Tests/RunCMake/VS10Project/VsCSharpDocumentationFile.cmake new file mode 100644 index 0000000..83b6b97 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpDocumentationFile.cmake @@ -0,0 +1,8 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +enable_language(CSharp) + +add_library(foo SHARED + foo.cs) + +set_target_properties(foo PROPERTIES + VS_DOTNET_DOCUMENTATION_FILE foo.xml) diff --git a/Tests/RunCMake/VS10Project/VsDotnetTargetFramework-check.cmake b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework-check.cmake new file mode 100644 index 0000000..e656639 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework-check.cmake @@ -0,0 +1,40 @@ +set(files foo.csproj bar.csproj) + +set(inLib1 FALSE) +set(targetFrameworkInLib1 FALSE) + +set(inLib2 FALSE) +set(targetFrameworksInLib2 FALSE) + +foreach(file ${files}) + set(csProjectFile ${RunCMake_TEST_BINARY_DIR}/${file}) + + if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() + endif() + + file(STRINGS "${csProjectFile}" lines) + + foreach(line IN LISTS lines) + if(NOT inLib1) + if(line MATCHES " *<TargetFramework>netcoreapp3.1</TargetFramework> *$") + set(targetFrameworkInLib1 TRUE) + set(inLib1 TRUE) + endif() + elseif(NOT inLib2) + if(line MATCHES " *<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks> *$") + set(targetFrameworksInLib2 TRUE) + set(inLib2 TRUE) + endif() + endif() + endforeach() +endforeach() + +if(NOT targetFrameworkInLib1) + set(RunCMake_TEST_FAILED "TargetFramework not set correctly.") +endif() + +if(NOT targetFrameworksInLib2) + set(RunCMake_TEST_FAILED "TargetFrameworks not set correctly.") +endif() diff --git a/Tests/RunCMake/VS10Project/VsDotnetTargetFramework.cmake b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework.cmake new file mode 100644 index 0000000..f553679 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework.cmake @@ -0,0 +1,11 @@ +enable_language(CSharp) +if(NOT CMAKE_CSharp_COMPILER) + return() +endif() + +set(CMAKE_DOTNET_TARGET_FRAMEWORK "netcoreapp3.1") +set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "net461") +add_library(foo SHARED foo.cs) + +set(CMAKE_DOTNET_TARGET_FRAMEWORK "netcoreapp3.1;net461") +add_library(bar SHARED foo.cs) diff --git a/Tests/RunCMake/VS10Project/VsDotnetTargetFrameworkVersion-check.cmake b/Tests/RunCMake/VS10Project/VsDotnetTargetFrameworkVersion-check.cmake new file mode 100644 index 0000000..d2c3c3b --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetTargetFrameworkVersion-check.cmake @@ -0,0 +1,40 @@ +set(files foo.csproj bar.csproj) + +set(inLib1 FALSE) +set(targetFrameworkInLib1 FALSE) + +set(inLib2 FALSE) +set(targetFrameworksInLib2 FALSE) + +foreach(file ${files}) + set(csProjectFile ${RunCMake_TEST_BINARY_DIR}/${file}) + + if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() + endif() + + file(STRINGS "${csProjectFile}" lines) + + foreach(line IN LISTS lines) + if(NOT inLib1) + if(line MATCHES " *<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> *$") + set(targetFrameworkInLib1 TRUE) + set(inLib1 TRUE) + endif() + elseif(NOT inLib2) + if(line MATCHES " *<TargetFramework>netcoreapp3.1</TargetFramework> *$") + set(targetFrameworksInLib2 TRUE) + set(inLib2 TRUE) + endif() + endif() + endforeach() +endforeach() + +if(NOT targetFrameworkInLib1) + set(RunCMake_TEST_FAILED "TargetFrameworkVersion not set correctly.") +endif() + +if(NOT targetFrameworksInLib2) + set(RunCMake_TEST_FAILED "TargetFramework not set correctly.") +endif() diff --git a/Tests/RunCMake/VS10Project/VsGlobals-check.cmake b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake index 0e7fd45..6a30099 100644 --- a/Tests/RunCMake/VS10Project/VsGlobals-check.cmake +++ b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake @@ -1,44 +1,65 @@ -set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") -if(NOT EXISTS "${vcProjectFile}") - set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") - return() -endif() +macro(check_project_file projectFile) + if(NOT EXISTS "${projectFile}") + set(RunCMake_TEST_FAILED "Project file ${projectFile} does not exist.") + return() + endif() + + string(REPLACE "${RunCMake_TEST_BINARY_DIR}/" "" projectName ${projectFile}) -set(InsideGlobals FALSE) -set(DefaultLanguageSet FALSE) -set(MinimumVisualStudioVersionSet FALSE) + set(InsideGlobals FALSE) + set(DefaultLanguageSet FALSE) + set(MinimumVisualStudioVersionSet FALSE) + set(TestPropertySet FALSE) -file(STRINGS "${vcProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<PropertyGroup Label=\"Globals\"> *$") - set(InsideGlobals TRUE) - elseif(line MATCHES "^ *<DefaultLanguage>([a-zA-Z\\-]+)</DefaultLanguage> *$") - if("${CMAKE_MATCH_1}" STREQUAL "en-US") - if(InsideGlobals) - message(STATUS "foo.vcxproj has correct DefaultLanguage global property") - set(DefaultLanguageSet TRUE) - else() - message(STATUS "DefaultLanguage is set but not within \"Globals\" property group") + file(STRINGS "${projectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<PropertyGroup Label=\"Globals\"> *$") + set(InsideGlobals TRUE) + elseif(line MATCHES "^ *<DefaultLanguage>([a-zA-Z\\-]+)</DefaultLanguage> *$") + if("${CMAKE_MATCH_1}" STREQUAL "en-US") + if(InsideGlobals) + message(STATUS "${projectName} has correct DefaultLanguage global property") + set(DefaultLanguageSet TRUE) + else() + message(STATUS "DefaultLanguage is set but not within \"Globals\" property group") + endif() endif() - endif() - elseif(line MATCHES "^ *<MinimumVisualStudioVersion>([0-9\\.]+)</MinimumVisualStudioVersion> *$") - if("${CMAKE_MATCH_1}" STREQUAL "14.0") - if(InsideGlobals) - message(STATUS "foo.vcxproj has correct MinimumVisualStudioVersion global property") - set(MinimumVisualStudioVersionSet TRUE) - else() - message(STATUS "MinimumVisualStudioVersion is set but not within \"Globals\" property group") + elseif(line MATCHES "^ *<MinimumVisualStudioVersion>([0-9\\.]+)</MinimumVisualStudioVersion> *$") + if("${CMAKE_MATCH_1}" STREQUAL "10.0") + if(InsideGlobals) + message(STATUS "${projectName} has correct MinimumVisualStudioVersion global property") + set(MinimumVisualStudioVersionSet TRUE) + else() + message(STATUS "MinimumVisualStudioVersion is set but not within \"Globals\" property group") + endif() + endif() + elseif(line MATCHES "^ *<TestProperty>(.+)</TestProperty> *$") + if("${CMAKE_MATCH_1}" STREQUAL "TestValue") + if(InsideGlobals) + message(STATUS "${projectName} has correct TestProperty global property") + set(TestPropertySet TRUE) + else() + message(STATUS "TestProperty is set but not within \"Globals\" property group") + endif() endif() endif() + endforeach() + + if(NOT DefaultLanguageSet) + set(RunCMake_TEST_FAILED "DefaultLanguage not found or not set correctly in ${projectName}.") + return() + endif() + + if(NOT MinimumVisualStudioVersionSet) + set(RunCMake_TEST_FAILED "MinimumVisualStudioVersion not found or not set correctly in ${projectName}.") + return() endif() -endforeach() -if(NOT DefaultLanguageSet) - set(RunCMake_TEST_FAILED "DefaultLanguageSet not found or not set correctly.") - return() -endif() + if(NOT TestPropertySet) + set(RunCMake_TEST_FAILED "TestProperty not found or not set correctly in ${projectName}.") + return() + endif() +endmacro() -if(NOT MinimumVisualStudioVersionSet) - set(RunCMake_TEST_FAILED "MinimumVisualStudioVersionSet not found or not set correctly.") - return() -endif() +check_project_file("${RunCMake_TEST_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION}/CompilerIdCXX/CompilerIdCXX.vcxproj") +check_project_file("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") diff --git a/Tests/RunCMake/VS10Project/VsGlobals.cmake b/Tests/RunCMake/VS10Project/VsGlobals.cmake index a3ed5af..09d806d 100644 --- a/Tests/RunCMake/VS10Project/VsGlobals.cmake +++ b/Tests/RunCMake/VS10Project/VsGlobals.cmake @@ -1,8 +1,9 @@ -enable_language(CXX) - set(CMAKE_VS_GLOBALS "DefaultLanguage=en-US" - "MinimumVisualStudioVersion=14.0" + "MinimumVisualStudioVersion=10.0" + "TestProperty=TestValue" ) +enable_language(CXX) + add_library(foo foo.cpp) diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake index 91cea0e..9c214f1 100644 --- a/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake +++ b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake @@ -1,4 +1,4 @@ -set(pch_header "CMakeFiles/tgt.dir/cmake_pch.hxx") +set(pch_header "CMakeFiles/tgt.dir/Debug/cmake_pch.hxx") set(pch_source [=[CMakeFiles\\tgt.dir\\cmake_pch.cxx]=]) if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${pch_header}") diff --git a/Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake b/Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake new file mode 100644 index 0000000..5b1701c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake @@ -0,0 +1,32 @@ +macro(check_project_file projectFile) + set(insideGlobals FALSE) + set(pathFound FALSE) + + if(NOT EXISTS "${projectFile}") + set(RunCMake_TEST_FAILED "Project file ${projectFile} does not exist.") + return() + endif() + + string(REPLACE "${RunCMake_TEST_BINARY_DIR}/" "" projectName ${projectFile}) + + file(STRINGS "${projectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<PropertyGroup Label=\"Globals\">.*$") + set(insideGlobals TRUE) + elseif(insideGlobals) + if(line MATCHES "^ *</PropertyGroup>.*$") + set(insideGlobals FALSE) + elseif(line MATCHES "^ *<VCTargetsPath>(.+)</VCTargetsPath>*$") + message(STATUS "Found VCTargetsPath = ${CMAKE_MATCH_1} in PropertyGroup 'Globals' in ${projectName}") + set(pathFound TRUE) + endif() + endif() + endforeach() + if(NOT pathFound) + set(RunCMake_TEST_FAILED "VCTargetsPath not found in \"Globals\" propertygroup in ${projectName}") + return() # This should intentionally return from the caller, not the macro + endif() +endmacro() + +check_project_file("${RunCMake_TEST_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION}/CompilerIdCXX/CompilerIdCXX.vcxproj") +check_project_file("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") diff --git a/Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake b/Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake new file mode 100644 index 0000000..6a6088f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) + +add_library(foo foo.cpp) diff --git a/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake b/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake new file mode 100644 index 0000000..15bbaf2 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake @@ -0,0 +1,66 @@ +macro(checkCompileAsWinRT projectPath) + if(RunCMake_TEST_FAILED) + return() + endif() + + if (NOT EXISTS "${projectPath}") + set(RunCMake_TEST_FAILED "Project file ${projectPath} does not exist.") + return() + endif() + + get_filename_component(projectName "${projectPath}" NAME_WE) + + cmake_parse_arguments("" "" "GLOBAL" "OVERRIDES_ENABLE;OVERRIDES_DISABLE" ${ARGN}) + + unset(sourceOverride) + + file(STRINGS "${projectPath}" lines) + set(foundGlobalWinRT false) + + foreach(line IN LISTS lines) + if(line MATCHES "^ *<CompileAsWinRT( Condition=\"[^\\\"]+\")?>(true|false)</CompileAsWinRT>$") + set(value ${CMAKE_MATCH_2}) + + if(sourceOverride) + set(expectedList) + + if(value) + set(expectedList _OVERRIDES_ENABLE) + else() + set(expectedList _OVERRIDES_DISABLE) + endif() + + if(NOT sourceOverride IN_LIST ${expectedList}) + set(RunCMake_TEST_FAILED + "${projectName}: Unexpected CompileAsWinRT override ${value} for ${sourceOverride}") + return() + endif() + else() + if (NOT _GLOBAL STREQUAL value) + set(RunCMake_TEST_FAILED + "${projectName}: Global CompileAsWinRT value is ${value}, but expected ${_GLOBAL}") + return() + endif() + + set(foundGlobalWinRT true) + endif() + elseif(line MATCHES "^ *<ClCompile Include=\"([^\"]+)\">$") + get_filename_component(sourceOverride "${CMAKE_MATCH_1}" NAME) + elseif(line MATCHES "^ *</ClCompile>$") + unset(sourceOverride) + endif() + endforeach() + + if(NOT foundGlobalWinRT AND DEFINED _GLOBAL) + set(RunCMake_TEST_FAILED "${projectName}: Global CompileAsWinRT not found or have invalid value, but expected") + return() + endif() +endmacro() + +checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagOnlyC.vcxproj" GLOBAL false) +checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagMixedCAndCxx.vcxproj" GLOBAL false) +checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagOnlyCxx.vcxproj" GLOBAL false) + +checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagOnlyC.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c) +checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagMixedCAndCxx.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c) +checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagOnlyCxx.vcxproj" GLOBAL true) diff --git a/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake b/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake new file mode 100644 index 0000000..139048b --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake @@ -0,0 +1,16 @@ +set(CMAKE_VS_WINRT_BY_DEFAULT true) + +enable_language(C) +enable_language(CXX) + +add_library(noFlagOnlyC empty.c) +add_library(noFlagMixedCAndCXX empty.c foo.cpp) +add_library(noFlagOnlyCXX foo.cpp) + +add_library(flagOnlyC empty.c) +add_library(flagMixedCAndCXX empty.c foo.cpp) +add_library(flagOnlyCXX foo.cpp) + +target_compile_options(flagOnlyC PRIVATE /ZW) +target_compile_options(flagMixedCAndCXX PRIVATE /ZW) +target_compile_options(flagOnlyCXX PRIVATE /ZW) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 6ecf3f2..342dbbc 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -8,6 +8,16 @@ run_cmake(XcodeAttributeLocation) run_cmake(XcodeAttributeGenex) run_cmake(XcodeAttributeGenexError) run_cmake(XcodeGenerateTopLevelProjectOnly) + +function(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeGenerateTopLevelProjectOnlyWithObjectLibrary-build) + run_cmake(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary-build ${CMAKE_COMMAND} --build . --target shared_lib) +endfunction() + +XcodeGenerateTopLevelProjectOnlyWithObjectLibrary() + run_cmake(XcodeObjectNeedsEscape) run_cmake(XcodeObjectNeedsQuote) run_cmake(XcodeOptimizationFlags) @@ -68,6 +78,15 @@ endfunction() XcodeObjcxxFlags(XcodeObjcFlags) XcodeObjcxxFlags(XcodeObjcxxFlags) +function(XcodeRemoveExcessiveISystem) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeRemoveExcessiveISystem-build) + run_cmake(XcodeRemoveExcessiveISystem) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(XcodeRemoveExcessiveISystem-build ${CMAKE_COMMAND} --build .) +endfunction() + +XcodeRemoveExcessiveISystem() + # Isolate device tests from host architecture selection. unset(ENV{CMAKE_OSX_ARCHITECTURES}) @@ -287,4 +306,16 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) xctest_lookup_test(tvOS appletvsimulator) endif() +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + function(XcodeRemoveExcessiveISystemSDK SDK) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeRemoveExcessiveISystemSDK-${SDK}-build) + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS") + run_cmake(XcodeRemoveExcessiveISystem) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(XcodeRemoveExcessiveISystemSDK-${SDK}-build ${CMAKE_COMMAND} --build . -- -sdk ${SDK}) + endfunction() + + XcodeRemoveExcessiveISystemSDK(iphoneos) + XcodeRemoveExcessiveISystemSDK(iphonesimulator) +endif() # Please add macOS-only tests above before the device-specific tests. diff --git a/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnlyWithObjectLibrary.cmake b/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnlyWithObjectLibrary.cmake new file mode 100644 index 0000000..67e4a00 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnlyWithObjectLibrary.cmake @@ -0,0 +1,3 @@ +set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE) +project(XcodeGenerateTopLevelProjectOnly NONE) +add_subdirectory(subproject_with_object_lib) diff --git a/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake b/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake index aa3eafc..4e85db6 100644 --- a/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake +++ b/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake @@ -1,4 +1,4 @@ -set(pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/cmake_pch.hxx") +set(pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Debug/cmake_pch.hxx") if(NOT EXISTS "${pch_header}") set(RunCMake_TEST_FAILED "Generated PCH header ${pch_header} does not exist.") diff --git a/Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake b/Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake new file mode 100644 index 0000000..44052f0 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake @@ -0,0 +1,52 @@ +cmake_minimum_required (VERSION 3.14) + +if(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") + set(USE_SWIFT 1) +else() + set(USE_SWIFT 0) +endif() + +if(IOS) + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO) + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + if(XCODE_VERSION VERSION_LESS 9) + set(USE_SWIFT 0) + endif() +endif () + +enable_language (CXX) + +if(USE_SWIFT) + enable_language (Swift) + if(NOT XCODE_VERSION VERSION_LESS 10.2) + set(CMAKE_Swift_LANGUAGE_VERSION 5.0) + elseif(NOT XCODE_VERSION VERSION_LESS 8.0) + set(CMAKE_Swift_LANGUAGE_VERSION 3.0) + endif() +endif() + +# Try to find ZLIB in the SDK rather than in system locations. +set(CMAKE_FIND_USE_PACKAGE_ROOT_PATH FALSE) +set(CMAKE_FIND_USE_CMAKE_PATH FALSE) +set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE) +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) +list(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH /usr/local /usr / /usr/X11R6 /usr/pkg /opt /sw /opt/local) + +find_package(ZLIB REQUIRED) +add_library (framework_dependency STATIC) +target_sources (framework_dependency PRIVATE use_cmath.cpp) +target_link_libraries(framework_dependency INTERFACE ZLIB::ZLIB) + +add_library (framework_test SHARED use_cmath.cpp) +if(USE_SWIFT) + target_sources(framework_test PRIVATE foo.swift) +endif() +target_link_libraries (framework_test PRIVATE framework_dependency) + +set_target_properties (framework_test PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION A + MACOSX_FRAMEWORK_IDENTIFIER "framework.test" + VERSION "1.0" + SOVERSION 1.0 + ) diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake index 7d83a70..c742f50 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake @@ -45,6 +45,7 @@ check_property("ENVIRONMENT" [=[key="FOO"]=]) check_property("ENVIRONMENT" [=[value="foo"]=]) check_property("ENVIRONMENT" [=[key="BAR"]=]) check_property("ENVIRONMENT" [=[value="bar"]=]) +check_property("WORKING_DIRECTORY" [=["/working/dir"]=]) expect_no_schema("NoSchema") diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake index be219f4..ce5c0c9 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake @@ -35,6 +35,7 @@ endfunction() create_scheme_for_property(EXECUTABLE myExecutable) create_scheme_for_property(ARGUMENTS "--foo;--bar=baz") create_scheme_for_property(ENVIRONMENT "FOO=foo;BAR=bar") +create_scheme_for_property(WORKING_DIRECTORY "/working/dir") add_executable(NoSchema main.cpp) set_target_properties(NoSchema PROPERTIES XCODE_GENERATE_SCHEME OFF) diff --git a/Tests/RunCMake/XcodeProject/foo.swift b/Tests/RunCMake/XcodeProject/foo.swift new file mode 100644 index 0000000..fb2d3dc --- /dev/null +++ b/Tests/RunCMake/XcodeProject/foo.swift @@ -0,0 +1,2 @@ +func foo() { +} diff --git a/Tests/RunCMake/XcodeProject/subproject_with_object_lib/CMakeLists.txt b/Tests/RunCMake/XcodeProject/subproject_with_object_lib/CMakeLists.txt new file mode 100644 index 0000000..ab400f4 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/subproject_with_object_lib/CMakeLists.txt @@ -0,0 +1,7 @@ +project(subproject_with_object_lib) + +add_library(object_lib_dependency OBJECT dummy.cpp) + +add_library(shared_lib SHARED dummy.cpp) +target_sources(shared_lib PRIVATE $<TARGET_OBJECTS:object_lib_dependency>) +set_target_properties(shared_lib PROPERTIES MACOSX_RPATH ON) diff --git a/Tests/RunCMake/XcodeProject/subproject_with_object_lib/dummy.cpp b/Tests/RunCMake/XcodeProject/subproject_with_object_lib/dummy.cpp new file mode 100644 index 0000000..bb4218a --- /dev/null +++ b/Tests/RunCMake/XcodeProject/subproject_with_object_lib/dummy.cpp @@ -0,0 +1,5 @@ +namespace { +void dummy() +{ +} +} diff --git a/Tests/RunCMake/XcodeProject/use_cmath.cpp b/Tests/RunCMake/XcodeProject/use_cmath.cpp new file mode 100644 index 0000000..8a58af5 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/use_cmath.cpp @@ -0,0 +1,6 @@ +#include <cmath> + +bool foo(double arg) +{ + return std::isfinite(arg); +} diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake index 34dcc67..c77b43c 100644 --- a/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake +++ b/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake @@ -11,7 +11,7 @@ string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAK add_library(example SHARED LinkOptionsLib.c) # use LAUNCH facility to dump linker command -set_property(TARGET example PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"") +set_property(TARGET example PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"") add_dependencies (example dump) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt index 38566fb..206ab21 100644 --- a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt @@ -1 +1,2 @@ -Unable to find executable:.*MyThirdPartyDependency/src/thirdparty +Unable to find executable:.*MyThirdPartyDependency/src(/[^/ +]+)?/thirdparty diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 6877e6a..d0a6e5f 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -1,6 +1,9 @@ include(RunCTest) set(RunCMake_TEST_TIMEOUT 60) +unset(ENV{CTEST_PARALLEL_LEVEL}) +unset(ENV{CTEST_OUTPUT_ON_FAILURE}) + set(CASE_CTEST_TEST_ARGS "") set(CASE_CTEST_TEST_LOAD "") @@ -71,7 +74,50 @@ add_test(NAME PassingTest COMMAND ${CMAKE_COMMAND} -E echo PassingTestOutput) add_test(NAME FailingTest COMMAND ${CMAKE_COMMAND} -E no_such_command) ]]) - unset(ENV{CTEST_PARALLEL_LEVEL}) run_ctest(TestOutputSize) endfunction() run_TestOutputSize() + +run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3) +run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1) + +function(run_TestRepeat case return_value ) + set(CASE_CTEST_TEST_ARGS RETURN_VALUE result EXCLUDE RunCMakeVersion ${ARGN}) + string(CONCAT suffix_code [[ +add_test(NAME testRepeat + COMMAND ${CMAKE_COMMAND} -D COUNT_FILE=${CMAKE_CURRENT_BINARY_DIR}/count.cmake + -P "]] "${RunCMake_SOURCE_DIR}/TestRepeat${case}" [[.cmake") +set_property(TEST testRepeat PROPERTY TIMEOUT 5) + ]]) + string(APPEND CASE_CMAKELISTS_SUFFIX_CODE "${suffix_code}") + + run_ctest(TestRepeat${case}) + + #write to end of the test file logic to Verify we get the expected + #return code + string(REPLACE "RETURN_VALUE:" "" return_value "${return_value}" ) + file(APPEND "${RunCMake_BINARY_DIR}/TestRepeat${case}/test.cmake" +" + + set(expected_result ${return_value}) + message(STATUS \${result}) + if(NOT result EQUAL expected_result) + message(FATAL_ERROR \"expected a return value of: \${expected_result}, + instead got: \${result}\") + endif() +" + ) +endfunction() + +run_TestRepeat(UntilFail RETURN_VALUE:1 REPEAT UNTIL_FAIL:3) +run_TestRepeat(UntilPass RETURN_VALUE:0 REPEAT UNTIL_PASS:3) +run_TestRepeat(AfterTimeout RETURN_VALUE:0 REPEAT AFTER_TIMEOUT:3) + +# test repeat and not run tests interact correctly +set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME testNotRun + COMMAND ${CMAKE_COMMAND}/doesnt_exist) + set_property(TEST testNotRun PROPERTY TIMEOUT 5) + ]]) +run_TestRepeat(NotRun RETURN_VALUE:1 REPEAT UNTIL_PASS:3) +unset(CASE_CMAKELISTS_SUFFIX_CODE) diff --git a/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-stdout.txt new file mode 100644 index 0000000..17657c5 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-stdout.txt @@ -0,0 +1,10 @@ +Test project [^ +]*/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-build + Start 1: testRepeat +1/1 Test #1: testRepeat .......................\*\*\*Timeout +[0-9.]+ sec + Start 1: testRepeat + Test #1: testRepeat ....................... Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout.cmake b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout.cmake new file mode 100644 index 0000000..abde4f0 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout.cmake @@ -0,0 +1,10 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(NOT COUNT EQUAL 2) + message("this test times out except on the 2nd run") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10) +endif() diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad1-result.txt b/Tests/RunCMake/ctest_test/TestRepeatBad1-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad1-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad1-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatBad1-stderr.txt new file mode 100644 index 0000000..37cffbf --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad1-stderr.txt @@ -0,0 +1 @@ +Repeat option invalid value: UNKNOWN:3 diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad2-result.txt b/Tests/RunCMake/ctest_test/TestRepeatBad2-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad2-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad2-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatBad2-stderr.txt new file mode 100644 index 0000000..ca5cef7 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad2-stderr.txt @@ -0,0 +1 @@ +Repeat option invalid value: UNTIL_FAIL:-1 diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt new file mode 100644 index 0000000..a69932d --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt @@ -0,0 +1 @@ +.*Unable to find executable.* diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt new file mode 100644 index 0000000..72c98bc --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt @@ -0,0 +1,5 @@ +.* +50% tests passed, 1 tests failed out of 2 +.* +The following tests FAILED: +.*testNotRun.*Not Run.* diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake b/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake new file mode 100644 index 0000000..abde4f0 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun.cmake @@ -0,0 +1,10 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(NOT COUNT EQUAL 2) + message("this test times out except on the 2nd run") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10) +endif() diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilFail-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatUntilFail-stdout.txt new file mode 100644 index 0000000..5f91a67 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilFail-stdout.txt @@ -0,0 +1,13 @@ +Test project [^ +]*/Tests/RunCMake/ctest_test/TestRepeatUntilFail-build + Start 1: testRepeat + Test #1: testRepeat ....................... Passed +[0-9.]+ sec + Start 1: testRepeat + Test #1: testRepeat .......................\*\*\*Failed +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[ ]+1 - testRepeat \(Failed\)$ diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilFail.cmake b/Tests/RunCMake/ctest_test/TestRepeatUntilFail.cmake new file mode 100644 index 0000000..5eb0d8a --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilFail.cmake @@ -0,0 +1,9 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(COUNT EQUAL 2) + message(FATAL_ERROR "this test fails on the 2nd run") +endif() diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilPass-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatUntilPass-stdout.txt new file mode 100644 index 0000000..bc6939a --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilPass-stdout.txt @@ -0,0 +1,10 @@ +Test project [^ +]*/Tests/RunCMake/ctest_test/TestRepeatUntilPass-build + Start 1: testRepeat +1/1 Test #1: testRepeat .......................\*\*\*Failed +[0-9.]+ sec + Start 1: testRepeat + Test #1: testRepeat ....................... Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilPass.cmake b/Tests/RunCMake/ctest_test/TestRepeatUntilPass.cmake new file mode 100644 index 0000000..0662522 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilPass.cmake @@ -0,0 +1,9 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(NOT COUNT EQUAL 2) + message(FATAL_ERROR "this test passes only on the 2nd run") +endif() diff --git a/Tests/RunCMake/export/Repeat.cmake b/Tests/RunCMake/export/Repeat.cmake new file mode 100644 index 0000000..f3262e7 --- /dev/null +++ b/Tests/RunCMake/export/Repeat.cmake @@ -0,0 +1,5 @@ +add_library(foo INTERFACE) +export(TARGETS foo FILE foo.cmake) +export(TARGETS foo FILE foo.cmake) +add_subdirectory(Repeat) +include(CMakePackageConfigHelpers) diff --git a/Tests/RunCMake/export/Repeat/CMakeLists.txt b/Tests/RunCMake/export/Repeat/CMakeLists.txt new file mode 100644 index 0000000..b37f6ca --- /dev/null +++ b/Tests/RunCMake/export/Repeat/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(bar INTERFACE) +export(TARGETS bar FILE ${CMAKE_BINARY_DIR}/foo.cmake) diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 4d2f217..df35d95 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -2,6 +2,7 @@ include(RunCMake) run_cmake(CustomTarget) run_cmake(Empty) +run_cmake(Repeat) run_cmake(TargetNotFound) run_cmake(AppendExport) run_cmake(OldIface) diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt new file mode 100644 index 0000000..05c9a91 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build-stdout.txt @@ -0,0 +1 @@ +test2/test_folder_symlink diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt new file mode 100644 index 0000000..05c9a91 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild-stdout.txt @@ -0,0 +1 @@ +test2/test_folder_symlink diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt new file mode 100644 index 0000000..1fbac01 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-stdout.txt @@ -0,0 +1 @@ +.*Running CMake on GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake new file mode 100644 index 0000000..da40534 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake.cmake @@ -0,0 +1,10 @@ +cmake_policy(SET CMP0009 NEW) +message(STATUS "Running CMake on GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake") +file(GLOB_RECURSE + CONTENT_LIST + CONFIGURE_DEPENDS + LIST_DIRECTORIES false + RELATIVE "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/test2/*" + ) +add_custom_target(CONTENT_ECHO ALL ${CMAKE_COMMAND} -E echo ${CONTENT_LIST}) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 5db4b3b..f5461ad 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -69,7 +69,7 @@ if(NOT WIN32 OR CYGWIN) run_cmake(INSTALL-FOLLOW_SYMLINK_CHAIN) endif() -if(RunCMake_GENERATOR STREQUAL "Ninja") +if(RunCMake_GENERATOR MATCHES "Ninja") # Detect ninja version so we know what tests can be supported. execute_process( COMMAND "${RunCMake_MAKE_PROGRAM}" --version @@ -90,7 +90,7 @@ if(RunCMake_GENERATOR STREQUAL "Ninja") endif() endif() -if(RunCMake_GENERATOR STREQUAL "Ninja" AND "${ninja_version}" VERSION_LESS 1.8) +if(RunCMake_GENERATOR MATCHES "Ninja" AND "${ninja_version}" VERSION_LESS 1.8) run_cmake(GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version) else() run_cmake(GLOB-warn-CONFIGURE_DEPENDS-late) @@ -111,7 +111,7 @@ else() set(tf_1 "${RunCMake_TEST_BINARY_DIR}/test/1.txt") file(WRITE "${tf_1}" "1") - message(STATUS "GLOB-RerunCMake: first configuration...") + message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: first configuration...") run_cmake(GLOB-CONFIGURE_DEPENDS-RerunCMake) run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-build ${CMAKE_COMMAND} --build .) @@ -125,10 +125,25 @@ else() execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: remove first test file...") - file(REMOVE "${RunCMake_TEST_BINARY_DIR}/test/1.txt") + file(REMOVE "${tf_1}") run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second ${CMAKE_COMMAND} --build .) run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .) + if(NOT WIN32 OR CYGWIN) + message(STATUS "GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake: link the first test directory into a new directory...") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test2") + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${RunCMake_TEST_BINARY_DIR}/test" "${RunCMake_TEST_BINARY_DIR}/test2/test_folder_symlink") + + message(STATUS "GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake: first configuration...") + run_cmake(GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake) + run_cmake_command(GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-build ${CMAKE_COMMAND} --build .) + + message(STATUS "GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake: add another file in the linked directory...") + set(tf_3 "${RunCMake_TEST_BINARY_DIR}/test/3.txt") + file(WRITE "${tf_3}" "3") + run_cmake_command(GLOB-CONFIGURE_DEPENDS-CMP0009-RerunCMake-rebuild ${CMAKE_COMMAND} --build .) + endif() + unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_DEFAULT_stderr) diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stderr.txt b/Tests/RunCMake/find_file/PrefixInPATH-stderr.txt new file mode 100644 index 0000000..0d77571 --- /dev/null +++ b/Tests/RunCMake/find_file/PrefixInPATH-stderr.txt @@ -0,0 +1,13 @@ + find_file called with the following settings:.* + VAR: PrefixInPATH_INCLUDE_DIR + NAMES: \"PrefixInPATH\.h\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_file considered the following locations:.* +.*include/PrefixInPATH.* diff --git a/Tests/RunCMake/find_file/PrefixInPATH.cmake b/Tests/RunCMake/find_file/PrefixInPATH.cmake index 1e33c08..c334d89 100644 --- a/Tests/RunCMake/find_file/PrefixInPATH.cmake +++ b/Tests/RunCMake/find_file/PrefixInPATH.cmake @@ -1,4 +1,10 @@ set(ENV_PATH "$ENV{PATH}") + +set(CMAKE_FIND_DEBUG_MODE 1) +set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/bin") +find_file(PrefixInPATH_INCLUDE_DIR NAMES PrefixInPATH.h) +set(CMAKE_FIND_DEBUG_MODE 0) + foreach(path "/does_not_exist" "" "/bin" "/sbin") unset(PrefixInPATH_INCLUDE_DIR CACHE) set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_library/FromPATHEnv-stderr.txt new file mode 100644 index 0000000..a690eec --- /dev/null +++ b/Tests/RunCMake/find_library/FromPATHEnv-stderr.txt @@ -0,0 +1,28 @@ + find_library called with the following settings:.* + VAR: CREATED_LIBRARY + NAMES: \"created\" + \"created_no_exist\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_library considered the following locations:.* + The item was not found.* + find_library called with the following settings:.* + VAR: CREATED_LIBRARY + NAMES: \"created\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_library considered the following locations:.* + The item was found at.* +.*lib/libcreated.a diff --git a/Tests/RunCMake/find_library/FromPATHEnv.cmake b/Tests/RunCMake/find_library/FromPATHEnv.cmake index fec041d..c24e640 100644 --- a/Tests/RunCMake/find_library/FromPATHEnv.cmake +++ b/Tests/RunCMake/find_library/FromPATHEnv.cmake @@ -4,6 +4,19 @@ set(ENV_PATH "$ENV{PATH}") file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created") +set(CMAKE_FIND_DEBUG_MODE 1) +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) + +set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/lib") +find_library(CREATED_LIBRARY NAMES created created_no_exist) + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) + +set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/lib") +find_library(CREATED_LIBRARY NAMES created) +set(CMAKE_FIND_DEBUG_MODE 0) + + foreach(path "/does_not_exist" "/lib" "") unset(CREATED_LIBRARY CACHE) set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}") diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stderr.txt b/Tests/RunCMake/find_library/PrefixInPATH-stderr.txt new file mode 100644 index 0000000..1d24c84 --- /dev/null +++ b/Tests/RunCMake/find_library/PrefixInPATH-stderr.txt @@ -0,0 +1,14 @@ + find_library called with the following settings:.* + VAR: PrefixInPATH_LIBRARY + NAMES: \"PrefixInPATH\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_library considered the following locations:.* +.*/does_not_exist.* + The item was not found diff --git a/Tests/RunCMake/find_library/PrefixInPATH.cmake b/Tests/RunCMake/find_library/PrefixInPATH.cmake index f1b8b18..e27d362 100644 --- a/Tests/RunCMake/find_library/PrefixInPATH.cmake +++ b/Tests/RunCMake/find_library/PrefixInPATH.cmake @@ -2,6 +2,12 @@ list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) set(ENV_PATH "$ENV{PATH}") + +set(CMAKE_FIND_DEBUG_MODE 1) +set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist") +find_library(PrefixInPATH_LIBRARY NAMES PrefixInPATH) +set(CMAKE_FIND_DEBUG_MODE 0) + foreach(path "/does_not_exist" "" "/bin" "/sbin") unset(PrefixInPATH_LIBRARY CACHE) set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") diff --git a/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt new file mode 100644 index 0000000..b35f05e --- /dev/null +++ b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt @@ -0,0 +1,20 @@ +CMake Debug Log at FromPATHEnv.cmake:5 \(find_package\): + find_package considered the following paths for Resolved.cmake.* +.*/Modules/FindResolved.cmake.* + The file was not found.* + <PackageName>_ROOT CMake variable.* + CMAKE_PREFIX_PATH variable.* + CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.* + Env variable Resolved_DIR.* + CMAKE_PREFIX_PATH env variable.* + Paths specified by the find_package HINTS option.* + Standard system environment variables.* +.*Tests/RunCMake/find_package/PackageRoot.* + CMake User Package Registry.* + CMake variables defined in the Platform file.* + CMake System Package Registry.* + Paths specified by the find_package PATHS option.* + find_package considered the following locations for the Config module:.* +.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake.* + The file was found at.* +.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake diff --git a/Tests/RunCMake/find_package/FromPATHEnv.cmake b/Tests/RunCMake/find_package/FromPATHEnv.cmake index 4822b13..ceb79b6 100644 --- a/Tests/RunCMake/find_package/FromPATHEnv.cmake +++ b/Tests/RunCMake/find_package/FromPATHEnv.cmake @@ -1,4 +1,10 @@ set(ENV_PATH "$ENV{PATH}") + +set(CMAKE_FIND_DEBUG_MODE ON) +set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Resolved QUIET) +set(CMAKE_FIND_DEBUG_MODE OFF) + foreach(path "/does_not_exist" "/PackageRoot" "") unset(Resolved_FOUND CACHE) set(Resolved_DIR "") diff --git a/Tests/RunCMake/find_package/MissingConfigDebug-stderr.txt b/Tests/RunCMake/find_package/MissingConfigDebug-stderr.txt new file mode 100644 index 0000000..379bf7a --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigDebug-stderr.txt @@ -0,0 +1,18 @@ + <PackageName>_ROOT CMake variable.* + CMAKE_PREFIX_PATH variable.* + CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.* + Env variable NotHere_DIR.* + CMAKE_PREFIX_PATH env variable.* + Standard system environment variables.* + CMake User Package Registry.* + CMake variables defined in the Platform file.* + CMake System Package Registry.* + Paths specified by the find_package PATHS option.* +.* + .*NotHereConfig.cmake + .*nothere-config.cmake +.* +CMake Warning at MissingConfigDebug.cmake:3 \(message\): + This warning must be reachable. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/find_package/MissingConfigDebug.cmake b/Tests/RunCMake/find_package/MissingConfigDebug.cmake new file mode 100644 index 0000000..4e3bb22 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigDebug.cmake @@ -0,0 +1,4 @@ +set(CMAKE_FIND_DEBUG_MODE ON) +find_package(NotHere CONFIG) +message(WARNING "This warning must be reachable.") +set(CMAKE_FIND_DEBUG_MODE OFF) diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 208f83c..5186297 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -13,6 +13,7 @@ run_cmake(MissingNormalWarnNoModuleNew) run_cmake(MissingModule) run_cmake(MissingModuleRequired) run_cmake(MissingConfig) +run_cmake(MissingConfigDebug) run_cmake(MissingConfigOneName) run_cmake(MissingConfigRequired) run_cmake(MissingConfigVersion) diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_path/FromPATHEnv-stderr.txt new file mode 100644 index 0000000..088efd5 --- /dev/null +++ b/Tests/RunCMake/find_path/FromPATHEnv-stderr.txt @@ -0,0 +1,27 @@ + find_path called with the following settings:.* + VAR: PATH_IN_ENV_PATH + NAMES: \"PrefixInPATH\.h\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_path considered the following locations:.* + The item was not found.* + find_path called with the following settings:.* + VAR: PATH_IN_ENV_PATH + NAMES: \"PrefixInPATH\.h\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_path considered the following locations:.* + The item was found at.* +.*include/PrefixInPATH.* diff --git a/Tests/RunCMake/find_path/FromPATHEnv.cmake b/Tests/RunCMake/find_path/FromPATHEnv.cmake index af13d09..535e624 100644 --- a/Tests/RunCMake/find_path/FromPATHEnv.cmake +++ b/Tests/RunCMake/find_path/FromPATHEnv.cmake @@ -1,4 +1,16 @@ set(ENV_PATH "$ENV{PATH}") + +set(CMAKE_FIND_DEBUG_MODE 1) +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) + +set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/include") +find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h) + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) +find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h) + +set(CMAKE_FIND_DEBUG_MODE 0) + foreach(path "/does_not_exist" "/include" "") unset(PATH_IN_ENV_PATH CACHE) set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") diff --git a/Tests/RunCMake/find_program/EnvAndHints-stderr.txt b/Tests/RunCMake/find_program/EnvAndHints-stderr.txt new file mode 100644 index 0000000..8951345 --- /dev/null +++ b/Tests/RunCMake/find_program/EnvAndHints-stderr.txt @@ -0,0 +1,28 @@ + find_program called with the following settings:.* + VAR: PROG + NAMES: \"testAandB\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_program considered the following locations:.* + The item was found at.* +.*testAandB +.* + find_program called with the following settings:.* + VAR: PROG + NAMES: \"testAandB\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_program considered the following locations:.* + The item was not found.* diff --git a/Tests/RunCMake/find_program/EnvAndHints.cmake b/Tests/RunCMake/find_program/EnvAndHints.cmake index 0f12eff..beed873 100644 --- a/Tests/RunCMake/find_program/EnvAndHints.cmake +++ b/Tests/RunCMake/find_program/EnvAndHints.cmake @@ -1,4 +1,5 @@ +set(CMAKE_FIND_DEBUG_MODE 1) set(ENV_PATH "$ENV{PATH}") set(ENV{PATH} ${CMAKE_CURRENT_SOURCE_DIR}/A) find_program(PROG @@ -13,6 +14,7 @@ find_program(PROG ) message(STATUS "PROG='${PROG}'") unset(PROG CACHE) +set(CMAKE_FIND_DEBUG_MODE 0) find_program(PROG NAMES testAandB diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake index 4b74cfe..22a0a75 100644 --- a/Tests/RunCMake/foreach/RunCMakeTest.cmake +++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake @@ -1,3 +1,21 @@ include(RunCMake) run_cmake(BadRangeInFunction) +run_cmake(foreach-all-test) +run_cmake(foreach-ITEMS-multiple-iter-vars-test) +run_cmake(foreach-LISTS-multiple-iter-vars-test) +run_cmake(foreach-ZIP_LISTS-test) +run_cmake(foreach-ITEMS-with-ZIP_LISTS-mix-test) +run_cmake(foreach-LISTS-with-ZIP_LISTS-mix-test) +run_cmake(foreach-ZIP_LISTS-with-ITEMS-mix-test) +run_cmake(foreach-ZIP_LISTS-with-LISTS-mix-test) +run_cmake(foreach-ZIP_LISTS-multiple-iter-vars-test) +run_cmake(foreach-ZIP_LISTS-iter-vars-mismatch-test-1) +run_cmake(foreach-ZIP_LISTS-iter-vars-mismatch-test-2) +run_cmake(foreach-RANGE-non-int-test-1) +run_cmake(foreach-RANGE-non-int-test-2-1) +run_cmake(foreach-RANGE-non-int-test-2-2) +run_cmake(foreach-RANGE-non-int-test-3-1) +run_cmake(foreach-RANGE-non-int-test-3-2) +run_cmake(foreach-RANGE-non-int-test-3-3) +run_cmake(foreach-RANGE-invalid-test) diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-result.txt b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-stderr.txt new file mode 100644 index 0000000..d174bb1 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ITEMS-multiple-iter-vars-test.cmake:1 \(foreach\): + ITEMS or LISTS require exactly one iteration variable +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test.cmake b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test.cmake new file mode 100644 index 0000000..55d33a8 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test.cmake @@ -0,0 +1,2 @@ +foreach(one two IN ITEMS one two) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-stderr.txt new file mode 100644 index 0000000..f7d5ae7 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake new file mode 100644 index 0000000..28099a0 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN ITEMS one two three ZIP_LISTS blah) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-result.txt b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-stderr.txt b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-stderr.txt new file mode 100644 index 0000000..f2f83c2 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-LISTS-multiple-iter-vars-test.cmake:1 \(foreach\): + ITEMS or LISTS require exactly one iteration variable +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test.cmake b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test.cmake new file mode 100644 index 0000000..78f3847 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test.cmake @@ -0,0 +1,2 @@ +foreach(one two IN LISTS one two) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-stderr.txt new file mode 100644 index 0000000..42f8d1e --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-LISTS-with-ZIP_LISTS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test.cmake new file mode 100644 index 0000000..8a919dd --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN LISTS one two three ZIP_LISTS blah) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt new file mode 100644 index 0000000..66efdc1 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-invalid-test\.cmake:[0-9]+ \(foreach\): + foreach called with incorrect range specification: start 2, stop 1, step 1 +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake new file mode 100644 index 0000000..2f8eaba --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 2 1 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-stderr.txt new file mode 100644 index 0000000..78355dc --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-1\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1.cmake new file mode 100644 index 0000000..452fbdf --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE b) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-stderr.txt new file mode 100644 index 0000000..787ffc1 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-2-1\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1.cmake new file mode 100644 index 0000000..885c805 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE b 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-stderr.txt new file mode 100644 index 0000000..70cc73f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-2-2\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2.cmake new file mode 100644 index 0000000..d52aeb9 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 1 b) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-stderr.txt new file mode 100644 index 0000000..5803fe8 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-3-1\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1.cmake new file mode 100644 index 0000000..33a488d --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE b 1 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-stderr.txt new file mode 100644 index 0000000..189c60d --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-3-2\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2.cmake new file mode 100644 index 0000000..ff119d3 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 1 b 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-stderr.txt new file mode 100644 index 0000000..ee9e62c --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-3-3\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3.cmake new file mode 100644 index 0000000..fdebdf0 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 1 1 b) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-stderr.txt new file mode 100644 index 0000000..fa51e46 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake:1 \(foreach\): + Expected 3 list variables, but given 4 +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake new file mode 100644 index 0000000..458b6ca --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake @@ -0,0 +1,2 @@ +foreach(less than lists IN ZIP_LISTS list_1 list_2 list_3 list_4) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-stderr.txt new file mode 100644 index 0000000..7b6b484 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake:1 \(foreach\): + Expected 3 list variables, but given 2 +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake new file mode 100644 index 0000000..d24d99c --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake @@ -0,0 +1,2 @@ +foreach(greater than lists IN ZIP_LISTS list_1 list_2) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test-stdout.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test-stdout.txt new file mode 100644 index 0000000..e009d15 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test-stdout.txt @@ -0,0 +1,6 @@ +-- foreach\(\.\.\. IN ZIP_LISTS\): +-- Begin output +-- | one, satu, raz +-- | two, dua, dva +-- | three, tiga, tri +-- End output diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake new file mode 100644 index 0000000..9647dea --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake @@ -0,0 +1,42 @@ +function(foreachTest result list_var_1 list_var_2 list_var_3) + set(_options MUTE) + set(_one_value_args) + set(_multi_value_args) + cmake_parse_arguments(PARSE_ARGV 3 _arg "${_options}" "${_one_value_args}" "${_multi_value_args}") + + set(_has_any_output FALSE) + list(APPEND CMAKE_MESSAGE_INDENT "| ") + foreach(first second third IN ZIP_LISTS ${list_var_1} ${list_var_2} ${list_var_3}) + if(NOT first) + set(first "[undefiend]") + endif() + if(NOT second) + set(second "[undefiend]") + endif() + if(NOT third) + set(third "[undefiend]") + endif() + if(NOT _arg_MUTE) + message(STATUS "${first}, ${second}, ${third}") + endif() + set(_has_any_output TRUE) + endforeach() + set(${result} ${_has_any_output} PARENT_SCOPE) +endfunction() + +function(foreachTestDecorated list_var_1 list_var_2 list_var_3) + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(STATUS "Begin output") + foreachTest(_has_any_output ${list_var_1} ${list_var_2} ${list_var_3}) + if(NOT _has_any_output) + message(STATUS "--> empty-output <--") + endif() + message(STATUS "End output") +endfunction() + +list(APPEND english one two three) +list(APPEND bahasa satu dua tiga) +list(APPEND russian raz dva tri) + +message(STATUS "foreach(... IN ZIP_LISTS):") +foreachTestDecorated(english bahasa russian) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt new file mode 100644 index 0000000..25433fd --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt @@ -0,0 +1,19 @@ +-- foreach\(IN ZIP_LISTS\): +-- <<< empty lists case >>> +-- Begin output +-- --> empty-output <-- +-- End output +-- <<< same lengths lists case >>> +-- Begin output +-- | one, satu, raz +-- | two, dua, dva +-- | three, tiga, tri +-- End output +-- <<< different lengths lists case >>> +-- Begin output +-- | one, satu, raz +-- | two, dua, dva +-- | three, tiga, tri +-- | \[undefiend\], empat, \[undefiend\] +-- End output +-- <<< test variable value restored -- PASSED >>> diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake new file mode 100644 index 0000000..56cfe64 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake @@ -0,0 +1,68 @@ +function(foreachTest result list_var_1 list_var_2 list_var_3) + set(_options MUTE) + set(_one_value_args) + set(_multi_value_args) + cmake_parse_arguments(PARSE_ARGV 3 _arg "${_options}" "${_one_value_args}" "${_multi_value_args}") + + set(_has_any_output FALSE) + list(APPEND CMAKE_MESSAGE_INDENT "| ") + foreach(num IN ZIP_LISTS ${list_var_1} ${list_var_2} ${list_var_3}) + foreach(i RANGE 2) + if(NOT num_${i}) + set(num_${i} "[undefiend]") + endif() + endforeach() + if(NOT _arg_MUTE) + message(STATUS "${num_0}, ${num_1}, ${num_2}") + endif() + set(_has_any_output TRUE) + endforeach() + set(${result} ${_has_any_output} PARENT_SCOPE) +endfunction() + +function(foreachTestDecorated list_var_1 list_var_2 list_var_3) + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(STATUS "Begin output") + foreachTest(_has_any_output ${list_var_1} ${list_var_2} ${list_var_3}) + if(NOT _has_any_output) + message(STATUS "--> empty-output <--") + endif() + message(STATUS "End output") +endfunction() + +message(STATUS "foreach(IN ZIP_LISTS):") +list(APPEND CMAKE_MESSAGE_INDENT " ") + +set(english) +set(bahasa) +set(russian) + +message(STATUS "<<< empty lists case >>>") +foreachTestDecorated(english bahasa russian) + +list(APPEND english one two three) +list(APPEND bahasa satu dua tiga) +list(APPEND russian raz dva tri) + +message(STATUS "<<< same lengths lists case >>>") +foreachTestDecorated(english bahasa russian) + +list(APPEND bahasa empat) + +message(STATUS "<<< different lengths lists case >>>") +foreachTestDecorated(english bahasa russian) + +set(num_0 "old-0") +set(num_1 "old-1") +set(num_2 "old-2") +foreachTest(_ english bahasa russian MUTE) +set(check PASSED) +foreach(i RANGE 2) + if(NOT "${num_${i}}" STREQUAL "old-${i}") + message(SEND_ERROR "num_${i} value is corrupted") + set(check FAILED) + endif() +endforeach() +message(STATUS "<<< test variable value restored -- ${check} >>>") + +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-stderr.txt new file mode 100644 index 0000000..0dcab01 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake new file mode 100644 index 0000000..71ed842 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN ZIP_LISTS blah ITEMS blah) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-stderr.txt new file mode 100644 index 0000000..a6b6e9c --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-with-LISTS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test.cmake new file mode 100644 index 0000000..11a97b2 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN ZIP_LISTS blah LISTS blah) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-all-test-stdout.txt b/Tests/RunCMake/foreach/foreach-all-test-stdout.txt new file mode 100644 index 0000000..e8f622d --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-all-test-stdout.txt @@ -0,0 +1,44 @@ +-- foreach\(RANGE\): +-- \[0\.\.1\]/1 +-- < 0 +-- < 1 +-- \[1\.\.1\]/1 +-- < 1 +-- \[0\.\.10\]/2 +-- < 0 +-- < 2 +-- < 4 +-- < 6 +-- < 8 +-- < 10 +-- \[-10\.\.0\]/3 +-- < -10 +-- < -7 +-- < -4 +-- < -1 +-- \[0\.\.-10\]/-5 +-- < 0 +-- < -5 +-- < -10 +-- foreach\(IN ITEMS\): +-- < one +-- < two +-- < three +-- foreach\(IN LISTS\): +-- < satu +-- < dua +-- < tiga +-- foreach\(IN LISTS and ITEMS\): +-- < satu +-- < dua +-- < tiga +-- < one +-- < two +-- < three +-- foreach\(IN ITEMS and LISTS\): +-- < one +-- < two +-- < three +-- < satu +-- < dua +-- < tiga diff --git a/Tests/RunCMake/foreach/foreach-all-test.cmake b/Tests/RunCMake/foreach/foreach-all-test.cmake new file mode 100644 index 0000000..2e377c8 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-all-test.cmake @@ -0,0 +1,67 @@ +message(STATUS "foreach(RANGE):") +list(APPEND CMAKE_MESSAGE_INDENT " ") + +message(STATUS "[0..1]/1") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 1) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[1..1]/1") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 1 1) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[0..10]/2") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 0 10 2) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[-10..0]/3") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE -10 0 3) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[0..-10]/-5") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 0 -10 -5) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN ITEMS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i IN ITEMS one two three) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN LISTS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +list(APPEND count satu dua tiga) +foreach(i IN LISTS count) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN LISTS and ITEMS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i IN LISTS count ITEMS one two three) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN ITEMS and LISTS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i IN ITEMS one two three LISTS count) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/Tests/RunCMake/function/CMAKE_CURRENT_FUNCTION-stdout.txt b/Tests/RunCMake/function/CMAKE_CURRENT_FUNCTION-stdout.txt new file mode 100644 index 0000000..5ebc89a --- /dev/null +++ b/Tests/RunCMake/function/CMAKE_CURRENT_FUNCTION-stdout.txt @@ -0,0 +1,7 @@ +function\(print_self\) + file\(STRINGS "\${CMAKE_CURRENT_FUNCTION_LIST_FILE}" _lines\) + math\(EXPR _begin "\${CMAKE_CURRENT_FUNCTION_LIST_LINE} - 1"\) + list\(SUBLIST _lines \${_begin} 7 _lines\) # This function has 7 lines only + list\(JOIN _lines "\\n" _lines\) + message\(STATUS "Print the `\${CMAKE_CURRENT_FUNCTION}` function:\\n\${_lines}"\) +endfunction\(\) diff --git a/Tests/RunCMake/function/CMAKE_CURRENT_FUNCTION.cmake b/Tests/RunCMake/function/CMAKE_CURRENT_FUNCTION.cmake new file mode 100644 index 0000000..38c032f --- /dev/null +++ b/Tests/RunCMake/function/CMAKE_CURRENT_FUNCTION.cmake @@ -0,0 +1,94 @@ +set(_THIS_FILE "${CMAKE_CURRENT_LIST_FILE}") +set(_THIS_DIR "${CMAKE_CURRENT_LIST_DIR}") + +if(CMAKE_CURRENT_FUNCTION) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION` is not expected to be set here") +endif() +if(CMAKE_CURRENT_FUNCTION_LIST_FILE) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION_LIST_FILE` is not expected to be set here") +endif() +if(CMAKE_CURRENT_FUNCTION_LIST_DIR) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION_LIST_DIR` is not expected to be set here") +endif() +if(CMAKE_CURRENT_FUNCTION_LIST_LINE) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION_LIST_LINE` is not expected to be set here") +endif() + +function(bar) + if(NOT CMAKE_CURRENT_FUNCTION STREQUAL "bar") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_FILE MATCHES "^.*/CMAKE_CURRENT_FUNCTION.cmake$") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_FILE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_FILE STREQUAL _THIS_FILE) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_FILE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_DIR MATCHES "^.*/Tests/RunCMake/function$") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_DIR`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_DIR STREQUAL _THIS_DIR) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_DIR`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_LINE EQUAL 17) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_LINE`") + endif() +endfunction() + +function(foo) + if(NOT CMAKE_CURRENT_FUNCTION STREQUAL "foo") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_FILE MATCHES "^.*/function/CMAKE_CURRENT_FUNCTION.cmake$") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_FILE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_FILE STREQUAL _THIS_FILE) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_FILE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_DIR MATCHES "^.*/Tests/RunCMake/function$") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_DIR`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_LINE EQUAL 38) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_LINE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_DIR STREQUAL _THIS_DIR) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_DIR`") + endif() + bar() +endfunction() + +foo() + +if(CMAKE_CURRENT_FUNCTION) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION` is not expected to be set here") +endif() +if(CMAKE_CURRENT_FUNCTION_LIST_FILE) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION_LIST_FILE` is not expected to be set here") +endif() +if(CMAKE_CURRENT_FUNCTION_LIST_DIR) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION_LIST_DIR` is not expected to be set here") +endif() +if(CMAKE_CURRENT_FUNCTION_LIST_LINE) + message(SEND_ERROR "`CMAKE_CURRENT_FUNCTION_LIST_LINE` is not expected to be set here") +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/DummyMacro.cmake") + +function(calling_macro) + dummy() +endfunction() + +calling_macro() + +cmake_policy(SET CMP0007 NEW) + +# ATTENTION `CMAKE_CURRENT_LIST_LINE` can't be used in `math()' +function(print_self) + file(STRINGS "${CMAKE_CURRENT_FUNCTION_LIST_FILE}" _lines) + math(EXPR _begin "${CMAKE_CURRENT_FUNCTION_LIST_LINE} - 1") + list(SUBLIST _lines ${_begin} 7 _lines) # This function has 7 lines only + list(JOIN _lines "\n" _lines) + message(STATUS "Print the `${CMAKE_CURRENT_FUNCTION}` function:\n${_lines}") +endfunction() + +print_self() diff --git a/Tests/RunCMake/function/CMakeLists.txt b/Tests/RunCMake/function/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/function/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/function/DummyMacro.cmake b/Tests/RunCMake/function/DummyMacro.cmake new file mode 100644 index 0000000..1ab53e4 --- /dev/null +++ b/Tests/RunCMake/function/DummyMacro.cmake @@ -0,0 +1,20 @@ +macro(dummy) + if(NOT CMAKE_CURRENT_FUNCTION STREQUAL "calling_macro") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_FILE MATCHES "^.*/function/CMAKE_CURRENT_FUNCTION.cmake$") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_FILE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_FILE STREQUAL _THIS_FILE) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_FILE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_DIR MATCHES "^.*/Tests/RunCMake/function$") + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_DIR`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_LINE EQUAL 77) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_LINE`") + endif() + if(NOT CMAKE_CURRENT_FUNCTION_LIST_DIR STREQUAL _THIS_DIR) + message(SEND_ERROR "Bad value of `CMAKE_CURRENT_FUNCTION_LIST_DIR`") + endif() +endmacro() diff --git a/Tests/RunCMake/function/RunCMakeTest.cmake b/Tests/RunCMake/function/RunCMakeTest.cmake new file mode 100644 index 0000000..88f48af --- /dev/null +++ b/Tests/RunCMake/function/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(CMAKE_CURRENT_FUNCTION) diff --git a/Tests/RunCMake/get_property/RunCMakeTest.cmake b/Tests/RunCMake/get_property/RunCMakeTest.cmake index 06a0c67..6e36473 100644 --- a/Tests/RunCMake/get_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/get_property/RunCMakeTest.cmake @@ -27,7 +27,7 @@ run_cmake(NoCache) # don't rely on RunCMake_GENERATOR_IS_MULTI_CONFIG being set correctly # and instead explicitly check for a match against those generators we # expect to be multi-config -if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") +if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode|Ninja Multi-Config") run_cmake(IsMultiConfig) else() run_cmake(NotMultiConfig) diff --git a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake index 47dac34..7ed0773 100644 --- a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake @@ -5,3 +5,7 @@ run_cmake(CustomGuid) run_cmake(CustomTypePlatform) run_cmake(CustomGuidTypePlatform) run_cmake(CustomConfig) + +if(RunCMake_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])") + run_cmake(SkipGetTargetFrameworkProperties) +endif() diff --git a/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties-check.cmake b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties-check.cmake new file mode 100644 index 0000000..375b231 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties-check.cmake @@ -0,0 +1,21 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/ALL_BUILD.vcxproj" all_build) + +macro(project_reference EXTERNAL_PROJECT) + string(REGEX MATCH + "<ProjectReference.Include=.${${EXTERNAL_PROJECT}}.>.*</SkipGetTargetFrameworkProperties>" + EndOfProjectReference + ${all_build} + ) +endmacro() + +set(external_project "external.project") +project_reference(external_project) +if(NOT ${EndOfProjectReference} MATCHES ".*</ProjectReference>") + set(RunCMake_TEST_FAILED "${test} is being set unexpectedly.") +endif() + +set(external_project "external.csproj") +project_reference(external_project) +if(${EndOfProjectReference} MATCHES ".*</ProjectReference>") + set(RunCMake_TEST_FAILED "${test} is not set.") +endif() diff --git a/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties.cmake b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties.cmake new file mode 100644 index 0000000..f660bd0 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties.cmake @@ -0,0 +1,5 @@ +include_external_msproject(external1 external.project + GUID aaa-bbb-ccc-000) + +include_external_msproject(external2 external.csproj + GUID aaa-bbb-ccc-001) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 21c320b..70570b7 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -156,10 +156,12 @@ run_install_test(TARGETS-RPATH) run_install_test(InstallRequiredSystemLibraries) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") - run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos) - run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-unresolved) - run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-conflict) - run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-notfile) + if(NOT CMake_INSTALL_NAME_TOOL_BUG) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-unresolved) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-conflict) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-notfile) + endif() run_cmake(file-GET_RUNTIME_DEPENDENCIES-project) run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs1) run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs2) diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt index 1e123f6..2561263 100644 --- a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt +++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt @@ -1,4 +1,4 @@ -^CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\): +CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\): Policy CMP0095 is not set: RPATH entries are properly escaped in the intermediary CMake install script\. Run "cmake --help-policy CMP0095" for policy details\. Use the cmake_policy command to set the policy and @@ -20,4 +20,4 @@ CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(ins intermediary cmake_install\.cmake script\. 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\. diff --git a/Tests/RunCMake/load_cache/CMakeLists.txt b/Tests/RunCMake/load_cache/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/load_cache/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/load_cache/NewForm_Project.cmake b/Tests/RunCMake/load_cache/NewForm_Project.cmake new file mode 100644 index 0000000..13a450b --- /dev/null +++ b/Tests/RunCMake/load_cache/NewForm_Project.cmake @@ -0,0 +1,16 @@ +load_cache(${CMAKE_CURRENT_BINARY_DIR}/../test_project READ_WITH_PREFIX LOAD_CACHE_TEST_ + CACHE_STRING + CACHE_BOOL + CACHE_INTERNAL) + +if(NOT LOAD_CACHE_TEST_CACHE_STRING STREQUAL "cache string") + message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_BOOL) + message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_INTERNAL STREQUAL "cache internal") + message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"") +endif() diff --git a/Tests/RunCMake/load_cache/NewForm_Script.cmake b/Tests/RunCMake/load_cache/NewForm_Script.cmake new file mode 100644 index 0000000..f3cee92 --- /dev/null +++ b/Tests/RunCMake/load_cache/NewForm_Script.cmake @@ -0,0 +1,16 @@ +load_cache(${RunCMake_BINARY_DIR}/test_project READ_WITH_PREFIX LOAD_CACHE_TEST_ + CACHE_STRING + CACHE_BOOL + CACHE_INTERNAL) + +if(NOT LOAD_CACHE_TEST_CACHE_STRING STREQUAL "cache string") + message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_BOOL) + message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_INTERNAL STREQUAL "cache internal") + message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"") +endif() diff --git a/Tests/RunCMake/load_cache/OldForm_Script-result.txt b/Tests/RunCMake/load_cache/OldForm_Script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/load_cache/OldForm_Script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt b/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt new file mode 100644 index 0000000..9ad5c80 --- /dev/null +++ b/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at.*/Tests/RunCMake/load_cache/OldForm_Script.cmake:1 \(load_cache\): + load_cache Only load_cache\(READ_WITH_PREFIX\) may be used in script mode$ diff --git a/Tests/RunCMake/load_cache/OldForm_Script.cmake b/Tests/RunCMake/load_cache/OldForm_Script.cmake new file mode 100644 index 0000000..9560f61 --- /dev/null +++ b/Tests/RunCMake/load_cache/OldForm_Script.cmake @@ -0,0 +1,13 @@ +load_cache(${RunCMake_BINARY_DIR}/test_project INCLUDE_INTERNALS CACHE_INTERNAL) + +if(NOT CACHE_STRING STREQUAL "cache string") + message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"") +endif() + +if(NOT CACHE_BOOL) + message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON") +endif() + +if(NOT CACHE_INTERNAL STREQUAL "cache internal") + message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"") +endif() diff --git a/Tests/RunCMake/load_cache/RunCMakeTest.cmake b/Tests/RunCMake/load_cache/RunCMakeTest.cmake new file mode 100644 index 0000000..a0d54ea --- /dev/null +++ b/Tests/RunCMake/load_cache/RunCMakeTest.cmake @@ -0,0 +1,13 @@ +include(RunCMake) + +file(WRITE ${RunCMake_BINARY_DIR}/test_project/CMakeCache.txt [[ +CACHE_STRING:STRING=cache string +CACHE_BOOL:BOOL=ON +CACHE_INTERNAL:INTERNAL=cache internal +]]) + +run_cmake(NewForm_Project) +run_cmake_command(NewForm_Script ${CMAKE_COMMAND} -DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR} + -P "${RunCMake_SOURCE_DIR}/NewForm_Script.cmake") +run_cmake_command(OldForm_Script ${CMAKE_COMMAND} -DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR} + -P "${RunCMake_SOURCE_DIR}/OldForm_Script.cmake") diff --git a/Tests/RunCMake/message/RunCMakeTest.cmake b/Tests/RunCMake/message/RunCMakeTest.cmake index 681839d..0313ed1 100644 --- a/Tests/RunCMake/message/RunCMakeTest.cmake +++ b/Tests/RunCMake/message/RunCMakeTest.cmake @@ -65,6 +65,11 @@ foreach(opt IN ITEMS loglevel log-level) endforeach() run_cmake_command( + message-log-level-override + ${CMAKE_COMMAND} --log-level=debug -DCMAKE_MESSAGE_LOG_LEVEL=TRACE -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) + +run_cmake_command( message-indent ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-indent.cmake ) @@ -72,3 +77,23 @@ run_cmake_command( message-indent-multiline ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-indent-multiline.cmake ) + +run_cmake_command( + message-context-cli + ${CMAKE_COMMAND} --log-level=trace --log-context -P ${RunCMake_SOURCE_DIR}/message-context.cmake + ) + +run_cmake_command( + message-context-cache + ${CMAKE_COMMAND} -DCMAKE_MESSAGE_LOG_LEVEL=TRACE -DCMAKE_MESSAGE_CONTEXT_SHOW=ON -P ${RunCMake_SOURCE_DIR}/message-context.cmake + ) + +run_cmake_command( + message-context-cli-wins-cache + ${CMAKE_COMMAND} --log-level=verbose --log-context -DCMAKE_MESSAGE_CONTEXT_SHOW=OFF -P ${RunCMake_SOURCE_DIR}/message-context.cmake + ) + +run_cmake_command( + message-checks + ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-checks.cmake + ) diff --git a/Tests/RunCMake/message/message-checks-stderr.txt b/Tests/RunCMake/message/message-checks-stderr.txt new file mode 100644 index 0000000..fdacdb2 --- /dev/null +++ b/Tests/RunCMake/message/message-checks-stderr.txt @@ -0,0 +1,3 @@ +^CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-checks.cmake:13 \(message\): + Ignored CHECK_FAIL without CHECK_START +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/message/message-checks-stdout.txt b/Tests/RunCMake/message/message-checks-stdout.txt new file mode 100644 index 0000000..4f5f2ef --- /dev/null +++ b/Tests/RunCMake/message/message-checks-stdout.txt @@ -0,0 +1,10 @@ +-- Find `libfoo` +-- Looking for `libfoo\.h` +-- Looking for `libfoo\.h` - found \[/usr/include\] +-- Looking for `libfoo\.so` +-- Looking for `libfoo\.so` - found \[/usr/lib/libfoo\.so\] +-- Getting `libfoo` version +-- Looking for `libfoo/version\.h` +-- Looking for `libfoo/version\.h` - found +-- Getting `libfoo` version - 1\.2\.3 +-- Find `libfoo` - required version 4\.5\.6 but found 1\.2\.3 diff --git a/Tests/RunCMake/message/message-checks.cmake b/Tests/RunCMake/message/message-checks.cmake new file mode 100644 index 0000000..605846e --- /dev/null +++ b/Tests/RunCMake/message/message-checks.cmake @@ -0,0 +1,13 @@ +message(CHECK_START "Find `libfoo`") +message(CHECK_START "Looking for `libfoo.h`") +message(CHECK_PASS "found [/usr/include]") +message(CHECK_START "Looking for `libfoo.so`") +message(CHECK_PASS "found [/usr/lib/libfoo.so]") +message(CHECK_START "Getting `libfoo` version") +message(CHECK_START "Looking for `libfoo/version.h`") +message(CHECK_PASS "found") +message(CHECK_PASS "1.2.3") +message(CHECK_FAIL "required version 4.5.6 but found 1.2.3") + +# Should generate an error, no associated CHECK_START +message(CHECK_FAIL "unmatched check fail case") diff --git a/Tests/RunCMake/message/message-context-cache-stdout.txt b/Tests/RunCMake/message/message-context-cache-stdout.txt new file mode 100644 index 0000000..af18c15 --- /dev/null +++ b/Tests/RunCMake/message/message-context-cache-stdout.txt @@ -0,0 +1,8 @@ +-- Begin context output test +-- \[top\] Top: before +-- \[top\.foo\.bar\] <-- indent -->bar VERBOSE message +-- \[top\.foo\] foo TRACE message +-- \[top\.foo\.baz\] This is the multi-line +\[top\.foo\.baz\] baz DEBUG message +-- \[top\] Top: after +-- End of context output test diff --git a/Tests/RunCMake/message/message-context-cli-stdout.txt b/Tests/RunCMake/message/message-context-cli-stdout.txt new file mode 100644 index 0000000..af18c15 --- /dev/null +++ b/Tests/RunCMake/message/message-context-cli-stdout.txt @@ -0,0 +1,8 @@ +-- Begin context output test +-- \[top\] Top: before +-- \[top\.foo\.bar\] <-- indent -->bar VERBOSE message +-- \[top\.foo\] foo TRACE message +-- \[top\.foo\.baz\] This is the multi-line +\[top\.foo\.baz\] baz DEBUG message +-- \[top\] Top: after +-- End of context output test diff --git a/Tests/RunCMake/message/message-context-cli-wins-cache-stdout.txt b/Tests/RunCMake/message/message-context-cli-wins-cache-stdout.txt new file mode 100644 index 0000000..157db97 --- /dev/null +++ b/Tests/RunCMake/message/message-context-cli-wins-cache-stdout.txt @@ -0,0 +1,5 @@ +-- Begin context output test +-- \[top\] Top: before +-- \[top\.foo\.bar\] <-- indent -->bar VERBOSE message +-- \[top\] Top: after +-- End of context output test diff --git a/Tests/RunCMake/message/message-context.cmake b/Tests/RunCMake/message/message-context.cmake new file mode 100644 index 0000000..93d4cd9 --- /dev/null +++ b/Tests/RunCMake/message/message-context.cmake @@ -0,0 +1,27 @@ +function(bar) + list(APPEND CMAKE_MESSAGE_CONTEXT "bar") + list(APPEND CMAKE_MESSAGE_INDENT "<-- indent -->") + message(VERBOSE "bar VERBOSE message") +endfunction() + +function(baz) + list(APPEND CMAKE_MESSAGE_CONTEXT "baz") + message(DEBUG "This is the multi-line\nbaz DEBUG message") +endfunction() + +function(foo) + list(APPEND CMAKE_MESSAGE_CONTEXT "foo") + bar() + message(TRACE "foo TRACE message") + baz() +endfunction() + +message(STATUS "Begin context output test") +list(APPEND CMAKE_MESSAGE_CONTEXT "top") + +message(STATUS "Top: before") +foo() +message(STATUS "Top: after") + +list(POP_BACK CMAKE_MESSAGE_CONTEXT) +message(STATUS "End of context output test") diff --git a/Tests/RunCMake/message/message-log-level-debug-stdout.txt b/Tests/RunCMake/message/message-log-level-debug-stdout.txt index 1452137..feee110 100644 --- a/Tests/RunCMake/message/message-log-level-debug-stdout.txt +++ b/Tests/RunCMake/message/message-log-level-debug-stdout.txt @@ -1,3 +1,3 @@ -- STATUS message -- VERBOSE message --- DEBUG message +-- DEBUG message$ diff --git a/Tests/RunCMake/message/message-log-level-default-stdout.txt b/Tests/RunCMake/message/message-log-level-default-stdout.txt index 809f4cc..b5d6acb 100644 --- a/Tests/RunCMake/message/message-log-level-default-stdout.txt +++ b/Tests/RunCMake/message/message-log-level-default-stdout.txt @@ -1 +1 @@ --- STATUS message +-- STATUS message$ diff --git a/Tests/RunCMake/message/message-log-level-override-stderr.txt b/Tests/RunCMake/message/message-log-level-override-stderr.txt new file mode 100644 index 0000000..efec736 --- /dev/null +++ b/Tests/RunCMake/message/message-log-level-override-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-log-level-override-stdout.txt b/Tests/RunCMake/message/message-log-level-override-stdout.txt new file mode 100644 index 0000000..feee110 --- /dev/null +++ b/Tests/RunCMake/message/message-log-level-override-stdout.txt @@ -0,0 +1,3 @@ +-- STATUS message +-- VERBOSE message +-- DEBUG message$ diff --git a/Tests/RunCMake/message/message-log-level-status-stdout.txt b/Tests/RunCMake/message/message-log-level-status-stdout.txt index 809f4cc..b5d6acb 100644 --- a/Tests/RunCMake/message/message-log-level-status-stdout.txt +++ b/Tests/RunCMake/message/message-log-level-status-stdout.txt @@ -1 +1 @@ --- STATUS message +-- STATUS message$ diff --git a/Tests/RunCMake/message/message-log-level-trace-stdout.txt b/Tests/RunCMake/message/message-log-level-trace-stdout.txt index 1cfce6f..3d36a7f 100644 --- a/Tests/RunCMake/message/message-log-level-trace-stdout.txt +++ b/Tests/RunCMake/message/message-log-level-trace-stdout.txt @@ -1,4 +1,4 @@ -- STATUS message -- VERBOSE message -- DEBUG message --- TRACE message +-- TRACE message$ diff --git a/Tests/RunCMake/message/message-log-level-verbose-stdout.txt b/Tests/RunCMake/message/message-log-level-verbose-stdout.txt index c15d43f..47c0846 100644 --- a/Tests/RunCMake/message/message-log-level-verbose-stdout.txt +++ b/Tests/RunCMake/message/message-log-level-verbose-stdout.txt @@ -1,2 +1,2 @@ -- STATUS message --- VERBOSE message +-- VERBOSE message$ diff --git a/Tests/RunCMake/message/message-loglevel-debug-stdout.txt b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt index 1452137..feee110 100644 --- a/Tests/RunCMake/message/message-loglevel-debug-stdout.txt +++ b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt @@ -1,3 +1,3 @@ -- STATUS message -- VERBOSE message --- DEBUG message +-- DEBUG message$ diff --git a/Tests/RunCMake/message/message-loglevel-default-stdout.txt b/Tests/RunCMake/message/message-loglevel-default-stdout.txt index 809f4cc..b5d6acb 100644 --- a/Tests/RunCMake/message/message-loglevel-default-stdout.txt +++ b/Tests/RunCMake/message/message-loglevel-default-stdout.txt @@ -1 +1 @@ --- STATUS message +-- STATUS message$ diff --git a/Tests/RunCMake/message/message-loglevel-status-stdout.txt b/Tests/RunCMake/message/message-loglevel-status-stdout.txt index 809f4cc..b5d6acb 100644 --- a/Tests/RunCMake/message/message-loglevel-status-stdout.txt +++ b/Tests/RunCMake/message/message-loglevel-status-stdout.txt @@ -1 +1 @@ --- STATUS message +-- STATUS message$ diff --git a/Tests/RunCMake/message/message-loglevel-trace-stdout.txt b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt index 1cfce6f..3d36a7f 100644 --- a/Tests/RunCMake/message/message-loglevel-trace-stdout.txt +++ b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt @@ -1,4 +1,4 @@ -- STATUS message -- VERBOSE message -- DEBUG message --- TRACE message +-- TRACE message$ diff --git a/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt index c15d43f..47c0846 100644 --- a/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt +++ b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt @@ -1,2 +1,2 @@ -- STATUS message --- VERBOSE message +-- VERBOSE message$ diff --git a/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake b/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake new file mode 100644 index 0000000..8016230 --- /dev/null +++ b/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake @@ -0,0 +1,8 @@ + +add_executable (CMP0101_OLD CMP0101.c) +target_compile_options (main PRIVATE -UBEFORE_KEYWORD) +target_compile_options (main BEFORE PRIVATE -DBEFORE_KEYWORD) + +add_executable (CMP0101_NEW CMP0101.c) +target_compile_options (main PRIVATE -UBEFORE_KEYWORD) +target_compile_options (main BEFORE PRIVATE -DBEFORE_KEYWORD) diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt new file mode 100644 index 0000000..850aa65 --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt @@ -0,0 +1 @@ +BEFORE not honored diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake new file mode 100644 index 0000000..577427f --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake @@ -0,0 +1,15 @@ + +enable_language(C) + +cmake_policy (SET CMP0101 OLD) + +add_executable (CMP0101_OLD CMP0101.c) +target_compile_options (CMP0101_OLD PRIVATE -UBEFORE_KEYWORD) +target_compile_options (CMP0101_OLD BEFORE PRIVATE -DBEFORE_KEYWORD) + + +cmake_policy (SET CMP0101 NEW) + +add_executable (CMP0101_NEW CMP0101.c) +target_compile_options (CMP0101_NEW PRIVATE -UBEFORE_KEYWORD) +target_compile_options (CMP0101_NEW BEFORE PRIVATE -DBEFORE_KEYWORD) diff --git a/Tests/RunCMake/target_compile_options/CMP0101.c b/Tests/RunCMake/target_compile_options/CMP0101.c new file mode 100644 index 0000000..250869a --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101.c @@ -0,0 +1,9 @@ + +#if defined(BEFORE_KEYWORD) +# error "BEFORE not honored" +#endif + +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake index b67c598..9f51a9a 100644 --- a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake @@ -1,3 +1,21 @@ include(RunCMake) run_cmake(empty_keyword_args) + +if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") + macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_OUTPUT_MERGE 1) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_OUTPUT_MERGE) + unset(RunCMake_TEST_NO_CLEAN) + endmacro() + + run_cmake(CMP0101-BEFORE_keyword) + + run_cmake_target(CMP0101-BEFORE_keyword OLD CMP0101_OLD) + run_cmake_target(CMP0101-BEFORE_keyword NEW CMP0101_NEW) +endif() diff --git a/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-check.cmake b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-check.cmake new file mode 100644 index 0000000..2fffddd --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "DIR_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nNot found expected 'DIR_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-result.txt b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_directories/CMP0099-NEW.cmake b/Tests/RunCMake/target_link_directories/CMP0099-NEW.cmake new file mode 100644 index 0000000..17dd68e --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 NEW) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-check.cmake b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-check.cmake new file mode 100644 index 0000000..16573a7 --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-check.cmake @@ -0,0 +1,4 @@ + +if (actual_stdout MATCHES "DIR_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected 'DIR_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-result.txt b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_directories/CMP0099-OLD.cmake b/Tests/RunCMake/target_link_directories/CMP0099-OLD.cmake new file mode 100644 index 0000000..193a4c7 --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 OLD) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_directories/CMP0099.cmake b/Tests/RunCMake/target_link_directories/CMP0099.cmake new file mode 100644 index 0000000..a2be279 --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099.cmake @@ -0,0 +1,14 @@ + +enable_language(C) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE) + +add_library(LinkDirs_interface INTERFACE) +target_link_directories (LinkDirs_interface INTERFACE "/DIR_INTERFACE"}) + +add_library(LinkDirs_static STATIC lib.c) +target_link_libraries (LinkDirs_static PRIVATE LinkDirs_interface) + +add_executable(LinkDirs_exe exe.c) +target_link_libraries (LinkDirs_exe PRIVATE LinkDirs_static) diff --git a/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake b/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake index b67c598..a74ee25 100644 --- a/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake @@ -1,3 +1,33 @@ include(RunCMake) +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + run_cmake(empty_keyword_args) + +if(RunCMake_GENERATOR MATCHES "(Ninja|Makefiles)" AND + NOT RunCMake_GENERATOR MATCHES "(NMake|Borland)") + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + if (RunCMake_GENERATOR MATCHES "Ninja") + set(VERBOSE -- -v) + endif() + + run_cmake(CMP0099-NEW) + run_cmake_target(CMP0099-NEW basic LinkDirs_exe ${VERBOSE}) + + + run_cmake(CMP0099-OLD) + run_cmake_target(CMP0099-OLD basic LinkDirs_exe ${VERBOSE}) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() diff --git a/Tests/RunCMake/target_link_directories/exe.c b/Tests/RunCMake/target_link_directories/exe.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/target_link_directories/exe.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/target_link_directories/lib.c b/Tests/RunCMake/target_link_directories/lib.c new file mode 100644 index 0000000..9bbd24c --- /dev/null +++ b/Tests/RunCMake/target_link_directories/lib.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) +__declspec(dllexport) +#endif + int flags_lib(void) +{ + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt index 89cd806..1c5cf45 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt @@ -1 +1 @@ --- INTERFACE_LINK_LIBRARIES='foo::@<[Xx0-9A-Fa-f]+>' +-- INTERFACE_LINK_LIBRARIES='::@\([Xx0-9A-Fa-f]+\);\$<\$<CONFIG:DEBUG>:\$<1:foo;foo>>;\$<\$<NOT:\$<CONFIG:DEBUG>>:\$<1:foo;foo>>;::@' diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt index e575e16..4eb06d9 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt @@ -1 +1 @@ --- INTERFACE_LINK_LIBRARIES='foo' +-- INTERFACE_LINK_LIBRARIES='\$<\$<CONFIG:DEBUG>:\$<1:foo;foo>>;\$<\$<NOT:\$<CONFIG:DEBUG>>:\$<1:foo;foo>>' diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt index 6dd7d30..4c09a1f 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt @@ -10,7 +10,25 @@ is not created in this directory. For compatibility with older versions of CMake, link library - foo + \$<1:foo;foo> + + will be looked up in the directory in which the target was created rather + than in this calling directory. +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0079-iface/CMakeLists.txt:[0-9]+ \(target_link_libraries\): + Policy CMP0079 is not set: target_link_libraries allows use with targets in + other directories. Run "cmake --help-policy CMP0079" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + Target + + top + + is not created in this directory. For compatibility with older versions of + CMake, link library + + \$<1:foo;foo> will be looked up in the directory in which the target was created rather than in this calling directory. diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt index e575e16..4eb06d9 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt @@ -1 +1 @@ --- INTERFACE_LINK_LIBRARIES='foo' +-- INTERFACE_LINK_LIBRARIES='\$<\$<CONFIG:DEBUG>:\$<1:foo;foo>>;\$<\$<NOT:\$<CONFIG:DEBUG>>:\$<1:foo;foo>>' diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt index 4b15b32..e410607 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt @@ -1 +1 @@ -target_link_libraries(top INTERFACE foo) +target_link_libraries(top INTERFACE debug "$<1:foo;foo>" optimized "$<1:foo;foo>") diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt index 8ef35c1..9e38bec 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at CMP0079-link-NEW-bogus.cmake:[0-9]+ \(add_executable\): - Target "top" links to target "foo::@<0xdeadbeef>" but the target was not + Target "top" links to target "::@\(0xdeadbeef\)" but the target was not found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or an ALIAS target is missing\? Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake index 8622f14..8932521 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake +++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake @@ -3,4 +3,4 @@ cmake_policy(SET CMP0079 NEW) enable_language(C) add_executable(top empty.c) -set_property(TARGET top APPEND PROPERTY LINK_LIBRARIES "foo::@<0xdeadbeef>") +set_property(TARGET top APPEND PROPERTY LINK_LIBRARIES "::@(0xdeadbeef);foo;::@") diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt index 84b30bd..fa5d4a3 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt @@ -1 +1 @@ --- LINK_LIBRARIES='foo::@<[Xx0-9A-Fa-f]+>' +-- LINK_LIBRARIES='::@\([Xx0-9A-Fa-f]+\);foo;::@' diff --git a/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-check.cmake b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-check.cmake new file mode 100644 index 0000000..555bc37 --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nNot found expected 'BADFLAG_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-result.txt b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/CMP0099-NEW.cmake b/Tests/RunCMake/target_link_options/CMP0099-NEW.cmake new file mode 100644 index 0000000..17dd68e --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 NEW) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-check.cmake b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-check.cmake new file mode 100644 index 0000000..4f159f1 --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-check.cmake @@ -0,0 +1,4 @@ + +if (actual_stdout MATCHES "BADFLAG_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected 'BADFLAG_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-result.txt b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/CMP0099-OLD.cmake b/Tests/RunCMake/target_link_options/CMP0099-OLD.cmake new file mode 100644 index 0000000..193a4c7 --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 OLD) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_options/CMP0099.cmake b/Tests/RunCMake/target_link_options/CMP0099.cmake new file mode 100644 index 0000000..edb457e --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099.cmake @@ -0,0 +1,19 @@ + +enable_language(C) + +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() + +add_library(LinkOptions_interface INTERFACE) +target_link_options (LinkOptions_interface INTERFACE ${pre}BADFLAG_INTERFACE${obj}) + +add_library(LinkOptions_static1 STATIC LinkOptionsLib.c) +target_link_libraries (LinkOptions_static1 PRIVATE LinkOptions_interface) + +add_library(LinkOptions_static2 STATIC LinkOptionsLib.c) +target_link_libraries (LinkOptions_static2 PRIVATE LinkOptions_static1) + +add_executable(LinkOptions_exe LinkOptionsExe.c) +target_link_libraries (LinkOptions_exe PRIVATE LinkOptions_static2) diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion.cmake index b344867..f86d19f 100644 --- a/Tests/RunCMake/target_link_options/LINKER_expansion.cmake +++ b/Tests/RunCMake/target_link_options/LINKER_expansion.cmake @@ -1,6 +1,13 @@ enable_language(C) +set(cfg_dir) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + set(cfg_dir /Debug) +endif() +set(DUMP_EXE "${CMAKE_CURRENT_BINARY_DIR}${cfg_dir}/dump${CMAKE_EXECUTABLE_SUFFIX}") + add_executable(dump dump.c) # ensure no temp file will be used @@ -13,7 +20,7 @@ add_library(linker SHARED LinkOptionsLib.c) target_link_options(linker PRIVATE "LINKER:-foo,bar") # use LAUNCH facility to dump linker command -set_property(TARGET linker PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"") +set_property(TARGET linker PROPERTY RULE_LAUNCH_LINK "\"${DUMP_EXE}\"") add_dependencies (linker dump) @@ -23,7 +30,7 @@ add_library(linker_shell SHARED LinkOptionsLib.c) target_link_options(linker_shell PRIVATE "LINKER:SHELL:-foo bar") # use LAUNCH facility to dump linker command -set_property(TARGET linker_shell PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"") +set_property(TARGET linker_shell PROPERTY RULE_LAUNCH_LINK "\"${DUMP_EXE}\"") add_dependencies (linker_shell dump) diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake index 1d9ef8b..cdfdd7b 100644 --- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake @@ -41,3 +41,21 @@ if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)") endif() run_cmake(empty_keyword_args) + +if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + # Intel compiler does not reject bad flags or objects! + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(CMP0099-NEW) + run_cmake_target(CMP0099-NEW basic LinkOptions_exe) + + + run_cmake(CMP0099-OLD) + run_cmake_target(CMP0099-OLD basic LinkOptions_exe) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() diff --git a/Tests/RunCMake/try_compile/CleanupNoFollowSymlink.cmake b/Tests/RunCMake/try_compile/CleanupNoFollowSymlink.cmake new file mode 100644 index 0000000..dea0f61 --- /dev/null +++ b/Tests/RunCMake/try_compile/CleanupNoFollowSymlink.cmake @@ -0,0 +1,21 @@ +enable_language(C) + +set(out "${CMAKE_CURRENT_BINARY_DIR}/folder") +set(link_folder "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp") +set(link_dir "${link_folder}/link_dir") +file(MAKE_DIRECTORY "${out}") +file(MAKE_DIRECTORY "${link_folder}") +file(WRITE ${out}/empty_file "") +file(CREATE_LINK ${out} ${link_dir} SYMBOLIC) + +try_compile(res ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c) + +if(EXISTS ${link_dir}) + message(FATAL_ERROR "did not remove ${link_dir}") +endif() +if(NOT EXISTS ${out}) + message(FATAL_ERROR "should not have removed ${out}/dir") +endif() + +file(REMOVE_RECURSE "${out}") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 91f014e..bee9e5b 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -49,11 +49,7 @@ if(CMAKE_OBJCXX_STANDARD_DEFAULT) run_cmake(ObjCxxStandard) endif() if(CMake_TEST_CUDA) - if(CMAKE_HOST_WIN32) - run_cmake(CudaStandardNoDefault) - else() - run_cmake(CudaStandard) - endif() + run_cmake(CudaStandard) endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) run_cmake(CStandardGNU) @@ -98,3 +94,7 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) endif() + +if(UNIX) + run_cmake(CleanupNoFollowSymlink) +endif() diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt index 8d2519e..9ed5c12 100644 --- a/Tests/StagingPrefix/CMakeLists.txt +++ b/Tests/StagingPrefix/CMakeLists.txt @@ -5,7 +5,7 @@ project(StagingPrefix) # Wipe out the install tree add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/CleanupProject - COMMAND ${CMAKE_COMMAND} -E remove_directory + COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_BINARY_DIR}/ConsumerBuild ${CMAKE_BINARY_DIR}/ProducerBuild ${CMAKE_BINARY_DIR}/stage diff --git a/Tests/SubDir/Examples/example1/CMakeLists.txt b/Tests/SubDir/Examples/example1/CMakeLists.txt index 20d065e..8ec1c02 100644 --- a/Tests/SubDir/Examples/example1/CMakeLists.txt +++ b/Tests/SubDir/Examples/example1/CMakeLists.txt @@ -3,5 +3,5 @@ project(example1) add_executable(example1 example1.cxx) add_custom_command(TARGET example1 POST_BUILD - COMMAND "${CMAKE_COMMAND}" ARGS -E remove ${SUBDIR_BINARY_DIR}/ShouldBeHere + COMMAND "${CMAKE_COMMAND}" ARGS -E rm -f ${SUBDIR_BINARY_DIR}/ShouldBeHere COMMENT "Remove marker file that should exist because this should not be run") diff --git a/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt b/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt index 20d065e..8ec1c02 100644 --- a/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt +++ b/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt @@ -3,5 +3,5 @@ project(example1) add_executable(example1 example1.cxx) add_custom_command(TARGET example1 POST_BUILD - COMMAND "${CMAKE_COMMAND}" ARGS -E remove ${SUBDIR_BINARY_DIR}/ShouldBeHere + COMMAND "${CMAKE_COMMAND}" ARGS -E rm -f ${SUBDIR_BINARY_DIR}/ShouldBeHere COMMENT "Remove marker file that should exist because this should not be run") diff --git a/Tests/VSMidl/CMakeLists.txt b/Tests/VSMidl/CMakeLists.txt index 432506c..3ff7c27 100644 --- a/Tests/VSMidl/CMakeLists.txt +++ b/Tests/VSMidl/CMakeLists.txt @@ -56,8 +56,8 @@ set(source_dir "${base_dir}/src") # ExternalProject_Add(clean-${PROJECT_NAME} DOWNLOAD_COMMAND "" - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${source_dir}" - BUILD_COMMAND ${CMAKE_COMMAND} -E remove_directory "${binary_dir}" + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E rm -rf "${source_dir}" + BUILD_COMMAND ${CMAKE_COMMAND} -E rm -rf "${binary_dir}" INSTALL_COMMAND "" ) |