diff options
Diffstat (limited to 'Tests')
620 files changed, 5006 insertions, 1000 deletions
diff --git a/Tests/BootstrapTest.cmake b/Tests/BootstrapTest.cmake index 9c9fe09..07a65bf 100644 --- a/Tests/BootstrapTest.cmake +++ b/Tests/BootstrapTest.cmake @@ -1,7 +1,12 @@ file(MAKE_DIRECTORY "${bin_dir}") -message(STATUS "running bootstrap: ${bootstrap}") +include(ProcessorCount) +ProcessorCount(nproc) +if(NOT nproc EQUAL 0) + set(parallel_arg --parallel=${nproc}) +endif() +message(STATUS "running bootstrap: ${bootstrap} ${parallel_arg}") execute_process( - COMMAND ${bootstrap} + COMMAND ${bootstrap} ${parallel_arg} WORKING_DIRECTORY "${bin_dir}" RESULT_VARIABLE result ) diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt index 9b35f27..555a08f 100644 --- a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt @@ -26,7 +26,7 @@ if (CMAKE_C_COMPILE_FEATURES) target_link_libraries(restrict_user lib_restrict) endif() -if (CMAKE_CXX_COMPILE_FEATURES) +if (CMAKE_CXX_COMPILE_FEATURES AND ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;") if (CMAKE_C_COMPILE_FEATURES) set(target_suffix _cxx) endif() diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 405917a..d680205 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -31,6 +31,9 @@ create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) target_link_libraries(CMakeLibTests CMakeLib) +add_executable(testEncoding testEncoding.cxx) +target_link_libraries(testEncoding cmsys) + # Xcode 2.x forgets to create the output directory before linking # the individual architectures. if(CMAKE_OSX_ARCHITECTURES AND XCODE diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 0bf0a7c..5d4ca70 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -1,4 +1,4 @@ -#include "cmSystemTools.h" +#include <cmConfigure.h> #include <cmsys/FStream.hxx> #include <iostream> @@ -8,6 +8,8 @@ #include <utility> #include <vector> +#include "cmSystemTools.h" + class CompileCommandParser { public: diff --git a/Tests/CMakeLib/testEncoding.cxx b/Tests/CMakeLib/testEncoding.cxx new file mode 100644 index 0000000..88743b0 --- /dev/null +++ b/Tests/CMakeLib/testEncoding.cxx @@ -0,0 +1,49 @@ +#include <fstream> +#include <iostream> +#include <string> + +#include <cmsys/ConsoleBuf.hxx> + +#ifdef _WIN32 +void setEncoding(cmsys::ConsoleBuf::Manager& buf, UINT codepage) +{ + cmsys::ConsoleBuf* cb = buf.GetConsoleBuf(); + if (cb) { + cb->input_pipe_codepage = codepage; + cb->output_pipe_codepage = codepage; + cb->input_file_codepage = codepage; + cb->output_file_codepage = codepage; + cb->activateCodepageChange(); + } +} +#endif + +int main(int argc, char* argv[]) +{ +#ifdef _WIN32 + cmsys::ConsoleBuf::Manager consoleOut(std::cout); +#endif + if (argc <= 2) { + std::cout << "Usage: testEncoding <encoding> <file>" << std::endl; + return 1; + } + const std::string encoding(argv[1]); +#ifdef _WIN32 + if (encoding == "UTF8") { + setEncoding(consoleOut, CP_UTF8); + } else if (encoding == "ANSI") { + setEncoding(consoleOut, CP_ACP); + } else if (encoding == "OEM") { + setEncoding(consoleOut, CP_OEMCP); + } // else AUTO +#endif + std::ifstream file(argv[2]); + if (!file.is_open()) { + std::cout << "Failed to open file: " << argv[2] << std::endl; + return 2; + } + std::string text((std::istreambuf_iterator<char>(file)), + std::istreambuf_iterator<char>()); + std::cout << text; + return 0; +} diff --git a/Tests/CMakeLib/testFindPackageCommand.cxx b/Tests/CMakeLib/testFindPackageCommand.cxx index 7622756..bfd429f 100644 --- a/Tests/CMakeLib/testFindPackageCommand.cxx +++ b/Tests/CMakeLib/testFindPackageCommand.cxx @@ -1,9 +1,13 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmFindPackageCommand.h" + +#include <cmConfigure.h> // IWYU pragma: keep #include <iostream> #include <string> +#include <vector> + +#include "cmFindPackageCommand.h" #define cmPassed(m) std::cout << "Passed: " << (m) << "\n" #define cmFailed(m) \ diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index b16b088..0dfa326 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -1,9 +1,14 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmSystemTools.h" + +#include <cmConfigure.h> // IWYU pragma: keep #include <iostream> +#include <stddef.h> #include <string> +#include <vector> + +#include "cmSystemTools.h" #define cmPassed(m) std::cout << "Passed: " << (m) << "\n" #define cmFailed(m) \ diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx index 6c59128..fe776c5 100644 --- a/Tests/CMakeLib/testXMLSafe.cxx +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -1,11 +1,14 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmXMLSafe.h" + +#include <cmConfigure.h> #include <sstream> #include <stdio.h> #include <string> +#include "cmXMLSafe.h" + struct test_pair { const char* in; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 7df9403..4945b31 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -324,6 +324,11 @@ if(BUILD_TESTING) ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake) endif() endif() + + if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^789]|[789][0-9])") + ADD_TEST_MACRO(CSharpOnly CSharpOnly) + endif() + ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(CxxSubdirC CxxSubdirC) @@ -1243,7 +1248,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V) set(run_autouic_test ${CMAKE_CTEST_COMMAND} -V) else() - set(run_autogen_test QtAutogen) + set(run_autogen_test complex/QtAutogen) set(run_autouic_test QtAutoUicInterface) endif() if(NOT CMAKE_CONFIGURATION_TYPES) @@ -1353,6 +1358,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() endif() + if(CMake_TEST_CUDA) + add_subdirectory(Cuda) + add_subdirectory(CudaOnly) + endif() + if(CMake_TEST_FindBoost) add_subdirectory(FindBoost) endif() @@ -1377,6 +1387,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindJsonCpp) endif() + if(CMake_TEST_FindLibRHash) + add_subdirectory(FindLibRHash) + endif() + if(CMake_TEST_FindLibUV) add_subdirectory(FindLibUV) endif() @@ -1389,6 +1403,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindOpenCL) endif() + if(CMake_TEST_FindOpenGL) + add_subdirectory(FindOpenGL) + endif() + if(CMake_TEST_FindOpenSSL) add_subdirectory(FindOpenSSL) endif() @@ -3081,8 +3099,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest") - # Make this test run early during parallel execution - set_tests_properties(BootstrapTest PROPERTIES COST 5000) + # This test will use all processors. + set_tests_properties(BootstrapTest PROPERTIES RUN_SERIAL 1) # provide more time for the bootstrap test get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT) @@ -3346,20 +3364,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --test-command InterfaceLinkLibraries) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries") - if(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE) - # The "make StyleCheck" command line as a test. If the test fails, look - # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the - # output to find where the style errors are... - add_test(KWStyle ${KWSTYLE_EXECUTABLE} - -xml ${CMake_BINARY_DIR}/CMake.kws.xml - -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt - -v - -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt - ) - set_tests_properties(KWStyle PROPERTIES - WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle) - endif() - if(NOT CMake_TEST_EXTERNAL_CMAKE) add_subdirectory(CMakeTests) endif() diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 7586de6..c692cbd 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -26,6 +26,9 @@ add_CMakeOnly_test(CompilerIdCXX) if(CMAKE_Fortran_COMPILER) add_CMakeOnly_test(CompilerIdFortran) endif() +if(CMAKE_GENERATOR MATCHES "Visual Studio ([^789]|[789][0-9])") + add_CMakeOnly_test(CompilerIdCSharp) +endif() add_CMakeOnly_test(AllFindModules) diff --git a/Tests/CMakeOnly/CompilerIdCSharp/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdCSharp/CMakeLists.txt new file mode 100644 index 0000000..6c07037 --- /dev/null +++ b/Tests/CMakeOnly/CompilerIdCSharp/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.7.0) +project(CompilerIdCSharp CSharp) + +foreach(v + CMAKE_CSharp_COMPILER + CMAKE_CSharp_COMPILER_ID + CMAKE_CSharp_COMPILER_VERSION + ) + if(${v}) + message(STATUS "${v}=[${${v}}]") + else() + message(SEND_ERROR "${v} not set!") + endif() +endforeach() + +# Version numbers may only contain numbers and periods. +if(NOT CMAKE_CSharp_COMPILER_VERSION MATCHES + "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$" + ) + message(SEND_ERROR "Compiler version is not numeric!") +endif() diff --git a/Tests/CMakeTests/File-SHA3_224-Works.cmake b/Tests/CMakeTests/File-SHA3_224-Works.cmake new file mode 100644 index 0000000..e4f4e85 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_224-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_224 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_224) +message("${sha3_224}") diff --git a/Tests/CMakeTests/File-SHA3_256-Works.cmake b/Tests/CMakeTests/File-SHA3_256-Works.cmake new file mode 100644 index 0000000..189c8a2 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_256-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_256 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_256) +message("${sha3_256}") diff --git a/Tests/CMakeTests/File-SHA3_384-Works.cmake b/Tests/CMakeTests/File-SHA3_384-Works.cmake new file mode 100644 index 0000000..08f9f5b --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_384-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_384 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_384) +message("${sha3_384}") diff --git a/Tests/CMakeTests/File-SHA3_512-Works.cmake b/Tests/CMakeTests/File-SHA3_512-Works.cmake new file mode 100644 index 0000000..4182196 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_512-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_512 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_512) +message("${sha3_512}") diff --git a/Tests/CMakeTests/File-TIMESTAMP-NotBogus.cmake b/Tests/CMakeTests/File-TIMESTAMP-NotBogus.cmake index d0e5fe3..f1aa390 100644 --- a/Tests/CMakeTests/File-TIMESTAMP-NotBogus.cmake +++ b/Tests/CMakeTests/File-TIMESTAMP-NotBogus.cmake @@ -1,6 +1,7 @@ set(STAMP_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/FileTimestamp-Stamp") set(STAMP_FORMAT "%Y-%m-%d") +unset(ENV{SOURCE_DATE_EPOCH}) string(TIMESTAMP timestamp1 "${STAMP_FORMAT}") file(WRITE "${STAMP_FILENAME}" "foo") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 61523e6..71cb3db 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -36,6 +36,14 @@ set(SHA384-Works-RESULT 0) set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") +set(SHA3_224-Works-RESULT 0) +set(SHA3_224-Works-STDERR "4272868085f4f25080681a7712509fd12e16dcda79bd356836dd2100") +set(SHA3_256-Works-RESULT 0) +set(SHA3_256-Works-STDERR "be0df472b6bd474417a166d12f2774f2ef5095e86f0a88ef4c78c703800cfc8a") +set(SHA3_384-Works-RESULT 0) +set(SHA3_384-Works-STDERR "935a17cc708443c1369549483656a4521af03a52e4f3b314566272017ccae03a2c5db838f6d4c156b1dc5c366182481b") +set(SHA3_512-Works-RESULT 0) +set(SHA3_512-Works-STDERR "471a85ed537e8f77f31412a089f22d836054ffa179599f87a5d7568927d8fa236b6793ded8a387d1de92398c967177bcc6361672a722bf736cb0f63a0956d5cf") set(TIMESTAMP-NoFile-RESULT 0) set(TIMESTAMP-NoFile-STDERR "~~") set(TIMESTAMP-BadArg1-RESULT 1) @@ -66,6 +74,10 @@ check_cmake_test(File SHA256-Works SHA384-Works SHA512-Works + SHA3_224-Works + SHA3_256-Works + SHA3_384-Works + SHA3_512-Works TIMESTAMP-NoFile TIMESTAMP-BadArg1 TIMESTAMP-NotBogus diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in index 1313dbf..d6d2357 100644 --- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in +++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in @@ -518,6 +518,13 @@ set(msys_g77_libs "frtbegin;g2c;mingw32;moldname;mingwex;msvcrt;user32;kernel32; set(msys_g77_dirs "C:/some-mingw/lib/gcc/mingw32/3.4.5;C:/some-mingw/lib/gcc;/some-mingw/lib;C:/some-mingw/lib") list(APPEND platforms msys_g77) +#----------------------------------------------------------------------------- +# MSVC from NVIDIA CUDA + +set(nvcc_msvc_text [[cuda-fake-ld cl.exe -nologo "tmp/a_dlink.obj" "tmp/CMakeCUDACompilerId.obj" -link -INCREMENTAL:NO "/LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/../lib/x64" cudadevrt.lib cudart_static.lib -Fe"a.exe"]]) +set(nvcc_msvc_libs "cudadevrt.lib;cudart_static.lib") +set(nvcc_msvc_dirs "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64") +list(APPEND platforms nvcc_msvc) #----------------------------------------------------------------------------- # Test parsing for all above examples. diff --git a/Tests/CMakeTests/String-SHA3_224-Works.cmake b/Tests/CMakeTests/String-SHA3_224-Works.cmake new file mode 100644 index 0000000..6aeb91d --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_224-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_224 sha3_224 "sample input string\n") +message("${sha3_224}") diff --git a/Tests/CMakeTests/String-SHA3_256-Works.cmake b/Tests/CMakeTests/String-SHA3_256-Works.cmake new file mode 100644 index 0000000..cc7ea1a --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_256-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_256 sha3_256 "sample input string\n") +message("${sha3_256}") diff --git a/Tests/CMakeTests/String-SHA3_384-Works.cmake b/Tests/CMakeTests/String-SHA3_384-Works.cmake new file mode 100644 index 0000000..9341c3f --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_384-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_384 sha3_384 "sample input string\n") +message("${sha3_384}") diff --git a/Tests/CMakeTests/String-SHA3_512-Works.cmake b/Tests/CMakeTests/String-SHA3_512-Works.cmake new file mode 100644 index 0000000..cf4eddd --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_512-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_512 sha3_512 "sample input string\n") +message("${sha3_512}") diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index a45b205..83655da 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -16,6 +16,14 @@ set(SHA384-Works-RESULT 0) set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") +set(SHA3_224-Works-RESULT 0) +set(SHA3_224-Works-STDERR "4272868085f4f25080681a7712509fd12e16dcda79bd356836dd2100") +set(SHA3_256-Works-RESULT 0) +set(SHA3_256-Works-STDERR "be0df472b6bd474417a166d12f2774f2ef5095e86f0a88ef4c78c703800cfc8a") +set(SHA3_384-Works-RESULT 0) +set(SHA3_384-Works-STDERR "935a17cc708443c1369549483656a4521af03a52e4f3b314566272017ccae03a2c5db838f6d4c156b1dc5c366182481b") +set(SHA3_512-Works-RESULT 0) +set(SHA3_512-Works-STDERR "471a85ed537e8f77f31412a089f22d836054ffa179599f87a5d7568927d8fa236b6793ded8a387d1de92398c967177bcc6361672a722bf736cb0f63a0956d5cf") set(TIMESTAMP-BadArg1-RESULT 1) set(TIMESTAMP-BadArg1-STDERR "string sub-command TIMESTAMP requires at least one argument") set(TIMESTAMP-BadArg2-RESULT 1) @@ -52,6 +60,10 @@ check_cmake_test(String SHA256-Works SHA384-Works SHA512-Works + SHA3_224-Works + SHA3_256-Works + SHA3_384-Works + SHA3_512-Works TIMESTAMP-BadArg1 TIMESTAMP-BadArg2 TIMESTAMP-BadArg3 diff --git a/Tests/CSharpOnly/CMakeLists.txt b/Tests/CSharpOnly/CMakeLists.txt new file mode 100644 index 0000000..0e3e39e --- /dev/null +++ b/Tests/CSharpOnly/CMakeLists.txt @@ -0,0 +1,10 @@ +# a simple CSharp only test case +project (CSharpOnly CSharp) + +# C# does not make any difference between STATIC and SHARED libs +add_library(lib1 STATIC lib1.cs) +add_library(lib2 SHARED lib2.cs) + +add_executable(CSharpOnly csharponly.cs) + +target_link_libraries(CSharpOnly lib1 lib2) diff --git a/Tests/CSharpOnly/csharponly.cs b/Tests/CSharpOnly/csharponly.cs new file mode 100644 index 0000000..ad4641a --- /dev/null +++ b/Tests/CSharpOnly/csharponly.cs @@ -0,0 +1,15 @@ +namespace CSharpOnly +{ + class CSharpOnly + { + public static void Main(string[] args) + { + int val = Lib1.getResult(); + + Lib2 l = new Lib2(); + val = l.myVal; + + return; + } + } +} diff --git a/Tests/CSharpOnly/lib1.cs b/Tests/CSharpOnly/lib1.cs new file mode 100644 index 0000000..7a7ae10 --- /dev/null +++ b/Tests/CSharpOnly/lib1.cs @@ -0,0 +1,10 @@ +namespace CSharpOnly +{ + public class Lib1 + { + public static int getResult() + { + return 23; + } + } +} diff --git a/Tests/CSharpOnly/lib2.cs b/Tests/CSharpOnly/lib2.cs new file mode 100644 index 0000000..b4b38ce --- /dev/null +++ b/Tests/CSharpOnly/lib2.cs @@ -0,0 +1,10 @@ +namespace CSharpOnly +{ + public class Lib2 + { + public int myVal = 42; + + public Lib2() + {} + } +} diff --git a/Tests/CTestTestLaunchers/launcher_compiler_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CMakeLists.txt new file mode 100644 index 0000000..7376a40 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(launcher_compiler_test_project) + +include(CTest) + +add_executable(build_error build_error.cxx) diff --git a/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake index 669b0fb..669b0fb 100644 --- a/Tests/CTestTestLaunchers/launcher_test_project/CTestConfig.cmake +++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake diff --git a/Tests/CTestTestLaunchers/launcher_compiler_test_project/build_error.cxx b/Tests/CTestTestLaunchers/launcher_compiler_test_project/build_error.cxx new file mode 100644 index 0000000..2d51693 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/build_error.cxx @@ -0,0 +1,5 @@ +int main() +{ + int = 3; + return; +} diff --git a/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CMakeLists.txt index 06c5725..b31f587 100644 --- a/Tests/CTestTestLaunchers/launcher_test_project/CMakeLists.txt +++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8.12) -project(launcher_test_project) +project(launcher_custom_command_test_project) include(CTest) diff --git a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake new file mode 100644 index 0000000..669b0fb --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake @@ -0,0 +1,8 @@ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_PROJECT_NAME "CTestTestLaunchers") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_test_project/command.cmake b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/command.cmake index 7f31af9..7f31af9 100644 --- a/Tests/CTestTestLaunchers/launcher_test_project/command.cmake +++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/command.cmake diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/CMakeLists.txt b/Tests/CTestTestLaunchers/launcher_linker_test_project/CMakeLists.txt new file mode 100644 index 0000000..38980aa --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(launcher_linker_test_project) + +include(CTest) + +add_executable(link_error link_error.cxx) diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake new file mode 100644 index 0000000..669b0fb --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake @@ -0,0 +1,8 @@ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_PROJECT_NAME "CTestTestLaunchers") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/link_error.cxx b/Tests/CTestTestLaunchers/launcher_linker_test_project/link_error.cxx new file mode 100644 index 0000000..c879be1 --- /dev/null +++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/link_error.cxx @@ -0,0 +1,6 @@ +extern int foo(); + +int main() +{ + return foo(); +} diff --git a/Tests/CTestTestLaunchers/test.cmake.in b/Tests/CTestTestLaunchers/test.cmake.in index 03a118a..2db1ddd 100644 --- a/Tests/CTestTestLaunchers/test.cmake.in +++ b/Tests/CTestTestLaunchers/test.cmake.in @@ -1,39 +1,51 @@ cmake_minimum_required(VERSION 2.8.12) -# Settings: -set(CTEST_DASHBOARD_SOURCE "@CMake_SOURCE_DIR@/Tests/CTestTestLaunchers") -set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTestLaunchers") -set(CTEST_SITE "@SITE@") -set(CTEST_BUILD_NAME "Launchers-@BUILDNAME@-CTestTestLaunchers") - -set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_SOURCE}/launcher_test_project") -set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/launcher_test_project-bin") -set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") -set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") - -ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) - -file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ -CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ -CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ -CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ -CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ -CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ -") - -set(TEST_SUCCESS FALSE) - -ctest_start(Experimental) -ctest_configure(OPTIONS "-DCTEST_USE_LAUNCHERS=1") -ctest_build(NUMBER_ERRORS error_count) - -if("${error_count}" STREQUAL "1") - set(TEST_SUCCESS TRUE) -endif() +set(TEST_SUCCESS TRUE) + +function(run_test_case NAME WHAT) + set(_message "Testing that launchers are used when running ${WHAT}") + message(STATUS "${_message}...") + + # Settings: + set(CTEST_DASHBOARD_SOURCE "@CMake_SOURCE_DIR@/Tests/CTestTestLaunchers") + set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTestLaunchers") + set(CTEST_SITE "@SITE@") + set(CTEST_BUILD_NAME "Launchers-@BUILDNAME@-CTestTestLaunchers") + + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_SOURCE}/${NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${NAME}-bin") + set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") + set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@") + set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") + set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + + ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) + + file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " + CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ + CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ + CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ + CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ + CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ + CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ + ") + + ctest_start(Experimental) + ctest_configure(OPTIONS "-DCTEST_USE_LAUNCHERS=1") + ctest_build(NUMBER_ERRORS error_count) + + if("${error_count}" STREQUAL "0") + set(TEST_SUCCESS FALSE PARENT_SCOPE) + message(STATUS "${_message}... FAIL") + else() + message(STATUS "${_message}... PASS") + endif() +endfunction() + +run_test_case(launcher_compiler_test_project "the compiler") +run_test_case(launcher_linker_test_project "the linker") +run_test_case(launcher_custom_command_test_project "a custom command") if(TEST_SUCCESS) message("CTEST_TEST_LAUNCHER_SUCCESS") diff --git a/Tests/CTestTestStopTime/GetDate.cmake b/Tests/CTestTestStopTime/GetDate.cmake index 1f4cb24..46ab2fb 100644 --- a/Tests/CTestTestStopTime/GetDate.cmake +++ b/Tests/CTestTestStopTime/GetDate.cmake @@ -49,6 +49,7 @@ macro(GET_DATE) # 01/12/2006 08:55:12 # mm/dd/YYYY HH:MM:SS # + unset(ENV{SOURCE_DATE_EPOCH}) string(TIMESTAMP "${GD_PREFIX}OV" "%m/%d/%Y %H:%M:%S") if(${GD_PREFIX}VERBOSE) diff --git a/Tests/CompileFeatures/.gitattributes b/Tests/CompileFeatures/.gitattributes new file mode 100644 index 0000000..83da28d --- /dev/null +++ b/Tests/CompileFeatures/.gitattributes @@ -0,0 +1,2 @@ +# Do not format a source containing C++11 '>>' syntax as C++98. +cxx_right_angle_brackets.cpp -format.clang-format diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 9f08523..2a307d0 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -3,14 +3,6 @@ cmake_minimum_required(VERSION 3.1) project(CompileFeatures) -if (NOT CMAKE_C_COMPILE_FEATURES AND NOT CMAKE_CXX_COMPILE_FEATURES) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" - "int main(int,char**) { return 0; }\n" - ) - add_executable(CompileFeatures "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") - return() -endif() - macro(run_test feature lang) if (";${CMAKE_${lang}_COMPILE_FEATURES};" MATCHES ${feature}) add_library(test_${feature} OBJECT ${feature}) @@ -23,10 +15,12 @@ macro(run_test feature lang) endmacro() get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) +list(REMOVE_ITEM c_features c_std_90 c_std_99 c_std_11) foreach(feature ${c_features}) run_test(${feature} C) endforeach() get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) +list(REMOVE_ITEM cxx_features cxx_std_98 cxx_std_11 cxx_std_14 cxx_std_17) foreach(feature ${cxx_features}) run_test(${feature} CXX) endforeach() @@ -168,6 +162,15 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") endif() endif() +if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.2) + # This works on some pre-15.0.2 versions and not others. + list(REMOVE_ITEM C_non_features + c_static_assert + ) + endif() +endif() + set(C_ext c) set(C_standard_flag 11) set(CXX_ext cpp) @@ -257,13 +260,23 @@ if (CMAKE_CXX_COMPILE_FEATURES) if (std_flag_idx EQUAL -1) add_executable(default_dialect default_dialect.cpp) target_compile_definitions(default_dialect PRIVATE + DEFAULT_CXX17=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},17> DEFAULT_CXX14=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},14> DEFAULT_CXX11=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},11> DEFAULT_CXX98=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},98> ) endif() endif() +endif () +# always add a target "CompileFeatures" +if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" + "int main(int,char**) { return 0; }\n" + ) + add_executable(CompileFeatures "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") +else() + # these tests only work if at least cxx_auto_type is available add_executable(CompileFeatures main.cpp) set_property(TARGET CompileFeatures PROPERTY COMPILE_FEATURES "cxx_auto_type" @@ -396,7 +409,7 @@ if (CMAKE_CXX_COMPILE_FEATURES) ) add_executable(CompileFeaturesGenex2 genex_test.cpp) - target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert) + target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11) target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> @@ -405,10 +418,10 @@ if (CMAKE_CXX_COMPILE_FEATURES) HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> ) - add_library(static_assert_iface INTERFACE) - target_compile_features(static_assert_iface INTERFACE cxx_static_assert) + add_library(std_11_iface INTERFACE) + target_compile_features(std_11_iface INTERFACE cxx_std_11) add_executable(CompileFeaturesGenex3 genex_test.cpp) - target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface) + target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface) target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> diff --git a/Tests/CompileFeatures/cxx_right_angle_brackets.cpp b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp index 8f1b0ee..4d494b5 100644 --- a/Tests/CompileFeatures/cxx_right_angle_brackets.cpp +++ b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp @@ -7,6 +7,8 @@ struct A void someFunc() { - A<A<int> > object; + /* clang-format off */ + A<A<int>> object; + /* clang-format on */ (void)object; } diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 0efaefa..9b65b42 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -2,7 +2,11 @@ template <long l> struct Outputter; -#if DEFAULT_CXX14 +#if DEFAULT_CXX17 +#if __cplusplus <= 201402L +Outputter<__cplusplus> o; +#endif +#elif DEFAULT_CXX14 #if __cplusplus != 201402L Outputter<__cplusplus> o; #endif diff --git a/Tests/Cuda/.clang-format b/Tests/Cuda/.clang-format new file mode 100644 index 0000000..a77589a --- /dev/null +++ b/Tests/Cuda/.clang-format @@ -0,0 +1,9 @@ +--- +# This configuration requires clang-format 3.8 or higher. +BasedOnStyle: Mozilla +AlignOperands: false +AlwaysBreakAfterReturnType: None +AlwaysBreakAfterDefinitionReturnType: None +ColumnLimit: 79 +Standard: Cpp11 +... diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt new file mode 100644 index 0000000..de48501 --- /dev/null +++ b/Tests/Cuda/CMakeLists.txt @@ -0,0 +1,7 @@ + +ADD_TEST_MACRO(Cuda.Complex CudaComplex) +ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures) +ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary) +ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude) +ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) +ADD_TEST_MACRO(Cuda.WithC CudaWithC) diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt new file mode 100644 index 0000000..bff7d07 --- /dev/null +++ b/Tests/Cuda/Complex/CMakeLists.txt @@ -0,0 +1,40 @@ + +cmake_minimum_required(VERSION 3.7) +project (CudaComplex CXX CUDA) +#Goal for this example: + +#build a cpp dynamic library base +#build a cuda static library base that uses separable compilation + +#build a cuda dynamic library that uses the first dynamic library +#build a mixed cpp & cuda dynamic library uses all 3 previous libraries + +#lastly build a cpp executable that uses this last cuda dynamic library + +#this tests that we can properly handle linking cuda and cpp together +#and also bulding cpp targets that need cuda implicit libraries + +#verify that we can pass explicit cuda arch flags +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CXX_STANDARD 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(CudaComplexMixedLib SHARED mixed.cpp mixed.cu) +target_link_libraries(CudaComplexMixedLib + PUBLIC CudaComplexSharedLib + PRIVATE CudaComplexSeperableLib) + +add_executable(CudaComplex main.cpp) +target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib) diff --git a/Tests/Cuda/Complex/dynamic.cpp b/Tests/Cuda/Complex/dynamic.cpp new file mode 100644 index 0000000..3848ce7 --- /dev/null +++ b/Tests/Cuda/Complex/dynamic.cpp @@ -0,0 +1,11 @@ + +#ifdef _WIN32 +#define EXPORT __declspec(dllexport) +#else +#define EXPORT +#endif + +EXPORT int dynamic_base_func(int x) +{ + return x * x; +} diff --git a/Tests/Cuda/Complex/dynamic.cu b/Tests/Cuda/Complex/dynamic.cu new file mode 100644 index 0000000..82255c5 --- /dev/null +++ b/Tests/Cuda/Complex/dynamic.cu @@ -0,0 +1,30 @@ + +#include <cuda.h> +#include <iostream> +#include <string> + +#ifdef _WIN32 +#define EXPORT __declspec(dllexport) +#else +#define EXPORT +#endif + +int dynamic_base_func(int); + +EXPORT int __host__ cuda_dynamic_host_func(int x) +{ + return dynamic_base_func(x); +} + +static __global__ void DetermineIfValidCudaDevice() +{ +} + +EXPORT void cuda_dynamic_lib_func() +{ + DetermineIfValidCudaDevice<<<1, 1>>>(); + cudaError_t err = cudaGetLastError(); + if (err == cudaSuccess) { + std::cerr << cudaGetErrorString(err) << std::endl; + } +} diff --git a/Tests/Cuda/Complex/file1.cu b/Tests/Cuda/Complex/file1.cu new file mode 100644 index 0000000..1ce63bf --- /dev/null +++ b/Tests/Cuda/Complex/file1.cu @@ -0,0 +1,10 @@ + +#include "file1.h" + +result_type __device__ file1_func(int x) +{ + result_type r; + r.input = x; + r.sum = x * x; + return r; +} diff --git a/Tests/Cuda/Complex/file1.h b/Tests/Cuda/Complex/file1.h new file mode 100644 index 0000000..ff1945c --- /dev/null +++ b/Tests/Cuda/Complex/file1.h @@ -0,0 +1,7 @@ + +#pragma once +struct result_type +{ + int input; + int sum; +}; diff --git a/Tests/Cuda/Complex/file2.cu b/Tests/Cuda/Complex/file2.cu new file mode 100644 index 0000000..74f3558 --- /dev/null +++ b/Tests/Cuda/Complex/file2.cu @@ -0,0 +1,16 @@ + +#include "file2.h" + +result_type __device__ file1_func(int x); + +result_type_dynamic __device__ file2_func(int x) +{ + if (x != 42) { + const result_type r = file1_func(x); + const result_type_dynamic rd{ r.input, r.sum, true }; + return rd; + } else { + const result_type_dynamic rd{ x, x * x * x, false }; + return rd; + } +} diff --git a/Tests/Cuda/Complex/file2.h b/Tests/Cuda/Complex/file2.h new file mode 100644 index 0000000..d2dbaa4 --- /dev/null +++ b/Tests/Cuda/Complex/file2.h @@ -0,0 +1,10 @@ + +#pragma once +#include "file1.h" + +struct result_type_dynamic +{ + int input; + int sum; + bool from_static; +}; diff --git a/Tests/Cuda/Complex/file3.cu b/Tests/Cuda/Complex/file3.cu new file mode 100644 index 0000000..7c37d66 --- /dev/null +++ b/Tests/Cuda/Complex/file3.cu @@ -0,0 +1,26 @@ + +#include <iostream> + +#include "file1.h" +#include "file2.h" + +result_type __device__ file1_func(int x); +result_type_dynamic __device__ file2_func(int x); + +static __global__ void file3_kernel(result_type& r, int x) +{ + r = file1_func(x); + result_type_dynamic rd = file2_func(x); +} + +int file3_launch_kernel(int x) +{ + result_type r; + file3_kernel<<<1, 1>>>(r, x); + cudaError_t err = cudaGetLastError(); + if (err == cudaSuccess) { + std::cerr << cudaGetErrorString(err) << std::endl; + return x; + } + return r.sum; +} diff --git a/Tests/Cuda/Complex/main.cpp b/Tests/Cuda/Complex/main.cpp new file mode 100644 index 0000000..5a3f820 --- /dev/null +++ b/Tests/Cuda/Complex/main.cpp @@ -0,0 +1,20 @@ +#include <iostream> + +#include "file1.h" +#include "file2.h" + +#ifdef _WIN32 +#define IMPORT __declspec(dllimport) +#else +#define IMPORT +#endif + +IMPORT int call_cuda_seperable_code(int x); +IMPORT int mixed_launch_kernel(int x); + +int main(int argc, char** argv) +{ + call_cuda_seperable_code(42); + mixed_launch_kernel(42); + return 0; +} diff --git a/Tests/Cuda/Complex/mixed.cpp b/Tests/Cuda/Complex/mixed.cpp new file mode 100644 index 0000000..bd32e51 --- /dev/null +++ b/Tests/Cuda/Complex/mixed.cpp @@ -0,0 +1,22 @@ + +#ifdef _WIN32 +#define EXPORT __declspec(dllexport) +#define IMPORT __declspec(dllimport) +#else +#define EXPORT +#define IMPORT +#endif + +int dynamic_base_func(int); +IMPORT int cuda_dynamic_host_func(int); +int file3_launch_kernel(int); + +int dynamic_final_func(int x) +{ + return cuda_dynamic_host_func(dynamic_base_func(x)); +} + +EXPORT int call_cuda_seperable_code(int x) +{ + return file3_launch_kernel(x); +} diff --git a/Tests/Cuda/Complex/mixed.cu b/Tests/Cuda/Complex/mixed.cu new file mode 100644 index 0000000..4bba07c --- /dev/null +++ b/Tests/Cuda/Complex/mixed.cu @@ -0,0 +1,33 @@ + +#include <iostream> + +#include "file1.h" +#include "file2.h" + +#ifdef _WIN32 +#define EXPORT __declspec(dllexport) +#define IMPORT __declspec(dllimport) +#else +#define EXPORT +#define IMPORT +#endif + +result_type __device__ file1_func(int x); +result_type_dynamic __device__ file2_func(int x); + +IMPORT void __host__ cuda_dynamic_lib_func(); + +static __global__ void mixed_kernel(result_type& r, int x) +{ + r = file1_func(x); + result_type_dynamic rd = file2_func(x); +} + +EXPORT int mixed_launch_kernel(int x) +{ + cuda_dynamic_lib_func(); + + result_type r; + mixed_kernel<<<1, 1>>>(r, x); + return r.sum; +} diff --git a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt new file mode 100644 index 0000000..9fda2d0 --- /dev/null +++ b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt @@ -0,0 +1,17 @@ + +cmake_minimum_required(VERSION 3.7) +project (CudaConsumeCompileFeatures CXX CUDA) +#Goal for this example: + +#build a c++11 library that express a c++11 public compile feature +#link a cuda library and verify it builds with c++11 enabled + +#build a standalone c++/cuda mixed executable where we express a c++11 +#compile feature. + + +add_library(CudaConsumeLib STATIC static.cpp static.cu) +target_compile_features(CudaConsumeLib PUBLIC cxx_nullptr) + +add_executable(CudaConsumeCompileFeatures main.cu) +target_link_libraries(CudaConsumeCompileFeatures PRIVATE CudaConsumeLib) diff --git a/Tests/Cuda/ConsumeCompileFeatures/main.cu b/Tests/Cuda/ConsumeCompileFeatures/main.cu new file mode 100644 index 0000000..bc32450 --- /dev/null +++ b/Tests/Cuda/ConsumeCompileFeatures/main.cu @@ -0,0 +1,20 @@ + +#include <iostream> + +int static_cxx11_func(int); + +void test_functions() +{ + auto x = static_cxx11_func(int(42)); + std::cout << x << std::endl; +} + +int main(int argc, char** argv) +{ + test_functions(); + std::cout + << "this executable doesn't use cuda code, just call methods defined" + << std::endl; + std::cout << "in libraries that have cuda code" << std::endl; + return 0; +} diff --git a/Tests/Cuda/ConsumeCompileFeatures/static.cpp b/Tests/Cuda/ConsumeCompileFeatures/static.cpp new file mode 100644 index 0000000..565d52e --- /dev/null +++ b/Tests/Cuda/ConsumeCompileFeatures/static.cpp @@ -0,0 +1,10 @@ + + +#include <type_traits> + +int static_cuda11_func(int); + +int static_cxx11_func(int x) +{ + return static_cuda11_func(x) + std::integral_constant<int, 32>::value; +} diff --git a/Tests/Cuda/ConsumeCompileFeatures/static.cu b/Tests/Cuda/ConsumeCompileFeatures/static.cu new file mode 100644 index 0000000..73e43a8 --- /dev/null +++ b/Tests/Cuda/ConsumeCompileFeatures/static.cu @@ -0,0 +1,9 @@ + +#include <type_traits> + +using tt = std::true_type; +using ft = std::false_type; +int __host__ static_cuda11_func(int x) +{ + return x * x + std::integral_constant<int, 17>::value; +} diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt new file mode 100644 index 0000000..cbe1e67 --- /dev/null +++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.7) +project (CudaObjectLibrary CUDA CXX) +#Goal for this example: + +#build a object files some with cuda and some without than +#embed these into an executable + +add_library(CudaMixedObjectLib OBJECT static.cu static.cpp) + +add_executable(CudaObjectLibrary + main.cpp + $<TARGET_OBJECTS:CudaMixedObjectLib>) diff --git a/Tests/Cuda/ObjectLibrary/main.cpp b/Tests/Cuda/ObjectLibrary/main.cpp new file mode 100644 index 0000000..1a70a99 --- /dev/null +++ b/Tests/Cuda/ObjectLibrary/main.cpp @@ -0,0 +1,20 @@ + +#include <iostream> + +int static_func(int); +int file1_sq_func(int); + +void test_functions() +{ + file1_sq_func(static_func(42)); +} + +int main(int argc, char** argv) +{ + test_functions(); + std::cout + << "this executable doesn't use cuda code, just call methods defined" + << std::endl; + std::cout << "in object files that have cuda code" << std::endl; + return 0; +} diff --git a/Tests/Cuda/ObjectLibrary/static.cpp b/Tests/Cuda/ObjectLibrary/static.cpp new file mode 100644 index 0000000..6db1f91 --- /dev/null +++ b/Tests/Cuda/ObjectLibrary/static.cpp @@ -0,0 +1,6 @@ +int file1_sq_func(int); + +int static_func(int x) +{ + return file1_sq_func(x); +} diff --git a/Tests/Cuda/ObjectLibrary/static.cu b/Tests/Cuda/ObjectLibrary/static.cu new file mode 100644 index 0000000..cdf682b --- /dev/null +++ b/Tests/Cuda/ObjectLibrary/static.cu @@ -0,0 +1,21 @@ + +#include <cuda.h> +#include <cuda_runtime.h> +#include <iostream> + +int __host__ file1_sq_func(int x) +{ + cudaError_t err; + int nDevices = 0; + err = cudaGetDeviceCount(&nDevices); + if (err != cudaSuccess) { + std::cout << "nDevices: " << nDevices << std::endl; + std::cout << "err: " << err << std::endl; + return 1; + } + std::cout << "this library uses cuda code" << std::endl; + std::cout << "you have " << nDevices << " devices that support cuda" + << std::endl; + + return x * x; +} diff --git a/Tests/Cuda/ProperLinkFlags/CMakeLists.txt b/Tests/Cuda/ProperLinkFlags/CMakeLists.txt new file mode 100644 index 0000000..b6e0e39 --- /dev/null +++ b/Tests/Cuda/ProperLinkFlags/CMakeLists.txt @@ -0,0 +1,20 @@ + +cmake_minimum_required(VERSION 3.7) +project (ProperLinkFlags CUDA CXX) + +#Goal for this example: +#Verify that when we have CXX and CUDA enabled and we link an executable that +#has CUDA and CXX we use the CUDA link flags when doing the device link +#step + +#Specify a set of valid CUDA flags and an invalid set of CXX flags ( for CUDA ) +#to make sure we don't use the CXX flags when linking CUDA executables +string(APPEND CMAKE_CUDA_FLAGS " -arch=sm_35 --use_fast_math") +set(CMAKE_CXX_FLAGS "-Wall") + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CUDA_STANDARD 11) +add_executable(ProperLinkFlags file1.cu main.cxx) + +set_target_properties( ProperLinkFlags + PROPERTIES CUDA_SEPARABLE_COMPILATION ON) diff --git a/Tests/Cuda/ProperLinkFlags/file1.cu b/Tests/Cuda/ProperLinkFlags/file1.cu new file mode 100644 index 0000000..9a105f0 --- /dev/null +++ b/Tests/Cuda/ProperLinkFlags/file1.cu @@ -0,0 +1,11 @@ + +#include "file1.h" + +result_type __device__ file1_func(int x) +{ + __ldg(&x); + result_type r; + r.input = x; + r.sum = x * x; + return r; +} diff --git a/Tests/Cuda/ProperLinkFlags/file1.h b/Tests/Cuda/ProperLinkFlags/file1.h new file mode 100644 index 0000000..ff1945c --- /dev/null +++ b/Tests/Cuda/ProperLinkFlags/file1.h @@ -0,0 +1,7 @@ + +#pragma once +struct result_type +{ + int input; + int sum; +}; diff --git a/Tests/Cuda/ProperLinkFlags/main.cxx b/Tests/Cuda/ProperLinkFlags/main.cxx new file mode 100644 index 0000000..7c0ee9e --- /dev/null +++ b/Tests/Cuda/ProperLinkFlags/main.cxx @@ -0,0 +1,9 @@ + +#include <iostream> + +#include "file1.h" + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/Cuda/ToolkitInclude/CMakeLists.txt b/Tests/Cuda/ToolkitInclude/CMakeLists.txt new file mode 100644 index 0000000..f246b54 --- /dev/null +++ b/Tests/Cuda/ToolkitInclude/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project (ToolkitInclude 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 + ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) diff --git a/Tests/Cuda/ToolkitInclude/main.cpp b/Tests/Cuda/ToolkitInclude/main.cpp new file mode 100644 index 0000000..c8d5c6b --- /dev/null +++ b/Tests/Cuda/ToolkitInclude/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/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt new file mode 100644 index 0000000..1f25ab4 --- /dev/null +++ b/Tests/Cuda/WithC/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.7) +project(CudaComplex CUDA C) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +add_executable(CudaWithC main.c cuda.cu) + +if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + target_link_libraries(CudaWithC PRIVATE -Wl,-rpath,/usr/local/cuda/lib) +endif() diff --git a/Tests/Cuda/WithC/cuda.cu b/Tests/Cuda/WithC/cuda.cu new file mode 100644 index 0000000..06bd7b9 --- /dev/null +++ b/Tests/Cuda/WithC/cuda.cu @@ -0,0 +1,16 @@ +#include <cuda.h> + +#include <iostream> + +extern "C" int use_cuda(void) +{ + 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; + } + std::cout << "Found " << nDevices << " CUDA enabled devices" << std::endl; + return 0; +} diff --git a/Tests/Cuda/WithC/main.c b/Tests/Cuda/WithC/main.c new file mode 100644 index 0000000..cb5fddc --- /dev/null +++ b/Tests/Cuda/WithC/main.c @@ -0,0 +1,14 @@ +extern int use_cuda(void); + +#ifdef _WIN32 +#include <windows.h> +#endif + +int main() +{ +#ifdef _WIN32 + /* Use an API that requires CMake's "standard" C libraries. */ + GetOpenFileName(NULL); +#endif + return use_cuda(); +} diff --git a/Tests/CudaOnly/.clang-format b/Tests/CudaOnly/.clang-format new file mode 100644 index 0000000..a77589a --- /dev/null +++ b/Tests/CudaOnly/.clang-format @@ -0,0 +1,9 @@ +--- +# This configuration requires clang-format 3.8 or higher. +BasedOnStyle: Mozilla +AlignOperands: false +AlwaysBreakAfterReturnType: None +AlwaysBreakAfterDefinitionReturnType: None +ColumnLimit: 79 +Standard: Cpp11 +... diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt new file mode 100644 index 0000000..85a2051 --- /dev/null +++ b/Tests/CudaOnly/CMakeLists.txt @@ -0,0 +1,4 @@ + +ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) +ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) +ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt new file mode 100644 index 0000000..35a1deb --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt @@ -0,0 +1,26 @@ + +cmake_minimum_required(VERSION 3.7) +project (CudaOnlyEnableStandard CUDA) + +#Goal for this example: +#build cuda sources that require C++11 to be enabled. + +add_library(CUDAStatic11 STATIC static.cu) +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) + +#Verify CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES +foreach(dir ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) + if(NOT IS_DIRECTORY "${dir}") + message(FATAL_ERROR + "CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES entry\n" + " ${dir}\n" + "is not an existing directory." + ) + endif() +endforeach() diff --git a/Tests/CudaOnly/EnableStandard/main.cu b/Tests/CudaOnly/EnableStandard/main.cu new file mode 100644 index 0000000..f219583 --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/main.cu @@ -0,0 +1,23 @@ + +#include <iostream> + +#ifdef _WIN32 +#define IMPORT __declspec(dllimport) +#else +#define IMPORT +#endif + +int static_cuda11_func(int); +IMPORT int shared_cuda11_func(int); + +void test_functions() +{ + static_cuda11_func(int(42)); + shared_cuda11_func(int(42)); +} + +int main(int argc, char** argv) +{ + test_functions(); + return 0; +} diff --git a/Tests/CudaOnly/EnableStandard/shared.cu b/Tests/CudaOnly/EnableStandard/shared.cu new file mode 100644 index 0000000..ccdd0b2 --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/shared.cu @@ -0,0 +1,15 @@ + +#include <type_traits> + +#ifdef _WIN32 +#define EXPORT __declspec(dllexport) +#else +#define EXPORT +#endif + +using tt = std::true_type; +using ft = std::false_type; +EXPORT int __host__ shared_cuda11_func(int x) +{ + return x * x + std::integral_constant<int, 17>::value; +} diff --git a/Tests/CudaOnly/EnableStandard/static.cu b/Tests/CudaOnly/EnableStandard/static.cu new file mode 100644 index 0000000..73e43a8 --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/static.cu @@ -0,0 +1,9 @@ + +#include <type_traits> + +using tt = std::true_type; +using ft = std::false_type; +int __host__ static_cuda11_func(int x) +{ + return x * x + std::integral_constant<int, 17>::value; +} diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt new file mode 100644 index 0000000..d134b96 --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -0,0 +1,33 @@ + +cmake_minimum_required(VERSION 3.7) +project (CudaOnlySeparateCompilation CUDA) + +#Goal for this example: +#Build a static library that defines multiple methods and kernels that +#use each other. +#After that confirm that we can call those methods from dynamic libraries +#and executables. +#We complicate the matter by also testing that multiple static libraries +#all containing cuda separable compilation code links properly +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CUDA_STANDARD 11) +add_library(CUDASerarateLibA STATIC file1.cu file2.cu file3.cu) + +#Having file4/file5 in a shared library causes serious problems +#with the nvcc linker and it will generate bad entries that will +#cause a segv when trying to run the executable +# +add_library(CUDASerarateLibB STATIC file4.cu file5.cu) +target_link_libraries(CUDASerarateLibB PRIVATE CUDASerarateLibA) + +add_executable(CudaOnlySeparateCompilation main.cu) +target_link_libraries(CudaOnlySeparateCompilation PRIVATE CUDASerarateLibB) + +set_target_properties( CUDASerarateLibA + CUDASerarateLibB + PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + +set_target_properties( CUDASerarateLibA + CUDASerarateLibB + PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/Tests/CudaOnly/SeparateCompilation/file1.cu b/Tests/CudaOnly/SeparateCompilation/file1.cu new file mode 100644 index 0000000..1ce63bf --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/file1.cu @@ -0,0 +1,10 @@ + +#include "file1.h" + +result_type __device__ file1_func(int x) +{ + result_type r; + r.input = x; + r.sum = x * x; + return r; +} diff --git a/Tests/CudaOnly/SeparateCompilation/file1.h b/Tests/CudaOnly/SeparateCompilation/file1.h new file mode 100644 index 0000000..ff1945c --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/file1.h @@ -0,0 +1,7 @@ + +#pragma once +struct result_type +{ + int input; + int sum; +}; diff --git a/Tests/CudaOnly/SeparateCompilation/file2.cu b/Tests/CudaOnly/SeparateCompilation/file2.cu new file mode 100644 index 0000000..74f3558 --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/file2.cu @@ -0,0 +1,16 @@ + +#include "file2.h" + +result_type __device__ file1_func(int x); + +result_type_dynamic __device__ file2_func(int x) +{ + if (x != 42) { + const result_type r = file1_func(x); + const result_type_dynamic rd{ r.input, r.sum, true }; + return rd; + } else { + const result_type_dynamic rd{ x, x * x * x, false }; + return rd; + } +} diff --git a/Tests/CudaOnly/SeparateCompilation/file2.h b/Tests/CudaOnly/SeparateCompilation/file2.h new file mode 100644 index 0000000..d2dbaa4 --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/file2.h @@ -0,0 +1,10 @@ + +#pragma once +#include "file1.h" + +struct result_type_dynamic +{ + int input; + int sum; + bool from_static; +}; diff --git a/Tests/CudaOnly/SeparateCompilation/file3.cu b/Tests/CudaOnly/SeparateCompilation/file3.cu new file mode 100644 index 0000000..155b513 --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/file3.cu @@ -0,0 +1,22 @@ + + +#include "file1.h" +#include "file2.h" + +result_type __device__ file1_func(int x); +result_type_dynamic __device__ file2_func(int x); + +static __global__ void file3_kernel(result_type& r, int x) +{ + // call static_func which is a method that is defined in the + // static library that is always out of date + r = file1_func(x); + result_type_dynamic rd = file2_func(x); +} + +result_type file3_launch_kernel(int x) +{ + result_type r; + file3_kernel<<<1, 1>>>(r, x); + return r; +} diff --git a/Tests/CudaOnly/SeparateCompilation/file4.cu b/Tests/CudaOnly/SeparateCompilation/file4.cu new file mode 100644 index 0000000..2e3e01e --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/file4.cu @@ -0,0 +1,23 @@ + +#include <iostream> + +#include "file1.h" +#include "file2.h" + +result_type __device__ file1_func(int x); +result_type_dynamic __device__ file2_func(int x); + +static __global__ void file4_kernel(result_type& r, int x) +{ + // call static_func which is a method that is defined in the + // static library that is always out of date + r = file1_func(x); + result_type_dynamic rd = file2_func(x); +} + +int file4_launch_kernel(int x) +{ + result_type r; + file4_kernel<<<1, 1>>>(r, x); + return r.sum; +} diff --git a/Tests/CudaOnly/SeparateCompilation/file5.cu b/Tests/CudaOnly/SeparateCompilation/file5.cu new file mode 100644 index 0000000..fee8e9e --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/file5.cu @@ -0,0 +1,23 @@ + +#include <iostream> + +#include "file1.h" +#include "file2.h" + +result_type __device__ file1_func(int x); +result_type_dynamic __device__ file2_func(int x); + +static __global__ void file5_kernel(result_type& r, int x) +{ + // call static_func which is a method that is defined in the + // static library that is always out of date + r = file1_func(x); + result_type_dynamic rd = file2_func(x); +} + +int file5_launch_kernel(int x) +{ + result_type r; + file5_kernel<<<1, 1>>>(r, x); + return r.sum; +} diff --git a/Tests/CudaOnly/SeparateCompilation/main.cu b/Tests/CudaOnly/SeparateCompilation/main.cu new file mode 100644 index 0000000..03e0921 --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/main.cu @@ -0,0 +1,15 @@ + +#include <iostream> + +#include "file1.h" +#include "file2.h" + +int file4_launch_kernel(int x); +int file5_launch_kernel(int x); + +int main(int argc, char** argv) +{ + file4_launch_kernel(42); + file5_launch_kernel(42); + return 0; +} diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt new file mode 100644 index 0000000..2646d29 --- /dev/null +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -0,0 +1,36 @@ + +cmake_minimum_required(VERSION 3.7) +project (CudaOnlyWithDefs CUDA) + +#verify that we can pass explicit cuda arch flags +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +set(debug_compile_flags --generate-code arch=compute_20,code=sm_20) +if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC") + list(APPEND debug_compile_flags -Xcompiler=-WX) +else() + list(APPEND debug_compile_flags -Xcompiler=-Werror) +endif() +set(release_compile_defs DEFREL) + +#Goal for this example: +#build a executable that needs to be passed a complex define through add_defintions +#this verifies we can pass things such as '_','(' to nvcc +add_definitions("-DPACKED_DEFINE=__attribute__((packed))") +set_source_files_properties(main.notcu PROPERTIES LANGUAGE CUDA) +add_executable(CudaOnlyWithDefs main.notcu) + +target_compile_options(CudaOnlyWithDefs + PRIVATE + $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>> + ) + +target_compile_definitions(CudaOnlyWithDefs + PRIVATE + $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>> + ) + +#we need to add an rpath for the cuda library so that everything +#loads properly on the mac +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + set_target_properties(CudaOnlyWithDefs PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") +endif() diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu new file mode 100644 index 0000000..80ed3a5 --- /dev/null +++ b/Tests/CudaOnly/WithDefs/main.notcu @@ -0,0 +1,53 @@ +#include <cuda.h> +#include <cuda_runtime.h> +#include <iostream> + +#ifndef PACKED_DEFINE +#error "PACKED_DEFINE not defined!" +#endif + +static __global__ void DetermineIfValidCudaDevice() +{ +} + +#ifdef _MSC_VER +#pragma pack(push, 1) +#undef PACKED_DEFINE +#define PACKED_DEFINE +#endif +struct PACKED_DEFINE result_type +{ + bool valid; + int value; +#if defined(NDEBUG) && !defined(DEFREL) +#error missing DEFREL flag +#endif +}; +#ifdef _MSC_VER +#pragma pack(pop) +#endif + +result_type can_launch_kernel() +{ + result_type r; + DetermineIfValidCudaDevice<<<1, 1>>>(); + r.valid = (cudaSuccess == cudaGetLastError()); + if (r.valid) { + r.value = 1; + } else { + r.value = -1; + } + return r; +} + +int main(int argc, char** argv) +{ + cudaError_t err; + int nDevices = 0; + err = cudaGetDeviceCount(&nDevices); + if (err != cudaSuccess) { + std::cerr << cudaGetErrorString(err) << std::endl; + return 1; + } + return 0; +} diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index db57e19..e9a9f52 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -513,3 +513,24 @@ add_custom_target(UseConsoleTarget ALL VERBATIM USES_TERMINAL ) + +# Test COMMAND_EXPAND_LISTS +set(cmp_args "1ARG=COMMAND_EXPAND_LISTS" "2ARG=test" "3ARG=outfile" + "4ARG=content") +set(AARGS "") +foreach(arg IN LISTS cmp_args) + list(APPEND AARGS "-DA${arg}") +endforeach() + +set(gen_file "expand_custom_command.phony") +add_custom_command( + OUTPUT "${gen_file}" + COMMAND ${CMAKE_COMMAND} ${AARGS} + "-DB$<JOIN:$<TARGET_PROPERTY:command_expand_lists,CMPARGS>,;-DB>" + "-P" "${CMAKE_CURRENT_SOURCE_DIR}/compare_options.cmake" + COMMAND_EXPAND_LISTS + VERBATIM +) +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}") diff --git a/Tests/CustomCommand/compare_options.cmake b/Tests/CustomCommand/compare_options.cmake new file mode 100644 index 0000000..a32e579 --- /dev/null +++ b/Tests/CustomCommand/compare_options.cmake @@ -0,0 +1,14 @@ +set(range 1 2 3 4 5 6 7 8 9 10) +set(aargs "") +set(bargs "") +foreach(n IN LISTS range) + set(aval "${A${n}ARG}") + set(bval "${B${n}ARG}") + if(aval OR bval) + list(APPEND aargs "\"${aval}\"") + list(APPEND bargs "\"${bval}\"") + endif() +endforeach() +if(NOT "${aargs}" STREQUAL "${bargs}") + message(FATAL_ERROR "COMPARE_OPTIONS: \n\t${aargs} != \n\t${bargs}") +endif() diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index ca6462d..72c20eb 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -363,6 +363,23 @@ if(do_git_tests) ) set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + # Live git / master (no GIT_TAG), but git config flags + # + # The `git clone --config` parameter has been introduced in Git 1.7.7 + if(NOT git_version VERSION_LESS 1.7.7) + set(proj TutorialStep1-GIT-config) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_CONFIG core.eol=lf core.autocrlf=input + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + LOG_UPDATE 1 + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + endif() + # git by explicit branch/tag with empty submodule list # set(proj TutorialStep1-GIT-bytag-withsubmodules) diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index 17f1630..5b94163 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/Tests/ExternalProjectLocal/CMakeLists.txt @@ -131,6 +131,7 @@ ExternalProject_Add(${proj} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> INSTALL_COMMAND "" LOG_BUILD 1 + UPDATE_DISCONNECTED 1 ) set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ") diff --git a/Tests/FindLibRHash/CMakeLists.txt b/Tests/FindLibRHash/CMakeLists.txt new file mode 100644 index 0000000..4d3954d --- /dev/null +++ b/Tests/FindLibRHash/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindLibRHash.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLibRHash/Test" + "${CMake_BINARY_DIR}/Tests/FindLibRHash/Test" + ${build_generator_args} + --build-project TestFindLibRHash + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindLibRHash/Test/CMakeLists.txt b/Tests/FindLibRHash/Test/CMakeLists.txt new file mode 100644 index 0000000..37e062a --- /dev/null +++ b/Tests/FindLibRHash/Test/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.7) +project(TestFindLibRHash C) +include(CTest) + +# CMake does not actually provide FindLibRHash publicly. +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules) + +find_package(LibRHash REQUIRED) + +add_executable(test_librhash_tgt main.c) +target_link_libraries(test_librhash_tgt LibRHash::LibRHash) +add_test(NAME test_librhash_tgt COMMAND test_librhash_tgt) + +add_executable(test_librhash_var main.c) +target_include_directories(test_librhash_var PRIVATE ${LibRHash_INCLUDE_DIRS}) +target_link_libraries(test_librhash_var PRIVATE ${LibRHash_LIBRARIES}) +add_test(NAME test_librhash_var COMMAND test_librhash_var) diff --git a/Tests/FindLibRHash/Test/main.c b/Tests/FindLibRHash/Test/main.c new file mode 100644 index 0000000..201dced --- /dev/null +++ b/Tests/FindLibRHash/Test/main.c @@ -0,0 +1,7 @@ +#include <rhash.h> + +int main() +{ + rhash_library_init(); + return 0; +} diff --git a/Tests/FindOpenGL/CMakeLists.txt b/Tests/FindOpenGL/CMakeLists.txt new file mode 100644 index 0000000..9aa3aba --- /dev/null +++ b/Tests/FindOpenGL/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindOpenGL.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindOpenGL/Test" + "${CMake_BINARY_DIR}/Tests/FindOpenGL/Test" + ${build_generator_args} + --build-project TestFindOpenGL + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt new file mode 100644 index 0000000..cac3424 --- /dev/null +++ b/Tests/FindOpenGL/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.7) +project(TestFindOpenGL C) +include(CTest) + +find_package(OpenGL REQUIRED) + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt OpenGL::GLU) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${OPENGL_INGLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${OPENGL_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindOpenGL/Test/main.c b/Tests/FindOpenGL/Test/main.c new file mode 100644 index 0000000..bca3d7e --- /dev/null +++ b/Tests/FindOpenGL/Test/main.c @@ -0,0 +1,17 @@ +#ifdef _WIN32 +#include <windows.h> +#endif +#ifdef __APPLE__ +#include <OpenGL/gl.h> +#else +#include <GL/gl.h> +#endif + +#include <stdio.h> + +int main() +{ + /* Reference a GL symbol without requiring a context at runtime. */ + printf("&glGetString = %p\n", &glGetString); + return 0; +} diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 56fcc5d..23832da 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -20,16 +20,9 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) # now set up the test: - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk" - CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n" - ) - else() - get_target_property(cmakeLocation cmake LOCATION) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk" - "CMAKE = \"${cmakeLocation}\"\n" - ) - endif() + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk" + CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n" + ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt index 271aaf1..a313c2c 100644 --- a/Tests/Framework/CMakeLists.txt +++ b/Tests/Framework/CMakeLists.txt @@ -57,29 +57,30 @@ add_custom_target(fooCustom ALL COMMAND ${CMAKE_COMMAND} -E copy foo-post-build add_dependencies(fooCustom foo) # Make a static library and apply the framework properties to it to verify -# that everything still builds correctly, but it will not actually produce -# a framework... The framework properties only apply when the library type -# is SHARED. +# that everything still builds correctly. Xcode prior to version 5 does not +# support static Frameworks. # -add_library(fooStatic STATIC - foo.cxx - foo.h - foo2.h - fooExtensionlessResource - fooPublic.h - fooPublicExtensionlessHeader - fooPrivate.h - fooPrivateExtensionlessHeader - fooNeither.h - fooBoth.h - test.lua - fooDeepPublic.h -) -set_target_properties(fooStatic PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION none -) -add_executable(barStatic bar.cxx) -target_link_libraries(barStatic fooStatic) +if(NOT XCODE OR NOT XCODE_VERSION VERSION_LESS 5) + add_library(fooStatic STATIC + foo.cxx + foo.h + foo2.h + fooExtensionlessResource + fooPublic.h + fooPublicExtensionlessHeader + fooPrivate.h + fooPrivateExtensionlessHeader + fooNeither.h + fooBoth.h + test.lua + fooDeepPublic.h + ) + set_target_properties(fooStatic PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION none + ) + add_executable(barStatic bar.cxx) + target_link_libraries(barStatic fooStatic) +endif() include(CPack) diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 27f33a2..adc87cd 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -145,13 +145,13 @@ add_library(imported1 SHARED IMPORTED) set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) set_property(TARGET imported1 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) -set_property(TARGET imported1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported1/include) +set_property(TARGET imported1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "/imported1/include/with space") add_library(imported2 SHARED IMPORTED) set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) set_property(TARGET imported2 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) -set_property(TARGET imported2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported2/include) +set_property(TARGET imported2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "/imported2/include/with space") add_library(imported3 SHARED IMPORTED) set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) @@ -161,6 +161,10 @@ set_property(TARGET imported3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:DEBUG>:$<TARGET_PROPERTY:imported1,INTERFACE_INCLUDE_DIRECTORIES>>) set_property(TARGET imported3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELEASE>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) +set_property(TARGET imported3 APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELWITHDEBINFO>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) +set_property(TARGET imported3 APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:MINSIZEREL>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) add_library(imported4 SHARED IMPORTED) set_property(TARGET imported4 APPEND PROPERTY @@ -171,6 +175,13 @@ add_executable(Alias::SomeExe ALIAS someexe) add_library(Alias::SomeLib ALIAS empty1) +add_library(importedFallback STATIC IMPORTED) +set_property(TARGET importedFallback PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +set_property(TARGET importedFallback PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET importedFallback PROPERTY IMPORTED_LOCATION fallback_loc) +set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_DEBUG "" DEBUG) +set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_RELEASE "") + add_custom_target(check-part3 ALL COMMAND ${CMAKE_COMMAND} -Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1> @@ -180,10 +191,8 @@ add_custom_target(check-part3 ALL -Dtest_version_equal_1=$<VERSION_EQUAL:1.0.1,1.1> -Dtest_version_equal_2=$<VERSION_EQUAL:1.1,1.1> -Dconfig=$<CONFIGURATION> - -Dtest_imported_debug=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> - -Dtest_imported_release=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> - -Dtest_imported_relwithdebinfo=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> - -Dtest_imported_minsizerel=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> + -Dtest_imported_includes=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> + -Dtest_imported_fallback=$<STREQUAL:$<TARGET_FILE_NAME:importedFallback>,fallback_loc> -Dtest_alias_file_exe=$<STREQUAL:$<TARGET_FILE:Alias::SomeExe>,$<TARGET_FILE:someexe>> -Dtest_alias_file_lib=$<STREQUAL:$<TARGET_FILE:Alias::SomeLib>,$<TARGET_FILE:empty1>> -Dtest_alias_target_name=$<STREQUAL:$<TARGET_PROPERTY:Alias::SomeLib,NAME>,$<TARGET_PROPERTY:empty1,NAME>> @@ -238,6 +247,10 @@ add_custom_target(check-part4 ALL # CMake as command-line argument -Dtest_shell_path=${path_prefix}$<SHELL_PATH:${test_shell_path}> -Dpath_prefix=${path_prefix} + -Dif_1=$<IF:1,a,b> + -Dif_2=$<IF:0,a,b> + -Dif_3=$<IF:$<EQUAL:10,30>,a,b> + -Dif_4=$<IF:$<EQUAL:30,30>,a,b> -DWIN32=${WIN32} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake @@ -249,6 +262,7 @@ add_custom_target(check-part4 ALL # Cover test properties with generator expressions. add_executable(echo echo.c) add_executable(pwd pwd.c) +set_property(SOURCE echo.c PROPERTY COMPILE_FLAGS $<1:-DSRC_GENEX_WORKS>) add_test(NAME echo-configuration COMMAND echo $<CONFIGURATION>) set_property(TEST echo-configuration PROPERTY diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 70ccfe1..9014406 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -8,18 +8,17 @@ check(test_version_less_2 "1") check(test_version_equal_1 "0") check(test_version_equal_2 "1") -foreach(c debug release relwithdebinfo minsizerel) - if(config AND NOT config STREQUAL NoConfig) - if(NOT "${test_imported_${c}}" MATCHES "^;/imported2/include$" - AND NOT "${test_imported_${c}}" MATCHES "^/imported1/include;$") - message(SEND_ERROR "test_imported_${c} is not correct: ${test_imported_${c}}") - endif() - else() - if(NOT "${test_imported_${c}}" MATCHES "^;$") - message(SEND_ERROR "test_imported_${c} is not an empty list: ${test_imported_${c}}") - endif() +if(config AND NOT config STREQUAL NoConfig) + if(NOT "${test_imported_includes}" MATCHES "^;*/imported[12]/include/with space;*$") + message(SEND_ERROR "test_imported_includes is not correct: ${test_imported_includes}") endif() -endforeach() +else() + if(NOT "${test_imported_includes}" MATCHES "^;;;$") + message(SEND_ERROR "test_imported_includes is not an empty list: ${test_imported_includes}") + endif() +endif() + +check(test_imported_fallback "1") check(test_alias_file_exe "1") check(test_alias_file_lib "1") diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake index 9e516d5..f5d14dd 100644 --- a/Tests/GeneratorExpression/check-part4.cmake +++ b/Tests/GeneratorExpression/check-part4.cmake @@ -13,3 +13,8 @@ if(WIN32) else() check(test_shell_path [[/shell/path]]) endif() + +check(if_1 "a") +check(if_2 "b") +check(if_3 "b") +check(if_4 "a") diff --git a/Tests/GeneratorExpression/echo.c b/Tests/GeneratorExpression/echo.c index 06b0844..41596a2 100644 --- a/Tests/GeneratorExpression/echo.c +++ b/Tests/GeneratorExpression/echo.c @@ -3,6 +3,9 @@ int main(int argc, char* argv[]) { +#ifndef SRC_GENEX_WORKS +#error SRC_GENEX_WORKS not defined +#endif printf("%s\n", argv[1]); return EXIT_SUCCESS; } diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 4920582..db18462 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -3,7 +3,9 @@ project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) - AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) + AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" + OR CMAKE_GENERATOR STREQUAL "Ninja" + OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) if(run_sys_includes_test) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index dcee85e..5078f30 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -15,10 +15,17 @@ target_include_directories(upstream SYSTEM PUBLIC ) add_library(config_specific INTERFACE) -set(testConfig ${CMAKE_BUILD_TYPE}) -target_include_directories(config_specific SYSTEM INTERFACE - "$<$<CONFIG:${testConfig}>:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>" -) +if(CMAKE_GENERATOR STREQUAL "Xcode") + # CMAKE_BUILD_TYPE does not work here for multi-config generators + target_include_directories(config_specific SYSTEM INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/config_specific" + ) +else() + set(testConfig ${CMAKE_BUILD_TYPE}) + target_include_directories(config_specific SYSTEM INTERFACE + "$<$<CONFIG:${testConfig}>:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>" + ) +endif() add_library(consumer consumer.cpp) target_link_libraries(consumer upstream config_specific) diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index ee81419..33c4b90 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -25,8 +25,25 @@ target_sources(iface_objlib INTERFACE $<TARGET_OBJECTS:objlib>) add_library(intermediate INTERFACE) target_link_libraries(intermediate INTERFACE iface_objlib) +add_library(item_fake_tgt STATIC item_fake.cpp) +set_property(TARGET item_fake_tgt PROPERTY OUTPUT_NAME item_fake) +add_library(item_real STATIC item.cpp) +add_library(item_iface INTERFACE IMPORTED) +set_property(TARGET item_iface PROPERTY IMPORTED_LIBNAME item_real) +add_dependencies(item_iface item_real) +link_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_executable(InterfaceLibrary definetestexe.cpp) -target_link_libraries(InterfaceLibrary iface_nodepends headeriface subiface intermediate) +target_link_libraries(InterfaceLibrary + iface_nodepends + headeriface + subiface + intermediate + + item_iface + item_fake # ensure that 'item_real' is ordered in place of item_iface + ) +add_dependencies(InterfaceLibrary item_fake_tgt) add_subdirectory(libsdir) @@ -47,6 +64,7 @@ target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTO add_executable(exec_whitelist dummy.cpp) target_link_libraries(exec_whitelist iface_whitelist) +set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1) add_library(iface_imported INTERFACE IMPORTED) set_property(TARGET iface_imported PROPERTY INTERFACE_COMPILE_DEFINITIONS diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp index a6b5592..098502c 100644 --- a/Tests/InterfaceLibrary/definetestexe.cpp +++ b/Tests/InterfaceLibrary/definetestexe.cpp @@ -17,8 +17,9 @@ extern int obj(); extern int sub(); +extern int item(); int main(int, char**) { - return obj() + sub(); + return obj() + sub() + item(); } diff --git a/Tests/InterfaceLibrary/item.cpp b/Tests/InterfaceLibrary/item.cpp new file mode 100644 index 0000000..85cda1b --- /dev/null +++ b/Tests/InterfaceLibrary/item.cpp @@ -0,0 +1,4 @@ +int item() +{ + return 0; +} diff --git a/Tests/InterfaceLibrary/item_fake.cpp b/Tests/InterfaceLibrary/item_fake.cpp new file mode 100644 index 0000000..b4bd829 --- /dev/null +++ b/Tests/InterfaceLibrary/item_fake.cpp @@ -0,0 +1,5 @@ +extern int item_undefined(); +int item() +{ + return item_undefined(); +} diff --git a/Tests/MacRuntimePath/A/CMakeLists.txt b/Tests/MacRuntimePath/A/CMakeLists.txt index ade0a3c..bf937e6 100644 --- a/Tests/MacRuntimePath/A/CMakeLists.txt +++ b/Tests/MacRuntimePath/A/CMakeLists.txt @@ -40,21 +40,30 @@ target_link_libraries(test3 framework) add_executable(test4 test1.cpp) target_link_libraries(test4 shared2) +# executable to test a shared library dependency with build rpath +add_executable(test5 test1.cpp) + +# avoid linking by 'target_link_libraries' so CMake +# will not be able to set correct RPATH automatically +add_dependencies(test5 shared) +target_link_libraries(test5 "$<TARGET_FILE:shared>") +set_target_properties(test5 PROPERTIES BUILD_RPATH "@loader_path/../lib") + set_target_properties(shared shared2 framework PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") -set_target_properties(test1 test2 test3 test4 PROPERTIES +set_target_properties(test1 test2 test3 test4 test5 PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") foreach(config ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${config} CONFIG) set_target_properties(shared shared2 framework PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_CURRENT_BINARY_DIR}/${config}/lib") - set_target_properties(test1 test2 test3 test4 PROPERTIES + set_target_properties(test1 test2 test3 test4 test5 PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_CURRENT_BINARY_DIR}/${config}/bin") endforeach() -foreach(test test1 test2 test3 test4) +foreach(test test1 test2 test3 test4 test5) add_custom_target(${test}_run ALL COMMAND ${test} DEPENDS ${test} diff --git a/Tests/MathTest/CMakeLists.txt b/Tests/MathTest/CMakeLists.txt index ed2c7d4..f764b3a 100644 --- a/Tests/MathTest/CMakeLists.txt +++ b/Tests/MathTest/CMakeLists.txt @@ -10,6 +10,9 @@ set(expressions "1 +(3*4) + 10 >> 2" "10000 / 20 / 4" "10000 / (20 / 4)" + "-1 + +1" + "+1 - -1" + "+1 - - + + -(-3 + - - +1)" ) set(FILE_EXPRESSIONS "") diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index 1018dd8..737e17a 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -45,6 +45,8 @@ ExternalData_Add_Test(Data1 -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat} -D Directory=DATA{Directory/,A.dat,REGEX:[BC].dat} -D DirRecurse=DATA{DirRecurse/,RECURSE:,A.dat,REGEX:[BC].dat} + -D MultipleAlgorithmNoSHA1=DATA{MultipleAlgorithmNoSHA1.dat} + -D MultipleAlgorithmNoMD5=DATA{MultipleAlgorithmNoMD5.dat} -D "Semicolons=DATA{Data.dat}\\;DATA{Data.dat}" -P ${CMAKE_CURRENT_SOURCE_DIR}/Data1Check.cmake ) diff --git a/Tests/Module/ExternalData/MultipleAlgorithmNoMD5.dat.md5 b/Tests/Module/ExternalData/MultipleAlgorithmNoMD5.dat.md5 new file mode 100644 index 0000000..a956f36 --- /dev/null +++ b/Tests/Module/ExternalData/MultipleAlgorithmNoMD5.dat.md5 @@ -0,0 +1 @@ +29848e54a4d0343f138ab14419b863de diff --git a/Tests/Module/ExternalData/MultipleAlgorithmNoMD5.dat.sha1 b/Tests/Module/ExternalData/MultipleAlgorithmNoMD5.dat.sha1 new file mode 100644 index 0000000..43a3540 --- /dev/null +++ b/Tests/Module/ExternalData/MultipleAlgorithmNoMD5.dat.sha1 @@ -0,0 +1 @@ +2af59a7022024974f3b8521b7ed8137c996a79f1 diff --git a/Tests/Module/ExternalData/MultipleAlgorithmNoSHA1.dat.md5 b/Tests/Module/ExternalData/MultipleAlgorithmNoSHA1.dat.md5 new file mode 100644 index 0000000..1906cbf --- /dev/null +++ b/Tests/Module/ExternalData/MultipleAlgorithmNoSHA1.dat.md5 @@ -0,0 +1 @@ +08cfcf221f76ace7b906b312284e73d7 diff --git a/Tests/Module/ExternalData/MultipleAlgorithmNoSHA1.dat.sha1 b/Tests/Module/ExternalData/MultipleAlgorithmNoSHA1.dat.sha1 new file mode 100644 index 0000000..65781b2 --- /dev/null +++ b/Tests/Module/ExternalData/MultipleAlgorithmNoSHA1.dat.sha1 @@ -0,0 +1 @@ +223b134e6e3a9bf34aa7531c009d97cff6b0d8a3 diff --git a/Tests/Module/ExternalData/SHA3_256/.gitattributes b/Tests/Module/ExternalData/SHA3_256/.gitattributes new file mode 100644 index 0000000..3e51d39 --- /dev/null +++ b/Tests/Module/ExternalData/SHA3_256/.gitattributes @@ -0,0 +1 @@ +* -crlf diff --git a/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 b/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 new file mode 100644 index 0000000..0377f5d --- /dev/null +++ b/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 @@ -0,0 +1 @@ +SeriesMixed.5 diff --git a/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256 b/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256 new file mode 100644 index 0000000..1a5db39 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256 @@ -0,0 +1 @@ +c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 8b251d7..2657aeb 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -4,6 +4,7 @@ project(WriteCompilerDetectionHeader) set(CMAKE_INCLUDE_CURRENT_DIR ON) include(WriteCompilerDetectionHeader) +include(CheckCXXSourceCompiles) get_property(cxx_known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) get_property(c_known_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) @@ -19,14 +20,78 @@ write_compiler_detection_header( ${cxx_known_features} ${c_known_features} ) -if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES) +write_compiler_detection_header( + FILE "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/multi_file_compiler_detection.h" + PREFIX MULTI + OUTPUT_FILES_VAR multi_files + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/compiler_support" + COMPILERS GNU Clang AppleClang MSVC SunPro Intel + VERSION 3.1 + FEATURES + ${cxx_known_features} ${c_known_features} +) + +macro(set_defines target true_defs false_defs) + set(defines) + foreach(def ${true_defs}) + list(APPEND defines ${def}=1) + endforeach() + foreach(def ${false_defs}) + list(APPEND defines ${def}=0) + endforeach() + target_compile_definitions(${target} + PRIVATE + ${defines} + EXPECTED_COMPILER_VERSION_MAJOR=${COMPILER_VERSION_MAJOR} + EXPECTED_COMPILER_VERSION_MINOR=${COMPILER_VERSION_MINOR} + EXPECTED_COMPILER_VERSION_PATCH=${COMPILER_VERSION_PATCH} + ) +endmacro() + +if (CMAKE_C_COMPILE_FEATURES) + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJOR "${CMAKE_C_COMPILER_VERSION}") + string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINOR "${CMAKE_C_COMPILER_VERSION}") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_C_COMPILER_VERSION}") + + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" + OR CMAKE_C_COMPILER_ID STREQUAL "Clang" + OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang" + OR CMAKE_C_COMPILER_ID STREQUAL "Intel") + add_executable(WriteCompilerDetectionHeader_C11 main.c) + set_property(TARGET WriteCompilerDetectionHeader_C11 PROPERTY C_STANDARD 11) + set_defines(WriteCompilerDetectionHeader_C11 "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT" "") + + add_executable(WriteCompilerDetectionHeader_C11_multi main_multi.c) + set_property(TARGET WriteCompilerDetectionHeader_C11_multi PROPERTY C_STANDARD 11) + set_defines(WriteCompilerDetectionHeader_C11_multi "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT" "") + target_include_directories(WriteCompilerDetectionHeader_C11_multi PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files) + + add_executable(C_undefined c_undefined.c) + set_property(TARGET C_undefined PROPERTY C_STANDARD 90) + include(CheckCCompilerFlag) + check_c_compiler_flag(-Werror=undef use_error_undef) + if (use_error_undef) + target_compile_options(C_undefined PRIVATE -Werror=undef) + endif() + + add_executable(WriteCompilerDetectionHeader_C main.c) + set_property(TARGET WriteCompilerDetectionHeader_C PROPERTY C_STANDARD 90) + set_defines(WriteCompilerDetectionHeader_C "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES" "EXPECTED_COMPILER_C_RESTRICT") + + add_executable(WriteCompilerDetectionHeader_C_multi main_multi.c) + set_property(TARGET WriteCompilerDetectionHeader_C_multi PROPERTY C_STANDARD 90) + set_defines(WriteCompilerDetectionHeader_C_multi "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES" "EXPECTED_COMPILER_C_RESTRICT") + target_include_directories(WriteCompilerDetectionHeader_C_multi PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files) + endif() +endif() + +if (NOT CMAKE_CXX_COMPILE_FEATURES) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" "int main(int,char**) { return 0; }\n" ) add_executable(WriteCompilerDetectionHeader "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") if(UNIX OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - include(CheckCXXSourceCompiles) check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n" file_include_works ) @@ -41,23 +106,6 @@ string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJO string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINOR "${CMAKE_CXX_COMPILER_VERSION}") string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_CXX_COMPILER_VERSION}") -macro(set_defines target true_defs false_defs) - set(defines) - foreach(def ${true_defs}) - list(APPEND defines ${def}=1) - endforeach() - foreach(def ${false_defs}) - list(APPEND defines ${def}=0) - endforeach() - target_compile_definitions(${target} - PRIVATE - ${defines} - EXPECTED_COMPILER_VERSION_MAJOR=${COMPILER_VERSION_MAJOR} - EXPECTED_COMPILER_VERSION_MINOR=${COMPILER_VERSION_MINOR} - EXPECTED_COMPILER_VERSION_PATCH=${COMPILER_VERSION_PATCH} - ) -endmacro() - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" @@ -79,40 +127,10 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") endif() endif() -if (CMAKE_C_COMPILER_ID STREQUAL "GNU" - OR CMAKE_C_COMPILER_ID STREQUAL "Clang" - OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang" - OR CMAKE_C_COMPILER_ID STREQUAL "Intel") - - add_executable(C_undefined c_undefined.c) - set_property(TARGET C_undefined PROPERTY C_STANDARD 90) - target_compile_options(C_undefined PRIVATE -Werror=undef) - - add_executable(WriteCompilerDetectionHeader_C main.c) - set_property(TARGET WriteCompilerDetectionHeader_C PROPERTY C_STANDARD 90) - set_defines(WriteCompilerDetectionHeader_C "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES" "EXPECTED_COMPILER_C_RESTRICT") - - add_executable(WriteCompilerDetectionHeader_C_multi main_multi.c) - set_property(TARGET WriteCompilerDetectionHeader_C_multi PROPERTY C_STANDARD 90) - set_defines(WriteCompilerDetectionHeader_C_multi "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES" "EXPECTED_COMPILER_C_RESTRICT") - target_include_directories(WriteCompilerDetectionHeader_C_multi PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files) -endif() - add_executable(WriteCompilerDetectionHeader main.cpp) set_property(TARGET WriteCompilerDetectionHeader PROPERTY CXX_STANDARD 98) set_defines(WriteCompilerDetectionHeader "${true_defs}" "${false_defs}") -write_compiler_detection_header( - FILE "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/multi_file_compiler_detection.h" - PREFIX MULTI - OUTPUT_FILES_VAR multi_files - OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/compiler_support" - COMPILERS GNU Clang AppleClang MSVC SunPro Intel - VERSION 3.1 - FEATURES - ${cxx_known_features} ${c_known_features} -) - add_executable(multi_files multi_files.cpp) set_property(TARGET multi_files PROPERTY CXX_STANDARD 98) target_include_directories(multi_files PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files) @@ -143,16 +161,30 @@ set_property(TARGET multi_files_11 PROPERTY CXX_STANDARD 11) target_include_directories(multi_files_11 PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files) set_defines(multi_files_11 "${true_defs}" "${false_defs}") -if (CMAKE_C_COMPILER_ID STREQUAL "GNU" - OR CMAKE_C_COMPILER_ID STREQUAL "Clang" - OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang" - OR CMAKE_C_COMPILER_ID STREQUAL "Intel") - add_executable(WriteCompilerDetectionHeader_C11 main.c) - set_property(TARGET WriteCompilerDetectionHeader_C11 PROPERTY C_STANDARD 11) - set_defines(WriteCompilerDetectionHeader_C11 "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT" "") - - add_executable(WriteCompilerDetectionHeader_C11_multi main_multi.c) - set_property(TARGET WriteCompilerDetectionHeader_C11_multi PROPERTY C_STANDARD 11) - set_defines(WriteCompilerDetectionHeader_C11_multi "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT" "") - target_include_directories(WriteCompilerDetectionHeader_C11_multi PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files) +# test for ALLOW_UNKNOWN_COMPILERS + +# use a compiler does not match the current one, +# so one always hits the fallback code +if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") + set(OTHER_CXX "Intel") +else() + set(OTHER_CXX "SunPro") +endif() + +write_compiler_detection_header( + FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_allow_unknown.h" + PREFIX TEST + COMPILERS ${OTHER_CXX} + FEATURES cxx_nullptr + ALLOW_UNKNOWN_COMPILERS +) + +# intentionally abuse the TEST_NULLPR variable: this will only work +# with the fallback code. +check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_allow_unknown.h\" +int main() {\n int i = TEST_NULLPTR;\n return 0; }\n" + file_include_works_allow_unknown +) +if (NOT file_include_works_allow_unknown) + message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_allow_unknown.h was expected to work, but did not.") endif() diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt index 188fd64..c185d75 100644 --- a/Tests/ObjectLibrary/A/CMakeLists.txt +++ b/Tests/ObjectLibrary/A/CMakeLists.txt @@ -21,3 +21,4 @@ add_custom_command( add_library(A OBJECT a1.c a2.c a.cmake) target_include_directories(A PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +set_property(TARGET A PROPERTY COMPILE_PDB_NAME Apdb) diff --git a/Tests/PositionIndependentTargets/.gitattributes b/Tests/PositionIndependentTargets/.gitattributes new file mode 100644 index 0000000..ed36631 --- /dev/null +++ b/Tests/PositionIndependentTargets/.gitattributes @@ -0,0 +1,2 @@ +# Do not format a source where we want a long line preserved. +pic_test.h -format.clang-format diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index 15f0338..807a427 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -214,18 +214,24 @@ set(FILE_PATH "${Preprocess_SOURCE_DIR}/file_def.h") set(TARGET_PATH "${Preprocess_SOURCE_DIR}/target_def.h") # Set some definition properties. -foreach(c "" "_DEBUG" "_RELEASE") +foreach(c "" "_DEBUG" "_RELEASE" "_RELWITHDEBINFO" "_MINSIZEREL") + set(FLAVOR "${c}") + # Treat RelWithDebInfo and MinSizeRel as Release to avoid having + # an exponentional matrix of inclusions and exclusions of defines + if("${c}" STREQUAL "_RELWITHDEBINFO" OR "${c}" STREQUAL "_MINSIZEREL") + set(FLAVOR "_RELEASE") + endif() set_property( DIRECTORY . - APPEND PROPERTY COMPILE_DEFINITIONS${c} "DIRECTORY_DEF${c}" + APPEND PROPERTY COMPILE_DEFINITIONS${c} "DIRECTORY_DEF${FLAVOR}" ) set_property( TARGET Preprocess - PROPERTY COMPILE_DEFINITIONS${c} "TARGET_DEF${c}" + PROPERTY COMPILE_DEFINITIONS${c} "TARGET_DEF${FLAVOR}" ) set_property( SOURCE preprocess.c preprocess.cxx - PROPERTY COMPILE_DEFINITIONS${c} "FILE_DEF${c}" + PROPERTY COMPILE_DEFINITIONS${c} "FILE_DEF${FLAVOR}" ) endforeach() diff --git a/Tests/QtAutoUicInterface/CMakeLists.txt b/Tests/QtAutoUicInterface/CMakeLists.txt index 555f016..70175fb 100644 --- a/Tests/QtAutoUicInterface/CMakeLists.txt +++ b/Tests/QtAutoUicInterface/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.7) project(QtAutoUicInterface) @@ -21,7 +21,6 @@ else() endif() set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) -set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) @@ -65,6 +64,6 @@ target_link_libraries(MyWidget KI18n ${QT_GUI_TARGET}) add_executable(QtAutoUicInterface main.cpp) target_compile_definitions(QtAutoUicInterface PRIVATE - UI_LIBWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/ui_libwidget.h" - UI_MYWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/ui_mywidget.h" + UI_LIBWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/LibWidget_autogen/include/ui_libwidget.h" + UI_MYWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/MyWidget_autogen/include/ui_mywidget.h" ) diff --git a/Tests/QtAutoUicInterface/libwidget.cpp b/Tests/QtAutoUicInterface/libwidget.cpp index b25f3d7..008c22a 100644 --- a/Tests/QtAutoUicInterface/libwidget.cpp +++ b/Tests/QtAutoUicInterface/libwidget.cpp @@ -7,3 +7,8 @@ LibWidget::LibWidget(QWidget* parent) { ui->setupUi(this); } + +LibWidget::~LibWidget() +{ + delete ui; +} diff --git a/Tests/QtAutoUicInterface/libwidget.h b/Tests/QtAutoUicInterface/libwidget.h index a4400d2..b6f3e82 100644 --- a/Tests/QtAutoUicInterface/libwidget.h +++ b/Tests/QtAutoUicInterface/libwidget.h @@ -16,9 +16,10 @@ class LibWidget : public QWidget Q_OBJECT public: explicit LibWidget(QWidget* parent = 0); + ~LibWidget(); private: - const std::auto_ptr<Ui::LibWidget> ui; + Ui::LibWidget* ui; }; #endif diff --git a/Tests/QtAutoUicInterface/mywidget.cpp b/Tests/QtAutoUicInterface/mywidget.cpp index 885165b..7cf1a13 100644 --- a/Tests/QtAutoUicInterface/mywidget.cpp +++ b/Tests/QtAutoUicInterface/mywidget.cpp @@ -7,3 +7,8 @@ MyWidget::MyWidget(QWidget* parent) { ui->setupUi(this); } + +MyWidget::~MyWidget() +{ + delete ui; +} diff --git a/Tests/QtAutoUicInterface/mywidget.h b/Tests/QtAutoUicInterface/mywidget.h index fc49e80..c23e55d 100644 --- a/Tests/QtAutoUicInterface/mywidget.h +++ b/Tests/QtAutoUicInterface/mywidget.h @@ -16,9 +16,10 @@ class MyWidget : public QWidget Q_OBJECT public: explicit MyWidget(QWidget* parent = 0); + ~MyWidget(); private: - const std::auto_ptr<Ui::MyWidget> ui; + Ui::MyWidget* ui; }; #endif diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index c713d1c..4b90ad8 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.7) project(QtAutogen) @@ -44,114 +44,44 @@ else() endif() -# -- RCC only -add_executable(rcconly rcconly.cpp second_resource.qrc) -set_property(TARGET rcconly PROPERTY AUTORCC ON) -target_link_libraries(rcconly ${QT_QTCORE_TARGET}) +get_property(QT_COMPILE_FEATURES TARGET ${QT_QTCORE_TARGET} PROPERTY INTERFACE_COMPILE_FEATURES) -# -- RCC empty -add_executable(rcc_empty rcc_empty.cpp rcc_empty_resource.qrc) -set_property(TARGET rcc_empty PROPERTY AUTORCC ON) -target_link_libraries(rcc_empty ${QT_QTCORE_TARGET}) +# -- Test: AUTORCC +# RCC only +add_executable(rccOnly rccOnly.cpp rccOnlyRes.qrc) +set_property(TARGET rccOnly PROPERTY AUTORCC ON) +target_link_libraries(rccOnly ${QT_QTCORE_TARGET}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) +# -- Test: AUTORCC +# RCC empty +add_executable(rccEmpty rccEmpty.cpp rccEmptyRes.qrc) +set_property(TARGET rccEmpty PROPERTY AUTORCC ON) +target_link_libraries(rccEmpty ${QT_QTCORE_TARGET}) -add_definitions(-DFOO -DSomeDefine="Barx") - -# enable relaxed mode so automoc can handle all the special cases: -set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTORCC ON) - -# create an executable and two library targets, each requiring automoc: -add_library(codeeditorLib STATIC codeeditor.cpp) - -add_library(privateSlot OBJECT private_slot.cpp) - -configure_file(generated_resource.qrc.in generated_resource.qrc @ONLY) -add_custom_command( - OUTPUT generated.txt - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" "${CMAKE_CURRENT_BINARY_DIR}/generated.txt" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" - ) - -add_custom_target(generate_moc_input - DEPENDS generated.txt - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}" - COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h" -) - -add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" -) - -if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_GENERATOR STREQUAL Ninja) - set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>) - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:TEST_DEBUG_CLASS>) -endif() - -# The -no-protection option disables the generation of include guards. Verify -# that setting the source file property has an effect by using this and -# issue an error in the preprocessor in calwidget.cpp if the include guard -# is defined. -set_source_files_properties(calwidget.ui PROPERTIES AUTOUIC_OPTIONS "-no-protection") - -add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp - multiplewidgets.cpp - xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot> - test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs} - ${CMAKE_CURRENT_BINARY_DIR}/generated_resource.qrc -) -set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h") - -add_executable(targetObjectsTest targetObjectsTest.cpp $<TARGET_OBJECTS:privateSlot>) -target_link_libraries(targetObjectsTest ${QT_LIBRARIES}) - -set_target_properties( - QtAutogen codeeditorLib privateSlot targetObjectsTest - PROPERTIES - AUTOMOC TRUE -) - -# Test AUTOMOC and AUTORCC on source files with the same name -# but in different subdirectories -add_subdirectory(sameName) - -include(GenerateExportHeader) -# The order is relevant here. B depends on A, and B headers depend on A -# headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we -# test that CMAKE_AUTOMOC successfully reads the include directories -# for the build interface from those targets. There has previously been -# a bug where caching of the include directories happened before -# extracting the includes to pass to moc. -add_subdirectory(Bdir) -add_subdirectory(Adir) -add_library(libC SHARED libC.cpp) -set_target_properties(libC PROPERTIES AUTOMOC TRUE) -generate_export_header(libC) -target_link_libraries(libC LINK_PUBLIC libB) - -target_link_libraries(QtAutogen codeeditorLib ${QT_LIBRARIES} libC) +# -- Test: AUTOUIC +# UIC only +qtx_wrap_cpp(uicOnlyMoc uicOnlySource/uiconly.h) +add_executable(uicOnly uicOnlySource/uiconly.cpp ${uicOnlyMoc}) +set_property(TARGET uicOnly PROPERTY AUTOUIC ON) +target_link_libraries(uicOnly ${QT_LIBRARIES}) +# -- Test: AUTOMOC, AUTORCC # Add not_generated_file.qrc to the source list to get the file-level # dependency, but don't generate a c++ file from it. Disable the AUTORCC # feature for this target. This tests that qrc files in the sources don't # have an effect on generation if AUTORCC is off. add_library(empty STATIC empty.cpp not_generated_file.qrc) set_target_properties(empty PROPERTIES AUTORCC OFF) - set_target_properties(empty PROPERTIES AUTOMOC TRUE) target_link_libraries(empty no_link_language) add_library(no_link_language STATIC empty.h) set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE) +# Pass Qt compiler features to targets that don't link against Qt +target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES}) +target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) -qtx_wrap_cpp(uicOnlyMoc sub/uiconly.h) -add_executable(uiconly sub/uiconly.cpp ${uicOnlyMoc}) -target_link_libraries(uiconly ${QT_LIBRARIES}) - +# -- Test: AUTORCC +# When a file listed in a .qrc file changes the target must be rebuilt try_compile(RCC_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends" "${CMAKE_CURRENT_SOURCE_DIR}/autorcc_depends" @@ -185,7 +115,8 @@ if (NOT file1_step1 GREATER file1_before) message(SEND_ERROR "file1 (${qrc_file1}) should have changed in the first step!") endif() -#----------------------------------------------------------------------------- +# -- Test: AUTOMOC +# Ensure a repeated build succeeds when a header containing a QObject changes try_compile(MOC_RERUN "${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun" "${CMAKE_CURRENT_SOURCE_DIR}/automoc_rerun" @@ -207,3 +138,74 @@ execute_process(COMMAND "${CMAKE_COMMAND}" --build . if (automoc_rerun_result) message(SEND_ERROR "Second build of automoc_rerun failed.") endif() + +# -- Test: AUTOMOC, SKIP_AUTOMOC +# Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target +qtx_wrap_cpp(skipMocWrapMoc + skipSource/qItemA.hpp + skipSource/qItemB.hpp) +set(skipMocSources + skipMoc.cpp + skipSource/qItemA.cpp + skipSource/qItemB.cpp + skipSource/qItemC.cpp) +set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON) +set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON) +# AUTOMOC enabled only +add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) +set_property(TARGET skipMocA PROPERTY AUTOMOC ON) +target_link_libraries(skipMocA ${QT_LIBRARIES}) +# AUTOMOC and AUTOUIC enabled +add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc}) +set_property(TARGET skipMocB PROPERTY AUTOMOC ON) +set_property(TARGET skipMocB PROPERTY AUTOUIC ON) +target_link_libraries(skipMocB ${QT_LIBRARIES}) + +# -- Test: AUTOUIC, SKIP_AUTOUIC +# Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target +set(skipUicSources + skipUic.cpp + skipSource/skipUicGen.cpp + skipSource/skipUicNoGen1.cpp + skipSource/skipUicNoGen2.cpp +) +set_property(SOURCE skipSource/skipUicNoGen1.cpp PROPERTY SKIP_AUTOUIC ON) +set_property(SOURCE skipSource/skipUicNoGen2.cpp PROPERTY SKIP_AUTOGEN ON) +# AUTOUIC enabled +add_executable(skipUicA ${skipUicSources}) +set_property(TARGET skipUicA PROPERTY AUTOUIC ON) +target_link_libraries(skipUicA ${QT_LIBRARIES}) +# AUTOUIC and AUTOMOC enabled +add_executable(skipUicB ${skipUicSources}) +set_property(TARGET skipUicB PROPERTY AUTOUIC ON) +set_property(TARGET skipUicB PROPERTY AUTOMOC ON) +target_link_libraries(skipUicB ${QT_LIBRARIES}) + +# -- Test: AUTORCC, SKIP_AUTORCC +# Test for SKIP_AUTORCC and SKIP_AUTOGEN on an AUTORCC enabled target +set(skipRccSources + skipRcc.cpp + skipSource/skipRccBad1.qrc + skipSource/skipRccBad2.qrc + skipSource/skipRccGood.qrc +) +set_property(SOURCE skipSource/skipRccBad1.qrc PROPERTY SKIP_AUTORCC ON) +set_property(SOURCE skipSource/skipRccBad2.qrc PROPERTY SKIP_AUTOGEN ON) +# AUTORCC enabled +add_executable(skipRccA ${skipRccSources}) +set_property(TARGET skipRccA PROPERTY AUTORCC ON) +target_link_libraries(skipRccA ${QT_LIBRARIES}) +# AUTORCC, AUTOUIC and AUTOMOC enabled +add_executable(skipRccB ${skipRccSources}) +set_property(TARGET skipRccB PROPERTY AUTORCC ON) +set_property(TARGET skipRccB PROPERTY AUTOUIC ON) +set_property(TARGET skipRccB PROPERTY AUTOMOC ON) +target_link_libraries(skipRccB ${QT_LIBRARIES}) + +# -- Test: AUTOMOC AUTORCC +# Source files with the same basename in different subdirectories +add_subdirectory(sameName) + +# -- Test: AUTOMOC AUTORCC AUTOUIC +# Complex test case +add_subdirectory(complex) diff --git a/Tests/QtAutogen/automoc_rerun/CMakeLists.txt b/Tests/QtAutogen/automoc_rerun/CMakeLists.txt index 17bc332..92a682b 100644 --- a/Tests/QtAutogen/automoc_rerun/CMakeLists.txt +++ b/Tests/QtAutogen/automoc_rerun/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.7) project(automoc_rerun CXX) if (QT_TEST_VERSION STREQUAL 4) diff --git a/Tests/QtAutogen/autorcc_depends/CMakeLists.txt b/Tests/QtAutogen/autorcc_depends/CMakeLists.txt index fbe71ad..7b51e11 100644 --- a/Tests/QtAutogen/autorcc_depends/CMakeLists.txt +++ b/Tests/QtAutogen/autorcc_depends/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.7) project(autorcc_depends) set(CMAKE_AUTORCC ON) diff --git a/Tests/QtAutogen/Adir/CMakeLists.txt b/Tests/QtAutogen/complex/Adir/CMakeLists.txt index a1c36ff..a1c36ff 100644 --- a/Tests/QtAutogen/Adir/CMakeLists.txt +++ b/Tests/QtAutogen/complex/Adir/CMakeLists.txt diff --git a/Tests/QtAutogen/Adir/libA.cpp b/Tests/QtAutogen/complex/Adir/libA.cpp index f79f24a..f79f24a 100644 --- a/Tests/QtAutogen/Adir/libA.cpp +++ b/Tests/QtAutogen/complex/Adir/libA.cpp diff --git a/Tests/QtAutogen/Adir/libA.h b/Tests/QtAutogen/complex/Adir/libA.h index c4eb9f7..c4eb9f7 100644 --- a/Tests/QtAutogen/Adir/libA.h +++ b/Tests/QtAutogen/complex/Adir/libA.h diff --git a/Tests/QtAutogen/Bdir/CMakeLists.txt b/Tests/QtAutogen/complex/Bdir/CMakeLists.txt index d9d4aa7..d338763 100644 --- a/Tests/QtAutogen/Bdir/CMakeLists.txt +++ b/Tests/QtAutogen/complex/Bdir/CMakeLists.txt @@ -6,5 +6,4 @@ set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) add_library(libB SHARED libB.cpp) generate_export_header(libB) -# set_property(TARGET libB APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries(libB LINK_PUBLIC libA) diff --git a/Tests/QtAutogen/Bdir/libB.cpp b/Tests/QtAutogen/complex/Bdir/libB.cpp index d3b6753..d3b6753 100644 --- a/Tests/QtAutogen/Bdir/libB.cpp +++ b/Tests/QtAutogen/complex/Bdir/libB.cpp diff --git a/Tests/QtAutogen/Bdir/libB.h b/Tests/QtAutogen/complex/Bdir/libB.h index e4ab788..e4ab788 100644 --- a/Tests/QtAutogen/Bdir/libB.h +++ b/Tests/QtAutogen/complex/Bdir/libB.h diff --git a/Tests/QtAutogen/complex/CMakeLists.txt b/Tests/QtAutogen/complex/CMakeLists.txt new file mode 100644 index 0000000..d48f6cc --- /dev/null +++ b/Tests/QtAutogen/complex/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 3.7) + +# -- Test: AUTOMOC AUTORCC AUTOUIC +add_definitions(-DFOO -DSomeDefine="Barx") + +# enable relaxed mode so automoc can handle all the special cases: +set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +# create an executable and two library targets, each requiring automoc: +add_library(codeeditorLib STATIC codeeditor.cpp) +add_library(privateSlot OBJECT private_slot.cpp) +# Pass Qt compiler features to targets that don't link against Qt +target_compile_features(codeeditorLib PRIVATE ${QT_COMPILE_FEATURES}) +target_compile_features(privateSlot PRIVATE ${QT_COMPILE_FEATURES}) + +configure_file(generated_resource.qrc.in generated_resource.qrc @ONLY) +add_custom_command( + OUTPUT generated.txt + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" "${CMAKE_CURRENT_BINARY_DIR}/generated.txt" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" + ) + +add_custom_target(generate_moc_input + DEPENDS generated.txt + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}" + COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h" +) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" +) + +if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_GENERATOR STREQUAL Ninja) + set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:TEST_DEBUG_CLASS>) +endif() + +# The -no-protection option disables the generation of include guards. Verify +# that setting the source file property has an effect by using this and +# issue an error in the preprocessor in calwidget.cpp if the include guard +# is defined. +set_source_files_properties(calwidget.ui PROPERTIES AUTOUIC_OPTIONS "-no-protection") + +add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp + multiplewidgets.cpp + xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot> + test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs} + ${CMAKE_CURRENT_BINARY_DIR}/generated_resource.qrc +) +set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h") + +add_executable(targetObjectsTest targetObjectsTest.cpp $<TARGET_OBJECTS:privateSlot>) +target_link_libraries(targetObjectsTest ${QT_LIBRARIES}) + +set_target_properties( + QtAutogen codeeditorLib privateSlot targetObjectsTest + PROPERTIES + AUTOMOC TRUE +) + + +include(GenerateExportHeader) +# The order is relevant here. B depends on A, and B headers depend on A +# headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we +# test that CMAKE_AUTOMOC successfully reads the include directories +# for the build interface from those targets. There has previously been +# a bug where caching of the include directories happened before +# extracting the includes to pass to moc. +add_subdirectory(Bdir) +add_subdirectory(Adir) +add_library(libC SHARED libC.cpp) +set_target_properties(libC PROPERTIES AUTOMOC TRUE) +generate_export_header(libC) +target_link_libraries(libC LINK_PUBLIC libB) +target_include_directories(libC PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +set_property(TARGET libC APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR} ) + +target_link_libraries(QtAutogen codeeditorLib ${QT_LIBRARIES} libC) diff --git a/Tests/QtAutogen/abc.cpp b/Tests/QtAutogen/complex/abc.cpp index 2929b92..2929b92 100644 --- a/Tests/QtAutogen/abc.cpp +++ b/Tests/QtAutogen/complex/abc.cpp diff --git a/Tests/QtAutogen/abc.h b/Tests/QtAutogen/complex/abc.h index ec5f411..ec5f411 100644 --- a/Tests/QtAutogen/abc.h +++ b/Tests/QtAutogen/complex/abc.h diff --git a/Tests/QtAutogen/abc_p.h b/Tests/QtAutogen/complex/abc_p.h index be98487..be98487 100644 --- a/Tests/QtAutogen/abc_p.h +++ b/Tests/QtAutogen/complex/abc_p.h diff --git a/Tests/QtAutogen/bar.cpp b/Tests/QtAutogen/complex/bar.cpp index 734bd7a..734bd7a 100644 --- a/Tests/QtAutogen/bar.cpp +++ b/Tests/QtAutogen/complex/bar.cpp diff --git a/Tests/QtAutogen/blub.cpp b/Tests/QtAutogen/complex/blub.cpp index 1c497e0..1c497e0 100644 --- a/Tests/QtAutogen/blub.cpp +++ b/Tests/QtAutogen/complex/blub.cpp diff --git a/Tests/QtAutogen/blub.h b/Tests/QtAutogen/complex/blub.h index ff79878..ff79878 100644 --- a/Tests/QtAutogen/blub.h +++ b/Tests/QtAutogen/complex/blub.h diff --git a/Tests/QtAutogen/calwidget.cpp b/Tests/QtAutogen/complex/calwidget.cpp index 380e982..380e982 100644 --- a/Tests/QtAutogen/calwidget.cpp +++ b/Tests/QtAutogen/complex/calwidget.cpp diff --git a/Tests/QtAutogen/calwidget.h b/Tests/QtAutogen/complex/calwidget.h index 084d959..084d959 100644 --- a/Tests/QtAutogen/calwidget.h +++ b/Tests/QtAutogen/complex/calwidget.h diff --git a/Tests/QtAutogen/calwidget.ui b/Tests/QtAutogen/complex/calwidget.ui index 1c245ca..1c245ca 100644 --- a/Tests/QtAutogen/calwidget.ui +++ b/Tests/QtAutogen/complex/calwidget.ui diff --git a/Tests/QtAutogen/codeeditor.cpp b/Tests/QtAutogen/complex/codeeditor.cpp index 0caf8a7..0caf8a7 100644 --- a/Tests/QtAutogen/codeeditor.cpp +++ b/Tests/QtAutogen/complex/codeeditor.cpp diff --git a/Tests/QtAutogen/codeeditor.h b/Tests/QtAutogen/complex/codeeditor.h index b410bd4..b410bd4 100644 --- a/Tests/QtAutogen/codeeditor.h +++ b/Tests/QtAutogen/complex/codeeditor.h diff --git a/Tests/QtAutogen/debug_class.cpp b/Tests/QtAutogen/complex/debug_class.cpp index 46b09e7..46b09e7 100644 --- a/Tests/QtAutogen/debug_class.cpp +++ b/Tests/QtAutogen/complex/debug_class.cpp diff --git a/Tests/QtAutogen/debug_class.h b/Tests/QtAutogen/complex/debug_class.h index c02f0ed..c02f0ed 100644 --- a/Tests/QtAutogen/debug_class.h +++ b/Tests/QtAutogen/complex/debug_class.h diff --git a/Tests/QtAutogen/debug_class.ui b/Tests/QtAutogen/complex/debug_class.ui index dc2e1ac..dc2e1ac 100644 --- a/Tests/QtAutogen/debug_class.ui +++ b/Tests/QtAutogen/complex/debug_class.ui diff --git a/Tests/QtAutogen/debug_resource.qrc b/Tests/QtAutogen/complex/debug_resource.qrc index db98b9b..db98b9b 100644 --- a/Tests/QtAutogen/debug_resource.qrc +++ b/Tests/QtAutogen/complex/debug_resource.qrc diff --git a/Tests/QtAutogen/foo.cpp b/Tests/QtAutogen/complex/foo.cpp index f665eee..f665eee 100644 --- a/Tests/QtAutogen/foo.cpp +++ b/Tests/QtAutogen/complex/foo.cpp diff --git a/Tests/QtAutogen/foo.h b/Tests/QtAutogen/complex/foo.h index 3e03fe6..3e03fe6 100644 --- a/Tests/QtAutogen/foo.h +++ b/Tests/QtAutogen/complex/foo.h diff --git a/Tests/QtAutogen/gadget.cpp b/Tests/QtAutogen/complex/gadget.cpp index 23d95fa..23d95fa 100644 --- a/Tests/QtAutogen/gadget.cpp +++ b/Tests/QtAutogen/complex/gadget.cpp diff --git a/Tests/QtAutogen/gadget.h b/Tests/QtAutogen/complex/gadget.h index 3253e31..3253e31 100644 --- a/Tests/QtAutogen/gadget.h +++ b/Tests/QtAutogen/complex/gadget.h diff --git a/Tests/QtAutogen/generated.cpp b/Tests/QtAutogen/complex/generated.cpp index d514c61..d514c61 100644 --- a/Tests/QtAutogen/generated.cpp +++ b/Tests/QtAutogen/complex/generated.cpp diff --git a/Tests/QtAutogen/generated.h b/Tests/QtAutogen/complex/generated.h index 62e1607..62e1607 100644 --- a/Tests/QtAutogen/generated.h +++ b/Tests/QtAutogen/complex/generated.h diff --git a/Tests/QtAutogen/generated.txt.in b/Tests/QtAutogen/complex/generated.txt.in index 77507bb..77507bb 100644 --- a/Tests/QtAutogen/generated.txt.in +++ b/Tests/QtAutogen/complex/generated.txt.in diff --git a/Tests/QtAutogen/generated_resource.qrc.in b/Tests/QtAutogen/complex/generated_resource.qrc.in index da5fa62..da5fa62 100644 --- a/Tests/QtAutogen/generated_resource.qrc.in +++ b/Tests/QtAutogen/complex/generated_resource.qrc.in diff --git a/Tests/QtAutogen/libC.cpp b/Tests/QtAutogen/complex/libC.cpp index a3acff1..a3acff1 100644 --- a/Tests/QtAutogen/libC.cpp +++ b/Tests/QtAutogen/complex/libC.cpp diff --git a/Tests/QtAutogen/libC.h b/Tests/QtAutogen/complex/libC.h index 3bc2bad..3bc2bad 100644 --- a/Tests/QtAutogen/libC.h +++ b/Tests/QtAutogen/complex/libC.h diff --git a/Tests/QtAutogen/main.cpp b/Tests/QtAutogen/complex/main.cpp index d557c70..d557c70 100644 --- a/Tests/QtAutogen/main.cpp +++ b/Tests/QtAutogen/complex/main.cpp diff --git a/Tests/QtAutogen/multiplewidgets.cpp b/Tests/QtAutogen/complex/multiplewidgets.cpp index fda36ea..fda36ea 100644 --- a/Tests/QtAutogen/multiplewidgets.cpp +++ b/Tests/QtAutogen/complex/multiplewidgets.cpp diff --git a/Tests/QtAutogen/multiplewidgets.h b/Tests/QtAutogen/complex/multiplewidgets.h index a4d0a50..a4d0a50 100644 --- a/Tests/QtAutogen/multiplewidgets.h +++ b/Tests/QtAutogen/complex/multiplewidgets.h diff --git a/Tests/QtAutogen/myinterface.h.in b/Tests/QtAutogen/complex/myinterface.h.in index c6c0ba1..c6c0ba1 100644 --- a/Tests/QtAutogen/myinterface.h.in +++ b/Tests/QtAutogen/complex/myinterface.h.in diff --git a/Tests/QtAutogen/myotherinterface.h.in b/Tests/QtAutogen/complex/myotherinterface.h.in index d21e7af..d21e7af 100644 --- a/Tests/QtAutogen/myotherinterface.h.in +++ b/Tests/QtAutogen/complex/myotherinterface.h.in diff --git a/Tests/QtAutogen/private_slot.cpp b/Tests/QtAutogen/complex/private_slot.cpp index ab1682a..ab1682a 100644 --- a/Tests/QtAutogen/private_slot.cpp +++ b/Tests/QtAutogen/complex/private_slot.cpp diff --git a/Tests/QtAutogen/private_slot.h b/Tests/QtAutogen/complex/private_slot.h index 8041eb2..8041eb2 100644 --- a/Tests/QtAutogen/private_slot.h +++ b/Tests/QtAutogen/complex/private_slot.h diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/complex/resourcetester.cpp index 4ecb6b4..4ecb6b4 100644 --- a/Tests/QtAutogen/resourcetester.cpp +++ b/Tests/QtAutogen/complex/resourcetester.cpp diff --git a/Tests/QtAutogen/resourcetester.h b/Tests/QtAutogen/complex/resourcetester.h index dbdb3ad..dbdb3ad 100644 --- a/Tests/QtAutogen/resourcetester.h +++ b/Tests/QtAutogen/complex/resourcetester.h diff --git a/Tests/QtAutogen/second_resource.qrc b/Tests/QtAutogen/complex/second_resource.qrc index 27bfb14..27bfb14 100644 --- a/Tests/QtAutogen/second_resource.qrc +++ b/Tests/QtAutogen/complex/second_resource.qrc diff --git a/Tests/QtAutogen/second_widget.cpp b/Tests/QtAutogen/complex/second_widget.cpp index c575f10..c575f10 100644 --- a/Tests/QtAutogen/second_widget.cpp +++ b/Tests/QtAutogen/complex/second_widget.cpp diff --git a/Tests/QtAutogen/second_widget.h b/Tests/QtAutogen/complex/second_widget.h index c7929c4..c7929c4 100644 --- a/Tests/QtAutogen/second_widget.h +++ b/Tests/QtAutogen/complex/second_widget.h diff --git a/Tests/QtAutogen/second_widget.ui b/Tests/QtAutogen/complex/second_widget.ui index 4effa58..4effa58 100644 --- a/Tests/QtAutogen/second_widget.ui +++ b/Tests/QtAutogen/complex/second_widget.ui diff --git a/Tests/QtAutogen/sub/bar.h b/Tests/QtAutogen/complex/sub/bar.h index e4093f6..e4093f6 100644 --- a/Tests/QtAutogen/sub/bar.h +++ b/Tests/QtAutogen/complex/sub/bar.h diff --git a/Tests/QtAutogen/targetObjectsTest.cpp b/Tests/QtAutogen/complex/targetObjectsTest.cpp index 766b775..766b775 100644 --- a/Tests/QtAutogen/targetObjectsTest.cpp +++ b/Tests/QtAutogen/complex/targetObjectsTest.cpp diff --git a/Tests/QtAutogen/test.qrc b/Tests/QtAutogen/complex/test.qrc index c3d4e3c..c3d4e3c 100644 --- a/Tests/QtAutogen/test.qrc +++ b/Tests/QtAutogen/complex/test.qrc diff --git a/Tests/QtAutogen/widget1.ui b/Tests/QtAutogen/complex/widget1.ui index 8fce81a..8fce81a 100644 --- a/Tests/QtAutogen/widget1.ui +++ b/Tests/QtAutogen/complex/widget1.ui diff --git a/Tests/QtAutogen/widget2.ui b/Tests/QtAutogen/complex/widget2.ui index 1f411b9..1f411b9 100644 --- a/Tests/QtAutogen/widget2.ui +++ b/Tests/QtAutogen/complex/widget2.ui diff --git a/Tests/QtAutogen/xyz.cpp b/Tests/QtAutogen/complex/xyz.cpp index e46c9d3..e46c9d3 100644 --- a/Tests/QtAutogen/xyz.cpp +++ b/Tests/QtAutogen/complex/xyz.cpp diff --git a/Tests/QtAutogen/xyz.h b/Tests/QtAutogen/complex/xyz.h index 8b813fd..8b813fd 100644 --- a/Tests/QtAutogen/xyz.h +++ b/Tests/QtAutogen/complex/xyz.h diff --git a/Tests/QtAutogen/yaf.cpp b/Tests/QtAutogen/complex/yaf.cpp index 70e26aa..70e26aa 100644 --- a/Tests/QtAutogen/yaf.cpp +++ b/Tests/QtAutogen/complex/yaf.cpp diff --git a/Tests/QtAutogen/yaf.h b/Tests/QtAutogen/complex/yaf.h index f271061..f271061 100644 --- a/Tests/QtAutogen/yaf.h +++ b/Tests/QtAutogen/complex/yaf.h diff --git a/Tests/QtAutogen/yaf_p.h b/Tests/QtAutogen/complex/yaf_p.h index ea5eed6..ea5eed6 100644 --- a/Tests/QtAutogen/yaf_p.h +++ b/Tests/QtAutogen/complex/yaf_p.h diff --git a/Tests/QtAutogen/defines_test/CMakeLists.txt b/Tests/QtAutogen/defines_test/CMakeLists.txt index ad4e684..9ee9a22 100644 --- a/Tests/QtAutogen/defines_test/CMakeLists.txt +++ b/Tests/QtAutogen/defines_test/CMakeLists.txt @@ -1,6 +1,4 @@ -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - add_executable(defines_test defines_test.cpp) set_target_properties(defines_test PROPERTIES AUTOMOC TRUE) target_link_libraries(defines_test Qt4::QtGui) diff --git a/Tests/QtAutogen/rcconly.cpp b/Tests/QtAutogen/rccEmpty.cpp index 854c4c1..7f2c527 100644 --- a/Tests/QtAutogen/rcconly.cpp +++ b/Tests/QtAutogen/rccEmpty.cpp @@ -1,9 +1,9 @@ -extern int qInitResources_second_resource(); +extern int qInitResources_rccEmptyRes(); int main(int, char**) { // Fails to link if the symbol is not present. - qInitResources_second_resource(); + qInitResources_rccEmptyRes(); return 0; } diff --git a/Tests/QtAutogen/rcc_empty_resource.qrc b/Tests/QtAutogen/rccEmptyRes.qrc index 4ca9cd5..4ca9cd5 100644 --- a/Tests/QtAutogen/rcc_empty_resource.qrc +++ b/Tests/QtAutogen/rccEmptyRes.qrc diff --git a/Tests/QtAutogen/rcc_empty.cpp b/Tests/QtAutogen/rccOnly.cpp index 3f9f9a2..61c7bf4 100644 --- a/Tests/QtAutogen/rcc_empty.cpp +++ b/Tests/QtAutogen/rccOnly.cpp @@ -1,9 +1,9 @@ -extern int qInitResources_rcc_empty_resource(); +extern int qInitResources_rccOnlyRes(); int main(int, char**) { // Fails to link if the symbol is not present. - qInitResources_rcc_empty_resource(); + qInitResources_rccOnlyRes(); return 0; } diff --git a/Tests/QtAutogen/rccOnlyRes.qrc b/Tests/QtAutogen/rccOnlyRes.qrc new file mode 100644 index 0000000..5551348 --- /dev/null +++ b/Tests/QtAutogen/rccOnlyRes.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>rccOnly.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/sameName/CMakeLists.txt b/Tests/QtAutogen/sameName/CMakeLists.txt index ed045fb..9e47a3e 100644 --- a/Tests/QtAutogen/sameName/CMakeLists.txt +++ b/Tests/QtAutogen/sameName/CMakeLists.txt @@ -16,6 +16,5 @@ add_executable(sameName data.qrc main.cpp ) -target_include_directories(sameName PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(sameName ${QT_LIBRARIES}) -set_target_properties( sameName PROPERTIES AUTOMOC TRUE AUTORCC TRUE ) +set_target_properties(sameName PROPERTIES AUTOMOC TRUE AUTORCC TRUE) diff --git a/Tests/QtAutogen/skipMoc.cpp b/Tests/QtAutogen/skipMoc.cpp new file mode 100644 index 0000000..85305f5 --- /dev/null +++ b/Tests/QtAutogen/skipMoc.cpp @@ -0,0 +1,14 @@ + +#include "skipSource/qItemA.hpp" +#include "skipSource/qItemB.hpp" +#include "skipSource/qItemC.hpp" + +int main(int, char**) +{ + QItemA itemA; + QItemA itemB; + QItemA itemC; + + // Fails to link if the symbol is not present. + return 0; +} diff --git a/Tests/QtAutogen/skipRcc.cpp b/Tests/QtAutogen/skipRcc.cpp new file mode 100644 index 0000000..ec57110 --- /dev/null +++ b/Tests/QtAutogen/skipRcc.cpp @@ -0,0 +1,9 @@ + +extern int qInitResources_skipRccGood(); + +int main(int, char**) +{ + // Fails to link if the symbol is not present. + qInitResources_skipRccGood(); + return 0; +} diff --git a/Tests/QtAutogen/skipSource/qItemA.cpp b/Tests/QtAutogen/skipSource/qItemA.cpp new file mode 100644 index 0000000..522c2c7 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemA.cpp @@ -0,0 +1,5 @@ +#include "qItemA.hpp" + +void QItemA::go() +{ +} diff --git a/Tests/QtAutogen/skipSource/qItemA.hpp b/Tests/QtAutogen/skipSource/qItemA.hpp new file mode 100644 index 0000000..d295faf --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemA.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMA_HPP +#define QITEMA_HPP + +#include <QObject> + +class QItemA : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/skipSource/qItemB.cpp b/Tests/QtAutogen/skipSource/qItemB.cpp new file mode 100644 index 0000000..636e15d --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemB.cpp @@ -0,0 +1,5 @@ +#include "qItemB.hpp" + +void QItemB::go() +{ +} diff --git a/Tests/QtAutogen/skipSource/qItemB.hpp b/Tests/QtAutogen/skipSource/qItemB.hpp new file mode 100644 index 0000000..1775915 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemB.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMB_HPP +#define QITEMB_HPP + +#include <QObject> + +class QItemB : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/skipSource/qItemC.cpp b/Tests/QtAutogen/skipSource/qItemC.cpp new file mode 100644 index 0000000..700abd6 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemC.cpp @@ -0,0 +1,5 @@ +#include "qItemC.hpp" + +void QItemC::go() +{ +} diff --git a/Tests/QtAutogen/skipSource/qItemC.hpp b/Tests/QtAutogen/skipSource/qItemC.hpp new file mode 100644 index 0000000..f06bda2 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemC.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMC_HPP +#define QITEMC_HPP + +#include <QObject> + +class QItemC : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/skipSource/skipRccBad1.qrc b/Tests/QtAutogen/skipSource/skipRccBad1.qrc new file mode 100644 index 0000000..6cbd9ed --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipRccBad1.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>skipRccGood.cpp</file>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/skipSource/skipRccBad2.qrc b/Tests/QtAutogen/skipSource/skipRccBad2.qrc new file mode 100644 index 0000000..b32c589 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipRccBad2.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>< +<qresource> + <file>skipRccGood.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/skipSource/skipRccGood.qrc b/Tests/QtAutogen/skipSource/skipRccGood.qrc new file mode 100644 index 0000000..21a94b0 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipRccGood.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>skipRccBad1.qrc</file> + <file>skipRccBad2.qrc</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/skipSource/skipUicGen.cpp b/Tests/QtAutogen/skipSource/skipUicGen.cpp new file mode 100644 index 0000000..d2a55a6 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicGen.cpp @@ -0,0 +1,7 @@ + +#include "skipUicGen.hpp" +#include "ui_uigen2.h" + +void skipGen() +{ +} diff --git a/Tests/QtAutogen/skipSource/skipUicGen.hpp b/Tests/QtAutogen/skipSource/skipUicGen.hpp new file mode 100644 index 0000000..3669f0e --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicGen.hpp @@ -0,0 +1,8 @@ +#ifndef SKIPUICGEN_HPP +#define SKIPUICGEN_HPP + +#include "ui_uigen1.h" + +void skipGen(); + +#endif diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp b/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp new file mode 100644 index 0000000..f591a42 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp @@ -0,0 +1,7 @@ + +#include "skipUicNoGen1.hpp" +#include "ui_nogen2.h" + +void skipNoGen1() +{ +} diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp b/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp new file mode 100644 index 0000000..2864695 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp @@ -0,0 +1,8 @@ +#ifndef SKIPUICNOGEN1_H +#define SKIPUICNOGEN1_H + +#include "ui_nogen1.h" + +void skipNoGen1(); + +#endif diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp b/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp new file mode 100644 index 0000000..8c1c324 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp @@ -0,0 +1,7 @@ + +#include "skipUicNoGen2.hpp" +#include "ui_nogen2.h" + +void skipNoGen2() +{ +} diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp b/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp new file mode 100644 index 0000000..7c38193 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp @@ -0,0 +1,8 @@ +#ifndef SKIPUICNOGEN2_H +#define SKIPUICNOGEN2_H + +#include "ui_nogen1.h" + +void skipNoGen2(); + +#endif diff --git a/Tests/QtAutogen/skipSource/ui_nogen1.h b/Tests/QtAutogen/skipSource/ui_nogen1.h new file mode 100644 index 0000000..a7be52b --- /dev/null +++ b/Tests/QtAutogen/skipSource/ui_nogen1.h @@ -0,0 +1,6 @@ +#ifndef UI_NOGEN1_H +#define UI_NOGEN1_H + +void ui_nogen1(); + +#endif diff --git a/Tests/QtAutogen/skipSource/ui_nogen2.h b/Tests/QtAutogen/skipSource/ui_nogen2.h new file mode 100644 index 0000000..5d547d4 --- /dev/null +++ b/Tests/QtAutogen/skipSource/ui_nogen2.h @@ -0,0 +1,6 @@ +#ifndef UI_NOGEN2_H +#define UI_NOGEN2_H + +void ui_nogen2(); + +#endif
\ No newline at end of file diff --git a/Tests/QtAutogen/skipSource/uigen1.ui b/Tests/QtAutogen/skipSource/uigen1.ui new file mode 100644 index 0000000..fc7cb82 --- /dev/null +++ b/Tests/QtAutogen/skipSource/uigen1.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiGen1</class> + <widget class="QWidget" name="UiGen1"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/skipSource/uigen2.ui b/Tests/QtAutogen/skipSource/uigen2.ui new file mode 100644 index 0000000..01f08d2 --- /dev/null +++ b/Tests/QtAutogen/skipSource/uigen2.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiGen2</class> + <widget class="QWidget" name="UiGen2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/skipUic.cpp b/Tests/QtAutogen/skipUic.cpp new file mode 100644 index 0000000..0adf011 --- /dev/null +++ b/Tests/QtAutogen/skipUic.cpp @@ -0,0 +1,22 @@ + +#include "skipSource/skipUicGen.hpp" +#include "skipSource/skipUicNoGen1.hpp" +#include "skipSource/skipUicNoGen2.hpp" + +int main(int, char**) +{ + skipGen(); + skipNoGen1(); + skipNoGen2(); + + return 0; +} + +// -- Function definitions +void ui_nogen1() +{ +} + +void ui_nogen2() +{ +} diff --git a/Tests/QtAutogen/sub/uiconly.cpp b/Tests/QtAutogen/uicOnlySource/uiconly.cpp index ac22789..7b91b25 100644 --- a/Tests/QtAutogen/sub/uiconly.cpp +++ b/Tests/QtAutogen/uicOnlySource/uiconly.cpp @@ -7,6 +7,11 @@ UicOnly::UicOnly(QWidget* parent) { } +UicOnly::~UicOnly() +{ + delete ui; +} + int main() { return 0; diff --git a/Tests/QtAutogen/sub/uiconly.h b/Tests/QtAutogen/uicOnlySource/uiconly.h index 9b0b1b4..8f4eebe 100644 --- a/Tests/QtAutogen/sub/uiconly.h +++ b/Tests/QtAutogen/uicOnlySource/uiconly.h @@ -3,7 +3,6 @@ #define UIC_ONLY_H #include <QWidget> -#include <memory> #include "ui_uiconly.h" @@ -12,9 +11,10 @@ class UicOnly : public QWidget Q_OBJECT public: explicit UicOnly(QWidget* parent = 0); + ~UicOnly(); private: - const std::auto_ptr<Ui::UicOnly> ui; + Ui::UicOnly* ui; }; #endif diff --git a/Tests/QtAutogen/sub/uiconly.ui b/Tests/QtAutogen/uicOnlySource/uiconly.ui index 13fb832..13fb832 100644 --- a/Tests/QtAutogen/sub/uiconly.ui +++ b/Tests/QtAutogen/uicOnlySource/uiconly.ui diff --git a/Tests/RunCMake/AndroidTestUtilities/RunCMakeTest.cmake b/Tests/RunCMake/AndroidTestUtilities/RunCMakeTest.cmake index f0ae24b..7d031d4 100644 --- a/Tests/RunCMake/AndroidTestUtilities/RunCMakeTest.cmake +++ b/Tests/RunCMake/AndroidTestUtilities/RunCMakeTest.cmake @@ -18,3 +18,4 @@ endfunction() run_ATU(SetupTest1 "") run_ATU(SetupTest2 "tests") run_ATU(SetupTest3 "tests") +run_ATU(SetupTest4 "") diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest4.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest4.cmake new file mode 100644 index 0000000..9a27266 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest4.cmake @@ -0,0 +1,13 @@ +enable_testing() +include(AndroidTestUtilities) + +find_program(adb_executable adb) + +set(test_files "data/a.txt") + +set(ANDROID 1) + +android_add_test_data(setup_test + FILES ${test_files} + DEVICE_TEST_DIR "/data/local/tests/example1" + DEVICE_OBJECT_STORE "/sdcard/.ExternalData/SHA") diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest4Build-check.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest4Build-check.cmake new file mode 100644 index 0000000..ef7569d --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest4Build-check.cmake @@ -0,0 +1,5 @@ +include(${CMAKE_CURRENT_LIST_DIR}/check.cmake) +compare_build_to_expected(FILES + "data/a.txt" + ) +check_for_setup_test() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9dc540f..63016f1 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -179,6 +179,9 @@ add_RunCMake_test(add_custom_target) add_RunCMake_test(add_dependencies) add_RunCMake_test(add_subdirectory) add_RunCMake_test(build_command) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + set(execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>) +endif() add_RunCMake_test(execute_process) add_RunCMake_test(export) add_RunCMake_test(cmake_minimum_required) @@ -212,6 +215,19 @@ add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) add_RunCMake_test(return) add_RunCMake_test(set_property) add_RunCMake_test(string) +foreach(var + CMAKE_C_COMPILER_ID + CMAKE_C_COMPILER_VERSION + CMAKE_C_STANDARD_DEFAULT + CMAKE_CXX_COMPILER_ID + CMAKE_CXX_COMPILER_VERSION + CMAKE_CXX_STANDARD_DEFAULT + CMake_TEST_CUDA + ) + if(DEFINED ${var}) + list(APPEND try_compile_ARGS -D${var}=${${var}}) + endif() +endforeach() add_RunCMake_test(try_compile) add_RunCMake_test(try_run) add_RunCMake_test(set) @@ -239,6 +255,11 @@ if(PKG_CONFIG_FOUND) add_RunCMake_test(FindPkgConfig) endif() +find_package(GTK2 QUIET) +if (GTK2_FOUND) + add_RunCMake_test(FindGTK2) +endif() + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") add_RunCMake_test(include_external_msproject) if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) @@ -255,8 +276,7 @@ if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3) add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION}) endif() -if(NOT XCODE - AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang" +if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) add_RunCMake_test(Framework) endif() @@ -324,12 +344,14 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") endif() add_executable(pseudo_tidy pseudo_tidy.c) add_executable(pseudo_iwyu pseudo_iwyu.c) + add_executable(pseudo_cpplint pseudo_cpplint.c) add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>) add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>) + add_RunCMake_test(Cpplint -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint>) add_RunCMake_test(CompilerLauncher) endif() -add_RunCMake_test_group(CPack "DEB;RPM;TGZ") +add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ") # 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) diff --git a/Tests/RunCMake/CPack/7Z/Helpers.cmake b/Tests/RunCMake/CPack/7Z/Helpers.cmake new file mode 100644 index 0000000..f256a42 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "7z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/7Z/Prerequirements.cmake b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake index 81a5035..81a5035 100644 --- a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-specifics.cmake +++ b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake diff --git a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake new file mode 100644 index 0000000..ce039f5 --- /dev/null +++ b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake @@ -0,0 +1,62 @@ +set(ALL_FILES_GLOB "*.${cpack_archive_extension_}") + +function(getPackageContent FILE RESULT_VAR) + # TODO for some types this only works because libarchive handles it... (not + # part of for e.g. gnu tar) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xtf ${FILE} + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} + "${NAME}-${VERSION}-*${COMPONENT}.${cpack_archive_extension_}" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + getPackageContent("${FILE}" package_content_) + + string(REPLACE "\n" ";" package_content_ "${package_content_}") + foreach(i_ IN LISTS package_content_) + string(REGEX REPLACE "/$" "" result_ "${i_}") + list(APPEND items_ "${result_}") + endforeach() + + set(${RESULT_VAR} "${items_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + findExpectedFile("${FILE_NO}" "file_") + + # component and monolithic packages differ for some reason by either having + # package filename prefix in path or not + if(PACKAGING_TYPE STREQUAL "MONOLITHIC") + get_filename_component(prefix_ "${file_}" NAME) + # NAME_WE removes everything after the dot and dot is in version so replace instead + string(REPLACE ".${cpack_archive_extension_}" "/" prefix_ "${prefix_}") + else() + unset(prefix_) + endif() + + if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) + set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + endif() + + unset(filtered_) + foreach(part_ IN LISTS ${CONTENT_VAR}) + string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + + if(part_) + list(APPEND filtered_ "${prefix_}${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index e42e971..c361af0 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,12 +1,17 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "") + project(${RunCMake_TEST} CXX) -include(${RunCMake_TEST_FILE_PREFIX}.cmake) -# include test generator specifics -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake") - include("${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake") +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/packaging_${PACKAGING_TYPE}_default.cmake") + include(${GENERATOR_TYPE}/packaging_${PACKAGING_TYPE}_default.cmake) endif() +# set default test name (can be overwritten in test.cmake or specifics.cmake) +string(TOLOWER "${RunCMake_TEST_FILE_PREFIX}" CPACK_PACKAGE_NAME) + +include(tests/${RunCMake_TEST_FILE_PREFIX}/test.cmake) + set(CPACK_GENERATOR "${GENERATOR_TYPE}") include(CPack) diff --git a/Tests/RunCMake/CPack/COMPONENTS_EMPTY_DIR.cmake b/Tests/RunCMake/CPack/COMPONENTS_EMPTY_DIR.cmake deleted file mode 100644 index 7210e7d..0000000 --- a/Tests/RunCMake/CPack/COMPONENTS_EMPTY_DIR.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(CPACK_COMPONENTS_ALL test) -install(DIRECTORY DESTINATION empty - COMPONENT test) - -set(CPACK_PACKAGE_NAME "components_empty_dir") diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index 7e6b4b1..f883c69 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -1,6 +1,6 @@ cmake_policy(SET CMP0057 NEW) -function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) +function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE) if(TEST_TYPE IN_LIST types) set(RunCMake_TEST_NO_CLEAN TRUE) set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build") @@ -11,16 +11,17 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) set(full_test_name_ "${full_test_name_}-${SUBTEST_SUFFIX}-subtest") endif() + string(APPEND full_test_name_ "-${PACKAGING_TYPE}-type") + # TODO this should be executed only once per ctest run (not per generator) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake") - include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake") + if(EXISTS "${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake") + include("${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake") set(FOUND_PREREQUIREMENTS false) - get_test_prerequirements("FOUND_PREREQUIREMENTS" - "${TEST_CONFIG_DIR}/${type}_config.cmake") + get_test_prerequirements("FOUND_PREREQUIREMENTS" "${config_file}") # skip the test if prerequirements are not met if(NOT FOUND_PREREQUIREMENTS) @@ -32,7 +33,8 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) # execute cmake set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}" "-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}" - "-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}") + "-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}" + "-DPACKAGING_TYPE=${PACKAGING_TYPE}") run_cmake(${full_test_name_}) # execute optional build step @@ -43,7 +45,7 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) if(source) set(pack_params_ -G ${TEST_TYPE} --config ./CPackSourceConfig.cmake) FILE(APPEND ${RunCMake_TEST_BINARY_DIR}/CPackSourceConfig.cmake - "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_}\ -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME}\")") + "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_} -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME} -DGENERATOR_TYPE:STRING=${TEST_TYPE}\")") else() unset(pack_params_) endif() @@ -58,10 +60,16 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) ) foreach(o out err) - if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt) - set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt") - elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-std${o}.txt) - set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-std${o}.txt") + if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt") + elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/default_expected_std${o}.txt) + set(RunCMake-std${o}-file "${TEST_TYPE}/default_expected_std${o}.txt") endif() endforeach() @@ -73,6 +81,7 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) -DRunCMake_TEST_FILE_PREFIX=${TEST_NAME} -DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX} -DGENERATOR_TYPE=${TEST_TYPE} + -DPACKAGING_TYPE=${PACKAGING_TYPE} "-Dsrc_dir=${RunCMake_SOURCE_DIR}" "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}" "-Dconfig_file=${config_file}" @@ -81,16 +90,20 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) endif() endfunction() -function(run_cpack_test TEST_NAME types build) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false) -endfunction() - -function(run_cpack_source_test TEST_NAME types build) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" true) +function(run_cpack_test TEST_NAME types build PACKAGING_TYPES) + foreach(packaging_type_ IN LISTS PACKAGING_TYPES) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}") + endforeach() endfunction() -function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build) +function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build PACKAGING_TYPES) foreach(suffix_ IN LISTS SUBTEST_SUFFIXES) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false) + foreach(packaging_type_ IN LISTS PACKAGING_TYPES) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}") + endforeach() endforeach() endfunction() + +function(run_cpack_source_test TEST_NAME types) + run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "") +endfunction() diff --git a/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake b/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake deleted file mode 100644 index c89df89..0000000 --- a/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) - -set(CPACK_PACKAGE_NAME "custom_names") diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 62f2f9c..0000000 --- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir-test_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake deleted file mode 100644 index 2acf45b..0000000 --- a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "custom_names-pkg_1_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "second*.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "pkg_3_abc.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake deleted file mode 100644 index c64f161..0000000 --- a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") - -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PKG_2_PACKAGE_NAME "second") -set(CPACK_DEBIAN_PKG_3_FILE_NAME "pkg_3_abc.deb") diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake deleted file mode 100644 index 4531a34..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "deb_extra-foo_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "deb_extra-bar_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_3 "deb_extra-bas_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake deleted file mode 100644 index b98065a..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake +++ /dev/null @@ -1,7 +0,0 @@ -function(get_test_prerequirements found_var) - find_program(READELF_EXECUTABLE NAMES readelf) - - if(READELF_EXECUTABLE) - set(${found_var} true PARENT_SCOPE) - endif() -endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake deleted file mode 100644 index b98065a..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake +++ /dev/null @@ -1,7 +0,0 @@ -function(get_test_prerequirements found_var) - find_program(READELF_EXECUTABLE NAMES readelf) - - if(READELF_EXECUTABLE) - set(${found_var} true PARENT_SCOPE) - endif() -endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake deleted file mode 100644 index a6f08fe..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake +++ /dev/null @@ -1,14 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies-0.1.1-*-applications.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies-0.1.1-*-applications_auto.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$") -set(EXPECTED_FILE_3 "dependencies-0.1.1-*-headers.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies-0.1.1-*-libs.deb") -# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it -set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") -set(EXPECTED_FILE_5 "dependencies-0.1.1-*-libs_auto.deb") -set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index ba39f2e..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,34 +0,0 @@ -function(checkDependencies_ FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -foreach(dependency_type_ DEPENDS CONFLICTS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) - string(TOLOWER "${dependency_type_}" lower_dependency_type_) - string(SUBSTRING ${lower_dependency_type_} 1 -1 lower_dependency_type_tail_) - string(SUBSTRING ${dependency_type_} 0 1 dependency_type_head_) - set(dependency_type_name_ "${dependency_type_head_}${lower_dependency_type_tail_}") - - checkDependencies_("${FOUND_FILE_1}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") - checkDependencies_("${FOUND_FILE_2}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}.*${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") - checkDependencies_("${FOUND_FILE_3}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-headers.*") - checkDependencies_("${FOUND_FILE_4}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") - checkDependencies_("${FOUND_FILE_5}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") -endforeach() - -checkDependencies_("${FOUND_FILE_1}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_2}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_3}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_4}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib.*") -checkDependencies_("${FOUND_FILE_5}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib_auto.*, provided-lib_auto-b.*") - -# PREDEPENDS -checkDependencies_("${FOUND_FILE_1}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-application, predepends-application-b.*") -checkDependencies_("${FOUND_FILE_2}" ".*Pre-Depends${whitespaces_}:${whitespaces_}.*predepends-application, predepends-application-b.*") -checkDependencies_("${FOUND_FILE_3}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-headers.*") -checkDependencies_("${FOUND_FILE_4}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") -checkDependencies_("${FOUND_FILE_5}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake deleted file mode 100644 index 5f82cc6..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake +++ /dev/null @@ -1,23 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") -#intentionaly commented out to test old file naming -#set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") - -# false by default -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) -# FIXME can not be tested as libraries first have to be part of a package in order -# to determine their dependencies and we can not be certain if there will be any -set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) - -foreach(dependency_type_ DEPENDS CONFLICTS PREDEPENDS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) - string(TOLOWER "${dependency_type_}" lower_dependency_type_) - - set(CPACK_DEBIAN_PACKAGE_${dependency_type_} "${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b") - set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") - set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") - set(CPACK_DEBIAN_HEADERS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-headers") -endforeach() - -set(CPACK_DEBIAN_PACKAGE_PROVIDES "provided-default, provided-default-b") -set(CPACK_DEBIAN_LIBS_PACKAGE_PROVIDES "provided-lib") -set(CPACK_DEBIAN_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 6dc5906..0000000 --- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake deleted file mode 100644 index 4e9a2e7..0000000 --- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index 9b1be22..ad1b47b 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -9,6 +9,47 @@ function(getPackageContent FILE RESULT_VAR) set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) endfunction() +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + if(DEFINED EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT}") + elseif(DEFINED EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT}") + else() + set(GENERATOR_SPECIFIC_FORMAT FALSE) + endif() + + if(GENERATOR_SPECIFIC_FORMAT) + set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}-${REVISION}_*.deb" PARENT_SCOPE) + else() + set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.deb" PARENT_SCOPE) + endif() +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}" + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + unset(items_) + string(REPLACE "\n" ";" package_content_ "${package_content_}") + foreach(i_ IN LISTS package_content_) + string(REGEX REPLACE "^.* \.(/[^$]*)$" "\\1" result_ "${i_}") + string(REGEX REPLACE "/$" "" result_ "${result_}") + list(APPEND items_ "${result_}") + endforeach() + + set(${RESULT_VAR} "${items_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + # no need to do anything +endfunction() + function(getMissingShlibsErrorExtra FILE RESULT_VAR) execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX} ERROR_VARIABLE err_) @@ -43,8 +84,6 @@ function(getMissingShlibsErrorExtra FILE RESULT_VAR) string(APPEND error_extra "; errors \"${deb_install_files_errors}\"") endif() - find_program(READELF_EXECUTABLE NAMES readelf) - if(READELF_EXECUTABLE) string(APPEND error_extra "; readelf \"\n") diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-ExpectedFiles.cmake deleted file mode 100644 index dd72cf7..0000000 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "long_filenames_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt$") diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-Prerequirements.cmake deleted file mode 100644 index 0c1d77e..0000000 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-Prerequirements.cmake +++ /dev/null @@ -1,7 +0,0 @@ -function(get_test_prerequirements found_var) - find_program(FAKEROOT_EXECUTABLE NAMES fakeroot) - - if(FAKEROOT_EXECUTABLE) - set(${found_var} true PARENT_SCOPE) - endif() -endfunction() diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-specifics.cmake b/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-specifics.cmake deleted file mode 100644 index 39a6be4..0000000 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-specifics.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar") diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake deleted file mode 100644 index 648c866..0000000 --- a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake deleted file mode 100644 index 4e9a2e7..0000000 --- a/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake deleted file mode 100644 index 40f6730..0000000 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "per_component-pkg_1_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "second_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "per_component-pkg_3_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake deleted file mode 100644 index 55293be..0000000 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake +++ /dev/null @@ -1,18 +0,0 @@ -function(checkPackageInfo_ TYPE FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -# check package name -checkPackageInfo_("name" "${FOUND_FILE_1}" ".*Package${whitespaces_}:${whitespaces_}per_component-pkg_1") -checkPackageInfo_("name" "${FOUND_FILE_2}" ".*Package${whitespaces_}:${whitespaces_}second") -checkPackageInfo_("name" "${FOUND_FILE_3}" ".*Package${whitespaces_}:${whitespaces_}per_component-pkg_3") - -# check package group -checkPackageInfo_("group" "${FOUND_FILE_1}" ".*Section${whitespaces_}:${whitespaces_}default") -checkPackageInfo_("group" "${FOUND_FILE_2}" ".*Section${whitespaces_}:${whitespaces_}second_group") -checkPackageInfo_("group" "${FOUND_FILE_3}" ".*Section${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake deleted file mode 100644 index 25bd2e7..0000000 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") - -set(CPACK_DEBIAN_PACKAGE_SECTION "default") -set(CPACK_DEBIAN_PKG_2_PACKAGE_NAME "second") -set(CPACK_DEBIAN_PKG_2_PACKAGE_SECTION "second_group") diff --git a/Tests/RunCMake/CPack/DEB/Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/Prerequirements.cmake index cb9a277..60d02e7 100644 --- a/Tests/RunCMake/CPack/DEB/Prerequirements.cmake +++ b/Tests/RunCMake/CPack/DEB/Prerequirements.cmake @@ -12,4 +12,11 @@ function(get_test_prerequirements found_var config_file) file(APPEND "${config_file}" "\nset(FAKEROOT_EXECUTABLE \"${FAKEROOT_EXECUTABLE}\")") endif() + + # optional tool for some tests + find_program(READELF_EXECUTABLE NAMES readelf) + if(READELF_EXECUTABLE) + file(APPEND "${config_file}" + "\nset(READELF_EXECUTABLE \"${READELF_EXECUTABLE}\")") + endif() endfunction() diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/DEB/packaging_COMPONENT_default.cmake index 4b4ac8d..4219b0c 100644 --- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake +++ b/Tests/RunCMake/CPack/DEB/packaging_COMPONENT_default.cmake @@ -1,3 +1,2 @@ -set(CPACK_PACKAGE_CONTACT "someone") set(CPACK_DEB_COMPONENT_INSTALL "ON") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +set(CPACK_PACKAGE_CONTACT "someone") diff --git a/Tests/RunCMake/CPack/DEB/packaging_MONOLITHIC_default.cmake b/Tests/RunCMake/CPack/DEB/packaging_MONOLITHIC_default.cmake new file mode 100644 index 0000000..8821ab9 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/packaging_MONOLITHIC_default.cmake @@ -0,0 +1 @@ +set(CPACK_PACKAGE_CONTACT "someone") diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake deleted file mode 100644 index 4f6d65f..0000000 --- a/Tests/RunCMake/CPack/DEPENDENCIES.cmake +++ /dev/null @@ -1,20 +0,0 @@ -set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" - "int test_lib();\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" - "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") -add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" - "#include \"test_lib.hpp\"\nint main() {return test_lib();}\n") -add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") -target_link_libraries(test_prog test_lib) - -install(TARGETS test_prog DESTINATION foo COMPONENT applications) -install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) -install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) -install(TARGETS test_lib DESTINATION bas COMPONENT libs) -install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) - -set(CPACK_PACKAGE_NAME "dependencies") diff --git a/Tests/RunCMake/CPack/EMPTY_DIR.cmake b/Tests/RunCMake/CPack/EMPTY_DIR.cmake deleted file mode 100644 index 023ba17..0000000 --- a/Tests/RunCMake/CPack/EMPTY_DIR.cmake +++ /dev/null @@ -1,4 +0,0 @@ -install(DIRECTORY DESTINATION empty - COMPONENT test) - -set(CPACK_PACKAGE_NAME "empty_dir") diff --git a/Tests/RunCMake/CPack/MINIMAL.cmake b/Tests/RunCMake/CPack/MINIMAL.cmake deleted file mode 100644 index f29ad2a..0000000 --- a/Tests/RunCMake/CPack/MINIMAL.cmake +++ /dev/null @@ -1,3 +0,0 @@ -install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) - -set(CPACK_PACKAGE_NAME "minimal") diff --git a/Tests/RunCMake/CPack/PER_COMPONENT_FIELDS.cmake b/Tests/RunCMake/CPack/PER_COMPONENT_FIELDS.cmake deleted file mode 100644 index bb42cf4..0000000 --- a/Tests/RunCMake/CPack/PER_COMPONENT_FIELDS.cmake +++ /dev/null @@ -1,5 +0,0 @@ -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) - -set(CPACK_PACKAGE_NAME "per_component") diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index 5c86880..7c98f69 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -1,41 +1,75 @@ RunCMake.CPack is a test module that is intended for testing of package generators that can be validated from command line. -TODO: all tests should cover all packaging types (single package, grouped and - component packaging) - ------------- Adding a test ------------- -CPack test root directory: 'Tests/RunCMake/CPack'. +CPack test root directory: 'Tests/RunCMake/CPack/tests'. All phases are executed separately for each generator that is bound to a test. Tests for each generator are subtests of test 'RunCMake.CPack_<generator_name>'. Each test must also be added to 'RunCMakeTest.cmake' script located in CPack test root directory. + Line that adds a test is: -run_cpack_test(<test_name> "<generator_name>") +run_cpack_test(<test_name> "<generator_name_list>" <compile_stage> + "<packaging_type_list>") + +<generator_name_list> may be one generator e.g. "RPM" or multiple e.g. "RPM;DEB" +and will be run for all listed generators. In test and verification scripts +current generator can be accessed through GENERATOR_TYPE variable. + +<compile_stage> is a boolean variable that enables or disables compile stage - +most tests don't require compilation as a non binary file can be used for +package content but sometimes an executable or a library has to be created +before the packaging stage. -<generator_name> may be one generator e.g. "RPM" or multiple e.g. "RPM;DEB" and -will be run for all listed generators. +<packaging_type_list> can be a list of one or more packaging types: MONOLITHIC, +COMPONENT or GROUP - each type sets per generator default variables which can +be overwritten in the test if needed +(see <generator_type>/packaging_<packaging_type>_default.cmake for the variables +that are set by default for each packaging type). +Alternatively CUSTOM value can be set which means that default values will not +be set and that values will be set manually in the test itself. + +Alternatively a test with subtests can be added: +run_cpack_test_subtests(<test_name> "<subtests_list>" "<generator_name_list>" + <compile_stage> "<packaging_type_list>") + +<subtests_list> is the only new parameter and it is a list of names that will +be used for subtests. In test and verification scripts subtest name can be +accessed through RunCMake_SUBTEST_SUFFIX variable. + +Also source package tests can be added: +run_cpack_source_test(<test_name> "<generator_name_list>" true) Test consists of - test prerequirements phase (optional) - CMake execution phase +- build phase (optional and not available for source package tests) - CPack execution phase - verification of generated files +The phases are executed once per specified generator, packaging type and subtest +combinatiion. + test prerequirements phase (optional): -------------------------------------- In some cases individual tests for certain generator need additional prerequirements met. -In such cases '<generator_name>/<test_name>-Prerequirements.cmake' file -containing 'function(get_test_prerequirements found_var)' should be created. -Function should return true if all prerequirements are met. +In such cases '<test_name>/<generator_name>-Prerequirements.cmake' file +containing 'function(get_test_prerequirements found_var config_file)' should be +created. Function should return true in found_var if all prerequirements are +met. config_file variable contains the location of config file generated by the +generator so that this function can check if prerequired variable is set in the +file. +NOTE: All required programs should be searched for in generator prerequirements +function and only checked for the variable in configure file in per test +function. If prerequirements are not met test will be skipped outputting '<test_name> - SKIPPED' string. Note that this doesn't fail the entire test @@ -48,15 +82,21 @@ TODO: skipped tests should provide expected error string so test should fail CMake execution phase: ---------------------- -To add a new CPack test we first create a <test_name>.cmake script that contains -CMake commands that should be used as a preparation script for generation of -different types of packages. This script is placed into CPack test root -directory even if it will be used for only one of the generators. +To add a new CPack test we first create a '<test_name>/test.cmake' script that +contains CMake commands that should be used as a preparation script for +generation of different types of packages. This script is placed into CPack +test root directory. If test will be used for multiple generators but some of them require some -generator specific commands then those commands should be added to a separate -file that should be located in '<generator_name>/<test_name>-specifics.cmake' -in CPack test root directory. +generator specific commands then those commands should be added to 'test.cmake' +script wrapped with 'if(GENERATOR_TYPE STREQUAL <name_of_the_generator>)'. + +build phase (optional and not available for source package tests) +----------------------------------------------------------------- + +This phase only runs make command. + +NOTE: By default all tests have CMAKE_BUILD_TYPE variable set to Debug. CPack execution phase: ---------------------- @@ -64,6 +104,8 @@ CPack execution phase: Only executes CPack for content that was generated during CMake execution phase. +NOTE: By default CPACK_PACKAGE_NAME variable is set to lower case test name. + Verification of generated files: -------------------------------- @@ -76,24 +118,59 @@ contain expected files. Mandatory verification phase also checks that no other unexpected package files were generated (this is executed even if EXPECTED_FILES_COUNT contains 0 in order to verify that no files were generated). -CMake script '<generator_name>/<test_name>-ExpectedFiles.cmake' is required by +CMake script '<test_name>/ExpectedFiles.cmake' is required by this step and must contain - EXPECTED_FILES_COUNT variable that contains the number of expected files that will be generated (0 or more) + - EXPECTED_FILE_<file_number_starting_with_1> that contains globing expression that uniquely defines expected file name (will be used to find expected file) - and should be present once for each expected file + and should be present once for each expected file. + NOTE: This variable should be used only as last resort as it sets generator + specific globbing expression. Each generator can recreate file name from + parts that are already populated by default but can always be + overwritten if needed: + - EXPECTED_FILE_<file_number_starting_with_1>_NAME is the name component of + the file (by default it is set to package name that is same as test name + in lowercase) + - EXPECTED_FILE_<file_number_starting_with_1>_VERSION is the version of the + package (by default it is set to '0.1.1') + - EXPECTED_FILE_<file_number_starting_with_1>_REVISION is the revision of the + package (by default it is set to '1') + - EXPECTED_FILE_CONTENT_<file_number_starting_with_1> that contains regular expression of files that should be present in generated file and should be present once for each expected file + NOTE: This variable should be used only as last resort as it sets generator + specific regular expression. + EXPECTED_FILE_CONTENT_<file_number_starting_with_1>_LIST should be + prefered as it requires a list of expected files and directories that + is later changed automatically depending on the generator so expected + package content can be written only once per test for all generators. Optional verification phase is generator specific and is optionaly executed. -This phase is executed if '<generator_name>/<test_name>-VerifyResult.cmake' -script exists. -In case that the script doesn't exist VerifyResult.cmake script automatically -prints out standard output and standard error from CPack execution phase that -is compared with '<generator_name>/<test_name>-stdout.txt' regular expression -and '<generator_name>/<test_name>-stderr.txt' regular expresson respectively. +This phase is executed if '<test_name>/VerifyResult.cmake' script exists. + +VerifyResult.cmake script also automatically prints out standard output and +standard error from CPack execution phase that is compared with +'<test_name>/<generator_name>-stdout.txt' regular expression and +and '<test_name>/<generator_name>-stderr.txt' regular expresson respectively. +NOTE: For subtests generator name can also be suffixed with subtest name and/or + packaging type (MONOLITHIC, COMPONENT, GROUP) and in such cases the + preferences of which file will be used are as follows: + - generator name + packaging type + subtest name + - generator name + packaging type + - generator name + subtest name + - generator name + - default generator + File name format: '<generator_name>-<packaging_type>-<subtest_name>-std<type>.txt' + where <type> can either be 'out' or 'err'. + File name format: '<generator_name>-<packaging_type>-std<type>.txt' + where <type> can either be 'out' or 'err'. + File name format: '<generator_name>-<subtest_name>-std<type>.txt' where + <type> can either be 'out' or 'err'. +NOTE: If none of the comparison files are present then the default generator + file is used if present. ---------------------- Adding a new generator @@ -101,13 +178,44 @@ Adding a new generator To add a new generator we must - add new generator directory (e.g. RPM for RPM generator) to CPack test root - directory that contains 'Helpers.cmake' script. In this script a function - named 'getPackageContent' must exist. This function should list files that - are contained in a package. Function should accept two parameters - + FILE variable that will contain path to file for which the content should be - listed - + RESULT_VAR that will tell the function which variable in parent scope should - contain the result (list of files inside package file) + directory that contains 'Helpers.cmake' script. + - In this script some functions must exist: + - getPackageContent: This function should list files that are contained in + a package. + Function parameters: + + FILE variable that will contain path to file for which the content + should be listed + + RESULT_VAR that will tell the function which variable in parent scope + should contain the result (list of files inside package file) + - getPackageNameGlobexpr: This function should generate package name + globbing expression. + Function parameters: + + NAME that will contain the expected package name + + COMPONENT that will contain the expected package component + + VERSION that will contain the expected package version + + REVISION that will contain the expected package revision number + + FILE_NO that will contain the file number for which the globbing + expression is generated + + RESULT_VAR that will tell the function which variable in parent scope + should contain the result (file name globbing expression) + - getPackageContentList: This function should return a list of files and + directories that are in the provided package. + Function parameters: + + FILE that will contain the package file for which the package content + should be returned. + + RESULT_VAR that will tell the function which variable in parent scope + should contain the result (list of pacakge content) + - toExpectedContentList: This function should convert an expected package + content list into one that is expected for the + generator (e.g. rpm packages have install/relocate + path prefixes which aren't part of the package so + those paths have to be removed from the expected + content list). + Function parameters: + + FILE_NO that will contain the file number for which the conversion + should be performed + + CONTENT_VAR that will contain the input list and is also the variable + in parent scope which should contain the result (converted content list) - add 'Prerequirements.cmake' script to generator directory. In this script a function named 'get_test_prerequirements' must exist. This function should set a variable in parent scope (name of the variable is the first parameter) @@ -119,3 +227,10 @@ To add a new generator we must - add tests the same way as described above - add generator to 'add_RunCMake_test_group' function call that is located in RunCMake CMakeLists.txt file +- if needed add 'packaging_<packaging_type>_default.cmake' scripts that define + default variables that will be set for each packaging type (MONOLITHIC, + COMPONENT and GROUP) +- if needed add 'default_expected_std<type>.txt' files where <type> is either + 'out' or 'err' which will contain default expected output of package + generation regular expression. +- add generator to list of other CPack generators in RunCMake/CMakeLists.txt diff --git a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index d396276..0000000 --- a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/empty$") diff --git a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-stderr.txt b/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-stderr.txt deleted file mode 100644 index 6ddca12..0000000 --- a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/COMPONENTS_EMPTY_DIR-build/_CPack_Packages/.*/RPM/SPECS/components_empty_dir.spec$ diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake deleted file mode 100644 index 780e57e..0000000 --- a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "custom_names-pkg_1*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "second*.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "pkg_3_abc.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake deleted file mode 100644 index 575aa01..0000000 --- a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") -set(CPACK_RPM_PKG_2_PACKAGE_NAME "second") -set(CPACK_RPM_PKG_3_FILE_NAME "pkg_3_abc.rpm") diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt deleted file mode 100644 index 9bfba7e..0000000 --- a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_1.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/second.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_3.spec$ diff --git a/Tests/RunCMake/CPack/RPM/DEBUGINFO-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEBUGINFO-ExpectedFiles.cmake deleted file mode 100644 index a583e32..0000000 --- a/Tests/RunCMake/CPack/RPM/DEBUGINFO-ExpectedFiles.cmake +++ /dev/null @@ -1,14 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "debuginfo-applications-0*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "debuginfo*-headers.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_3 "debuginfo*-libs.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") - -set(EXPECTED_FILE_4 "debuginfo-applications-debuginfo*.rpm") -set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") -set(EXPECTED_FILE_5 "debuginfo-libs-debuginfo*.rpm") -set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*") diff --git a/Tests/RunCMake/CPack/RPM/DEBUGINFO-stderr.txt b/Tests/RunCMake/CPack/RPM/DEBUGINFO-stderr.txt deleted file mode 100644 index 557ef3d..0000000 --- a/Tests/RunCMake/CPack/RPM/DEBUGINFO-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/DEBUGINFO-build/_CPack_Packages/.*/RPM/SPECS/debuginfo-applications.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/DEBUGINFO-build/_CPack_Packages/.*/RPM/SPECS/debuginfo-headers.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/DEBUGINFO-build/_CPack_Packages/.*/RPM/SPECS/debuginfo-libs.spec$ diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake deleted file mode 100644 index cf85dab..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies*-applications.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$") -set(EXPECTED_FILE_3 "dependencies*-headers.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies*-libs.rpm") -set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") -set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm") -set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index fec8889..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,45 +0,0 @@ -function(checkDependencies_ FILE TYPE COMPARE_LIST) - set(whitespaces_ "[\t\n\r ]*") - - execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE FILE_DEPENDENCIES_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") - - foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) - unset(FOUND_) - - foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) - if(COMPARE_ MATCHES "${COMPARE_REGEX_}") - set(FOUND_ true) - break() - endif() - endforeach() - - if(NOT FOUND_) - message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") - endif() - endforeach() -endfunction() - -# TODO add tests for what should not be present in lists -checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") -checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") -checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") -checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") -checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") - -checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") -checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") -checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") - -checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") -checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake deleted file mode 100644 index 8b7fb1e..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild -# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 -set(CPACK_RPM_PACKAGE_AUTOREQ "no") -set(CPACK_RPM_PACKAGE_AUTOPROV "no") -set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_AUTOREQPROV "yes") -set(CPACK_RPM_LIBS_AUTO_PACKAGE_AUTOREQPROV "yes") - -set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") -set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_HEADERS_PACKAGE_REQUIRES "depend-headers") - -set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") -set(CPACK_RPM_APPLICATIONS_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_HEADERS_PACKAGE_CONFLICTS "conflict-headers") - -set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") -set(CPACK_RPM_LIBS_PACKAGE_PROVIDES "provided-lib") -set(CPACK_RPM_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 0c2977f..0000000 --- a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/empty$") diff --git a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-stderr.txt b/Tests/RunCMake/CPack/RPM/EMPTY_DIR-stderr.txt deleted file mode 100644 index 1777aa0..0000000 --- a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/EMPTY_DIR-build/_CPack_Packages/.*/RPM/SPECS/empty_dir.spec$ diff --git a/Tests/RunCMake/CPack/RPM/Helpers.cmake b/Tests/RunCMake/CPack/RPM/Helpers.cmake index ba77a4a..bbc358c8 100644 --- a/Tests/RunCMake/CPack/RPM/Helpers.cmake +++ b/Tests/RunCMake/CPack/RPM/Helpers.cmake @@ -9,6 +9,59 @@ function(getPackageContent FILE RESULT_VAR) set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) endfunction() +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + if(DEFINED EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT}") + elseif(DEFINED EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT}") + else() + set(GENERATOR_SPECIFIC_FORMAT FALSE) + endif() + + if(GENERATOR_SPECIFIC_FORMAT) + set(${RESULT_VAR} "${NAME}${COMPONENT}-${VERSION}-${REVISION}.*.rpm" PARENT_SCOPE) + else() + set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.rpm" PARENT_SCOPE) + endif() +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + execute_process(COMMAND ${RPM_EXECUTABLE} -pql ${FILE} + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE "\n" ";" package_content_ "${package_content_}") + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + if(NOT DEFINED TEST_INSTALL_PREFIX_PATHS) + set(TEST_INSTALL_PREFIX_PATHS "/usr") + endif() + + unset(filtered_) + foreach(part_ IN LISTS ${CONTENT_VAR}) + unset(dont_add_) + foreach(for_removal_ IN LISTS TEST_INSTALL_PREFIX_PATHS) + if(part_ STREQUAL for_removal_) + set(dont_add_ TRUE) + break() + endif() + endforeach() + + if(NOT dont_add_) + list(APPEND filtered_ "${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() + function(getPackageInfo FILE RESULT_VAR) execute_process(COMMAND ${RPM_EXECUTABLE} -pqi ${FILE} OUTPUT_VARIABLE info_content diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake deleted file mode 100644 index 033a45d..0000000 --- a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "2") -set(EXPECTED_FILE_1 "install_scripts*-foo.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "install_scripts*-bar.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake deleted file mode 100644 index 4eb53c3..0000000 --- a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake +++ /dev/null @@ -1,19 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh") -set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh") -set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh") -set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh") - -set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh") -set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh") -set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh") -set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh") diff --git a/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake deleted file mode 100644 index 800b78e..0000000 --- a/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt b/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt deleted file mode 100644 index 7c5fb46..0000000 --- a/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MINIMAL-build/_CPack_Packages/.*/RPM/SPECS/minimal.spec$ diff --git a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake deleted file mode 100644 index 4e01f7b..0000000 --- a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "PARTIALLY_RELOCATABLE_WARNING-0.1.1-*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/not_relocatable${whitespaces_}/not_relocatable/CMakeLists.txt${whitespaces_}/opt$") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-ExpectedFiles.cmake deleted file mode 100644 index 3d28d41..0000000 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "per_component*-pkg_1.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "per_component*-pkg_2.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "per_component*-pkg_3.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake deleted file mode 100644 index d7d4f9d..0000000 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake +++ /dev/null @@ -1,18 +0,0 @@ -function(checkPackageInfo_ TYPE FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -# check package name -checkPackageInfo_("name" "${FOUND_FILE_1}" ".*Name${whitespaces_}:${whitespaces_}per_component-pkg_1") -checkPackageInfo_("name" "${FOUND_FILE_2}" ".*Name${whitespaces_}:${whitespaces_}second") -checkPackageInfo_("name" "${FOUND_FILE_3}" ".*Name${whitespaces_}:${whitespaces_}per_component-pkg_3") - -# check package group -checkPackageInfo_("group" "${FOUND_FILE_1}" ".*Group${whitespaces_}:${whitespaces_}default") -checkPackageInfo_("group" "${FOUND_FILE_2}" ".*Group${whitespaces_}:${whitespaces_}second_group") -checkPackageInfo_("group" "${FOUND_FILE_3}" ".*Group${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake deleted file mode 100644 index 524ef0c..0000000 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -set(CPACK_RPM_PACKAGE_GROUP "default") -set(CPACK_RPM_PKG_2_PACKAGE_NAME "second") -set(CPACK_RPM_PKG_2_PACKAGE_GROUP "second_group") diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake deleted file mode 100644 index 3b5a347..0000000 --- a/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "rpm_dist*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake deleted file mode 100644 index d6811eb..0000000 --- a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "source_package*.src.rpm") -set(EXPECTED_FILE_CONTENT_1 "^source_package-0.1.1.tar.gz${whitespaces_}source_package.spec$") diff --git a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt new file mode 100644 index 0000000..4a0e4e6 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt @@ -0,0 +1 @@ +^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$ diff --git a/Tests/RunCMake/CPack/RPM/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/RPM/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..c8b93e9 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 60d42ac..65399db 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -3,20 +3,25 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) include(RunCMake) include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") -# args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP -run_cpack_test(MINIMAL "RPM;DEB;TGZ" false) -run_cpack_source_test(SOURCE_PACKAGE "RPM" true) -run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false) -run_cpack_test(DEB_EXTRA "DEB" false) -run_cpack_test(DEPENDENCIES "RPM;DEB" true) -run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true) -run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true) -run_cpack_test(CUSTOM_NAMES "RPM;DEB" true) -run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false) -run_cpack_test(RPM_DIST "RPM" false) -run_cpack_test(INSTALL_SCRIPTS "RPM" false) -run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true) -run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true) -run_cpack_test(DEBUGINFO "RPM" true) -run_cpack_test(LONG_FILENAMES "DEB" false) -run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false) +# run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" +run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM" false "MONOLITHIC;COMPONENT") +run_cpack_test(CUSTOM_NAMES "RPM;DEB" true "COMPONENT") +run_cpack_test(DEBUGINFO "RPM" true "COMPONENT") +run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT") +run_cpack_test(DIST "RPM" false "MONOLITHIC") +run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true "MONOLITHIC;COMPONENT") +run_cpack_test(EXTRA "DEB" false "COMPONENT") +run_cpack_test(GENERATE_SHLIBS "DEB" true "COMPONENT") +run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") +run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") +run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") +run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT") +run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") +run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") +run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") +run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true "CUSTOM") +run_cpack_source_test(SOURCE_PACKAGE "RPM") +run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC") +run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC") +run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/STGZ/Helpers.cmake b/Tests/RunCMake/CPack/STGZ/Helpers.cmake new file mode 100644 index 0000000..08224d3 --- /dev/null +++ b/Tests/RunCMake/CPack/STGZ/Helpers.cmake @@ -0,0 +1,64 @@ +set(ALL_FILES_GLOB "*.sh") + +function(getPackageContent FILE RESULT_VAR) + get_filename_component(path_ "${FILE}" DIRECTORY) + file(REMOVE_RECURSE "${path_}/content") + file(MAKE_DIRECTORY "${path_}/content") + execute_process(COMMAND ${FILE} --prefix=${path_}/content --include-subdir + RESULT_VARIABLE extract_result_ + ERROR_VARIABLE extract_error_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(extract_result_) + message(FATAL_ERROR "Extracting STGZ archive failed: '${extract_result_}';" + " '${extract_error_}'.") + endif() + + file(GLOB_RECURSE package_content_ LIST_DIRECTORIES true RELATIVE + "${path_}/content" "${path_}/content/*") + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.sh" 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) + findExpectedFile("${FILE_NO}" "file_") + + get_filename_component(prefix_ "${file_}" NAME) + # NAME_WE removes everything after the dot and dot is in version so replace instead + string(REPLACE ".sh" "" prefix_ "${prefix_}") + + if(NOT PACKAGING_TYPE STREQUAL "MONOLITHIC") + # STGZ packages don't have component dir prefix in subdir + string(FIND "${prefix_}" "-" pos_ REVERSE) + string(SUBSTRING "${prefix_}" 0 ${pos_} prefix_) + endif() + + if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) + set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + endif() + + set(filtered_ "${prefix_}") + foreach(part_ IN LISTS ${CONTENT_VAR}) + string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + + if(part_) + list(APPEND filtered_ "${prefix_}/${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/STGZ/Prerequirements.cmake b/Tests/RunCMake/CPack/STGZ/Prerequirements.cmake new file mode 100644 index 0000000..3b015ca --- /dev/null +++ b/Tests/RunCMake/CPack/STGZ/Prerequirements.cmake @@ -0,0 +1,11 @@ +function(get_test_prerequirements found_var config_file) + if(EXISTS "/bin/sh") + #gunzip is not part of posix so we should not rely on it being installed + find_program(GUNZIP_EXECUTABLE gunzip) + + if(GUNZIP_EXECUTABLE) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) + endif() + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/STGZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/STGZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/STGZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TBZ2/Helpers.cmake b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake new file mode 100644 index 0000000..292b691 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.bz2") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 26e2ab0..0000000 --- a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir*.tar.gz") -set(EXPECTED_FILE_CONTENT_1 "^[^\n]*empty/$") diff --git a/Tests/RunCMake/CPack/TGZ/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index a75514a..0000000 --- a/Tests/RunCMake/CPack/TGZ/EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir*.tar.gz") -set(EXPECTED_FILE_CONTENT_1 "^[^\n]*empty_dir-0.1.1-[^\n]*/empty/$") diff --git a/Tests/RunCMake/CPack/TGZ/Helpers.cmake b/Tests/RunCMake/CPack/TGZ/Helpers.cmake index f14d532..4357a59 100644 --- a/Tests/RunCMake/CPack/TGZ/Helpers.cmake +++ b/Tests/RunCMake/CPack/TGZ/Helpers.cmake @@ -1,10 +1,3 @@ -set(ALL_FILES_GLOB "*.tar.gz") +set(cpack_archive_extension_ "tar.gz") -function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztvf ${FILE} - OUTPUT_VARIABLE package_content_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) -endfunction() +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TGZ/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/MINIMAL-ExpectedFiles.cmake deleted file mode 100644 index 5c31f27..0000000 --- a/Tests/RunCMake/CPack/TGZ/MINIMAL-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal*.tar.gz") -set(EXPECTED_FILE_CONTENT_1 "^[^\n]*minimal-0.1.1-[^\n]*/foo/\n[^\n]*minimal-0.1.1-[^\n]*/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake deleted file mode 100644 index 205dcd8..0000000 --- a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "0") - -if (NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") - set(EXPECTED_FILES_COUNT "1") - set(EXPECTED_FILE_1 "package_checksum*.tar.gz") - set(EXPECTED_FILE_CONTENT_1 "^[^\n]*package_checksum*-[^\n]*/foo/\n[^\n]*package_checksum-[^\n]*/foo/CMakeLists.txt$") -endif() diff --git a/Tests/RunCMake/CPack/TGZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TGZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TGZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TXZ/Helpers.cmake b/Tests/RunCMake/CPack/TXZ/Helpers.cmake new file mode 100644 index 0000000..f390cb4 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.xz") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TZ/Helpers.cmake b/Tests/RunCMake/CPack/TZ/Helpers.cmake new file mode 100644 index 0000000..117cd24 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.Z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 8bc2a58..59751a7 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -1,5 +1,28 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION} FATAL_ERROR) +function(findExpectedFile FILE_NO RESULT_VAR) + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}) # explicit file name regex was not provided - construct one from other data + # set defaults if parameters are not provided + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_NAME) + string(TOLOWER "${RunCMake_TEST_FILE_PREFIX}" EXPECTED_FILE_${FILE_NO}_NAME) + endif() + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_VERSION) + set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1") + endif() + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_REVISION) + set(EXPECTED_FILE_${FILE_NO}_REVISION "1") + endif() + + getPackageNameGlobexpr("${EXPECTED_FILE_${FILE_NO}_NAME}" + "${EXPECTED_FILE_${FILE_NO}_COMPONENT}" "${EXPECTED_FILE_${FILE_NO}_VERSION}" + "${EXPECTED_FILE_${FILE_NO}_REVISION}" "${FILE_NO}" "EXPECTED_FILE_${FILE_NO}") + endif() + + file(GLOB found_file_ RELATIVE "${bin_dir}" "${EXPECTED_FILE_${FILE_NO}}") + + set(${RESULT_VAR} "${found_file_}" PARENT_SCOPE) +endfunction() + include("${config_file}") include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake") @@ -10,27 +33,46 @@ file(READ "${config_file}" config_file_content) set(output_error_message "\nCPack output: '${output}'\nCPack error: '${error}';\nCPack result: '${PACKAGING_RESULT}';\nconfig file: '${config_file_content}'") -# check that expected generated files exist and contain expected content -include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-ExpectedFiles.cmake") +# generate default expected files data +include("${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/ExpectedFiles.cmake") +# check that expected generated files exist and contain expected content if(NOT EXPECTED_FILES_COUNT EQUAL 0) foreach(file_no_ RANGE 1 ${EXPECTED_FILES_COUNT}) - file(GLOB FOUND_FILE_${file_no_} RELATIVE "${bin_dir}" "${EXPECTED_FILE_${file_no_}}") + findExpectedFile("${file_no_}" "FOUND_FILE_${file_no_}") list(APPEND foundFiles_ "${FOUND_FILE_${file_no_}}") list(LENGTH FOUND_FILE_${file_no_} foundFilesCount_) if(foundFilesCount_ EQUAL 1) unset(PACKAGE_CONTENT) - getPackageContent("${bin_dir}/${FOUND_FILE_${file_no_}}" "PACKAGE_CONTENT") - string(REGEX MATCH "${EXPECTED_FILE_CONTENT_${file_no_}}" - expected_content_list "${PACKAGE_CONTENT}") + if(DEFINED EXPECTED_FILE_CONTENT_${file_no_}) + getPackageContent("${bin_dir}/${FOUND_FILE_${file_no_}}" "PACKAGE_CONTENT") + + string(REGEX MATCH "${EXPECTED_FILE_CONTENT_${file_no_}}" + expected_content_list "${PACKAGE_CONTENT}") + else() # use content list + getPackageContentList("${bin_dir}/${FOUND_FILE_${file_no_}}" "PACKAGE_CONTENT") + set(EXPECTED_FILE_CONTENT_${file_no_} "${EXPECTED_FILE_CONTENT_${file_no_}_LIST}") + toExpectedContentList("${file_no_}" "EXPECTED_FILE_CONTENT_${file_no_}") + + list(SORT PACKAGE_CONTENT) + list(SORT EXPECTED_FILE_CONTENT_${file_no_}) + + if(PACKAGE_CONTENT STREQUAL EXPECTED_FILE_CONTENT_${file_no_}) + set(expected_content_list TRUE) + else() + set(expected_content_list FALSE) + endif() + endif() if(NOT expected_content_list) + string(REPLACE "\n" "\n actual> " msg_actual "\n${PACKAGE_CONTENT}") + string(REPLACE "\n" "\n expect> " msg_expected "\n${EXPECTED_FILE_CONTENT_${file_no_}}") message(FATAL_ERROR "Unexpected file content for file No. '${file_no_}'!\n" - " Content: '${PACKAGE_CONTENT}'\n\n" - " Expected: '${EXPECTED_FILE_CONTENT_${file_no_}}'" + "The content was:${msg_actual}\n" + "which does not match:${msg_expected}\n" "${output_error_message}") endif() else() @@ -38,6 +80,7 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) "Found more than one file for file No. '${file_no_}'!" " Found files count '${foundFilesCount_}'." " Files: '${FOUND_FILE_${file_no_}}'" + " Globbing expression: '${EXPECTED_FILE_${file_no_}}'" "${output_error_message}") endif() endforeach() @@ -82,11 +125,9 @@ else() endif() # handle additional result verifications -if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") - include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") -else() - # by default only print out output and error so that they can be compared by - # regex - message(STATUS "${output}") - message("${error}") +if(EXISTS "${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/VerifyResult.cmake") + include("${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/VerifyResult.cmake") endif() + +message(STATUS "${output}") +message("${error}") diff --git a/Tests/RunCMake/CPack/ZIP/Helpers.cmake b/Tests/RunCMake/CPack/ZIP/Helpers.cmake new file mode 100644 index 0000000..3710bcf --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "zip") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake new file mode 100644 index 0000000..694dc00 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake @@ -0,0 +1,9 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1_COMPONENT "test") + set(EXPECTED_FILE_2_COMPONENT "test2") + set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt new file mode 100644 index 0000000..e6d86d0 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt @@ -0,0 +1,2 @@ +^CPackRPM: Will use USER specified spec file: (/[^/]*)*/CUSTOM_BINARY_SPEC_FILE/custom\.spec\.in +CPackRPM: Will use GENERATED spec file:.*/Tests/RunCMake/RPM/CPack/CUSTOM_BINARY_SPEC_FILE-build/_CPack_Packages/.*/RPM/SPECS/custom_binary_spec_file-test2\.spec$ diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-MONOLITHIC-stderr.txt b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-MONOLITHIC-stderr.txt new file mode 100644 index 0000000..d7bb7af --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-MONOLITHIC-stderr.txt @@ -0,0 +1 @@ +CPackRPM: Will use USER specified spec file: (/[^/]*)*/CUSTOM_BINARY_SPEC_FILE/custom\.spec\.in diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/custom.spec.in b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/custom.spec.in new file mode 100644 index 0000000..db0ac6f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/custom.spec.in @@ -0,0 +1,80 @@ +# -*- rpm-spec -*- +BuildRoot: %_topdir/@CPACK_PACKAGE_FILE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@ +Summary: @CPACK_RPM_PACKAGE_SUMMARY@ +Name: @CPACK_RPM_PACKAGE_NAME@ +Version: @CPACK_RPM_PACKAGE_VERSION@ +Release: @CPACK_RPM_PACKAGE_RELEASE@ +License: @CPACK_RPM_PACKAGE_LICENSE@ +Group: @CPACK_RPM_PACKAGE_GROUP@ +Vendor: @CPACK_RPM_PACKAGE_VENDOR@ + +@TMP_RPM_URL@ +@TMP_RPM_REQUIRES@ +@TMP_RPM_REQUIRES_PRE@ +@TMP_RPM_REQUIRES_POST@ +@TMP_RPM_REQUIRES_PREUN@ +@TMP_RPM_REQUIRES_POSTUN@ +@TMP_RPM_PROVIDES@ +@TMP_RPM_OBSOLETES@ +@TMP_RPM_CONFLICTS@ +@TMP_RPM_SUGGESTS@ +@TMP_RPM_AUTOPROV@ +@TMP_RPM_AUTOREQ@ +@TMP_RPM_AUTOREQPROV@ +@TMP_RPM_BUILDARCH@ +@TMP_RPM_PREFIXES@ + +@TMP_RPM_DEBUGINFO@ + +%define _rpmdir %_topdir/RPMS +%define _srcrpmdir %_topdir/SRPMS +@FILE_NAME_DEFINE@ +%define _unpackaged_files_terminate_build 0 +@TMP_RPM_SPEC_INSTALL_POST@ +@CPACK_RPM_SPEC_MORE_DEFINE@ +@CPACK_RPM_COMPRESSION_TYPE_TMP@ + +%description +@CPACK_RPM_PACKAGE_DESCRIPTION@ + +# This is a shortcutted spec file generated by CMake RPM generator +# we skip _install step because CPack does that for us. +# We do only save CPack installed tree in _prepr +# and then restore it in build. +%prep +mv $RPM_BUILD_ROOT %_topdir/tmpBBroot + +%install +if [ -e $RPM_BUILD_ROOT ]; +then + rm -rf $RPM_BUILD_ROOT +fi +mv %_topdir/tmpBBroot $RPM_BUILD_ROOT + +@TMP_RPM_DEBUGINFO_INSTALL@ + +%clean + +%post +@RPM_SYMLINK_POSTINSTALL@ +@CPACK_RPM_SPEC_POSTINSTALL@ + +%postun +@CPACK_RPM_SPEC_POSTUNINSTALL@ + +%pre +@CPACK_RPM_SPEC_PREINSTALL@ + +%preun +@CPACK_RPM_SPEC_PREUNINSTALL@ + +%files +%defattr(@TMP_DEFAULT_FILE_PERMISSIONS@,@TMP_DEFAULT_USER@,@TMP_DEFAULT_GROUP@,@TMP_DEFAULT_DIR_PERMISSIONS@) +@CPACK_RPM_INSTALL_FILES@ +@CPACK_RPM_ABSOLUTE_INSTALL_FILES@ +@CPACK_RPM_USER_INSTALL_FILES@ + +%changelog +@CPACK_RPM_SPEC_CHANGELOG@ + +@TMP_OTHER_COMPONENTS@ diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/test.cmake new file mode 100644 index 0000000..a604863 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/test.cmake @@ -0,0 +1,9 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "MONOLITHIC") + set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_LIST_DIR}/custom.spec.in") +elseif(PACKAGING_TYPE STREQUAL "COMPONENT") + install(FILES CMakeLists.txt DESTINATION bar COMPONENT test2) + set(CPACK_RPM_TEST_USER_BINARY_SPECFILE + "${CMAKE_CURRENT_LIST_DIR}/custom.spec.in") +endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake new file mode 100644 index 0000000..ae5f0af --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake @@ -0,0 +1,12 @@ +set(EXPECTED_FILES_COUNT "3") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_1_COMPONENT "pkg_1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_NAME "second") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + string(TOLOWER "${GENERATOR_TYPE}" file_extension_) + set(EXPECTED_FILE_3 "pkg_3_abc.${file_extension_}") +endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake new file mode 100644 index 0000000..0c2b37b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake @@ -0,0 +1,14 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + set(generator_type_suffix_ "IAN") # not entirely compatible... + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_FILE_NAME "${GENERATOR_TYPE}-DEFAULT") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second") + string(TOLOWER "${GENERATOR_TYPE}" file_extension_) + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_3_FILE_NAME "pkg_3_abc.${file_extension_}") +endif() + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake new file mode 100644 index 0000000..06e56d3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake @@ -0,0 +1,16 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) + +set(EXPECTED_FILE_1_COMPONENT "applications") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") +set(EXPECTED_FILE_2 "debuginfo*-headers.rpm") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_3 "debuginfo*-libs.rpm") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so") + +set(EXPECTED_FILE_4_COMPONENT "applications-debuginfo") +set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") +set(EXPECTED_FILE_5_COMPONENT "libs-debuginfo") +set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*") diff --git a/Tests/RunCMake/CPack/DEBUGINFO.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake index d98b682..0642d83 100644 --- a/Tests/RunCMake/CPack/DEBUGINFO.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake @@ -6,8 +6,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id") endif() -set(CPACK_RPM_COMPONENT_INSTALL "ON") - set(CMAKE_BUILD_TYPE Debug) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" @@ -30,5 +28,3 @@ set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src") - -set(CPACK_PACKAGE_NAME "debuginfo") diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/DEB-stderr.txt b/Tests/RunCMake/CPack/tests/DEPENDENCIES/DEB-stderr.txt new file mode 100644 index 0000000..5df274a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/DEB-stderr.txt @@ -0,0 +1 @@ +^CPackDeb: ((- Generating dependency list)|(Using only user-provided dependencies because dpkg-shlibdeps is not found\.))$ diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake new file mode 100644 index 0000000..3b280ba --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake @@ -0,0 +1,18 @@ +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1_COMPONENT "applications") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") +set(EXPECTED_FILE_2_COMPONENT "applications_auto") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo_auto;/usr/foo_auto/test_prog") +set(EXPECTED_FILE_3_COMPONENT "headers") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_4_COMPONENT "libs") +set(EXPECTED_FILE_CONTENT_4_LIST "/usr/bas;/usr/bas/libtest_lib.so") +set(EXPECTED_FILE_5_COMPONENT "libs_auto") +set(EXPECTED_FILE_CONTENT_5_LIST "/usr;/usr/bas_auto;/usr/bas_auto/libtest_lib.so") + +if(GENERATOR_TYPE STREQUAL "DEB") + set(whitespaces_ "[\t\n\r ]*") + # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it + set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") + set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") +endif() diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake new file mode 100644 index 0000000..7923148 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake @@ -0,0 +1,82 @@ +if(GENERATOR_TYPE STREQUAL "DEB") + function(checkDependencies_ FILE REGEX) + set(whitespaces_ "[\t\n\r ]*") + + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") + endif() + endfunction() + + foreach(dependency_type_ DEPENDS CONFLICTS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) + string(TOLOWER "${dependency_type_}" lower_dependency_type_) + string(SUBSTRING ${lower_dependency_type_} 1 -1 lower_dependency_type_tail_) + string(SUBSTRING ${dependency_type_} 0 1 dependency_type_head_) + set(dependency_type_name_ "${dependency_type_head_}${lower_dependency_type_tail_}") + + checkDependencies_("${FOUND_FILE_1}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") + checkDependencies_("${FOUND_FILE_2}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}.*${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") + checkDependencies_("${FOUND_FILE_3}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-headers.*") + checkDependencies_("${FOUND_FILE_4}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") + checkDependencies_("${FOUND_FILE_5}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") + endforeach() + + checkDependencies_("${FOUND_FILE_1}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_2}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_3}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_4}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib.*") + checkDependencies_("${FOUND_FILE_5}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib_auto.*, provided-lib_auto-b.*") + + # PREDEPENDS + checkDependencies_("${FOUND_FILE_1}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-application, predepends-application-b.*") + checkDependencies_("${FOUND_FILE_2}" ".*Pre-Depends${whitespaces_}:${whitespaces_}.*predepends-application, predepends-application-b.*") + checkDependencies_("${FOUND_FILE_3}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-headers.*") + checkDependencies_("${FOUND_FILE_4}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") + checkDependencies_("${FOUND_FILE_5}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") +elseif(GENERATOR_TYPE STREQUAL "RPM") + function(checkDependencies_ FILE TYPE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_DEPENDENCIES_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() + endfunction() + + # TODO add tests for what should not be present in lists + checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") + checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") + checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") + checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") + checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") + + checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflicts-application;conflicts-application-b") + checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflicts-application;conflicts-application-b") + checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflicts-headers") + checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflicts-default;conflicts-default-b") + checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflicts-default;conflicts-default-b") + + checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") + checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") +endif() diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/test.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/test.cmake new file mode 100644 index 0000000..fbd786e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/test.cmake @@ -0,0 +1,60 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + # false by default + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) + # FIXME can not be tested as libraries first have to be part of a package in order + # to determine their dependencies and we can not be certain if there will be any + set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) + + foreach(dependency_type_ DEPENDS PREDEPENDS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) + string(TOLOWER "${dependency_type_}" lower_dependency_type_) + + set(CPACK_DEBIAN_PACKAGE_${dependency_type_} "${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b") + set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") + set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") + set(CPACK_DEBIAN_HEADERS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-headers") + endforeach() + + set(generator_type_suffix_ "IAN") # not entirely compatible... + else() # RPM + # FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild + # does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 + set(CPACK_RPM_PACKAGE_AUTOREQ "no") + set(CPACK_RPM_PACKAGE_AUTOPROV "no") + set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_AUTOREQPROV "yes") + set(CPACK_RPM_LIBS_AUTO_PACKAGE_AUTOREQPROV "yes") + + set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") + set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "depend-application, depend-application-b") + set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_REQUIRES "depend-application, depend-application-b") + set(CPACK_RPM_HEADERS_PACKAGE_REQUIRES "depend-headers") + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_CONFLICTS "conflicts-default, conflicts-default-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_APPLICATIONS_PACKAGE_CONFLICTS "conflicts-application, conflicts-application-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_APPLICATIONS_AUTO_PACKAGE_CONFLICTS "conflicts-application, conflicts-application-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_HEADERS_PACKAGE_CONFLICTS "conflicts-headers") + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_PROVIDES "provided-default, provided-default-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_LIBS_PACKAGE_PROVIDES "provided-lib") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") +endif() + +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "#include \"test_lib.hpp\"\nint main() {return test_lib();}\n") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(test_prog test_lib) + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) +install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) +install(TARGETS test_lib DESTINATION bas COMPONENT libs) +install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) diff --git a/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake index 7375ecc..7375ecc 100644 --- a/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/RPM_DIST.cmake b/Tests/RunCMake/CPack/tests/DIST/test.cmake index eb2a123..6bdd2c0 100644 --- a/Tests/RunCMake/CPack/RPM_DIST.cmake +++ b/Tests/RunCMake/CPack/tests/DIST/test.cmake @@ -1,4 +1,3 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) -set(CPACK_PACKAGE_NAME "rpm_dist") diff --git a/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake new file mode 100644 index 0000000..650687c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake @@ -0,0 +1,7 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/empty") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILE_1_COMPONENT "test") +endif() diff --git a/Tests/RunCMake/CPack/tests/EMPTY_DIR/test.cmake b/Tests/RunCMake/CPack/tests/EMPTY_DIR/test.cmake new file mode 100644 index 0000000..cd2c9fd --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EMPTY_DIR/test.cmake @@ -0,0 +1,14 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + set(generator_type_suffix_ "IAN") # not entirely compatible... + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_FILE_NAME "${GENERATOR_TYPE}-DEFAULT") +endif() + +install(DIRECTORY DESTINATION empty + COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake new file mode 100644 index 0000000..ded2923 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake @@ -0,0 +1,8 @@ +set(EXPECTED_FILES_COUNT "3") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_1_COMPONENT "foo") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_COMPONENT "bar") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_3_COMPONENT "bas") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/EXTRA/VerifyResult.cmake index 85e137f..85e137f 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/EXTRA/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/DEB_EXTRA.cmake b/Tests/RunCMake/CPack/tests/EXTRA/test.cmake index 189d123..efa6dac 100644 --- a/Tests/RunCMake/CPack/DEB_EXTRA.cmake +++ b/Tests/RunCMake/CPack/tests/EXTRA/test.cmake @@ -32,8 +32,4 @@ endforeach() set(CPACK_DEBIAN_BAR_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/bar/preinst;${CMAKE_CURRENT_BINARY_DIR}/bar/prerm") -set(CPACK_PACKAGE_NAME "deb_extra") -set(CPACK_PACKAGE_CONTACT "someone") set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") - -set(CPACK_DEB_COMPONENT_INSTALL ON) diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake new file mode 100644 index 0000000..be44b2e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var config_file) + include(${config_file}) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/ExpectedFiles.cmake index a8efb61..ccb5ef0 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/ExpectedFiles.cmake @@ -1,6 +1,6 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "generate_shlibs_0.1.1-1_*.deb") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake index b1952ef..b1952ef 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake index 1aeb06f..90351ba 100644 --- a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake @@ -1,5 +1,3 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON") @@ -14,5 +12,3 @@ add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") set_target_properties(test_lib PROPERTIES SOVERSION "0.8") install(TARGETS test_lib DESTINATION foo COMPONENT libs) - -set(CPACK_PACKAGE_NAME "generate_shlibs") diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake new file mode 100644 index 0000000..be44b2e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var config_file) + include(${config_file}) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/ExpectedFiles.cmake index 9a9dee3..d66c044 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/ExpectedFiles.cmake @@ -1,6 +1,6 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "generate_shlibs_ldconfig_0.1.1-1_*.deb") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it set(EXPECTED_FILE_CONTENT_1 "^.*/usr/lib${whitespaces_}.*/usr/lib/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake index 422cfbe..422cfbe 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/test.cmake index f58c876..15c496b 100644 --- a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/test.cmake @@ -1,5 +1,3 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON") @@ -15,5 +13,3 @@ add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") set_target_properties(test_lib PROPERTIES SOVERSION "0.8") install(TARGETS test_lib LIBRARY DESTINATION lib COMPONENT libs NAMELINK_SKIP) - -set(CPACK_PACKAGE_NAME "generate_shlibs_ldconfig") diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake new file mode 100644 index 0000000..44346ab --- /dev/null +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake @@ -0,0 +1,5 @@ +set(EXPECTED_FILES_COUNT "2") +set(EXPECTED_FILE_1_COMPONENT "foo") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_COMPONENT "bar") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake index d7d82f2..d7d82f2 100644 --- a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake index 13aa77b..fb1b8de 100644 --- a/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake @@ -1,3 +1,23 @@ +if(GENERATOR_TYPE STREQUAL "RPM") + set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh") + set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh") + set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh") + set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh") + + set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh") + set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh") + set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh") + set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh") +endif() + set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) # default @@ -22,5 +42,3 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh" install(FILES CMakeLists.txt DESTINATION foo COMPONENT foo) install(FILES CMakeLists.txt DESTINATION bar COMPONENT bar) - -set(CPACK_PACKAGE_NAME "install_scripts") diff --git a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/DEB-Prerequirements.cmake new file mode 100644 index 0000000..ddd16e5 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/DEB-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var config_file) + include(${config_file}) + + if(FAKEROOT_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake new file mode 100644 index 0000000..631d957 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake @@ -0,0 +1,3 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt") diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake index 0452343..0452343 100644 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/LONG_FILENAMES.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/test.cmake index 3242aef..f235d47 100644 --- a/Tests/RunCMake/CPack/LONG_FILENAMES.cmake +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/test.cmake @@ -1,3 +1,8 @@ +if(GENERATOR_TYPE STREQUAL "DEB") + set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") + set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar") +endif() + set(LONG_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt") @@ -6,5 +11,3 @@ file(WRITE "long_filename_test") install(FILES ${LONG_FILENAME} DESTINATION foo) - -set(CPACK_PACKAGE_NAME "long_filenames") diff --git a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake new file mode 100644 index 0000000..6bfb0c1 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake @@ -0,0 +1,11 @@ +set(EXPECTED_FILES_COUNT "0") + +if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "invalid") + set(EXPECTED_FILES_COUNT "3") + set(EXPECTED_FILE_1 "main_component-0.1.1-1.*.rpm") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + set(EXPECTED_FILE_2_COMPONENT "headers") + set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") + set(EXPECTED_FILE_3_COMPONENT "libs") + set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt") +endif() diff --git a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/RPM-invalid-stderr.txt b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/RPM-invalid-stderr.txt new file mode 100644 index 0000000..4d8ac6e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/RPM-invalid-stderr.txt @@ -0,0 +1 @@ +CPACK_RPM_MAIN_COMPONENT set to non existing component. diff --git a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/test.cmake b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/test.cmake new file mode 100644 index 0000000..791c586 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/test.cmake @@ -0,0 +1,10 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT applications) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) +install(FILES CMakeLists.txt DESTINATION bas COMPONENT libs) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid") + set(CPACK_RPM_MAIN_COMPONENT "") +else() + set(CPACK_RPM_MAIN_COMPONENT "applications") + set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT") +endif() diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake new file mode 100644 index 0000000..fbdda9c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake @@ -0,0 +1,3 @@ +set(whitespaces_ "[\t\n\r ]*") +set(md5sums_md5sums "^.* usr/foo/CMakeLists\.txt${whitespaces_}$") +verifyDebControl("${FOUND_FILE_1}" "md5sums" "md5sums") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake new file mode 100644 index 0000000..15c5892 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake @@ -0,0 +1,5 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake new file mode 100644 index 0000000..15c5892 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake @@ -0,0 +1,5 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake new file mode 100644 index 0000000..eed5b92 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake @@ -0,0 +1,6 @@ +set(EXPECTED_FILES_COUNT "0") + +if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +endif() diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/TGZ-invalid-stderr.txt index abf6d8c..abf6d8c 100644 --- a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/TGZ-invalid-stderr.txt diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake index e9e65d6..e4f9618 100644 --- a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake @@ -9,6 +9,4 @@ if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") if(NOT expected_value STREQUAL CHSUM_VALUE) message(FATAL_ERROR "Generated checksum is not valid! Expected [${expected_value}] Got [${CHSUM_VALUE}]") endif() -else() - message(${error}) endif() diff --git a/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/test.cmake index 5ca288c..0838063 100644 --- a/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/test.cmake @@ -1,4 +1,3 @@ install(FILES CMakeLists.txt DESTINATION foo) -set(CPACK_PACKAGE_NAME "package_checksum") set(CPACK_PACKAGE_CHECKSUM ${RunCMake_SUBTEST_SUFFIX}) diff --git a/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake new file mode 100644 index 0000000..ae58c4b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/not_relocatable;/not_relocatable/CMakeLists.txt;/opt") diff --git a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/RPM-stderr.txt index 3b63d5b..3b63d5b 100644 --- a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt +++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/RPM-stderr.txt diff --git a/Tests/RunCMake/CPack/PARTIALLY_RELOCATABLE_WARNING.cmake b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/test.cmake index 31e729b..4698fb3 100644 --- a/Tests/RunCMake/CPack/PARTIALLY_RELOCATABLE_WARNING.cmake +++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/test.cmake @@ -2,5 +2,3 @@ install(FILES CMakeLists.txt DESTINATION /not_relocatable COMPONENT static) set(CPACK_PACKAGE_RELOCATABLE TRUE) set(CPACK_PACKAGING_INSTALL_PREFIX "/opt") - -set(CPACK_RPM_COMPONENT_INSTALL ON) diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake new file mode 100644 index 0000000..9bdb176 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake @@ -0,0 +1,8 @@ +set(EXPECTED_FILES_COUNT "3") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_1_COMPONENT "pkg_1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_NAME "second") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_3_COMPONENT "pkg_3") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake new file mode 100644 index 0000000..18ef63c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake @@ -0,0 +1,26 @@ +function(checkPackageInfo_ TYPE FILE REGEX) + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") + endif() +endfunction() + +if(GENERATOR_TYPE STREQUAL "DEB") + set(name_ "Package") + set(group_ "Section") +elseif(GENERATOR_TYPE STREQUAL "RPM") + set(name_ "Name") + set(group_ "Group") +endif() + +set(whitespaces_ "[\t\n\r ]*") + +# check package name +checkPackageInfo_("name" "${FOUND_FILE_1}" ".*${name_}${whitespaces_}:${whitespaces_}per_component_fields-pkg_1") +checkPackageInfo_("name" "${FOUND_FILE_2}" ".*${name_}${whitespaces_}:${whitespaces_}second") +checkPackageInfo_("name" "${FOUND_FILE_3}" ".*${name_}${whitespaces_}:${whitespaces_}per_component_fields-pkg_3") + +# check package group +checkPackageInfo_("group" "${FOUND_FILE_1}" ".*${group_}${whitespaces_}:${whitespaces_}default") +checkPackageInfo_("group" "${FOUND_FILE_2}" ".*${group_}${whitespaces_}:${whitespaces_}second_group") +checkPackageInfo_("group" "${FOUND_FILE_3}" ".*${group_}${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake new file mode 100644 index 0000000..8719c0b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake @@ -0,0 +1,18 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + set(generator_type_suffix_ "IAN") # not entirely compatible... + set(group_ "SECTION") + else() + set(group_ "GROUP") + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_FILE_NAME "${GENERATOR_TYPE}-DEFAULT") + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_${group_} "default") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_${group_} "second_group") +endif() + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake new file mode 100644 index 0000000..ca866ea --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake @@ -0,0 +1,30 @@ +set(whitespaces_ "[\t\n\r ]*") +set(EXPECTED_FILES_COUNT "0") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") + set(EXPECTED_FILES_COUNT "4") + set(EXPECTED_FILE_1 "single_debuginfo-0.1.1-1.*.rpm") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") + set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm") + set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") + set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm") + set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so") + + set(EXPECTED_FILE_4_COMPONENT "debuginfo") + set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1 "single_debuginfo-0*-applications.rpm") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") + + set(EXPECTED_FILE_2 "single_debuginfo-applications-debuginfo*.rpm") + set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_components") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1 "single_debuginfo-0*.rpm") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") + + set(EXPECTED_FILE_2 "single_debuginfo-debuginfo*.rpm") + set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") +endif() diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/RPM-no_main_component-stderr.txt b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/RPM-no_main_component-stderr.txt new file mode 100644 index 0000000..454283c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/RPM-no_main_component-stderr.txt @@ -0,0 +1 @@ +CPack Error: CPACK_RPM_MAIN_COMPONENT not set but it is mandatory with CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE being set. diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake new file mode 100644 index 0000000..60e9038 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake @@ -0,0 +1,54 @@ +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) + +# PGI compiler doesn't add build id to binaries by default +if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") + string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id") + string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id") +endif() + +if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "no_components") + set(CPACK_RPM_COMPONENT_INSTALL "ON") +endif() + +set(CMAKE_BUILD_TYPE Debug) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "#include \"test_lib.hpp\"\nint main() {return test_lib();}\n") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(test_prog test_lib) + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_main_component" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") + install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) + install(TARGETS test_lib DESTINATION bas COMPONENT libs) +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo") + set(CPACK_COMPONENTS_ALL applications) +endif() + +set(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE ON) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") + set(CPACK_RPM_MAIN_COMPONENT "applications") + set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT") +endif() + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_main_component" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component") + set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON) +endif() + +set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src") diff --git a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake new file mode 100644 index 0000000..0a3e426 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "source_package-0.1.1.tar.gz;source_package.spec") diff --git a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake index a84e296..bc54d79 100644 --- a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake @@ -1,3 +1,5 @@ +set(whitespaces_ "[\t\n\r ]*") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILD") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILDROOT") diff --git a/Tests/RunCMake/CPack/SOURCE_PACKAGE.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/test.cmake index 946439d..359b98f 100644 --- a/Tests/RunCMake/CPack/SOURCE_PACKAGE.cmake +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/test.cmake @@ -5,5 +5,3 @@ add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") install(TARGETS test_prog DESTINATION foo COMPONENT applications) set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") - -set(CPACK_PACKAGE_NAME "source_package") diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt new file mode 100644 index 0000000..feb296c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt @@ -0,0 +1 @@ +^(.*CPackRPM:Warning: SUGGESTS not supported in provided rpmbuild.*)?CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build/_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec$ diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake new file mode 100644 index 0000000..32cc6d1 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake @@ -0,0 +1,31 @@ +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --querytags + OUTPUT_VARIABLE RPMBUILD_CAPS + RESULT_VARIABLE RPMBUILD_CAPS_RESULT) + +if(NOT RPMBUILD_CAPS_RESULT) + string(REPLACE "\n" ";" RPMBUILD_CAPS "${RPMBUILD_CAPS}") + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) + if(SUGGESTS IN_LIST RPMBUILD_CAPS) + set(should_contain_suggests_tag_ true) + endif() + cmake_policy(POP) +endif() + +# Only verify that suggests tag is present only if that tag is supported. +# If it is not supported the rpm package was corretly generated by ignoring +# that tag and that was already checked by expected files test. +if(should_contain_suggests_tag_) + execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p "${FOUND_FILE_1}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE rpm_result_ + OUTPUT_VARIABLE rpm_output_ + ERROR_VARIABLE error_variable_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(rpm_result_ OR NOT rpm_output_ STREQUAL "libsuggested") + message(FATAL_ERROR "RPM_SUGGESTED package error: no suggested packages" + " (result: '${rpm_result_}'; output: '${rpm_output_}';" + " error: '${error_variable_}')") + endif() +endif() diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/test.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/test.cmake new file mode 100644 index 0000000..dc90ae8 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/test.cmake @@ -0,0 +1,3 @@ +install(FILES CMakeLists.txt DESTINATION foo) + +set(CPACK_RPM_PACKAGE_SUGGESTS "libsuggested") diff --git a/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake new file mode 100644 index 0000000..aabe537 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr/one;/usr/one/foo.txt;/usr/one/two;/usr/one/two/bar.txt;/usr/three;/usr/three/baz.txt;/usr/three/qux.txt") diff --git a/Tests/RunCMake/CPack/tests/USER_FILELIST/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/USER_FILELIST/VerifyResult.cmake new file mode 100644 index 0000000..57444ed --- /dev/null +++ b/Tests/RunCMake/CPack/tests/USER_FILELIST/VerifyResult.cmake @@ -0,0 +1,12 @@ +execute_process(COMMAND ${RPM_EXECUTABLE} -qpd ${FOUND_FILE_1} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE DOC_FILES_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +string(REPLACE "\n" ";" DOC_FILES_ "${DOC_FILES_}") + +set(DOC_FILES_WANTED_ "/usr/one/foo.txt;/usr/one/two/bar.txt;/usr/three/baz.txt") +if (NOT "${DOC_FILES_}" STREQUAL "${DOC_FILES_WANTED_}") + message(FATAL_ERROR "USER_FILELIST handling error: Check filelist in spec file. Doc files were: ${DOC_FILES_}. Should have been ${DOC_FILES_WANTED_}") +endif() diff --git a/Tests/RunCMake/CPack/tests/USER_FILELIST/test.cmake b/Tests/RunCMake/CPack/tests/USER_FILELIST/test.cmake new file mode 100644 index 0000000..acfee42 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/USER_FILELIST/test.cmake @@ -0,0 +1,13 @@ +install(FILES CMakeLists.txt DESTINATION one RENAME foo.txt) +install(FILES CMakeLists.txt DESTINATION one/two RENAME bar.txt) +install(FILES CMakeLists.txt DESTINATION three RENAME baz.txt) +install(FILES CMakeLists.txt DESTINATION three RENAME qux.txt) + +# We are verifying the USER_FILELIST works by comparing what +# ends up with a %doc tag in the final rpm with what we expect +# from this USER_FILELIST. +set(CPACK_RPM_USER_FILELIST + "%doc /usr/one/foo.txt" + "%doc %attr(640,root,root) /usr/one/two/bar.txt" + "%attr(600, -, root) %doc /usr/three/baz.txt" +) diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 2bc3693..e936dab 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -135,6 +135,7 @@ function(run_TestOutputSize) ") run_cmake_command(TestOutputSize ${CMAKE_CTEST_COMMAND} -M Experimental -T Test + --no-compress-output --test-output-size-passed 10 --test-output-size-failed 12 ) diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-cmake.cmake b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-cmake.cmake index 4654416..ecb9a64 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-cmake.cmake +++ b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-cmake.cmake @@ -12,4 +12,6 @@ add_test(NAME test1 set_tests_properties(test1 PROPERTIES DEPENDS "initialization") add_test(hello ${CMAKE_COMMAND} -E echo hello) +set_tests_properties(hello PROPERTIES FAIL_REGULAR_EXPRESSION "hello.*hello") + add_test(goodbye ${CMAKE_COMMAND} -E echo goodbye) diff --git a/Tests/RunCMake/ClangTidy/C-bad-Build-result.txt b/Tests/RunCMake/ClangTidy/C-bad-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/C-bad-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/ClangTidy/C-bad-Build-stdout.txt b/Tests/RunCMake/ClangTidy/C-bad-Build-stdout.txt new file mode 100644 index 0000000..2370ce1 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/C-bad-Build-stdout.txt @@ -0,0 +1,2 @@ +stdout from bad command line arg '-bad' +stderr from bad command line arg '-bad' diff --git a/Tests/RunCMake/ClangTidy/C-bad.cmake b/Tests/RunCMake/ClangTidy/C-bad.cmake new file mode 100644 index 0000000..aa54c08 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/C-bad.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -bad) +add_executable(main main.c) diff --git a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake index 27cd922..2f41e50 100644 --- a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake +++ b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake @@ -20,3 +20,4 @@ if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") run_tidy(C-launch) run_tidy(CXX-launch) endif() +run_tidy(C-bad) diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt index 0d0d899..35f50b7 100644 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt @@ -1 +1 @@ -^__run_iwyu missing --tidy= or --iwyu=$ +^__run_iwyu missing --cpplint=, --iwyu=, --lwyu=, and/or --tidy=$ diff --git a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes new file mode 100644 index 0000000..9c22288 --- /dev/null +++ b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes @@ -0,0 +1,2 @@ +# Do not format a source encoded in UTF-16. +test_UTF-16LE.h -format.clang-format diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake index 09594bd..2d14a9e 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake @@ -3,13 +3,13 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_static_assert) +target_compile_features(empty3 INTERFACE cxx_std_11) target_link_libraries(empty1 # When starting, $<COMPILE_FEATURES:cxx_auto_type> is '0', so 'freeze' the # CXX_STANDARD at 98 during computation. $<$<COMPILE_FEATURES:cxx_auto_type>:empty2> - # This would add cxx_static_assert, but that would require CXX_STANDARD = 11, + # This would add cxx_std_11, but that would require CXX_STANDARD = 11, # which is not allowed after freeze. Report an error. empty3 ) diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake index bbcf4e0..a04dcec 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake @@ -3,7 +3,7 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_static_assert) +target_compile_features(empty3 INTERFACE cxx_std_11) target_link_libraries(empty1 $<$<COMPILE_FEATURES:cxx_nullptr>:empty2> diff --git a/Tests/RunCMake/Configure/RemoveCache-stdout.txt b/Tests/RunCMake/Configure/RemoveCache-stdout.txt new file mode 100644 index 0000000..73e7e5d --- /dev/null +++ b/Tests/RunCMake/Configure/RemoveCache-stdout.txt @@ -0,0 +1 @@ +-- The C compiler identification is diff --git a/Tests/RunCMake/Configure/RemoveCache.cmake b/Tests/RunCMake/Configure/RemoveCache.cmake new file mode 100644 index 0000000..304918f --- /dev/null +++ b/Tests/RunCMake/Configure/RemoveCache.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(vars + CMAKE_EXECUTABLE_FORMAT + ) + +if(CMAKE_HOST_UNIX) + list(APPEND vars + CMAKE_UNAME + ) +endif() + +foreach(v IN LISTS vars) + if(NOT DEFINED ${v}) + message(SEND_ERROR "Variable '${v}' is not set!") + endif() +endforeach() diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 91adb4e..4a135be 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -24,3 +24,12 @@ file(WRITE "${depend}" "2") run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) + +# Use a single build tree for a few tests without cleaning. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RemoveCache-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +run_cmake(RemoveCache) +file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") +run_cmake(RemoveCache) diff --git a/Tests/RunCMake/Cpplint/C-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/C-error-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/C-error-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-error-Build-stdout.txt new file mode 100644 index 0000000..3e7a1e9 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.c:0: message \[category/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/C-error-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-error-launch-Build-stdout.txt new file mode 100644 index 0000000..3e7a1e9 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-launch-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.c:0: message \[category/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/C-error-launch.cmake b/Tests/RunCMake/Cpplint/C-error-launch.cmake new file mode 100644 index 0000000..c76e2e2 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C-error.cmake) diff --git a/Tests/RunCMake/Cpplint/C-error.cmake b/Tests/RunCMake/Cpplint/C-error.cmake new file mode 100644 index 0000000..29cf7ba --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_CPPLINT "${PSEUDO_CPPLINT}" --error) +add_executable(main main.c) diff --git a/Tests/RunCMake/Cpplint/C-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-launch-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-launch-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/C-launch.cmake b/Tests/RunCMake/Cpplint/C-launch.cmake new file mode 100644 index 0000000..e66ca20 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C.cmake) diff --git a/Tests/RunCMake/Cpplint/C.cmake b/Tests/RunCMake/Cpplint/C.cmake new file mode 100644 index 0000000..68e6ff4 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) +add_executable(main main.c) diff --git a/Tests/RunCMake/Cpplint/CMakeLists.txt b/Tests/RunCMake/Cpplint/CMakeLists.txt new file mode 100644 index 0000000..a640c56 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.7) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Cpplint/CXX-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/CXX-error-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-error-Build-stdout.txt new file mode 100644 index 0000000..028cd37 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.cxx:0: message \[category\/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-stdout.txt new file mode 100644 index 0000000..028cd37 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.cxx:0: message \[category\/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch.cmake b/Tests/RunCMake/Cpplint/CXX-error-launch.cmake new file mode 100644 index 0000000..72dcbe9 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX-error.cmake) diff --git a/Tests/RunCMake/Cpplint/CXX-error.cmake b/Tests/RunCMake/Cpplint/CXX-error.cmake new file mode 100644 index 0000000..ad66ff5 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --error) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cpplint/CXX-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-launch-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-launch-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/CXX-launch.cmake b/Tests/RunCMake/Cpplint/CXX-launch.cmake new file mode 100644 index 0000000..3002c9d --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX.cmake) diff --git a/Tests/RunCMake/Cpplint/CXX.cmake b/Tests/RunCMake/Cpplint/CXX.cmake new file mode 100644 index 0000000..35f05ee --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cpplint/RunCMakeTest.cmake b/Tests/RunCMake/Cpplint/RunCMakeTest.cmake new file mode 100644 index 0000000..5a8471e --- /dev/null +++ b/Tests/RunCMake/Cpplint/RunCMakeTest.cmake @@ -0,0 +1,26 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}") + +function(run_cpplint lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${lang}) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .) +endfunction() + +run_cpplint(C) +run_cpplint(CXX) +run_cpplint(C-error) +run_cpplint(CXX-error) + +if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_cpplint(C-launch) + run_cpplint(CXX-launch) + run_cpplint(C-error-launch) + run_cpplint(CXX-error-launch) +endif() diff --git a/Tests/RunCMake/Cpplint/main.c b/Tests/RunCMake/Cpplint/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/Cpplint/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Cpplint/main.cxx b/Tests/RunCMake/Cpplint/main.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/Cpplint/main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake index 67fa30f..c4db11b 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake @@ -4,7 +4,15 @@ set(CMAKE_CROSSCOMPILING 1) add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx) # Executable: Return error code equal to 0 -add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx) +add_executable(generated_exe_emulator_unexpected generated_exe_emulator_unexpected.cxx) +# Place the executable in a predictable location. +set_property(TARGET generated_exe_emulator_unexpected PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>) + +# Executable: Imported version of above. Fake the imported target to use the above. +add_executable(generated_exe_emulator_unexpected_imported IMPORTED) +set_property(TARGET generated_exe_emulator_unexpected_imported PROPERTY IMPORTED_LOCATION + "${CMAKE_CURRENT_BINARY_DIR}/generated_exe_emulator_unexpected${CMAKE_EXECUTABLE_SUFFIX}") +add_dependencies(generated_exe_emulator_unexpected_imported generated_exe_emulator_unexpected) # DoesNotUseEmulator add_custom_command(OUTPUT output1 @@ -22,6 +30,12 @@ add_custom_command(OUTPUT output3 COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3 DEPENDS generated_exe_emulator_unexpected) +# DoesNotUseEmulator: The command will fail if emulator is prepended +add_custom_command(OUTPUT outputImp + COMMAND generated_exe_emulator_unexpected_imported + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp + ) + # UsesEmulator: The command only succeeds if the emulator is prepended # to the command. add_custom_command(OUTPUT output4 @@ -34,5 +48,6 @@ add_custom_target(ensure_build ALL ${CMAKE_CURRENT_BINARY_DIR}/output1 ${CMAKE_CURRENT_BINARY_DIR}/output2 ${CMAKE_CURRENT_BINARY_DIR}/output3 + ${CMAKE_CURRENT_BINARY_DIR}/outputImp ${CMAKE_CURRENT_BINARY_DIR}/output4 ) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake index ced569f..5b01abc 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake @@ -4,7 +4,15 @@ set(CMAKE_CROSSCOMPILING 1) add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx) # Executable: Return error code equal to 0 -add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx) +add_executable(generated_exe_emulator_unexpected generated_exe_emulator_unexpected.cxx) +# Place the executable in a predictable location. +set_property(TARGET generated_exe_emulator_unexpected PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>) + +# Executable: Imported version of above. Fake the imported target to use the above. +add_executable(generated_exe_emulator_unexpected_imported IMPORTED) +set_property(TARGET generated_exe_emulator_unexpected_imported PROPERTY IMPORTED_LOCATION + "${CMAKE_CURRENT_BINARY_DIR}/generated_exe_emulator_unexpected${CMAKE_EXECUTABLE_SUFFIX}") +add_dependencies(generated_exe_emulator_unexpected_imported generated_exe_emulator_unexpected) # DoesNotUseEmulator add_custom_target(generate_output1 ALL @@ -22,6 +30,12 @@ add_custom_target(generate_output3 ALL COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3 DEPENDS generated_exe_emulator_unexpected) +# DoesNotUseEmulator: The command will fail if emulator is prepended +add_custom_target(generate_outputImp ALL + COMMAND generated_exe_emulator_unexpected_imported + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp + ) + # UsesEmulator: The command only succeeds if the emulator is prepended # to the command. add_custom_target(generate_output4 ALL diff --git a/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx b/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx new file mode 100644 index 0000000..233f432 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + for (int i = 1; i < argc; ++i) { + fprintf(stderr, "unexpected argument: '%s'\n", argv[i]); + } + return argc == 1 ? 0 : 1; +} diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx deleted file mode 100644 index a3dd891..0000000 --- a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx +++ /dev/null @@ -1,4 +0,0 @@ -int main(int, char**) -{ - return 0; -} diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault-stderr.txt new file mode 100644 index 0000000..58f6125 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + Bad package property type OPTIONAL used in global property + FeatureSummary_DEFAULT_PKG_TYPE. Valid types are TYPE1, TYPE2 and TYPE3. + Either update FeatureSummary_DEFAULT_PKG_TYPE or add OPTIONAL to the + FeatureSummary_PKG_TYPES global property. +Call Stack \(most recent call first\): + .*/Modules/FeatureSummary\.cmake:[0-9]+. \(_FS_GET_FEATURE_SUMMARY\) + FeatureSummaryCustomBadDefault.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault.cmake new file mode 100644 index 0000000..7e2fd55 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomBadDefault.cmake @@ -0,0 +1,8 @@ +include(FeatureSummary) +set_property(GLOBAL PROPERTY FeatureSummary_PKG_TYPES TYPE1 TYPE2 TYPE3) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +find_package(Foo) + +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-stderr.txt new file mode 100644 index 0000000..e37b9f5 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + feature_summary\(\) Error: REQUIRED package\(s\) are missing, aborting CMake + run. +Call Stack \(most recent call first\): + FeatureSummaryCustomRequired.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-stdout.txt new file mode 100644 index 0000000..ecca71f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired-stdout.txt @@ -0,0 +1,17 @@ +-- The following TYPE3 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE2 packages have not been found: + + \* Bar + +-- The following TYPE3 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE3 packages have not been found: + + \* Bar + +-- Configuring incomplete, errors occurred! diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired.cmake new file mode 100644 index 0000000..11cf04c --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequired.cmake @@ -0,0 +1,16 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +set_property(GLOBAL PROPERTY FeatureSummary_PKG_TYPES TYPE1 TYPE2 TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE TYPE2) + +find_package(Foo) +find_package(Bar) + +set_package_properties(Foo PROPERTIES TYPE TYPE3) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) + +set_package_properties(Bar PROPERTIES TYPE TYPE3) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-stderr.txt new file mode 100644 index 0000000..c9d8b4b --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + feature_summary\(\) Error: REQUIRED package\(s\) are missing, aborting CMake + run. +Call Stack \(most recent call first\): + FeatureSummaryCustomRequiredListA.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-stdout.txt new file mode 100644 index 0000000..b12d53a --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA-stdout.txt @@ -0,0 +1,17 @@ +-- The following TYPE2 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE1 packages have not been found: + + \* Bar + +-- The following TYPE2 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE2 packages have not been found: + + \* Bar + +-- Configuring incomplete, errors occurred! diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA.cmake new file mode 100644 index 0000000..53111be --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListA.cmake @@ -0,0 +1,16 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +set_property(GLOBAL PROPERTY FeatureSummary_PKG_TYPES TYPE1 TYPE2 TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES TYPE2 TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE TYPE1) + +find_package(Foo) +find_package(Bar) + +set_package_properties(Foo PROPERTIES TYPE TYPE2) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) + +set_package_properties(Bar PROPERTIES TYPE TYPE2) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-stderr.txt new file mode 100644 index 0000000..8ef7a8d --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + feature_summary\(\) Error: REQUIRED package\(s\) are missing, aborting CMake + run. +Call Stack \(most recent call first\): + FeatureSummaryCustomRequiredListB.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-stdout.txt new file mode 100644 index 0000000..5f07173 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB-stdout.txt @@ -0,0 +1,17 @@ +-- The following TYPE3 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE1 packages have not been found: + + \* Bar + +-- The following TYPE3 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE3 packages have not been found: + + \* Bar + +-- Configuring incomplete, errors occurred! diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB.cmake new file mode 100644 index 0000000..526b979 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomRequiredListB.cmake @@ -0,0 +1,16 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +set_property(GLOBAL PROPERTY FeatureSummary_PKG_TYPES TYPE1 TYPE2 TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES TYPE2 TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE TYPE1) + +find_package(Foo) +find_package(Bar) + +set_package_properties(Foo PROPERTIES TYPE TYPE3) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) + +set_package_properties(Bar PROPERTIES TYPE TYPE3) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomTypes-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomTypes-stdout.txt new file mode 100644 index 0000000..a7f973b --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomTypes-stdout.txt @@ -0,0 +1,29 @@ +-- The following TYPE2 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE1 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE2 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE2 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE3 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE3 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following TYPE3 packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- Configuring done diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomTypes.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomTypes.cmake new file mode 100644 index 0000000..34b0c1f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryCustomTypes.cmake @@ -0,0 +1,36 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +set_property(GLOBAL PROPERTY FeatureSummary_PKG_TYPES TYPE1 TYPE2 TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES TYPE3) +set_property(GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE TYPE2) + +find_package(Foo) + +# Type not set => TYPE2 +feature_summary(WHAT ALL) + +# TYPE1 > not set => TYPE1 +set_package_properties(Foo PROPERTIES TYPE TYPE1) +feature_summary(WHAT ALL) + +# TYPE2 > TYPE1 => TYPE2 +set_package_properties(Foo PROPERTIES TYPE TYPE2) +feature_summary(WHAT ALL) + +# TYPE1 < TYPE2 => TYPE2 +set_package_properties(Foo PROPERTIES TYPE TYPE2) +feature_summary(WHAT ALL) + +# TYPE3 > TYPE2 => TYPE3 +set_package_properties(Foo PROPERTIES TYPE TYPE3) +feature_summary(WHAT ALL) + +# TYPE2 < TYPE3 => TYPE3 +set_package_properties(Foo PROPERTIES TYPE TYPE2) +feature_summary(WHAT ALL) + +# TYPE1 < TYPE3 => TYPE3 +set_package_properties(Foo PROPERTIES TYPE TYPE1) +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-stderr.txt new file mode 100644 index 0000000..214d74a --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + feature_summary\(\) Error: REQUIRED package\(s\) are missing, aborting CMake + run. +Call Stack \(most recent call first\): + FeatureSummaryFatalOnMissingRequiredPackages.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-stdout.txt new file mode 100644 index 0000000..6bd6427 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages-stdout.txt @@ -0,0 +1,17 @@ +-- The following REQUIRED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following OPTIONAL packages have not been found: + + \* Bar + +-- The following REQUIRED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following REQUIRED packages have not been found: + + \* Bar + +-- Configuring incomplete, errors occurred! diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages.cmake new file mode 100644 index 0000000..9563186 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryFatalOnMissingRequiredPackages.cmake @@ -0,0 +1,12 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +find_package(Foo) +find_package(Bar) + +set_package_properties(Foo PROPERTIES TYPE REQUIRED) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) + +set_package_properties(Bar PROPERTIES TYPE REQUIRED) +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryIncludeQuietPackages-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryIncludeQuietPackages-stdout.txt new file mode 100644 index 0000000..58599e0 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryIncludeQuietPackages-stdout.txt @@ -0,0 +1,14 @@ +-- The following OPTIONAL packages have not been found: + + \* Baz + +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following OPTIONAL packages have not been found: + + \* Bar + \* Baz + +-- Configuring done diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryIncludeQuietPackages.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryIncludeQuietPackages.cmake new file mode 100644 index 0000000..5cdb443 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryIncludeQuietPackages.cmake @@ -0,0 +1,11 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +find_package(Foo QUIET) +find_package(Bar QUIET) +find_package(Baz) + +feature_summary(WHAT ALL) + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryMultipleDepends-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryMultipleDepends-stdout.txt new file mode 100644 index 0000000..d5875e0 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryMultipleDepends-stdout.txt @@ -0,0 +1,10 @@ +-- The following features have been enabled: + + \* Bar, Bar\. + \* Baz, Baz\. + \* Goo, Goo\. + +-- The following features have been disabled: + + \* Foo, Foo\. + \* Fez, Fez\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryMultipleDepends.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryMultipleDepends.cmake new file mode 100644 index 0000000..f355ae7 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryMultipleDepends.cmake @@ -0,0 +1,12 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo "WITH_FOO;WITH_BAR" "Foo.") +add_feature_info(Bar "WITH_FOO;NOT WITH_BAR" "Bar.") +add_feature_info(Baz "WITH_FOO AND NOT WITH_BAR" "Baz.") +add_feature_info(Goo "WITH_FOO OR WITH_BAR" "Goo.") +add_feature_info(Fez "NOT WITH_FOO OR WITH_BAR" "Fez.") + +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryPurpose-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryPurpose-stdout.txt new file mode 100644 index 0000000..78e4fe1 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryPurpose-stdout.txt @@ -0,0 +1,16 @@ +The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + Because everyone needs some Foo. + +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + Because everyone needs some Foo. + Because Foo is better than Bar. + +-- Configuring done diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryPurpose.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryPurpose.cmake new file mode 100644 index 0000000..64735b6 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryPurpose.cmake @@ -0,0 +1,16 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +find_package(Foo) + +# Purpose not set +feature_summary(WHAT ALL) + +# Purpose set once +set_package_properties(Foo PROPERTIES PURPOSE "Because everyone needs some Foo.") +feature_summary(WHAT ALL) + +# Purpose set twice +set_package_properties(Foo PROPERTIES PURPOSE "Because Foo is better than Bar.") +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryQuietOnEmpty-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryQuietOnEmpty-stdout.txt new file mode 100644 index 0000000..65e97e0 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryQuietOnEmpty-stdout.txt @@ -0,0 +1,5 @@ +-- Enabled features: + \* Foo, Foo\. + \* Bar, Bar\. + +-- Configuring done diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryQuietOnEmpty.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryQuietOnEmpty.cmake new file mode 100644 index 0000000..8d1d007 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryQuietOnEmpty.cmake @@ -0,0 +1,14 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 1) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ENABLED_FEATURES + DESCRIPTION "Enabled features:" + QUIET_ON_EMPTY) +feature_summary(WHAT DISABLED_FEATURES + DESCRIPTION "Disabled features:" + QUIET_ON_EMPTY) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryTypes-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryTypes-stdout.txt new file mode 100644 index 0000000..79bb1e3 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryTypes-stdout.txt @@ -0,0 +1,45 @@ +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following RUNTIME packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following RECOMMENDED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following RECOMMENDED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following RECOMMENDED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following REQUIRED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following REQUIRED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following REQUIRED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following REQUIRED packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- Configuring done diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryTypes.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryTypes.cmake new file mode 100644 index 0000000..09d1e7a --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryTypes.cmake @@ -0,0 +1,48 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +find_package(Foo) + +# Type not set => OPTIONAL +feature_summary(WHAT ALL) + +# RUNTIME > not set => RUNTIME +set_package_properties(Foo PROPERTIES TYPE RUNTIME) +feature_summary(WHAT ALL) + +# OPTIONAL > RUNTIME => OPTIONAL +set_package_properties(Foo PROPERTIES TYPE OPTIONAL) +feature_summary(WHAT ALL) + +# RUNTIME < OPTIONAL => OPTIONAL +set_package_properties(Foo PROPERTIES TYPE OPTIONAL) +feature_summary(WHAT ALL) + +# RECOMMENDED > OPTIONAL => RECOMMENDED +set_package_properties(Foo PROPERTIES TYPE RECOMMENDED) +feature_summary(WHAT ALL) + +# OPTIONAL < RECOMMENDED => RECOMMENDED +set_package_properties(Foo PROPERTIES TYPE OPTIONAL) +feature_summary(WHAT ALL) + +# RUNTIME < RECOMMENDED => RECOMMENDED +set_package_properties(Foo PROPERTIES TYPE RUNTIME) +feature_summary(WHAT ALL) + +# REQUIRED > RECOMMENDED => REQUIRED +set_package_properties(Foo PROPERTIES TYPE REQUIRED) +feature_summary(WHAT ALL) + +# RECOMMENDED < REQUIRED => REQUIRED +set_package_properties(Foo PROPERTIES TYPE RECOMMENDED) +feature_summary(WHAT ALL) + +# OPTIONAL < REQUIRED => REQUIRED +set_package_properties(Foo PROPERTIES TYPE OPTIONAL) +feature_summary(WHAT ALL) + +# RUNTIME < REQUIRED => REQUIRED +set_package_properties(Foo PROPERTIES TYPE RUNTIME) +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryURLDescription-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryURLDescription-stdout.txt new file mode 100644 index 0000000..6a55bdf --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryURLDescription-stdout.txt @@ -0,0 +1,32 @@ +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following OPTIONAL packages have not been found: + + \* Bar + \* Baz + +-- The following OPTIONAL packages have been found: + + \* Foo, The Foo package, <https://foo.example/> + +-- The following OPTIONAL packages have not been found: + + \* Bar, <https://bar.net/> + \* Baz, A Baz package + +-- Warning: Property DESCRIPTION for package Foo already set to "The Foo package", overriding it with "A Foo package" +-- Warning: Property URL already set to "https://foo.example/", overriding it with "https://foo.net/" +-- Warning: Property URL already set to "https://bar.net/", overriding it with "https://bar.example/" +-- Warning: Property DESCRIPTION for package Baz already set to "A Baz package", overriding it with "The Baz package" +-- The following OPTIONAL packages have been found: + + \* Foo, A Foo package, <https://foo.net/> + +-- The following OPTIONAL packages have not been found: + + \* Bar, The Bar package, <https://bar.example/> + \* Baz, The Baz package, <https://baz.example/> + +-- Configuring done diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryURLDescription.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryURLDescription.cmake new file mode 100644 index 0000000..77fcf28 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryURLDescription.cmake @@ -0,0 +1,28 @@ +include(FeatureSummary) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +find_package(Foo) # URL and DESCRIPTION are set in the FindFoo.cmake file +find_package(Bar) # URL and DESCRIPTION are not set +find_package(Baz) # URL and DESCRIPTION are not set + +feature_summary(WHAT ALL) + +set_package_properties(Bar PROPERTIES URL "https://bar.net/") # URL and no DESCRIPTION +set_package_properties(Baz PROPERTIES DESCRIPTION "A Baz package") # DESCRIPTION and no URL +feature_summary(WHAT ALL) + +# Overwrite with the same value (no warning) +set_package_properties(Foo PROPERTIES URL "https://foo.example/" + DESCRIPTION "The Foo package") +set_package_properties(Bar PROPERTIES URL "https://bar.net/") +set_package_properties(Baz PROPERTIES DESCRIPTION "A Baz package") + +# Overwrite with different values (warnings) +set_package_properties(Foo PROPERTIES URL "https://foo.net/" + DESCRIPTION "A Foo package") # Overwrite URL and DESCRIPTION +set_package_properties(Bar PROPERTIES URL "https://bar.example/" + DESCRIPTION "The Bar package") # Overwrite URL and add DESCRIPTION +set_package_properties(Baz PROPERTIES URL "https://baz.example/" + DESCRIPTION "The Baz package") # Overwrite URL and add DESCRIPTION +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt index 9a3f023..f0631ae 100644 --- a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt @@ -1,7 +1,7 @@ -- The following features have been enabled: - \* Foo , Foo\. + \* Foo, Foo\. -- The following features have been disabled: - \* Bar , Bar\. + \* Bar, Bar\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt index 4d8f25f..f121417 100644 --- a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt @@ -1,7 +1,7 @@ -- The following features have been disabled: - \* Bar , Bar\. + \* Bar, Bar\. -- The following features have been enabled: - \* Foo , Foo\. + \* Foo, Foo\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce-stdout.txt index 39be105..8b4cd43 100644 --- a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce-stdout.txt +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce-stdout.txt @@ -1,4 +1,4 @@ --( ) - \* Foo , Foo decscription\. + \* Foo, Foo description\. + -- diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce.cmake index 545fb92..eaea40e 100644 --- a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce.cmake +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatOnce.cmake @@ -2,7 +2,7 @@ include(FeatureSummary) set(WITH_FOO 1) -add_feature_info(Foo WITH_FOO "Foo decscription.") -add_feature_info(Foo WITH_FOO "Foo decscription.") +add_feature_info(Foo WITH_FOO "Foo description.") +add_feature_info(Foo WITH_FOO "Foo description.") feature_summary(WHAT ENABLED_FEATURES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt index 240632d..7485df9 100644 --- a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt @@ -1 +1 @@ - \* Foo , Foo\. + \* Foo, Foo\. diff --git a/Tests/RunCMake/FeatureSummary/FindBar.cmake b/Tests/RunCMake/FeatureSummary/FindBar.cmake new file mode 100644 index 0000000..45f4d54 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FindBar.cmake @@ -0,0 +1,2 @@ +include(FeatureSummary) +set(Bar_FOUND 0) diff --git a/Tests/RunCMake/FeatureSummary/FindBaz.cmake b/Tests/RunCMake/FeatureSummary/FindBaz.cmake new file mode 100644 index 0000000..73aafcd --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FindBaz.cmake @@ -0,0 +1,2 @@ +include(FeatureSummary) +set(Baz_FOUND 0) diff --git a/Tests/RunCMake/FeatureSummary/FindFoo.cmake b/Tests/RunCMake/FeatureSummary/FindFoo.cmake new file mode 100644 index 0000000..baec987 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FindFoo.cmake @@ -0,0 +1,4 @@ +include(FeatureSummary) +set_package_properties(Foo PROPERTIES URL "https://foo.example/" + DESCRIPTION "The Foo package") +set(Foo_FOUND 1) diff --git a/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake index 6a5fc28..9caee4c 100644 --- a/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake +++ b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake @@ -7,3 +7,15 @@ run_cmake(FeatureSummaryWhatList) run_cmake(FeatureSummaryWhatListUnknown) run_cmake(FeatureSummaryWhatListAll) run_cmake(FeatureSummaryWhatOnce) +run_cmake(FeatureSummaryPurpose) +run_cmake(FeatureSummaryURLDescription) +run_cmake(FeatureSummaryTypes) +run_cmake(FeatureSummaryFatalOnMissingRequiredPackages) +run_cmake(FeatureSummaryIncludeQuietPackages) +run_cmake(FeatureSummaryQuietOnEmpty) +run_cmake(FeatureSummaryMultipleDepends) +run_cmake(FeatureSummaryCustomTypes) +run_cmake(FeatureSummaryCustomBadDefault) +run_cmake(FeatureSummaryCustomRequired) +run_cmake(FeatureSummaryCustomRequiredListA) +run_cmake(FeatureSummaryCustomRequiredListB) diff --git a/Tests/RunCMake/FindGTK2/CMakeLists.txt b/Tests/RunCMake/FindGTK2/CMakeLists.txt new file mode 100644 index 0000000..93ee9df --- /dev/null +++ b/Tests/RunCMake/FindGTK2/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindGTK2/FindGTK2RunTwice.cmake b/Tests/RunCMake/FindGTK2/FindGTK2RunTwice.cmake new file mode 100644 index 0000000..e0585ee --- /dev/null +++ b/Tests/RunCMake/FindGTK2/FindGTK2RunTwice.cmake @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.7) +project(testFindGTK2 C) + +# First call +find_package(GTK2 REQUIRED) + +# Backup variables +set(GTK2_LIBRARIES_BAK ${GTK2_LIBRARIES}) +set(GTK2_TARGETS_BAK ${GTK2_TARGETS}) + +# Second call +find_package(GTK2 REQUIRED) + +# Check variables +if(NOT "${GTK2_LIBRARIES_BAK}" STREQUAL "${GTK2_LIBRARIES}") + message(SEND_ERROR "GTK2_LIBRARIES is different:\nbefore: ${GTK2_LIBRARIES_BAK}\nafter: ${GTK2_LIBRARIES}") +endif() + +if(NOT "${GTK2_TARGETS_BAK}" STREQUAL "${GTK2_TARGETS}") + message(SEND_ERROR "GTK2_TARGETS is different:\nbefore: ${GTK2_TARGETS_BAK}\nafter: ${GTK2_TARGETS}") +endif() diff --git a/Tests/RunCMake/FindGTK2/RunCMakeTest.cmake b/Tests/RunCMake/FindGTK2/RunCMakeTest.cmake new file mode 100644 index 0000000..66364ca --- /dev/null +++ b/Tests/RunCMake/FindGTK2/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(FindGTK2RunTwice) diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake index 5184755..ae32134 100644 --- a/Tests/RunCMake/Framework/FrameworkLayout.cmake +++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.4) enable_language(C) -add_library(Framework SHARED +add_library(Framework ${FRAMEWORK_TYPE} foo.c foo.h res.txt) @@ -9,3 +9,6 @@ set_target_properties(Framework PROPERTIES FRAMEWORK TRUE PUBLIC_HEADER foo.h RESOURCE "res.txt") + +add_custom_command(TARGET Framework POST_BUILD + COMMAND /usr/bin/file $<TARGET_FILE:Framework>) diff --git a/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt new file mode 100644 index 0000000..8d90f5f --- /dev/null +++ b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt @@ -0,0 +1 @@ +.*/Framework: Mach-O[^\n]* dynamically linked shared library.* diff --git a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt new file mode 100644 index 0000000..c9f50b6 --- /dev/null +++ b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt @@ -0,0 +1 @@ +.*/Framework: current ar archive random library.* diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index eeea6f1..e64892d 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -1,33 +1,40 @@ include(RunCMake) -# iOS - -set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/iOSFrameworkLayout-build) -set(RunCMake_TEST_NO_CLEAN 1) -set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/ios.cmake") - -file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") -file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - -run_cmake(FrameworkLayout) -run_cmake_command(iOSFrameworkLayout-build ${CMAKE_COMMAND} --build .) - -unset(RunCMake_TEST_BINARY_DIR) -unset(RunCMake_TEST_NO_CLEAN) -unset(RunCMake_TEST_OPTIONS) - -# OSX - -set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/OSXFrameworkLayout-build) -set(RunCMake_TEST_NO_CLEAN 1) -set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake") - -file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") -file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - -run_cmake(FrameworkLayout) -run_cmake_command(OSXFrameworkLayout-build ${CMAKE_COMMAND} --build .) - -unset(RunCMake_TEST_BINARY_DIR) -unset(RunCMake_TEST_NO_CLEAN) -unset(RunCMake_TEST_OPTIONS) +function(framework_layout_test Name Toolchain Type) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkLayout-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake") + list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(FrameworkLayout) + run_cmake_command(${Name} ${CMAKE_COMMAND} --build .) +endfunction() + +# build check cannot cope with multi-configuration generators directory layout +if(NOT RunCMake_GENERATOR STREQUAL "Xcode") + framework_layout_test(iOSFrameworkLayout-build ios SHARED) + framework_layout_test(iOSFrameworkLayout-build ios STATIC) + framework_layout_test(OSXFrameworkLayout-build osx SHARED) + framework_layout_test(OSXFrameworkLayout-build osx STATIC) +endif() + +function(framework_type_test Toolchain Type) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkType-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake") + list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(FrameworkLayout) + run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .) +endfunction() + +framework_type_test(ios SHARED) +framework_type_test(ios STATIC) +framework_type_test(osx SHARED) +framework_type_test(osx STATIC) diff --git a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes new file mode 100644 index 0000000..883a7f1 --- /dev/null +++ b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes @@ -0,0 +1,2 @@ +# Exclude reference content from formatting. +* -format.clang-format diff --git a/Tests/RunCMake/GeneratorExpression/BadIF-result.txt b/Tests/RunCMake/GeneratorExpression/BadIF-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadIF-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/BadIF-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadIF-stderr.txt new file mode 100644 index 0000000..7c7506c --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadIF-stderr.txt @@ -0,0 +1,15 @@ +CMake Error at BadIF.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<IF:asdf,a,b> + + First parameter to \$<IF> must resolve to exactly one '0' or '1' value. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadIF.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<IF:asdf,a> + + \$<IF> expression requires 3 comma separated parameters, but got 2 instead. diff --git a/Tests/RunCMake/GeneratorExpression/BadIF.cmake b/Tests/RunCMake/GeneratorExpression/BadIF.cmake new file mode 100644 index 0000000..583f68d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadIF.cmake @@ -0,0 +1,5 @@ + +add_custom_target(check ALL COMMAND check + $<IF:asdf,a,b> + $<IF:asdf,a> + ) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index f5584d5..084b5c3 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(BadIF) run_cmake(BadCONFIG) run_cmake(BadOR) run_cmake(BadAND) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION-stderr.txt index e4dbb71..d4e5b29 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) in CMakeLists.txt: +CMake Warning \(dev\) at TARGET_PROPERTY-LOCATION.cmake:2 \(add_library\): Policy CMP0026 is not set: Disallow use of the LOCATION target property. Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy command to set the policy and suppress this warning. @@ -7,4 +7,6 @@ CMake Warning \(dev\) in CMakeLists.txt: name directly with add_custom_command, or use the generator expression \$<TARGET_FILE>, as appropriate. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-stderr.txt new file mode 100644 index 0000000..5737e95 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + .* + + does not recognize the toolset + + Test Toolset,host=x6[45] + + that was specified\.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index 283a2a0..e8ce47d 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -6,6 +6,21 @@ run_cmake(NoToolset) if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]|Xcode" AND NOT XCODE_BELOW_3) set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolset) + if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[245]") + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") + run_cmake(TestToolsetHostArchBoth) + set(RunCMake_GENERATOR_TOOLSET ",host=x64") + run_cmake(TestToolsetHostArchOnly) + set(RunCMake_GENERATOR_TOOLSET "host=x64") + run_cmake(TestToolsetHostArchOnly) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset") + run_cmake(TestToolsetHostArchNone) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x65") + run_cmake(BadToolsetHostArch) + else() + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") + run_cmake(BadToolsetHostArch) + endif() else() set(RunCMake_GENERATOR_TOOLSET "Bad Toolset") run_cmake(BadToolset) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth-stdout.txt new file mode 100644 index 0000000..f0b6d46 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='x64' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth.cmake new file mode 100644 index 0000000..26926f9 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt new file mode 100644 index 0000000..576b40c --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake new file mode 100644 index 0000000..26926f9 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt new file mode 100644 index 0000000..8271bd4 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='x64' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake new file mode 100644 index 0000000..26926f9 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") diff --git a/Tests/RunCMake/Ninja/NinjaToolMissing-result.txt b/Tests/RunCMake/Ninja/NinjaToolMissing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Ninja/NinjaToolMissing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Ninja/NinjaToolMissing-stderr.txt b/Tests/RunCMake/Ninja/NinjaToolMissing-stderr.txt new file mode 100644 index 0000000..1214288 --- /dev/null +++ b/Tests/RunCMake/Ninja/NinjaToolMissing-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Running + + 'ninja-tool-missing' '--version' + + failed with: diff --git a/Tests/RunCMake/Ninja/NinjaToolMissing.cmake b/Tests/RunCMake/Ninja/NinjaToolMissing.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/Ninja/NinjaToolMissing.cmake diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 1d3639d..7b4e51e 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -15,6 +15,12 @@ else() message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}") endif() +function(run_NinjaToolMissing) + set(RunCMake_MAKE_PROGRAM ninja-tool-missing) + run_cmake(NinjaToolMissing) +endfunction() +run_NinjaToolMissing() + function(run_CMP0058 case) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 247855a..5f66da0 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -75,6 +75,7 @@ function(run_cmake test) OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE ${actual_stderr_var} RESULT_VARIABLE actual_result + ENCODING UTF8 ${maybe_timeout} ) else() @@ -90,6 +91,7 @@ function(run_cmake test) OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE ${actual_stderr_var} RESULT_VARIABLE actual_result + ENCODING UTF8 ${maybe_timeout} ) endif() @@ -99,7 +101,7 @@ function(run_cmake test) endif() foreach(o out err) string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}") - string(REGEX REPLACE "(^|\n)((==[0-9]+==|BullseyeCoverage|[a-z]+\\([0-9]+\\) malloc:|Error kstat returned|[^\n]*from Time Machine by path|[^\n]*Bullseye Testing Technology)[^\n]*\n)+" "\\1" actual_std${o} "${actual_std${o}}") + string(REGEX REPLACE "(^|\n)((==[0-9]+==|BullseyeCoverage|[a-z]+\\([0-9]+\\) malloc:|Error kstat returned|[^\n]*is a member of multiple groups|[^\n]*from Time Machine by path|[^\n]*Bullseye Testing Technology)[^\n]*\n)+" "\\1" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") set(expect_${o} "") if(DEFINED expect_std${o}) diff --git a/Tests/RunCMake/RunCTest.cmake b/Tests/RunCMake/RunCTest.cmake index e94432b..89e16ee 100644 --- a/Tests/RunCMake/RunCTest.cmake +++ b/Tests/RunCMake/RunCTest.cmake @@ -12,6 +12,7 @@ function(run_ctest CASE_NAME) -S ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake -V --output-log ${RunCMake_BINARY_DIR}/${CASE_NAME}-build/testOutput.log + --no-compress-output ${ARGN} ) endfunction() diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index cc2cc2e..bc1ec97 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,2 +1,5 @@ include(RunCMake) run_cmake(VsConfigurationType) +run_cmake(VsTargetsFileReferences) +run_cmake(VsCustomProps) +run_cmake(VsDebuggerWorkingDir) diff --git a/Tests/RunCMake/VS10Project/VsCustomProps-check.cmake b/Tests/RunCMake/VS10Project/VsCustomProps-check.cmake new file mode 100644 index 0000000..22a3df0 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCustomProps-check.cmake @@ -0,0 +1,25 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(importFound FALSE) + +set(props_file "${RunCMake_SOURCE_DIR}/my.props") +file(TO_NATIVE_PATH "${props_file}" check_file) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<Import Project=\"([^\"]+)\".*Label=\"([^\"]+)\".*$") + if("${CMAKE_MATCH_1}" STREQUAL "${check_file}" AND + "${CMAKE_MATCH_2}" STREQUAL "LocalAppDataPlatform") + message(STATUS "foo.vcxproj is importing ${check_file}") + set(importFound TRUE) + endif() + endif() +endforeach() + +if(NOT importFound) + set(RunCMake_TEST_FAILED "Import of custom .props file not found.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCustomProps.cmake b/Tests/RunCMake/VS10Project/VsCustomProps.cmake new file mode 100644 index 0000000..fbbcfcf --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCustomProps.cmake @@ -0,0 +1,7 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set(props_file "${CMAKE_CURRENT_SOURCE_DIR}/my.props") + +set_target_properties(foo PROPERTIES + VS_USER_PROPS "${props_file}") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake new file mode 100644 index 0000000..637c68c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake @@ -0,0 +1,22 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(debuggerWorkDirSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory") + message(STATUS "foo.vcxproj has debugger working dir set") + set(debuggerWorkDirSet TRUE) + endif() + endif() +endforeach() + +if(NOT debuggerWorkDirSet) + set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake new file mode 100644 index 0000000..a277c65 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory") diff --git a/Tests/RunCMake/VS10Project/VsTargetsFileReferences-check.cmake b/Tests/RunCMake/VS10Project/VsTargetsFileReferences-check.cmake new file mode 100644 index 0000000..3d01c2c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsTargetsFileReferences-check.cmake @@ -0,0 +1,45 @@ +set(files foo.vcxproj bar.vcxproj baz.vcxproj) + +foreach(file ${files}) + set(vsProjectFile ${RunCMake_TEST_BINARY_DIR}/${file}) + + if(NOT EXISTS "${vsProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vsProjectFile} does not exist.") + return() + endif() + + set(waldoFound FALSE) + set(xyzzyFound FALSE) + file(STRINGS "${vsProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<Import Project=.*/>$") + if(line MATCHES "^.*waldo.targets.*$") + set(waldoFound TRUE) + message(STATUS "${file} is importing waldo.targets") + elseif(line MATCHES "^.*xyzzy.targets.*$") + set(xyzzyFound TRUE) + message(STATUS "${file} is importing xyzzy.targets") + endif() + endif() + endforeach() + + if("${file}" STREQUAL "foo.vcxproj") + if(NOT xyzzyFound) + set(RunCMake_TEST_FAILED "xyzzy.targets not imported from ${file}") + return() + endif() + if(waldoFound) + set(RunCMake_TEST_FAILED "waldo.targets imported from ${file}") + return() + endif() + else() + if(NOT xyzzyFound) + set(RunCMake_TEST_FAILED "xyzzy.targets not imported from ${file}") + return() + endif() + if(NOT waldoFound) + set(RunCMake_TEST_FAILED "waldo.targets not imported from ${file}") + return() + endif() + endif() +endforeach() diff --git a/Tests/RunCMake/VS10Project/VsTargetsFileReferences.cmake b/Tests/RunCMake/VS10Project/VsTargetsFileReferences.cmake new file mode 100644 index 0000000..5ca4f1f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsTargetsFileReferences.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) +add_library(foo foo.cpp) +target_link_libraries(foo ${CMAKE_BINARY_DIR}/xyzzy.targets) + +add_library(bar bar.cpp) +target_link_libraries(bar foo ${CMAKE_BINARY_DIR}/waldo.targets) + +add_executable(baz baz.cpp) +target_link_libraries(baz bar) diff --git a/Tests/RunCMake/VS10Project/bar.cpp b/Tests/RunCMake/VS10Project/bar.cpp new file mode 100644 index 0000000..b72a1a5 --- /dev/null +++ b/Tests/RunCMake/VS10Project/bar.cpp @@ -0,0 +1,3 @@ +void bar() +{ +} diff --git a/Tests/RunCMake/VS10Project/baz.cpp b/Tests/RunCMake/VS10Project/baz.cpp new file mode 100644 index 0000000..d5d334a --- /dev/null +++ b/Tests/RunCMake/VS10Project/baz.cpp @@ -0,0 +1,3 @@ +void baz() +{ +} diff --git a/Tests/RunCMake/VS10Project/my.props b/Tests/RunCMake/VS10Project/my.props new file mode 100644 index 0000000..7c98cde --- /dev/null +++ b/Tests/RunCMake/VS10Project/my.props @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + </PropertyGroup> +</Project> diff --git a/Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake b/Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake new file mode 100644 index 0000000..7265900 --- /dev/null +++ b/Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake @@ -0,0 +1,29 @@ +set(vcSlnFile "${RunCMake_TEST_BINARY_DIR}/AddPackageToDefault.sln") +if(NOT EXISTS "${vcSlnFile}") + set(RunCMake_TEST_FAILED "Project file ${vcSlnFile} does not exist.") + return() +endif() + +set(packageGuidFound FALSE) +set(packageGuid "") +set(packageInBuild FALSE) +file(STRINGS "${vcSlnFile}" lines) +foreach(line IN LISTS lines) + if(NOT packageGuidFound) + if(line MATCHES "^Project.*\"PACKAGE.vcx?proj\".*\"{([A-F0-9-]+)}\"$") + set(packageGuidFound TRUE) + set(packageGuid ${CMAKE_MATCH_1}) + endif() + else() + if(line MATCHES ".*{${packageGuid}}.*") + if(line MATCHES "^[ \t]*{${packageGuid}}\\..*\\.Build.0 = .*$") + set(packageInBuild TRUE) + endif() + endif() + endif() +endforeach() + +if(NOT packageInBuild) + set(RunCMake_TEST_FAILED "PACKAGE is not in default build") + return() +endif() diff --git a/Tests/RunCMake/VSSolution/AddPackageToDefault.cmake b/Tests/RunCMake/VSSolution/AddPackageToDefault.cmake new file mode 100644 index 0000000..5f69ec5 --- /dev/null +++ b/Tests/RunCMake/VSSolution/AddPackageToDefault.cmake @@ -0,0 +1,2 @@ +include(CPack) +set(CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD TRUE) diff --git a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake index afd74a1..4ec3e3b 100644 --- a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake +++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake @@ -10,6 +10,7 @@ run_cmake(Override1) run_cmake(Override2) run_cmake(StartupProject) run_cmake(StartupProjectMissing) +run_cmake(AddPackageToDefault) if(RunCMake_GENERATOR MATCHES "Visual Studio ([^7]|[7][0-9])" AND NOT NO_USE_FOLDERS) run_cmake(StartupProjectUseFolders) diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt new file mode 100644 index 0000000..6500649 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error in CMakeLists.txt: + Xcode does not support per-config per-source COMPILE_FLAGS: + + \$<\$<CONFIG:Debug>:-DMYDEBUG> + + specified for source: + + .*/Tests/RunCMake/XcodeProject/main.c$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags.cmake new file mode 100644 index 0000000..99cec5b --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(main main.c) +set_property(SOURCE main.c PROPERTY COMPILE_FLAGS "$<$<CONFIG:Debug>:-DMYDEBUG>") diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index d43c80d..f51a107 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -13,6 +13,8 @@ if (NOT XCODE_VERSION VERSION_LESS 6) run_cmake(XcodePlatformFrameworks) endif() +run_cmake(PerConfigPerSourceFlags) + # Use a single build tree for a few tests without cleaning. if(NOT XCODE_VERSION VERSION_LESS 5) @@ -164,3 +166,24 @@ if(NOT XCODE_VERSION VERSION_LESS 6) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_OPTIONS) endif() + +if(NOT XCODE_VERSION VERSION_LESS 5) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeMultiplatform-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeMultiplatform) + + # build ios before macos + run_cmake_command(XcodeMultiplatform-iphonesimulator-build ${CMAKE_COMMAND} --build . -- -sdk iphonesimulator) + run_cmake_command(XcodeMultiplatform-iphonesimulator-install ${CMAKE_COMMAND} --build . --target install -- -sdk iphonesimulator DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_iphonesimulator) + + run_cmake_command(XcodeMultiplatform-macosx-build ${CMAKE_COMMAND} --build . -- -sdk macosx) + run_cmake_command(XcodeMultiplatform-macosx-install ${CMAKE_COMMAND} --build . --target install -- -sdk macosx DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_macosx) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index ad4268d..833eb85 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -50,30 +50,56 @@ if (NOT TEST_IOS AND NOT TEST_WATCHOS AND NOT TEST_TVOS) add_dependencies(AppBundleExtTest AppBundleExt) endif() -# Framework (not supported for iOS on Xcode < 6) +# Shared Framework (not supported for iOS on Xcode < 6) if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6) - add_library(Framework SHARED main.c) - set_target_properties(Framework PROPERTIES FRAMEWORK TRUE) + add_library(SharedFramework SHARED main.c) + set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE) - add_custom_target(FrameworkTest ALL + add_custom_target(SharedFrameworkTest ALL COMMAND ${CMAKE_COMMAND} -E copy - "$<TARGET_FILE:Framework>" "$<TARGET_FILE:Framework>.old") + "$<TARGET_FILE:SharedFramework>" "$<TARGET_FILE:SharedFramework>.old") - add_dependencies(FrameworkTest Framework) + add_dependencies(SharedFrameworkTest SharedFramework) # with custom extension - add_library(FrameworkExt SHARED main.c) - set_target_properties(FrameworkExt PROPERTIES FRAMEWORK TRUE) - set_target_properties(FrameworkExt PROPERTIES BUNDLE_EXTENSION "foo") - install(TARGETS FrameworkExt FRAMEWORK DESTINATION FooExtension) + add_library(SharedFrameworkExt SHARED main.c) + set_target_properties(SharedFrameworkExt PROPERTIES FRAMEWORK TRUE) + set_target_properties(SharedFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo") + install(TARGETS SharedFrameworkExt FRAMEWORK DESTINATION FooExtension) - add_custom_target(FrameworkExtTest ALL + add_custom_target(SharedFrameworkExtTest ALL COMMAND ${CMAKE_COMMAND} -E copy - "$<TARGET_FILE:FrameworkExt>" "$<TARGET_FILE:FrameworkExt>.old") + "$<TARGET_FILE:SharedFrameworkExt>" "$<TARGET_FILE:SharedFrameworkExt>.old") - add_dependencies(FrameworkExtTest FrameworkExt) + add_dependencies(SharedFrameworkExtTest SharedFrameworkExt) +endif() + +# Static Framework (not supported for Xcode < 6) + +if(NOT XCODE_VERSION VERSION_LESS 6) + add_library(StaticFramework STATIC main.c) + set_target_properties(StaticFramework PROPERTIES FRAMEWORK TRUE) + + add_custom_target(StaticFrameworkTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:StaticFramework>" "$<TARGET_FILE:StaticFramework>.old") + + add_dependencies(StaticFrameworkTest StaticFramework) + + # with custom extension + + add_library(StaticFrameworkExt STATIC main.c) + set_target_properties(StaticFrameworkExt PROPERTIES FRAMEWORK TRUE) + set_target_properties(StaticFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo") + install(TARGETS StaticFrameworkExt FRAMEWORK DESTINATION StaticFooExtension) + + add_custom_target(StaticFrameworkExtTest ALL + COMMAND ${CMAKE_COMMAND} -E copy + "$<TARGET_FILE:StaticFrameworkExt>" "$<TARGET_FILE:StaticFrameworkExt>.old") + + add_dependencies(StaticFrameworkExtTest StaticFrameworkExt) endif() # Bundle diff --git a/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake b/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake new file mode 100644 index 0000000..a1064f4 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.3) +enable_language(CXX) + +set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME ON) + +set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx iphonesimulator") +set(CMAKE_MACOSX_BUNDLE true) + +add_library(library STATIC foo.cpp) + +add_executable(main main.cpp) +target_link_libraries(main library) + +install(TARGETS library ARCHIVE DESTINATION lib) diff --git a/Tests/RunCMake/add_dependencies/ReadOnlyProperty-result.txt b/Tests/RunCMake/add_dependencies/ReadOnlyProperty-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_dependencies/ReadOnlyProperty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_dependencies/ReadOnlyProperty-stderr.txt b/Tests/RunCMake/add_dependencies/ReadOnlyProperty-stderr.txt new file mode 100644 index 0000000..da30b81 --- /dev/null +++ b/Tests/RunCMake/add_dependencies/ReadOnlyProperty-stderr.txt @@ -0,0 +1 @@ +MANUALLY_ADDED_DEPENDENCIES property is read-only diff --git a/Tests/RunCMake/add_dependencies/ReadOnlyProperty.cmake b/Tests/RunCMake/add_dependencies/ReadOnlyProperty.cmake new file mode 100644 index 0000000..f0e4069 --- /dev/null +++ b/Tests/RunCMake/add_dependencies/ReadOnlyProperty.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.7) +project(ReadOnlyProperty C) + +add_library(a a.c) + +set_property(TARGET a PROPERTY MANUALLY_ADDED_DEPENDENCIES DEPENDENCIES foo) diff --git a/Tests/RunCMake/add_dependencies/RetrieveDependencies.cmake b/Tests/RunCMake/add_dependencies/RetrieveDependencies.cmake new file mode 100644 index 0000000..45b3974 --- /dev/null +++ b/Tests/RunCMake/add_dependencies/RetrieveDependencies.cmake @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.7) +project(RetrieveDependencies C) + +add_library(a a.c) + +add_library(b c.c) +target_link_libraries(a b) + +add_library(c c.c) +add_dependencies(a c) + +get_property(DEPS_A TARGET a PROPERTY MANUALLY_ADDED_DEPENDENCIES) + +if(NOT DEPS_A STREQUAL "c") + message(FATAL_ERROR "Expected target c being a dependency of a but got: '${DEPS_A}'") +endif() diff --git a/Tests/RunCMake/add_dependencies/RunCMakeTest.cmake b/Tests/RunCMake/add_dependencies/RunCMakeTest.cmake index 30b7e67..507d43f 100644 --- a/Tests/RunCMake/add_dependencies/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_dependencies/RunCMakeTest.cmake @@ -1,3 +1,5 @@ include(RunCMake) run_cmake(NoTarget) +run_cmake(ReadOnlyProperty) +run_cmake(RetrieveDependencies) diff --git a/Tests/RunCMake/add_dependencies/a.c b/Tests/RunCMake/add_dependencies/a.c new file mode 100644 index 0000000..707c1c3 --- /dev/null +++ b/Tests/RunCMake/add_dependencies/a.c @@ -0,0 +1,3 @@ +void a() +{ +} diff --git a/Tests/RunCMake/add_dependencies/b.c b/Tests/RunCMake/add_dependencies/b.c new file mode 100644 index 0000000..57b2900 --- /dev/null +++ b/Tests/RunCMake/add_dependencies/b.c @@ -0,0 +1,3 @@ +void b() +{ +} diff --git a/Tests/RunCMake/add_dependencies/c.c b/Tests/RunCMake/add_dependencies/c.c new file mode 100644 index 0000000..cbf94ca --- /dev/null +++ b/Tests/RunCMake/add_dependencies/c.c @@ -0,0 +1,3 @@ +void c() +{ +} diff --git a/Tests/RunCMake/ctest_build/CMakeLists.txt.in b/Tests/RunCMake/ctest_build/CMakeLists.txt.in index 82cb7c4..133ae36 100644 --- a/Tests/RunCMake/ctest_build/CMakeLists.txt.in +++ b/Tests/RunCMake/ctest_build/CMakeLists.txt.in @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.1) +@CASE_CMAKELISTS_PREFIX_CODE@ project(CTestBuild@CASE_NAME@ NONE) include(CTest) add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake index 324f25c..1092d2a 100644 --- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake @@ -13,6 +13,11 @@ function(run_BuildFailure) set(CASE_CMAKELISTS_SUFFIX_CODE [[ add_custom_target(BuildFailure ALL COMMAND command-does-not-exist) ]]) + set(CASE_CMAKELISTS_PREFIX_CODE [[ +if(NOT CTEST_USE_LAUNCHERS) + message(FATAL_ERROR "CTEST_USE_LAUNCHERS not set") +endif() +]]) set(CASE_TEST_PREFIX_CODE [[ cmake_policy(SET CMP0061 NEW) ]]) diff --git a/Tests/RunCMake/ctest_build/test.cmake.in b/Tests/RunCMake/ctest_build/test.cmake.in index 768f1c6..6f15ec9 100644 --- a/Tests/RunCMake/ctest_build/test.cmake.in +++ b/Tests/RunCMake/ctest_build/test.cmake.in @@ -9,6 +9,7 @@ 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}") +set(CTEST_USE_LAUNCHERS TRUE) set(ctest_build_args "@CASE_CTEST_BUILD_ARGS@") ctest_start(Experimental) diff --git a/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in b/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in index ba1c77a..ab50fdd 100644 --- a/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in +++ b/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in @@ -30,6 +30,8 @@ failTest(setupFails) # 9 passTest(wontRun) # 10 passTest(cyclicSetup) # 11 passTest(cyclicCleanup) # 12 +passTest(cleanupUnused) # 13 +passTest(setupUnused) # 14 # Define fixture dependencies and ordering set_tests_properties(setupFoo PROPERTIES FIXTURES_SETUP "Foo") @@ -50,6 +52,9 @@ set_tests_properties(two PROPERTIES FIXTURES_REQUIRED "Bar") set_tests_properties(three PROPERTIES FIXTURES_REQUIRED "Meta;Bar") set_tests_properties(wontRun PROPERTIES FIXTURES_REQUIRED "Fails") +set_tests_properties(cleanupUnused PROPERTIES FIXTURES_CLEANUP "Unused") +set_tests_properties(setupUnused PROPERTIES FIXTURES_SETUP "Unused") + @CASE_CMAKELISTS_CYCLIC_CODE@ # These are the cases verified by the main cmake build @@ -62,6 +67,7 @@ set_tests_properties(wontRun PROPERTIES FIXTURES_REQUIRED "Fails") # wontRun 9, 10 # cyclicSetup -NA- (configure fails) # cyclicCleanup -NA- (configure fails) +# unused 14, 13 # # In the case of asking for just setupFoo, since there are # no tests using the Foo fixture, we do NOT expect cleanupFoo diff --git a/Tests/RunCMake/ctest_fixtures/RunCMakeTest.cmake b/Tests/RunCMake/ctest_fixtures/RunCMakeTest.cmake index f13289a..673cf57 100644 --- a/Tests/RunCMake/ctest_fixtures/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_fixtures/RunCMakeTest.cmake @@ -17,6 +17,7 @@ run_ctest_test(two INCLUDE two) run_ctest_test(three INCLUDE three) run_ctest_test(setupFoo INCLUDE setupFoo) run_ctest_test(wontRun INCLUDE wontRun) +run_ctest_test(unused INCLUDE Unused) #------------------------------------------------------------ # CMake configure will fail due to cyclic test dependencies diff --git a/Tests/RunCMake/ctest_fixtures/unused-stdout.txt b/Tests/RunCMake/ctest_fixtures/unused-stdout.txt new file mode 100644 index 0000000..b04a621 --- /dev/null +++ b/Tests/RunCMake/ctest_fixtures/unused-stdout.txt @@ -0,0 +1,9 @@ +Test project .*/Tests/RunCMake/ctest_fixtures/unused-build + Start 14: setupUnused +1/2 Test #14: setupUnused +\.+ +Passed +[0-9.]+ sec + Start 13: cleanupUnused +2/2 Test #13: cleanupUnused +\.+ +Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 2 ++ +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_DELAY-result.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt index b57e2de..b57e2de 100644 --- a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_DELAY-result.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt new file mode 100644 index 0000000..327bd5c --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt @@ -0,0 +1 @@ +Cannot find memory tester output file: .*/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\* diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt new file mode 100644 index 0000000..97a8a9b --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt @@ -0,0 +1,3 @@ +Memory checking results: +Direct leak - 2 +Indirect leak - 1 diff --git a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_COUNT-result.txt b/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-result.txt index b57e2de..b57e2de 100644 --- a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_COUNT-result.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-result.txt diff --git a/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-stderr.txt b/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-stderr.txt new file mode 100644 index 0000000..d4b71ae --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-stderr.txt @@ -0,0 +1 @@ +Defect count: 3 diff --git a/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-stdout.txt new file mode 100644 index 0000000..97a8a9b --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-stdout.txt @@ -0,0 +1,3 @@ +Memory checking results: +Direct leak - 2 +Indirect leak - 1 diff --git a/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt index 5a5675c..88b4788 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt @@ -3,5 +3,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-result.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stderr.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stderr.txt new file mode 100644 index 0000000..ad28645 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stderr.txt @@ -0,0 +1 @@ +Defect count: 0 diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stdout.txt new file mode 100644 index 0000000..69ab584 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stdout.txt @@ -0,0 +1,8 @@ +1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec + +100% tests passed, 0 tests failed out of 1 +.* +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log +Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake index 5ad6511..ab4c5ab 100644 --- a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake @@ -12,12 +12,14 @@ endfunction() unset(CTEST_EXTRA_CONFIG) unset(CTEST_EXTRA_CODE) +unset(CTEST_SUFFIX_CODE) +unset(CTEST_MEMCHECK_ARGS) unset(CMAKELISTS_EXTRA_CODE) #----------------------------------------------------------------------------- # add ThreadSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -28,22 +30,22 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- -# add LeakSanitizer test +# add standalone LeakSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\" -P \"${RunCMake_SOURCE_DIR}/testLeakSanitizer.cmake\") ") -run_mc_test(DummyLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer) +run_mc_test(DummyLeakSanitizer "" -DMEMCHECK_TYPE=LeakSanitizer) unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- # add AddressSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -54,9 +56,22 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- +# add AddressSanitizer/LeakSanitizer test +set(CTEST_EXTRA_CODE +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") +") +set(CMAKELISTS_EXTRA_CODE +"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\" +-P \"${RunCMake_SOURCE_DIR}/testAddressLeakSanitizer.cmake\") +") +run_mc_test(DummyAddressLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer) +unset(CMAKELISTS_EXTRA_CODE) +unset(CTEST_EXTRA_CODE) + +#----------------------------------------------------------------------------- # add MemorySanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -132,4 +147,31 @@ run_mc_test(DummyValgrindNoLogFile "${PSEUDO_VALGRIND_NOLOG}") run_mc_test(DummyBCNoLogFile "${PSEUDO_BC_NOLOG}") run_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe") run_mc_test(Unknown "\${CMAKE_COMMAND}") -run_mc_test(DummyQuiet "${PSEUDO_VALGRIND}" -DMEMCHECK_ARGS=QUIET) + +#---------------------------------------------------------------------------- +set(CTEST_MEMCHECK_ARGS QUIET) +run_mc_test(DummyQuiet "${PSEUDO_VALGRIND}") +unset(CTEST_MEMCHECK_ARGS) + +#----------------------------------------------------------------------------- +set(CTEST_SUFFIX_CODE "message(\"Defect count: \${defect_count}\")") +set(CTEST_MEMCHECK_ARGS "DEFECT_COUNT defect_count") +run_mc_test(DummyValgrindNoDefects "${PSEUDO_VALGRIND}") +unset(CTEST_MEMCHECK_ARGS) +unset(CTEST_SUFFIX_CODE) + +#----------------------------------------------------------------------------- +set(CTEST_SUFFIX_CODE "message(\"Defect count: \${defect_count}\")") +set(CTEST_MEMCHECK_ARGS "DEFECT_COUNT defect_count") +set(CTEST_EXTRA_CODE +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") +") +set(CMAKELISTS_EXTRA_CODE +"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\" +-P \"${RunCMake_SOURCE_DIR}/testLeakSanitizer.cmake\") +") +run_mc_test(DummyLeakSanitizerPrintDefects "" -DMEMCHECK_TYPE=LeakSanitizer) +unset(CMAKELISTS_EXTRA_CODE) +unset(CTEST_EXTRA_CODE) +unset(CTEST_MEMCHECK_ARGS) +unset(CTEST_SUFFIX_CODE) diff --git a/Tests/RunCMake/ctest_memcheck/test.cmake.in b/Tests/RunCMake/ctest_memcheck/test.cmake.in index 8431fa6..50b4b6a 100644 --- a/Tests/RunCMake/ctest_memcheck/test.cmake.in +++ b/Tests/RunCMake/ctest_memcheck/test.cmake.in @@ -21,4 +21,6 @@ set(CTEST_MEMORYCHECK_TYPE "${MEMCHECK_TYPE}") CTEST_START(Experimental) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res ${MEMCHECK_ARGS}) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res @CTEST_MEMCHECK_ARGS@) + +@CTEST_SUFFIX_CODE@ diff --git a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake new file mode 100644 index 0000000..ca36a7c --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake @@ -0,0 +1,47 @@ +# this file simulates a program that has been built with AddressSanitizer +# options + +message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +message("LOG_FILE=[${LOG_FILE}]") + +# if we are not asked to simulate AddressSanitizer don't do it +if(NOT "$ENV{ASAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + return() +endif() + +# clear the log files +file(REMOVE "${LOG_FILE}.2343") +file(REMOVE "${LOG_FILE}.2344") + +# create an error of each type of LeakSanitizer + +file(APPEND "${LOG_FILE}.2343" +"================================================================= +==25308==ERROR: LeakSanitizer: detected memory leaks + +Direct leak of 4360 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4823b4 in main /home/kitware/msan/memcheck.cxx:12 + #2 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +") +file(APPEND "${LOG_FILE}.2342" +"================================================================= +==25308==ERROR: LeakSanitizer: detected memory leaks + +Direct leak of 76 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4 + #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 + #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +Indirect leak of 76 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4 + #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 + #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +") diff --git a/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake index 3082e4b..1219666 100644 --- a/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake @@ -2,7 +2,7 @@ # options message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate address sanitizer don't do it diff --git a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake index 02030be..6d51f83 100644 --- a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake @@ -1,20 +1,20 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with LeakSanitizer # options -message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +message("LSAN_OPTIONS = [$ENV{LSAN_OPTIONS}]") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") -# if we are not asked to simulate leak sanitizer don't do it -if(NOT "$ENV{ASAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + +# if we are not asked to simulate LeakSanitizer don't do it +if(NOT "$ENV{LSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") return() endif() -# clear the log file +# clear the log files file(REMOVE "${LOG_FILE}.2343") file(REMOVE "${LOG_FILE}.2344") -# create an error of each type of thread santizer -# these names come from tsan_report.cc in llvm +# create an error of each type of LeakSanitizer file(APPEND "${LOG_FILE}.2343" "================================================================= @@ -25,7 +25,7 @@ Direct leak of 4360 byte(s) in 1 object(s) allocated from: #1 0x4823b4 in main /home/kitware/msan/memcheck.cxx:12 #2 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 -SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s). ") file(APPEND "${LOG_FILE}.2342" "================================================================= @@ -43,5 +43,5 @@ Indirect leak of 76 byte(s) in 1 object(s) allocated from: #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 -SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s). ") diff --git a/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake index c87af9a..3b3ac22 100644 --- a/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with MemorySanitizer # options message("MSAN_OPTIONS = [$ENV{MSAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{MSAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{MSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate address sanitizer don't do it diff --git a/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake index d591931..e7a5c9f 100644 --- a/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with ThreadSanitizer # options message("TSAN_OPTIONS = [$ENV{TSAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") set(error_types diff --git a/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake index 8ef3c0a..ba6122d 100644 --- a/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with undefined behavior -# sanitizer options +# this file simulates a program that has been built with +# UndefinedBehaviorSanitizer options message("UBSAN_OPTIONS = [$ENV{UBSAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{UBSAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{UBSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate address sanitizer don't do it diff --git a/Tests/RunCMake/ctest_submit/CDashUploadMissingFile-result.txt b/Tests/RunCMake/ctest_submit/CDashUploadMissingFile-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_submit/CDashUploadMissingFile-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_submit/CDashUploadMissingFile-stderr.txt b/Tests/RunCMake/ctest_submit/CDashUploadMissingFile-stderr.txt new file mode 100644 index 0000000..364ecde --- /dev/null +++ b/Tests/RunCMake/ctest_submit/CDashUploadMissingFile-stderr.txt @@ -0,0 +1 @@ +Upload file not found: 'bad-upload' diff --git a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_COUNT-stderr.txt b/Tests/RunCMake/ctest_submit/CDashUploadRETRY_COUNT-stderr.txt deleted file mode 100644 index 21621d4..0000000 --- a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_COUNT-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -CMake Error at .*/Tests/RunCMake/ctest_submit/CDashUploadRETRY_COUNT/test.cmake:[0-9]+ \(ctest_submit\): - ctest_submit called with unknown argument "RETRY_COUNT". diff --git a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_DELAY-stderr.txt b/Tests/RunCMake/ctest_submit/CDashUploadRETRY_DELAY-stderr.txt deleted file mode 100644 index f726674..0000000 --- a/Tests/RunCMake/ctest_submit/CDashUploadRETRY_DELAY-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -CMake Error at .*/Tests/RunCMake/ctest_submit/CDashUploadRETRY_DELAY/test.cmake:[0-9]+ \(ctest_submit\): - ctest_submit called with unknown argument "RETRY_DELAY". diff --git a/Tests/RunCMake/ctest_submit/CDashUploadRetry-result.txt b/Tests/RunCMake/ctest_submit/CDashUploadRetry-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_submit/CDashUploadRetry-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_submit/CDashUploadRetry-stderr.txt b/Tests/RunCMake/ctest_submit/CDashUploadRetry-stderr.txt new file mode 100644 index 0000000..6780c17 --- /dev/null +++ b/Tests/RunCMake/ctest_submit/CDashUploadRetry-stderr.txt @@ -0,0 +1 @@ +error uploading to CDash. diff --git a/Tests/RunCMake/ctest_submit/CDashUploadRetry-stdout.txt b/Tests/RunCMake/ctest_submit/CDashUploadRetry-stdout.txt new file mode 100644 index 0000000..a5459ac --- /dev/null +++ b/Tests/RunCMake/ctest_submit/CDashUploadRetry-stdout.txt @@ -0,0 +1,4 @@ + Upload failed, waiting 1 seconds... + Retry upload: Attempt 1 of 2 + Upload failed, waiting 1 seconds... + Retry upload: Attempt 2 of 2 diff --git a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake index a81bc96..e104f8a 100644 --- a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake @@ -21,9 +21,9 @@ run_ctest_submit(PARTSCDashUpload PARTS Configure CDASH_UPLOAD) run_ctest_submit(PARTSCDashUploadType PARTS Configure CDASH_UPLOAD_TYPE) run_ctest_submit(CDashUploadPARTS CDASH_UPLOAD bad-upload PARTS) run_ctest_submit(CDashUploadFILES CDASH_UPLOAD bad-upload FILES) -run_ctest_submit(CDashUploadRETRY_COUNT CDASH_UPLOAD bad-upload RETRY_COUNT) -run_ctest_submit(CDashUploadRETRY_DELAY CDASH_UPLOAD bad-upload RETRY_DELAY) run_ctest_submit(CDashUploadNone CDASH_UPLOAD) +run_ctest_submit(CDashUploadMissingFile CDASH_UPLOAD bad-upload) +run_ctest_submit(CDashUploadRetry CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo RETRY_COUNT 2 RETRY_DELAY 1 INTERNAL_TEST_CHECKSUM) run_ctest_submit(CDashSubmitQuiet QUIET) function(run_ctest_CDashUploadFTP) diff --git a/Tests/RunCMake/execute_process/CMakeLists.txt b/Tests/RunCMake/execute_process/CMakeLists.txt new file mode 100644 index 0000000..a640c56 --- /dev/null +++ b/Tests/RunCMake/execute_process/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.7) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/execute_process/Encoding.cmake b/Tests/RunCMake/execute_process/Encoding.cmake new file mode 100644 index 0000000..3dc7c39 --- /dev/null +++ b/Tests/RunCMake/execute_process/Encoding.cmake @@ -0,0 +1,6 @@ +execute_process( + COMMAND ${TEST_ENCODING_EXE} ${TEST_ENCODING} ${CMAKE_CURRENT_LIST_DIR}/EncodingUTF8-stderr.txt + OUTPUT_VARIABLE out + ENCODING ${TEST_ENCODING} + ) +message("${out}") diff --git a/Tests/RunCMake/execute_process/EncodingMissing-result.txt b/Tests/RunCMake/execute_process/EncodingMissing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/execute_process/EncodingMissing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/execute_process/EncodingMissing-stderr.txt b/Tests/RunCMake/execute_process/EncodingMissing-stderr.txt new file mode 100644 index 0000000..1a69579 --- /dev/null +++ b/Tests/RunCMake/execute_process/EncodingMissing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at EncodingMissing.cmake:[0-9]+ \(execute_process\): + execute_process called with no value for ENCODING. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/execute_process/EncodingMissing.cmake b/Tests/RunCMake/execute_process/EncodingMissing.cmake new file mode 100644 index 0000000..ae97480 --- /dev/null +++ b/Tests/RunCMake/execute_process/EncodingMissing.cmake @@ -0,0 +1 @@ +execute_process(ENCODING) diff --git a/Tests/RunCMake/execute_process/EncodingUTF8-stderr.txt b/Tests/RunCMake/execute_process/EncodingUTF8-stderr.txt new file mode 100644 index 0000000..0ac68de --- /dev/null +++ b/Tests/RunCMake/execute_process/EncodingUTF8-stderr.txt @@ -0,0 +1 @@ +यूनिकोड είναι very здорово! diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index 2080437..62e18c6 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -6,3 +6,8 @@ unset(RunCMake_TEST_OUTPUT_MERGE) run_cmake_command(MergeOutputFile ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/MergeOutputFile.cmake) run_cmake_command(MergeOutputVars ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/MergeOutputVars.cmake) + +run_cmake(EncodingMissing) +if(TEST_ENCODING_EXE) + run_cmake_command(EncodingUTF8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake) +endif() diff --git a/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES.cmake b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES.cmake new file mode 100644 index 0000000..37a9d54 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST LIST_DIRECTORIES false) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 48fa757..7497544 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -31,6 +31,7 @@ run_cmake(GLOB_RECURSE) run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean) # test is valid both for GLOB and GLOB_RECURSE run_cmake(GLOB-error-LIST_DIRECTORIES-no-arg) +run_cmake(GLOB-noexp-LIST_DIRECTORIES) if(NOT WIN32 OR CYGWIN) run_cmake(GLOB_RECURSE-cyclic-recursion) diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt new file mode 100644 index 0000000..454c655 --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value-stderr.txt @@ -0,0 +1,44 @@ +^CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + -flag + + may not start with '-'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + item1;item2 + + may not contain ';'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + /path/to/item1 + + may not contain '/'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + \\path\\to\\item1 + + may not contain '\\'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + c:\\path\\to\\item1 + + may not contain ':'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake new file mode 100644 index 0000000..1af65b4 --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-bad-value.cmake @@ -0,0 +1,6 @@ +add_library(MyTarget INTERFACE IMPORTED) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME -flag) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME item1 item2) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME /path/to/item1) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME \\path\\to\\item1) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME c:\\path\\to\\item1) diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt new file mode 100644 index 0000000..3a329d2 --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface-stderr.txt @@ -0,0 +1,45 @@ +^CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may be set only on imported INTERFACE + library targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake new file mode 100644 index 0000000..fe6841a --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-iface.cmake @@ -0,0 +1,17 @@ +add_custom_target(MyCustom) +set_property(TARGET MyCustom PROPERTY IMPORTED_LIBNAME item1) +set_property(TARGET MyCustom APPEND PROPERTY IMPORTED_LIBNAME item2) +set_property(TARGET MyCustom PROPERTY IMPORTED_LIBNAME_DEBUG item1) +set_property(TARGET MyCustom APPEND PROPERTY IMPORTED_LIBNAME_DEBUG item2) + +add_library(MyStatic STATIC IMPORTED) +set_property(TARGET MyStatic PROPERTY IMPORTED_LIBNAME item1) + +add_library(MyShared SHARED IMPORTED) +set_property(TARGET MyShared PROPERTY IMPORTED_LIBNAME item1) + +add_library(MyModule MODULE IMPORTED) +set_property(TARGET MyModule PROPERTY IMPORTED_LIBNAME item1) + +add_executable(MyExe IMPORTED) +set_property(TARGET MyExe PROPERTY IMPORTED_LIBNAME item1) diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt new file mode 100644 index 0000000..e9d94cf --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported-stderr.txt @@ -0,0 +1,21 @@ +^CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may be set only on imported INTERFACE + library targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake new file mode 100644 index 0000000..07a67d7 --- /dev/null +++ b/Tests/RunCMake/interface_library/IMPORTED_LIBNAME-non-imported.cmake @@ -0,0 +1,5 @@ +add_library(MyTarget INTERFACE) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME item1) +set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LIBNAME item2) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME_DEBUG item1) +set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LIBNAME_DEBUG item2) diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index 201daa7..5a6af1d 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -8,3 +8,6 @@ run_cmake(invalid_signature) run_cmake(global-interface) run_cmake(genex_link) run_cmake(add_custom_command-TARGET) +run_cmake(IMPORTED_LIBNAME-bad-value) +run_cmake(IMPORTED_LIBNAME-non-iface) +run_cmake(IMPORTED_LIBNAME-non-imported) diff --git a/Tests/RunCMake/pseudo_cpplint.c b/Tests/RunCMake/pseudo_cpplint.c new file mode 100644 index 0000000..8b9ebf4 --- /dev/null +++ b/Tests/RunCMake/pseudo_cpplint.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> + +int main(int argc, char* argv[]) +{ + int error = 0; + int i; + for (i = 1; i < argc; ++i) { + if (strcmp(argv[i], "--error") == 0) { + error = 1; + } + if (argv[i][0] != '-') { + if (error) { + fprintf(stderr, "%s:0: message [category/category] [0]\n", argv[i]); + } + fprintf(stdout, "Done processing %s\nTotal errors found: %i\n", argv[i], + error); + } + } + return error; +} diff --git a/Tests/RunCMake/pseudo_emulator_custom_command.c b/Tests/RunCMake/pseudo_emulator_custom_command.c index 760e83c..3a94795 100644 --- a/Tests/RunCMake/pseudo_emulator_custom_command.c +++ b/Tests/RunCMake/pseudo_emulator_custom_command.c @@ -14,7 +14,8 @@ int main(int argc, const char* argv[]) { const char* substring_failure = "generated_exe_emulator_unexpected"; - const char* substring_success = "generated_exe_emulator_expected"; + // Require a slash to make sure it is a path and not a target name. + const char* substring_success = "/generated_exe_emulator_expected"; const char* str = argv[1]; if (argc < 2) { return EXIT_FAILURE; diff --git a/Tests/RunCMake/pseudo_iwyu.c b/Tests/RunCMake/pseudo_iwyu.c index 1e25de7..c761741 100644 --- a/Tests/RunCMake/pseudo_iwyu.c +++ b/Tests/RunCMake/pseudo_iwyu.c @@ -3,5 +3,6 @@ int main(void) { fprintf(stderr, "should add these lines:\n#include <...>\n"); - return 0; + /* include-what-you-use always returns failure */ + return 1; } diff --git a/Tests/RunCMake/pseudo_tidy.c b/Tests/RunCMake/pseudo_tidy.c index c950d03..2feeb0f 100644 --- a/Tests/RunCMake/pseudo_tidy.c +++ b/Tests/RunCMake/pseudo_tidy.c @@ -1,9 +1,15 @@ #include <stdio.h> +#include <string.h> int main(int argc, char* argv[]) { int i; for (i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-bad") == 0) { + fprintf(stdout, "stdout from bad command line arg '-bad'\n"); + fprintf(stderr, "stderr from bad command line arg '-bad'\n"); + return 1; + } if (argv[i][0] != '-') { fprintf(stdout, "%s:0:0: warning: message [checker]\n", argv[i]); break; diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 37c7124..1ddacee 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -6,4 +6,5 @@ run_cmake(COMPILE_OPTIONS) run_cmake(INCLUDE_DIRECTORIES) run_cmake(LINK_LIBRARIES) run_cmake(SOURCES) +run_cmake(TYPE) run_cmake(USER_PROP) diff --git a/Tests/RunCMake/set_property/TYPE-result.txt b/Tests/RunCMake/set_property/TYPE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/set_property/TYPE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/set_property/TYPE-stderr.txt b/Tests/RunCMake/set_property/TYPE-stderr.txt new file mode 100644 index 0000000..fbc8653 --- /dev/null +++ b/Tests/RunCMake/set_property/TYPE-stderr.txt @@ -0,0 +1 @@ +TYPE property is read-only diff --git a/Tests/RunCMake/set_property/TYPE.cmake b/Tests/RunCMake/set_property/TYPE.cmake new file mode 100644 index 0000000..8481266 --- /dev/null +++ b/Tests/RunCMake/set_property/TYPE.cmake @@ -0,0 +1,2 @@ +add_custom_target(CustomTarget) +set_property(TARGET CustomTarget PROPERTY TYPE foo) diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index 8067d9d..38a77b0 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -6,6 +6,11 @@ run_cmake(AppendNoArgs) run_cmake(Concat) run_cmake(ConcatNoArgs) +run_cmake(Timestamp) +run_cmake(TimestampEmpty) +run_cmake(TimestampInvalid) +run_cmake(TimestampInvalid2) + run_cmake(Uuid) run_cmake(UuidMissingNamespace) run_cmake(UuidMissingNamespaceValue) diff --git a/Tests/RunCMake/string/Timestamp-result.txt b/Tests/RunCMake/string/Timestamp-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/string/Timestamp-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt new file mode 100644 index 0000000..653974c --- /dev/null +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -0,0 +1 @@ +RESULT=2005-08-07 23:19:49 Sun Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789 diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake new file mode 100644 index 0000000..d242039 --- /dev/null +++ b/Tests/RunCMake/string/Timestamp.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "1123456789") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %a %b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC) +message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/string/TimestampEmpty-result.txt b/Tests/RunCMake/string/TimestampEmpty-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/string/TimestampEmpty-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/string/TimestampEmpty-stderr.txt b/Tests/RunCMake/string/TimestampEmpty-stderr.txt new file mode 100644 index 0000000..35cbd3c --- /dev/null +++ b/Tests/RunCMake/string/TimestampEmpty-stderr.txt @@ -0,0 +1 @@ +RESULT=2 diff --git a/Tests/RunCMake/string/TimestampEmpty.cmake b/Tests/RunCMake/string/TimestampEmpty.cmake new file mode 100644 index 0000000..21b770f --- /dev/null +++ b/Tests/RunCMake/string/TimestampEmpty.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC) +message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/string/TimestampInvalid-result.txt b/Tests/RunCMake/string/TimestampInvalid-result.txt new file mode 100644 index 0000000..f64f5d8 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid-result.txt @@ -0,0 +1 @@ +27 diff --git a/Tests/RunCMake/string/TimestampInvalid-stderr.txt b/Tests/RunCMake/string/TimestampInvalid-stderr.txt new file mode 100644 index 0000000..75566da --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid-stderr.txt @@ -0,0 +1 @@ +CMake Error: Cannot parse SOURCE_DATE_EPOCH as integer diff --git a/Tests/RunCMake/string/TimestampInvalid.cmake b/Tests/RunCMake/string/TimestampInvalid.cmake new file mode 100644 index 0000000..ab36270 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "invalid-integer") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC) +message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/string/TimestampInvalid2-result.txt b/Tests/RunCMake/string/TimestampInvalid2-result.txt new file mode 100644 index 0000000..f64f5d8 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid2-result.txt @@ -0,0 +1 @@ +27 diff --git a/Tests/RunCMake/string/TimestampInvalid2-stderr.txt b/Tests/RunCMake/string/TimestampInvalid2-stderr.txt new file mode 100644 index 0000000..75566da --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid2-stderr.txt @@ -0,0 +1 @@ +CMake Error: Cannot parse SOURCE_DATE_EPOCH as integer diff --git a/Tests/RunCMake/string/TimestampInvalid2.cmake b/Tests/RunCMake/string/TimestampInvalid2.cmake new file mode 100644 index 0000000..5cc61b8 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid2.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "123trailing-garbage") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC) +message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/try_compile/CMP0067-stderr.txt b/Tests/RunCMake/try_compile/CMP0067-stderr.txt new file mode 100644 index 0000000..e2677ed --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0067-stderr.txt @@ -0,0 +1,25 @@ +before try_compile with CMP0067 WARN-enabled but no variables +after try_compile with CMP0067 WARN-enabled but no variables +before try_compile with CMP0067 WARN-default +after try_compile with CMP0067 WARN-default +before try_compile with CMP0067 WARN-enabled +CMake Warning \(dev\) at CMP0067.cmake:[0-9]+ \(try_compile\): + Policy CMP0067 is not set: Honor language standard in try_compile\(\) + source-file signature. Run "cmake --help-policy CMP0067" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + For compatibility with older versions of CMake, try_compile is not honoring + language standard variables in the test project: + + CMAKE_C_STANDARD + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +after try_compile with CMP0067 WARN-enabled +before try_compile with CMP0067 OLD +after try_compile with CMP0067 OLD +before try_compile with CMP0067 NEW +after try_compile with CMP0067 NEW diff --git a/Tests/RunCMake/try_compile/CMP0067.cmake b/Tests/RunCMake/try_compile/CMP0067.cmake new file mode 100644 index 0000000..dd05d96 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0067.cmake @@ -0,0 +1,40 @@ +enable_language(C) + +set(CMAKE_POLICY_WARNING_CMP0067 ON) +message("before try_compile with CMP0067 WARN-enabled but no variables") +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + ) +message("after try_compile with CMP0067 WARN-enabled but no variables") +set(CMAKE_POLICY_WARNING_CMP0067 OFF) + +#----------------------------------------------------------------------------- + +set(CMAKE_C_STANDARD 90) + +message("before try_compile with CMP0067 WARN-default") +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + ) +message("after try_compile with CMP0067 WARN-default") + +set(CMAKE_POLICY_WARNING_CMP0067 ON) +message("before try_compile with CMP0067 WARN-enabled") +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + ) +message("after try_compile with CMP0067 WARN-enabled") + +cmake_policy(SET CMP0067 OLD) +message("before try_compile with CMP0067 OLD") +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + ) +message("after try_compile with CMP0067 OLD") + +cmake_policy(SET CMP0066 NEW) +message("before try_compile with CMP0067 NEW") +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c + ) +message("after try_compile with CMP0067 NEW") diff --git a/Tests/RunCMake/try_compile/CStandard-result.txt b/Tests/RunCMake/try_compile/CStandard-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/CStandard-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/CStandard-stderr.txt b/Tests/RunCMake/try_compile/CStandard-stderr.txt new file mode 100644 index 0000000..209afcc --- /dev/null +++ b/Tests/RunCMake/try_compile/CStandard-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Tests/RunCMake/try_compile/CStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\): + C_STANDARD is set to invalid value '3' ++ +CMake Error at CStandard.cmake:[0-9]+ \(try_compile\): + Failed to generate test project build system. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/CStandard.cmake b/Tests/RunCMake/try_compile/CStandard.cmake new file mode 100644 index 0000000..2849ed4 --- /dev/null +++ b/Tests/RunCMake/try_compile/CStandard.cmake @@ -0,0 +1,7 @@ +enable_language(C) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c + C_STANDARD 3 + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/CStandardGNU.c b/Tests/RunCMake/try_compile/CStandardGNU.c new file mode 100644 index 0000000..ac26c15 --- /dev/null +++ b/Tests/RunCMake/try_compile/CStandardGNU.c @@ -0,0 +1,10 @@ +#if __STDC_VERSION__ != 199901L +#error "Not GNU C 99 mode!" +#endif +#ifndef __STRICT_ANSI__ +#error "Not GNU C strict ANSI!" +#endif +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/try_compile/CStandardGNU.cmake b/Tests/RunCMake/try_compile/CStandardGNU.cmake new file mode 100644 index 0000000..79ae874 --- /dev/null +++ b/Tests/RunCMake/try_compile/CStandardGNU.cmake @@ -0,0 +1,23 @@ +enable_language(C) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CStandardGNU.c + C_STANDARD 99 + C_STANDARD_REQUIRED 1 + C_EXTENSIONS 0 + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() + +cmake_policy(SET CMP0067 NEW) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED 1) +set(CMAKE_C_EXTENSIONS 0) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CStandardGNU.c + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() diff --git a/Tests/RunCMake/try_compile/CStandardNoDefault.cmake b/Tests/RunCMake/try_compile/CStandardNoDefault.cmake new file mode 100644 index 0000000..97e72ea --- /dev/null +++ b/Tests/RunCMake/try_compile/CStandardNoDefault.cmake @@ -0,0 +1,9 @@ +enable_language(C) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c + C_STANDARD 3 # bogus, but not used + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() diff --git a/Tests/RunCMake/try_compile/CudaStandard-result.txt b/Tests/RunCMake/try_compile/CudaStandard-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/CudaStandard-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/CudaStandard-stderr.txt b/Tests/RunCMake/try_compile/CudaStandard-stderr.txt new file mode 100644 index 0000000..3c6bdf6 --- /dev/null +++ b/Tests/RunCMake/try_compile/CudaStandard-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Tests/RunCMake/try_compile/CudaStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\): + CUDA_STANDARD is set to invalid value '3' ++ +CMake Error at CudaStandard.cmake:[0-9]+ \(try_compile\): + Failed to generate test project build system. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/CudaStandard.cmake b/Tests/RunCMake/try_compile/CudaStandard.cmake new file mode 100644 index 0000000..96da422 --- /dev/null +++ b/Tests/RunCMake/try_compile/CudaStandard.cmake @@ -0,0 +1,7 @@ +enable_language(CUDA) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.cu + CUDA_STANDARD 3 + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/CudaStandardNoDefault.cmake b/Tests/RunCMake/try_compile/CudaStandardNoDefault.cmake new file mode 100644 index 0000000..ea22152 --- /dev/null +++ b/Tests/RunCMake/try_compile/CudaStandardNoDefault.cmake @@ -0,0 +1,9 @@ +enable_language(CUDA) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.cu + CUDA_STANDARD 3 # bogus, but not used + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() diff --git a/Tests/RunCMake/try_compile/CxxStandard-result.txt b/Tests/RunCMake/try_compile/CxxStandard-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/CxxStandard-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/CxxStandard-stderr.txt b/Tests/RunCMake/try_compile/CxxStandard-stderr.txt new file mode 100644 index 0000000..ec7245f --- /dev/null +++ b/Tests/RunCMake/try_compile/CxxStandard-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Tests/RunCMake/try_compile/CxxStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\): + CXX_STANDARD is set to invalid value '3' ++ +CMake Error at CxxStandard.cmake:[0-9]+ \(try_compile\): + Failed to generate test project build system. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/CxxStandard.cmake b/Tests/RunCMake/try_compile/CxxStandard.cmake new file mode 100644 index 0000000..bcb49b9 --- /dev/null +++ b/Tests/RunCMake/try_compile/CxxStandard.cmake @@ -0,0 +1,7 @@ +enable_language(CXX) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.cxx + CXX_STANDARD 3 + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/CxxStandardGNU.cmake b/Tests/RunCMake/try_compile/CxxStandardGNU.cmake new file mode 100644 index 0000000..e714fe4 --- /dev/null +++ b/Tests/RunCMake/try_compile/CxxStandardGNU.cmake @@ -0,0 +1,23 @@ +enable_language(CXX) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CxxStandardGNU.cxx + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED 1 + CXX_EXTENSIONS 0 + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() + +cmake_policy(SET CMP0067 NEW) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED 1) +set(CMAKE_CXX_EXTENSIONS 0) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CxxStandardGNU.cxx + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() diff --git a/Tests/RunCMake/try_compile/CxxStandardGNU.cxx b/Tests/RunCMake/try_compile/CxxStandardGNU.cxx new file mode 100644 index 0000000..7990a78 --- /dev/null +++ b/Tests/RunCMake/try_compile/CxxStandardGNU.cxx @@ -0,0 +1,11 @@ +#if __cplusplus != 201103L && \ + !(__cplusplus < 201103L && defined(__GXX_EXPERIMENTAL_CXX0X__)) +#error "Not GNU C++ 11 mode!" +#endif +#ifndef __STRICT_ANSI__ +#error "Not GNU C++ strict ANSI!" +#endif +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/try_compile/CxxStandardNoDefault.cmake b/Tests/RunCMake/try_compile/CxxStandardNoDefault.cmake new file mode 100644 index 0000000..35caa9d --- /dev/null +++ b/Tests/RunCMake/try_compile/CxxStandardNoDefault.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.cxx + CXX_STANDARD 3 # bogus, but not used + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 522433a..6a1bc64 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -18,14 +18,40 @@ run_cmake(NonSourceCompileDefinitions) set(RunCMake_TEST_OPTIONS --debug-trycompile) run_cmake(PlatformVariables) +run_cmake(WarnDeprecated) unset(RunCMake_TEST_OPTIONS) run_cmake(TargetTypeExe) run_cmake(TargetTypeInvalid) run_cmake(TargetTypeStatic) +if(CMAKE_C_STANDARD_DEFAULT) + run_cmake(CStandard) +elseif(DEFINED CMAKE_C_STANDARD_DEFAULT) + run_cmake(CStandardNoDefault) +endif() +if(CMAKE_CXX_STANDARD_DEFAULT) + run_cmake(CxxStandard) +elseif(DEFINED CMAKE_CXX_STANDARD_DEFAULT) + run_cmake(CxxStandardNoDefault) +endif() +if(CMake_TEST_CUDA) + if(CMAKE_HOST_WIN32) + run_cmake(CudaStandardNoDefault) + else() + run_cmake(CudaStandard) + endif() +endif() +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + run_cmake(CStandardGNU) +endif() +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + run_cmake(CxxStandardGNU) +endif() + run_cmake(CMP0056) run_cmake(CMP0066) +run_cmake(CMP0067) if(RunCMake_GENERATOR MATCHES "Make|Ninja") # Use a single build tree for a few tests without cleaning. diff --git a/Tests/RunCMake/try_compile/WarnDeprecated.cmake b/Tests/RunCMake/try_compile/WarnDeprecated.cmake new file mode 100644 index 0000000..dfcb5f9 --- /dev/null +++ b/Tests/RunCMake/try_compile/WarnDeprecated.cmake @@ -0,0 +1,19 @@ +enable_language(C) + +set(CMAKE_WARN_DEPRECATED SOME_VALUE) + +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() + +# Check that the cache was populated with our custom variable. +file(STRINGS ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeCache.txt entries + REGEX CMAKE_WARN_DEPRECATED:UNINITIALIZED=${CMAKE_WARN_DEPRECATED} + ) +if(NOT entries) + message(FATAL_ERROR "try_compile did not populate cache as expected") +endif() diff --git a/Tests/RunCMake/try_compile/src.cu b/Tests/RunCMake/try_compile/src.cu new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/try_compile/src.cu @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/try_compile/src.cxx b/Tests/RunCMake/try_compile/src.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/try_compile/src.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/while/EndAlone-stderr.txt b/Tests/RunCMake/while/EndAlone-stderr.txt index cd98687..5fe6655 100644 --- a/Tests/RunCMake/while/EndAlone-stderr.txt +++ b/Tests/RunCMake/while/EndAlone-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at EndAlone.cmake:1 \(endwhile\): endwhile An ENDWHILE command was found outside of a proper WHILE ENDWHILE - structure. + structure. Or its arguments did not match the opening WHILE command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt index 6573c82..9289e84 100644 --- a/Tests/SourceGroups/CMakeLists.txt +++ b/Tests/SourceGroups/CMakeLists.txt @@ -30,6 +30,17 @@ source_group(Base\\Sub1\\Base FILES bar.c) # a group without files, is currently not created source_group(EmptyGroup) +set(root ${CMAKE_CURRENT_SOURCE_DIR}) -add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c README.txt) +set(tree_files_without_prefix ${root}/sub1/tree_bar.c + ${root}/sub1/tree_baz.c + ${root}/sub1/tree_subdir/tree_foobar.c) +set(tree_files_with_prefix ${root}/tree_foo.c) + +source_group(TREE ${root} FILES ${tree_files_without_prefix}) + +source_group(TREE ${root} PREFIX tree_root/subgroup FILES ${tree_files_with_prefix}) + +add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c + ${tree_files_with_prefix} ${tree_files_without_prefix} README.txt) diff --git a/Tests/SourceGroups/main.c b/Tests/SourceGroups/main.c index f259f98..b88f2f8 100644 --- a/Tests/SourceGroups/main.c +++ b/Tests/SourceGroups/main.c @@ -5,10 +5,17 @@ extern int bar(void); extern int foobar(void); extern int barbar(void); extern int baz(void); +extern int tree_foo(void); +extern int tree_bar(void); +extern int tree_foobar(void); +extern int tree_baz(void); int main() { printf("foo: %d bar: %d foobar: %d barbar: %d baz: %d\n", foo(), bar(), foobar(), barbar(), baz()); + + printf("tree_foo: %d tree_bar: %d tree_foobar: %d tree_baz: %d\n", + tree_foo(), tree_bar(), tree_foobar(), tree_baz()); return 0; } diff --git a/Tests/SourceGroups/sub1/tree_bar.c b/Tests/SourceGroups/sub1/tree_bar.c new file mode 100644 index 0000000..6b79239 --- /dev/null +++ b/Tests/SourceGroups/sub1/tree_bar.c @@ -0,0 +1,4 @@ +int tree_bar(void) +{ + return 8; +} diff --git a/Tests/SourceGroups/sub1/tree_baz.c b/Tests/SourceGroups/sub1/tree_baz.c new file mode 100644 index 0000000..27ff5ab --- /dev/null +++ b/Tests/SourceGroups/sub1/tree_baz.c @@ -0,0 +1,4 @@ +int tree_baz(void) +{ + return 9; +} diff --git a/Tests/SourceGroups/sub1/tree_subdir/tree_foobar.c b/Tests/SourceGroups/sub1/tree_subdir/tree_foobar.c new file mode 100644 index 0000000..e955e04 --- /dev/null +++ b/Tests/SourceGroups/sub1/tree_subdir/tree_foobar.c @@ -0,0 +1,4 @@ +int tree_foobar(void) +{ + return 7; +} diff --git a/Tests/SourceGroups/tree_foo.c b/Tests/SourceGroups/tree_foo.c new file mode 100644 index 0000000..d392e41 --- /dev/null +++ b/Tests/SourceGroups/tree_foo.c @@ -0,0 +1,4 @@ +int tree_foo(void) +{ + return 6; +} diff --git a/Tests/SwigTest/CMakeLists.txt b/Tests/SwigTest/CMakeLists.txt index 17a502d..65f5c93 100644 --- a/Tests/SwigTest/CMakeLists.txt +++ b/Tests/SwigTest/CMakeLists.txt @@ -7,6 +7,7 @@ project(example_${language}_class) find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) +unset(SWIG_LANG_TYPE) if(${language} MATCHES python) find_package(PythonLibs) include_directories(${PYTHON_INCLUDE_PATH}) @@ -38,6 +39,12 @@ if(${language} MATCHES pike) include_directories(${PIKE_INCLUDE_PATH}) set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY}) endif() +if(${language} MATCHES lua) + find_package(Lua) + include_directories(${LUA_INCLUDE_DIR}) + set(SWIG_LANG_TYPE TYPE SHARED) + set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES}) +endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -45,6 +52,8 @@ set(CMAKE_SWIG_FLAGS "") set_source_files_properties(example.i PROPERTIES CPLUSPLUS ON) set_source_files_properties(example.i PROPERTIES SWIG_FLAGS "-includeall") -SWIG_ADD_MODULE(example "${language}" - example.i example.cxx) +SWIG_ADD_LIBRARY(example + LANGUAGE "${language}" + ${SWIG_LANG_TYPE} + SOURCES example.i example.cxx) SWIG_LINK_LIBRARIES(example ${SWIG_LANG_LIBRARIES}) |