diff options
Diffstat (limited to 'Tests')
319 files changed, 2814 insertions, 384 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 11978db..3b4ff60 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -42,7 +42,7 @@ list(APPEND _cmake_options "-DTEST_LINK_DEPENDS=${TEST_LINK_DEPENDS}") list(APPEND _cmake_options "-DCMAKE_FORCE_DEPFILES=1") -if(NOT CMAKE_GENERATOR MATCHES "Visual Studio ([^89]|[89][0-9])") +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])") set(TEST_MULTI3 1) list(APPEND _cmake_options "-DTEST_MULTI3=1") endif() diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt index 5096a58..9664025 100644 --- a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt @@ -1,5 +1,4 @@ -cmake_minimum_required(VERSION 3.0) -cmake_policy(SET CMP0057 NEW) +cmake_minimum_required(VERSION 3.3) project(target_compile_features) set(CMAKE_VERBOSE_MAKEFILE ON) @@ -19,7 +18,8 @@ if (c_restrict IN_LIST CMAKE_C_COMPILE_FEATURES) target_link_libraries(c_restrict_user_specific c_lib_restrict_specific) endif() -if (c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES) +if (c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES AND + NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") add_executable(c_target_compile_features_meta main.c) target_compile_features(c_target_compile_features_meta PRIVATE c_std_99 diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 06df53f..126076d 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -49,3 +49,6 @@ if(TEST_CompileCommandOutput) endif() add_subdirectory(PseudoMemcheck) + +add_executable(testAffinity testAffinity.cxx) +target_link_libraries(testAffinity CMakeLib) diff --git a/Tests/CMakeLib/testAffinity.cxx b/Tests/CMakeLib/testAffinity.cxx new file mode 100644 index 0000000..4b82280 --- /dev/null +++ b/Tests/CMakeLib/testAffinity.cxx @@ -0,0 +1,18 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmAffinity.h" + +#include <cstddef> +#include <iostream> +#include <set> + +int main() +{ + std::set<size_t> cpus = cmAffinity::GetProcessorsAvailable(); + if (!cpus.empty()) { + std::cout << "CPU affinity mask count is '" << cpus.size() << "'.\n"; + } else { + std::cout << "CPU affinity not supported on this platform.\n"; + } + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 08bfebe..aad7cfc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -64,7 +64,7 @@ if(BUILD_TESTING) set(CMake_TEST_DEVENV "") if(CMAKE_VS_DEVENV_COMMAND) set(CMake_TEST_DEVENV "${CMAKE_VS_DEVENV_COMMAND}") - elseif(CMAKE_GENERATOR MATCHES "Visual Studio [89] " AND + elseif(CMAKE_GENERATOR MATCHES "Visual Studio 9 " AND NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") endif() @@ -345,9 +345,10 @@ if(BUILD_TESTING) endif() endif() - if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") + if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") ADD_TEST_MACRO(CSharpOnly CSharpOnly) ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) + ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx) endif() ADD_TEST_MACRO(COnly COnly) @@ -816,6 +817,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(CustomCommandByproducts CustomCommandByproducts) + ADD_TEST_MACRO(CommandLength CommandLength) + ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND}) add_test(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND} @@ -1323,6 +1326,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindBZip2) endif() + if(CMake_TEST_FindCURL) + add_subdirectory(FindCURL) + endif() + if(CMake_TEST_FindDoxygen) add_subdirectory(FindDoxygen) endif() @@ -1364,6 +1371,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindLibUV) endif() + if(CMake_TEST_FindLibXml2) + add_subdirectory(FindLibXml2) + endif() + if(CMake_TEST_FindLTTngUST) add_subdirectory(FindLTTngUST) endif() @@ -1416,6 +1427,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindXercesC) endif() + if(CMake_TEST_FindPython) + add_subdirectory(FindPython) + endif() + + if(CMake_TEST_UseSWIG) + add_subdirectory(UseSWIG) + endif() + add_subdirectory(FindThreads) # Matlab module @@ -1423,6 +1442,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) endif() find_package(GTK2 QUIET) @@ -1443,6 +1463,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject") set_tests_properties(ExternalProject PROPERTIES + RUN_SERIAL 1 TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) add_test(NAME ExternalProjectSubdir @@ -1482,6 +1503,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal") set_tests_properties(ExternalProjectLocal PROPERTIES + RUN_SERIAL 1 TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND} @@ -1497,6 +1519,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate") set_tests_properties(ExternalProjectUpdateSetup PROPERTIES + RUN_SERIAL 1 TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) add_test(NAME ExternalProjectUpdate @@ -1511,6 +1534,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate") set_tests_properties(ExternalProjectUpdate PROPERTIES + RUN_SERIAL 1 TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT} WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate DEPENDS ExternalProjectUpdateSetup ) @@ -1910,7 +1934,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() if(MSVC AND NOT MSVC_VERSION LESS 1310 - AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio [89]( |$)" + AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio 9 " OR CMAKE_SIZEOF_VOID_P EQUAL 4) ) ADD_TEST_MACRO(VSMASM VSMASM) @@ -1921,7 +1945,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(SBCS SBCS) endif() - if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [89]( |$)" + if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 " AND NOT CMAKE_GENERATOR_TOOLSET) ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx) endif() @@ -2120,7 +2144,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() endif() - if(CMAKE_GENERATOR MATCHES "Visual Studio ([^89]|[89][0-9])" AND nasm) + if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])" AND nasm) ADD_TEST_MACRO(VSNASM VSNASM) endif() diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index c84fa74..204d54c 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -33,7 +33,7 @@ add_CMakeOnly_test(CompilerIdCXX) if(CMAKE_Fortran_COMPILER) add_CMakeOnly_test(CompilerIdFortran) endif() -if(CMAKE_GENERATOR MATCHES "Visual Studio ([^89]|[89][0-9])") +if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])") add_CMakeOnly_test(CompilerIdCSharp) endif() diff --git a/Tests/CSharpLinkFromCxx/.gitattributes b/Tests/CSharpLinkFromCxx/.gitattributes new file mode 100644 index 0000000..57a39049 --- /dev/null +++ b/Tests/CSharpLinkFromCxx/.gitattributes @@ -0,0 +1 @@ +UsefulManagedCppClass.* -format.clang-format diff --git a/Tests/CSharpLinkFromCxx/CMakeLists.txt b/Tests/CSharpLinkFromCxx/CMakeLists.txt new file mode 100644 index 0000000..9a1a993 --- /dev/null +++ b/Tests/CSharpLinkFromCxx/CMakeLists.txt @@ -0,0 +1,19 @@ +# Take a C# shared library and link it to a managed C++ shared library +cmake_minimum_required(VERSION 3.10) +project (CSharpLinkFromCxx CXX CSharp) + +add_library(CSharpLibrary SHARED UsefulCSharpClass.cs) + +# we have to change the default flags for the +# managed C++ project to build +string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) +string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + +# The C# project is a dependency of the C++/CLI project +add_library(ManagedCppLibrary SHARED UsefulManagedCppClass.cpp UsefulManagedCppClass.hpp) +target_compile_options(ManagedCppLibrary PRIVATE "/clr") +target_link_libraries(ManagedCppLibrary PUBLIC CSharpLibrary) + +# Main executable for the test framework +add_executable(CSharpLinkFromCxx CSharpLinkFromCxx.cs) +target_link_libraries(CSharpLinkFromCxx PRIVATE ManagedCppLibrary) diff --git a/Tests/CSharpLinkFromCxx/CSharpLinkFromCxx.cs b/Tests/CSharpLinkFromCxx/CSharpLinkFromCxx.cs new file mode 100644 index 0000000..31a74eb --- /dev/null +++ b/Tests/CSharpLinkFromCxx/CSharpLinkFromCxx.cs @@ -0,0 +1,16 @@ +using System; +using CSharpLibrary; + +namespace CSharpLinkFromCxx +{ + internal class CSharpLinkFromCxx + { + public static void Main(string[] args) + { + Console.WriteLine("Starting test for CSharpLinkFromCxx"); + + var useful = new UsefulManagedCppClass(); + useful.RunTest(); + } + } +} diff --git a/Tests/CSharpLinkFromCxx/UsefulCSharpClass.cs b/Tests/CSharpLinkFromCxx/UsefulCSharpClass.cs new file mode 100644 index 0000000..749e57d --- /dev/null +++ b/Tests/CSharpLinkFromCxx/UsefulCSharpClass.cs @@ -0,0 +1,12 @@ +using System; + +namespace CSharpLibrary +{ + public class UsefulCSharpClass + { + public string GetSomethingUseful() + { + return "Something Useful"; + } + } +} diff --git a/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.cpp b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.cpp new file mode 100644 index 0000000..9468812 --- /dev/null +++ b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.cpp @@ -0,0 +1,15 @@ +#include "UsefulManagedCppClass.hpp" + +namespace CSharpLibrary +{ + UsefulManagedCppClass::UsefulManagedCppClass() + { + auto useful = gcnew UsefulCSharpClass(); + m_usefulString = useful->GetSomethingUseful(); + } + + void UsefulManagedCppClass::RunTest() + { + Console::WriteLine("Printing from Managed CPP Class: " + m_usefulString); + } +} diff --git a/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.hpp b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.hpp new file mode 100644 index 0000000..def7cea --- /dev/null +++ b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.hpp @@ -0,0 +1,16 @@ +using namespace System; + +namespace CSharpLibrary +{ + public ref class UsefulManagedCppClass + { + public: + + UsefulManagedCppClass(); + void RunTest(); + + private: + + String^ m_usefulString; + }; +} diff --git a/Tests/CTestTest/test.cmake.in b/Tests/CTestTest/test.cmake.in index 589bd44..23166a7 100644 --- a/Tests/CTestTest/test.cmake.in +++ b/Tests/CTestTest/test.cmake.in @@ -62,7 +62,7 @@ COVERAGE_COMMAND:FILEPATH=@COVERAGE_COMMAND@ set (CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@/Tests/CTestTest") -# set any extra environment varibles here +# set any extra environment variables here set (CTEST_ENVIRONMENT ) diff --git a/Tests/CommandLength/CMakeLists.txt b/Tests/CommandLength/CMakeLists.txt new file mode 100644 index 0000000..6836051 --- /dev/null +++ b/Tests/CommandLength/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) +project(CommandLength C) + +add_executable(CommandLength test.c) +add_custom_command(TARGET CommandLength POST_BUILD VERBATIM + COMMAND ${CMAKE_COMMAND} -E make_directory log) + +set(msg "xxxx $$$$ yyyy") +set(msg "${msg} ${msg}") +set(msg "${msg} ${msg}") +set(msg "${msg} ${msg}") +set(msg "${msg} ${msg}") +foreach(i RANGE 1 1000) + add_custom_command(TARGET CommandLength POST_BUILD VERBATIM + COMMAND ${CMAKE_COMMAND} -E echo "${i} ${msg}" > log/${i} + ) +endforeach() diff --git a/Tests/CommandLength/test.c b/Tests/CommandLength/test.c new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/CommandLength/test.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index b560acd..b0bc656 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -224,54 +224,22 @@ if (C_expected_features) add_executable(CompileFeaturesGenex_C genex_test.c) set_property(TARGET CompileFeaturesGenex_C PROPERTY C_STANDARD 11) - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) - list(APPEND expected_defs - EXPECT_C_STATIC_ASSERT=1 - ) - else() - list(APPEND expected_defs - EXPECT_C_STATIC_ASSERT=0 + foreach(f + c_restrict + c_static_assert + c_function_prototypes ) - endif() - elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang" - OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") - list(APPEND expected_defs - EXPECT_C_STATIC_ASSERT=1 - ) - elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel") - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15) - list(APPEND expected_defs - EXPECT_C_STATIC_ASSERT=1 - ) + if(${f} IN_LIST C_expected_features) + set(expect_${f} 1) else() - list(APPEND expected_defs - EXPECT_C_STATIC_ASSERT=0 - ) + set(expect_${f} 0) endif() - elseif (CMAKE_C_COMPILER_ID STREQUAL "SunPro") - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.13) - list(APPEND expected_defs - EXPECT_C_STATIC_ASSERT=1 - ) - else() - list(APPEND expected_defs - EXPECT_C_STATIC_ASSERT=0 - ) - endif() - endif() - - list(APPEND expected_defs - EXPECT_C_FUNCTION_PROTOTYPES=1 - EXPECT_C_RESTRICT=1 - ) - - target_compile_definitions(CompileFeaturesGenex_C PRIVATE - HAVE_C_FUNCTION_PROTOTYPES=$<COMPILE_FEATURES:c_function_prototypes> - HAVE_C_RESTRICT=$<COMPILE_FEATURES:c_restrict> - HAVE_C_STATIC_ASSERT=$<COMPILE_FEATURES:c_static_assert> - ${expected_defs} - ) + string(TOUPPER "${f}" F) + target_compile_definitions(CompileFeaturesGenex_C PRIVATE + EXPECT_${F}=${expect_${f}} + HAVE_${F}=$<COMPILE_FEATURES:${f}> + ) + endforeach() endif() if (CMAKE_CXX_COMPILE_FEATURES) @@ -280,6 +248,7 @@ 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_CXX20=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},20> DEFAULT_CXX17=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},17> DEFAULT_CXX14=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},14> DEFAULT_CXX11=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},11> @@ -318,144 +287,62 @@ else() add_executable(IfaceCompileFeatures main.cpp) target_link_libraries(IfaceCompileFeatures iface) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=1 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 - ) - elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=0 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 - ) - else() - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=0 - -DEXPECT_INHERITING_CONSTRUCTORS=0 - -DEXPECT_FINAL=0 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 - ) - endif() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=1 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 - ) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=1 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 - ) - else() - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=0 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 - ) - endif() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0) - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=1 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 - ) - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0) - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=0 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 - ) - else() - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=0 - -DEXPECT_INHERITING_CONSTRUCTORS=0 - -DEXPECT_FINAL=0 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 - ) - endif() - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=1 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 - ) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=1 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 - ) - elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=1 - -DEXPECT_INHERITING_CONSTRUCTORS=0 - -DEXPECT_FINAL=1 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 + foreach(f + cxx_final + cxx_override + cxx_auto_type + cxx_inheriting_constructors ) + if(${f} IN_LIST CXX_expected_features) + set(expect_${f} 1) else() - add_definitions( - -DEXPECT_OVERRIDE_CONTROL=0 - -DEXPECT_INHERITING_CONSTRUCTORS=0 - -DEXPECT_FINAL=0 - -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 - ) + set(expect_${f} 0) endif() + endforeach() + + if(expect_cxx_final AND expect_cxx_override) + set(expect_override_control 1) + else() + set(expect_override_control 0) + endif() + if(expect_cxx_inheriting_constructors AND expect_cxx_final) + set(expect_inheriting_constructors_and_final 1) + else() + set(expect_inheriting_constructors_and_final 0) endif() - add_executable(CompileFeaturesGenex genex_test.cpp) - set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11) - target_compile_definitions(CompileFeaturesGenex PRIVATE + set(genex_test_defs HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> - ) + EXPECT_OVERRIDE_CONTROL=${expect_override_control} + EXPECT_INHERITING_CONSTRUCTORS=${expect_cxx_inheriting_constructors} + EXPECT_FINAL=${expect_cxx_final} + EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=${expect_inheriting_constructors_and_final} + ) if (CMAKE_CXX_STANDARD_DEFAULT) - target_compile_definitions(CompileFeaturesGenex PRIVATE + list(APPEND genex_test_defs TEST_CXX_STD HAVE_CXX_STD_11=$<COMPILE_FEATURES:cxx_std_11> HAVE_CXX_STD_14=$<COMPILE_FEATURES:cxx_std_14> HAVE_CXX_STD_17=$<COMPILE_FEATURES:cxx_std_17> + HAVE_CXX_STD_20=$<COMPILE_FEATURES:cxx_std_20> ) endif() + add_executable(CompileFeaturesGenex genex_test.cpp) + set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11) + target_compile_definitions(CompileFeaturesGenex PRIVATE ${genex_test_defs}) + add_executable(CompileFeaturesGenex2 genex_test.cpp) 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> - HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> - HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> - HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> - ) + target_compile_definitions(CompileFeaturesGenex2 PRIVATE ${genex_test_defs}) add_library(std_11_iface INTERFACE) target_compile_features(std_11_iface INTERFACE cxx_std_11) add_executable(CompileFeaturesGenex3 genex_test.cpp) target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface) - target_compile_definitions(CompileFeaturesGenex3 PRIVATE - HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> - HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> - HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> - HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> - HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> - ) + target_compile_definitions(CompileFeaturesGenex3 PRIVATE ${genex_test_defs}) endif() diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 0de1125..7ddcfe7 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -8,7 +8,11 @@ struct Outputter; #define CXX_STD __cplusplus #endif -#if DEFAULT_CXX17 +#if DEFAULT_CXX20 +#if CXX_STD <= 201703L +Outputter<CXX_STD> o; +#endif +#elif DEFAULT_CXX17 #if CXX_STD <= 201402L Outputter<CXX_STD> o; #endif diff --git a/Tests/CompileFeatures/genex_test.c b/Tests/CompileFeatures/genex_test.c index 1d54840..e58d793 100644 --- a/Tests/CompileFeatures/genex_test.c +++ b/Tests/CompileFeatures/genex_test.c @@ -8,7 +8,7 @@ #error EXPECT_C_RESTRICT not defined #endif -#if !EXPECT_C_STATIC_ASSERT +#if !HAVE_C_STATIC_ASSERT #if EXPECT_C_STATIC_ASSERT #error "Expect c_static_assert feature" #endif @@ -18,11 +18,17 @@ #endif #endif -#if !EXPECT_C_FUNCTION_PROTOTYPES +#if !HAVE_C_FUNCTION_PROTOTYPES +#if EXPECT_C_FUNCTION_PROTOTYPES #error Expect c_function_prototypes support #endif +#else +#if !EXPECT_C_FUNCTION_PROTOTYPES +#error Expect no c_function_prototypes support +#endif +#endif -#if !EXPECT_C_RESTRICT +#if !HAVE_C_RESTRICT #if EXPECT_C_RESTRICT #error Expect c_restrict support #endif diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index 692e0de..c9f1710 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -18,9 +18,21 @@ set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "-DTEST_DEFINE" "-DNEEDS_ESCAPE=\"E$CAPE\"" "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>" + "SHELL:" # produces no options ${c_tests} ${cxx_tests} ) +if(BORLAND OR WATCOM) + # these compilers do not support separate -D flags + target_compile_definitions(CompileOptions PRIVATE NO_DEF_TESTS) +else() + set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS + "SHELL:-D DEF_A" + "$<1:SHELL:-D DEF_B>" + "SHELL:-D 'DEF_C' -D \"DEF_D\"" + [[SHELL:-D "DEF_STR=\"string with spaces\""]] + ) +endif() if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero") set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp index 63a0480..4779b88 100644 --- a/Tests/CompileOptions/main.cpp +++ b/Tests/CompileOptions/main.cpp @@ -12,6 +12,28 @@ #endif #endif +#ifndef NO_DEF_TESTS +#ifndef DEF_A +#error Expected definition DEF_A +#endif + +#ifndef DEF_B +#error Expected definition DEF_B +#endif + +#ifndef DEF_C +#error Expected definition DEF_C +#endif + +#ifndef DEF_D +#error Expected definition DEF_D +#endif + +#ifndef DEF_STR +#error Expected definition DEF_STR +#endif +#endif + #include <string.h> int main() @@ -20,6 +42,9 @@ int main() #ifdef TEST_OCTOTHORPE && strcmp(TEST_OCTOTHORPE, "#") == 0 #endif +#ifndef NO_DEF_TESTS + && strcmp(DEF_STR, "string with spaces") == 0 +#endif && strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0 && strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == diff --git a/Tests/Complex/Cache/CMakeCache.txt b/Tests/Complex/Cache/CMakeCache.txt index 17c55aa..727faa2 100644 --- a/Tests/Complex/Cache/CMakeCache.txt +++ b/Tests/Complex/Cache/CMakeCache.txt @@ -5,7 +5,7 @@ # If you do want to change a value, simply edit, save, and exit the editor. # The syntax for the file is as follows: # KEY:TYPE=VALUE -# KEY is the name of a varible in the cache. +# KEY is the name of a variable in the cache. # TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!. # VALUE is the current value for the KEY. diff --git a/Tests/ComplexOneConfig/Cache/CMakeCache.txt b/Tests/ComplexOneConfig/Cache/CMakeCache.txt index 17c55aa..727faa2 100644 --- a/Tests/ComplexOneConfig/Cache/CMakeCache.txt +++ b/Tests/ComplexOneConfig/Cache/CMakeCache.txt @@ -5,7 +5,7 @@ # If you do want to change a value, simply edit, save, and exit the editor. # The syntax for the file is as follows: # KEY:TYPE=VALUE -# KEY is the name of a varible in the cache. +# KEY is the name of a variable in the cache. # TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!. # VALUE is the current value for the KEY. diff --git a/Tests/Contracts/PLplot/CMakeLists.txt b/Tests/Contracts/PLplot/CMakeLists.txt index b87b4c3..8e95ba3 100644 --- a/Tests/Contracts/PLplot/CMakeLists.txt +++ b/Tests/Contracts/PLplot/CMakeLists.txt @@ -9,7 +9,7 @@ if(NOT PLplot_GIT_TAG) set(PLplot_GIT_TAG "plplot-5.13.0") endif() ExternalProject_Add(PLplot - GIT_REPOSITORY "https://git.code.sf.net/p/plplot/plplot.git" + GIT_REPOSITORY "https://git.code.sf.net/p/plplot/plplot" GIT_TAG "${PLplot_GIT_TAG}" PREFIX "${PLplot_PREFIX}" CMAKE_ARGS diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 5ad6e6b..59f3e84 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -2,6 +2,11 @@ ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) +ADD_TEST_MACRO(CudaOnly.LinkSystemDeviceLibraries CudaOnlyLinkSystemDeviceLibraries) ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) + +if(MSVC) + ADD_TEST_MACRO(CudaOnly.PDB CudaOnlyPDB) +endif() diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt b/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt new file mode 100644 index 0000000..62be1e6 --- /dev/null +++ b/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(CudaOnlyLinkSystemDeviceLibraries CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35") +set(CMAKE_CUDA_STANDARD 11) + +add_executable(CudaOnlyLinkSystemDeviceLibraries main.cu) +set_target_properties( CudaOnlyLinkSystemDeviceLibraries + PROPERTIES CUDA_SEPARABLE_COMPILATION ON) +target_link_libraries( CudaOnlyLinkSystemDeviceLibraries PRIVATE cublas_device) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyLinkSystemDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu b/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu new file mode 100644 index 0000000..7eecec1 --- /dev/null +++ b/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu @@ -0,0 +1,77 @@ + +#include <cublas_v2.h> +#include <cuda_runtime.h> +#include <iostream> + +__global__ void deviceCublasSgemm(int n, float alpha, float beta, + const float* d_A, const float* d_B, + float* d_C) +{ + cublasHandle_t cnpHandle; + cublasStatus_t status = cublasCreate(&cnpHandle); + + if (status != CUBLAS_STATUS_SUCCESS) { + return; + } + + // Call function defined in the cublas_device system static library. + // This way we can verify that we properly pass system libraries to the + // device link line + status = cublasSgemm(cnpHandle, CUBLAS_OP_N, CUBLAS_OP_N, n, n, n, &alpha, + d_A, n, d_B, n, &beta, d_C, n); + + cublasDestroy(cnpHandle); +} + +int choose_cuda_device() +{ + int nDevices = 0; + cudaError_t err = cudaGetDeviceCount(&nDevices); + if (err != cudaSuccess) { + std::cerr << "Failed to retrieve the number of CUDA enabled devices" + << std::endl; + return 1; + } + for (int i = 0; i < nDevices; ++i) { + cudaDeviceProp prop; + cudaError_t err = cudaGetDeviceProperties(&prop, i); + if (err != cudaSuccess) { + std::cerr << "Could not retrieve properties from CUDA device " << i + << std::endl; + return 1; + } + + if (prop.major > 3 || (prop.major == 3 && prop.minor >= 5)) { + err = cudaSetDevice(i); + if (err != cudaSuccess) { + std::cout << "Could not select CUDA device " << i << std::endl; + } else { + return 0; + } + } + } + + std::cout << "Could not find a CUDA enabled card supporting compute >=3.5" + << std::endl; + return 1; +} + +int main(int argc, char** argv) +{ + int ret = choose_cuda_device(); + if (ret) { + return 0; + } + + // initial values that will make sure that the cublasSgemm won't actually + // do any work + int n = 0; + float alpha = 1; + float beta = 1; + float* d_A = nullptr; + float* d_B = nullptr; + float* d_C = nullptr; + deviceCublasSgemm<<<1, 1>>>(n, alpha, beta, d_A, d_B, d_C); + + return 0; +} diff --git a/Tests/CudaOnly/PDB/CMakeLists.txt b/Tests/CudaOnly/PDB/CMakeLists.txt new file mode 100644 index 0000000..34e1e5c --- /dev/null +++ b/Tests/CudaOnly/PDB/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.11) +project (CudaOnlyPDB CUDA) + +add_executable(CudaOnlyPDB main.cu) +set_target_properties(CudaOnlyPDB PROPERTIES + PDB_NAME LinkPDBName + PDB_OUTPUT_DIRECTORY LinkPDBDir + COMPILE_PDB_NAME CompPDBName + COMPILE_PDB_OUTPUT_DIRECTORY CompPDBDir + ) + +set(pdbs + ${CMAKE_CURRENT_BINARY_DIR}/CompPDBDir/${CMAKE_CFG_INTDIR}/CompPDBName.pdb + ${CMAKE_CURRENT_BINARY_DIR}/LinkPDBDir/${CMAKE_CFG_INTDIR}/LinkPDBName.pdb + ) +add_custom_command(TARGET CudaOnlyPDB POST_BUILD + COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIG> "-Dpdbs=${pdbs}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/check_pdbs.cmake + ) diff --git a/Tests/CudaOnly/PDB/check_pdbs.cmake b/Tests/CudaOnly/PDB/check_pdbs.cmake new file mode 100644 index 0000000..5e01ca7 --- /dev/null +++ b/Tests/CudaOnly/PDB/check_pdbs.cmake @@ -0,0 +1,10 @@ +if(NOT "${config}" MATCHES "[Dd][Ee][Bb]") + return() +endif() +foreach(pdb ${pdbs}) + if(EXISTS "${pdb}") + message(STATUS "PDB Exists: ${pdb}") + else() + message(SEND_ERROR "PDB MISSING:\n ${pdb}") + endif() +endforeach() diff --git a/Tests/CudaOnly/PDB/main.cu b/Tests/CudaOnly/PDB/main.cu new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/CudaOnly/PDB/main.cu @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index eeae3f0..0f1a556 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -83,11 +83,23 @@ set_property(TARGET testLib7 PROPERTY OUTPUT_NAME testLib7-$<CONFIG>) add_library(testLib8 OBJECT testLib8A.c testLib8B.c sub/testLib8C.c) if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]") - set(maybe_testLib8 testLib8) + set(maybe_OBJECTS_DESTINATION OBJECTS DESTINATION $<1:lib>) else() - set(maybe_testLib8 "") + set(maybe_OBJECTS_DESTINATION "") endif() +cmake_policy(PUSH) +cmake_policy(SET CMP0022 NEW) +add_library(testLib9ObjPub OBJECT testLib9ObjPub.c) +target_compile_definitions(testLib9ObjPub INTERFACE testLib9ObjPub_USED) +add_library(testLib9ObjPriv OBJECT testLib9ObjPriv.c) +target_compile_definitions(testLib9ObjPriv INTERFACE testLib9ObjPriv_USED) +add_library(testLib9ObjIface OBJECT testLib9ObjIface.c) +target_compile_definitions(testLib9ObjIface INTERFACE testLib9ObjIface_USED) +add_library(testLib9 STATIC testLib9.c) +target_link_libraries(testLib9 INTERFACE testLib9ObjIface PUBLIC testLib9ObjPub PRIVATE testLib9ObjPriv) +cmake_policy(POP) + # Test using the target_link_libraries command to set the # LINK_INTERFACE_LIBRARIES* properties. We construct two libraries # providing the same two symbols. In each library one of the symbols @@ -344,6 +356,14 @@ install(FILES set_property(TARGET testLib2 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB2) set_property(TARGET testLib3 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB3) +set_target_properties(testLib3 PROPERTIES + EXPORT_PROPERTIES "EXPORTED_PROPERTY1" + EXPORTED_PROPERTY1 "EXPORTING_TESTLIB3") +set_target_properties(testLib4 PROPERTIES + EXPORTED_PROPERTY2 "EXPORTING_TESTLIB4_1" + EXPORTED_PROPERTY3 "EXPORTING_TESTLIB4_2") +set_property(TARGET testLib4 PROPERTY + EXPORT_PROPERTIES EXPORTED_PROPERTY2 EXPORTED_PROPERTY3) set_property(TARGET cmp0022NEW APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2) # set_property(TARGET cmp0022NEW APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLibIncludeRequired2) # TODO: Test for error @@ -483,7 +503,8 @@ install( TARGETS testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt - testLib6 testLib7 ${maybe_testLib8} + testLib6 testLib7 testLib8 + testLib9 testLibCycleA testLibCycleB testLibNoSONAME cmp0022NEW cmp0022OLD @@ -492,10 +513,15 @@ install( RUNTIME DESTINATION $<1:bin> LIBRARY DESTINATION $<1:lib> NAMELINK_SKIP ARCHIVE DESTINATION $<1:lib> - OBJECTS DESTINATION $<1:lib> + ${maybe_OBJECTS_DESTINATION} FRAMEWORK DESTINATION Frameworks BUNDLE DESTINATION Applications ) +install( + TARGETS + testLib9ObjPub testLib9ObjPriv testLib9ObjIface + EXPORT exp + ) if (APPLE) file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/testLib4.framework/Headers) file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/testLib4.framework/Headers) @@ -545,7 +571,8 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 FILE ExportBuildTree.cmake ) export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib - ${maybe_testLib8} + testLib8 + testLib9 testLib9ObjPub testLib9ObjPriv testLib9ObjIface testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibNoSONAME diff --git a/Tests/ExportImport/Export/testLib9.c b/Tests/ExportImport/Export/testLib9.c new file mode 100644 index 0000000..fe8610b --- /dev/null +++ b/Tests/ExportImport/Export/testLib9.c @@ -0,0 +1,15 @@ +#ifndef testLib9ObjPub_USED +#error "testLib9ObjPub_USED not defined!" +#endif +#ifndef testLib9ObjPriv_USED +#error "testLib9ObjPriv_USED not defined!" +#endif +#ifdef testLib9ObjIface_USED +#error "testLib9ObjIface_USED defined but should not be!" +#endif +int testLib9ObjPub(void); +int testLib9ObjPriv(void); +int testLib9(void) +{ + return (testLib9ObjPub() + testLib9ObjPriv()); +} diff --git a/Tests/ExportImport/Export/testLib9ObjIface.c b/Tests/ExportImport/Export/testLib9ObjIface.c new file mode 100644 index 0000000..e75440a --- /dev/null +++ b/Tests/ExportImport/Export/testLib9ObjIface.c @@ -0,0 +1,11 @@ +/* Duplicate symbols from other sources to verify that this source + is not included when the object library is used. */ +int testLib9ObjMissing(void); +int testLib9ObjPub(void) +{ + return testLib9ObjMissing(); +} +int testLib9ObjPriv(void) +{ + return testLib9ObjMissing(); +} diff --git a/Tests/ExportImport/Export/testLib9ObjPriv.c b/Tests/ExportImport/Export/testLib9ObjPriv.c new file mode 100644 index 0000000..6fa63cc --- /dev/null +++ b/Tests/ExportImport/Export/testLib9ObjPriv.c @@ -0,0 +1,4 @@ +int testLib9ObjPriv(void) +{ + return 0; +} diff --git a/Tests/ExportImport/Export/testLib9ObjPub.c b/Tests/ExportImport/Export/testLib9ObjPub.c new file mode 100644 index 0000000..66e2624 --- /dev/null +++ b/Tests/ExportImport/Export/testLib9ObjPub.c @@ -0,0 +1,4 @@ +int testLib9ObjPub(void) +{ + return 0; +} diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 01960ea..39a89dc 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -32,6 +32,20 @@ add_executable(imp_testExe1 ${Import_BINARY_DIR}/exp_generated4.c ) +function(checkForProperty _TARGET _PROP _EXPECTED) + get_target_property(EXPORTED_PROPERTY ${_TARGET} "${_PROP}") + if (NOT EXPORTED_PROPERTY STREQUAL "${_EXPECTED}") + message(SEND_ERROR "${_TARGET} was expected to export \"${_PROP}\" with value \"${_EXPECTED}\" but got \"${EXPORTED_PROPERTY}\"") + endif() +endfunction() + +checkForProperty(bld_testLib3 "EXPORTED_PROPERTY1" "EXPORTING_TESTLIB3") +checkForProperty(exp_testLib3 "EXPORTED_PROPERTY1" "EXPORTING_TESTLIB3") +checkForProperty(bld_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1") +checkForProperty(exp_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1") +checkForProperty(bld_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2") +checkForProperty(exp_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2") + # Try linking to a library imported from the install tree. target_link_libraries(imp_testExe1 exp_testLib2 @@ -229,15 +243,44 @@ add_library(imp_lib1b STATIC imp_lib1.c) target_link_libraries(imp_lib1b bld_testLib2) if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]") - # Create a executable that is using objects imported from the install tree - add_executable(imp_testLib8 imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>) + set(bld_objlib_type OBJECT_LIBRARY) + + # Create executables using objects imported from the install tree + add_executable(imp_testLib8_src imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>) + add_executable(imp_testLib8_link imp_testLib8.c) + target_link_libraries(imp_testLib8_link exp_testLib8) if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT XCODE_VERSION VERSION_LESS 5) - # Create a executable that is using objects imported from the build tree - add_executable(imp_testLib8b imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>) + # Create executables using objects imported from the build tree + add_executable(imp_testLib8b_src imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>) + add_executable(imp_testLib8b_link imp_testLib8.c) + target_link_libraries(imp_testLib8b_link bld_testLib8) endif() +else() + set(bld_objlib_type INTERFACE_LIBRARY) endif() +# Create an executable that uses a library imported from the install tree +# that itself was built using an object library. Verify we get the usage +# requirements. +add_executable(imp_testLib9 imp_testLib9.c) +target_link_libraries(imp_testLib9 exp_testLib9) +# Similarly for importing from the build tree. +add_executable(imp_testLib9b imp_testLib9.c) +target_link_libraries(imp_testLib9b bld_testLib9) + +# Check that object libraries were transformed on export as expected. +foreach(vis Pub Priv Iface) + get_property(type TARGET exp_testLib9Obj${vis} PROPERTY TYPE) + if(NOT type STREQUAL INTERFACE_LIBRARY) + message(FATAL_ERROR "exp_testLib9Obj${vis} type is '${type}', not 'INTERFACE_LIBRARY'") + endif() + get_property(type TARGET bld_testLib9Obj${vis} PROPERTY TYPE) + if(NOT type STREQUAL "${bld_objlib_type}") + message(FATAL_ERROR "bld_testLib9Obj${vis} type is '${type}', not '${bld_objlib_type}'") + endif() +endforeach() + #----------------------------------------------------------------------------- # Test that handling imported targets, including transitive dependencies, # works in CheckFunctionExists (...and hopefully all other try_compile() checks diff --git a/Tests/ExportImport/Import/A/imp_testLib9.c b/Tests/ExportImport/Import/A/imp_testLib9.c new file mode 100644 index 0000000..f9c05fd --- /dev/null +++ b/Tests/ExportImport/Import/A/imp_testLib9.c @@ -0,0 +1,16 @@ +#ifndef testLib9ObjPub_USED +#error "testLib9ObjPub_USED not defined!" +#endif +#ifdef testLib9ObjPriv_USED +#error "testLib9ObjPriv_USED defined but should not be!" +#endif +#ifndef testLib9ObjIface_USED +#error "testLib9ObjIface_USED not defined!" +#endif + +int testLib9(void); + +int main() +{ + return testLib9(); +} diff --git a/Tests/FindCURL/CMakeLists.txt b/Tests/FindCURL/CMakeLists.txt new file mode 100644 index 0000000..0cfd629 --- /dev/null +++ b/Tests/FindCURL/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindCURL.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindCURL/Test" + "${CMake_BINARY_DIR}/Tests/FindCURL/Test" + ${build_generator_args} + --build-project TestFindCURL + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindCURL/Test/CMakeLists.txt b/Tests/FindCURL/Test/CMakeLists.txt new file mode 100644 index 0000000..f0e5568 --- /dev/null +++ b/Tests/FindCURL/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) +project(TestFindCURL C) +include(CTest) + +find_package(CURL REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_CURL_VERSION="${CURL_VERSION_STRING}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt CURL::CURL) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${CURL_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${CURL_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindCURL/Test/main.c b/Tests/FindCURL/Test/main.c new file mode 100644 index 0000000..263775f --- /dev/null +++ b/Tests/FindCURL/Test/main.c @@ -0,0 +1,17 @@ +#include <curl/curl.h> +#include <stdio.h> +#include <stdlib.h> + +int main() +{ + struct curl_slist* slist; + + curl_global_init(0); + + slist = curl_slist_append(NULL, "CMake"); + curl_slist_free_all(slist); + + curl_global_cleanup(); + + return 0; +} diff --git a/Tests/FindLibXml2/CMakeLists.txt b/Tests/FindLibXml2/CMakeLists.txt new file mode 100644 index 0000000..6c2464f --- /dev/null +++ b/Tests/FindLibXml2/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindLibXml2.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLibXml2/Test" + "${CMake_BINARY_DIR}/Tests/FindLibXml2/Test" + ${build_generator_args} + --build-project TestFindLibXml2 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindLibXml2/Test/CMakeLists.txt b/Tests/FindLibXml2/Test/CMakeLists.txt new file mode 100644 index 0000000..df5d8c3 --- /dev/null +++ b/Tests/FindLibXml2/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.4) +project(TestFindLibXml2 C) +include(CTest) + +find_package(LibXml2 REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_LibXml2_VERSION="${LIBXML2_VERSION_STRING}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt LibXml2::LibXml2) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${LIBXML2_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${LIBXML2_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindLibXml2/Test/main.c b/Tests/FindLibXml2/Test/main.c new file mode 100644 index 0000000..264f07d --- /dev/null +++ b/Tests/FindLibXml2/Test/main.c @@ -0,0 +1,19 @@ +#include <assert.h> +#include <libxml/tree.h> +#include <string.h> + +int main() +{ + xmlDoc* doc; + + xmlInitParser(); + + doc = xmlNewDoc(BAD_CAST "1.0"); + xmlFreeDoc(doc); + + assert(strstr(CMAKE_EXPECTED_LibXml2_VERSION, LIBXML_DOTTED_VERSION)); + + xmlCleanupParser(); + + return 0; +} diff --git a/Tests/FindMatlab/basic_checks/CMakeLists.txt b/Tests/FindMatlab/basic_checks/CMakeLists.txt index bf54427..951fcf2 100644 --- a/Tests/FindMatlab/basic_checks/CMakeLists.txt +++ b/Tests/FindMatlab/basic_checks/CMakeLists.txt @@ -24,11 +24,12 @@ matlab_add_mex( matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-1 - TIMEOUT 90 + TIMEOUT 300 UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> ) +# timeout tests, TIMEOUT set to very short on purpose matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-2 TIMEOUT 15 @@ -41,7 +42,7 @@ set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE) # testing the test without the unittest framework of Matlab matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-3 - TIMEOUT 30 + TIMEOUT 300 NO_UNITTEST_FRAMEWORK UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests2.m ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> @@ -49,7 +50,7 @@ matlab_add_unit_test( matlab_add_unit_test( NAME ${PROJECT_NAME}_matlabtest-4 - TIMEOUT 30 + TIMEOUT 300 NO_UNITTEST_FRAMEWORK UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests3.m ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> diff --git a/Tests/FindMatlab/failure_reports/CMakeLists.txt b/Tests/FindMatlab/failure_reports/CMakeLists.txt new file mode 100644 index 0000000..1cf9613 --- /dev/null +++ b/Tests/FindMatlab/failure_reports/CMakeLists.txt @@ -0,0 +1,39 @@ + +cmake_minimum_required (VERSION 2.8.12) +enable_testing() +project(failure_reports) + +# gather tests about proper failure reports + +set(MATLAB_FIND_DEBUG TRUE) + +find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY MAIN_PROGRAM) + +# main extensions for testing, same as other tests +matlab_add_mex( + # target name + NAME cmake_matlab_test_wrapper1 + # output name + OUTPUT_NAME cmake_matlab_mex1 + SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp + DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt + ) + +# the unit test file does not exist: the failure should be properly reported +matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-1 + TIMEOUT 300 + UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile.m + ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> + ) +set_tests_properties(${PROJECT_NAME}_matlabtest-1 PROPERTIES WILL_FAIL TRUE) + +# without the unit test framework +matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-2 + TIMEOUT 300 + NO_UNITTEST_FRAMEWORK + UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile2.m + ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> + ) +set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE) diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt new file mode 100644 index 0000000..639d29c --- /dev/null +++ b/Tests/FindPython/CMakeLists.txt @@ -0,0 +1,69 @@ +add_test(NAME FindPython.Python2 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2" + ${build_generator_args} + --build-project TestPython2 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + +add_test(NAME FindPython.Python2Fail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Fail" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2Fail" + ${build_generator_args} + --build-project TestPython2Fail + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +set_tests_properties(FindPython.Python2Fail PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") + +add_test(NAME FindPython.Python3 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3" + ${build_generator_args} + --build-project TestPython3 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + +add_test(NAME FindPython.Python3Fail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Fail" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3Fail" + ${build_generator_args} + --build-project TestPython3Fail + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +set_tests_properties(FindPython.Python3Fail PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") + +add_test(NAME FindPython.Python COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python" + "${CMake_BINARY_DIR}/Tests/FindPython/Python" + ${build_generator_args} + --build-project TestPython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + +add_test(NAME FindPython.MultiplePackages COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" + "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" + ${build_generator_args} + --build-project TestMultiplePackages + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindPython/MultiplePackages/CMakeLists.txt b/Tests/FindPython/MultiplePackages/CMakeLists.txt new file mode 100644 index 0000000..5c85155 --- /dev/null +++ b/Tests/FindPython/MultiplePackages/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestMultiplePackages C) + +find_package (Python2 REQUIRED COMPONENTS Interpreter Development) +find_package (Python3 REQUIRED COMPONENTS Interpreter Development) + +# Must find Python 3 +find_package (Python REQUIRED) + +if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE) + message (FATAL_ERROR + "Python interpreters do not match:\n" + " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" + " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n" + ) +endif() + + +Python2_add_library (spam2 MODULE ../spam.c) +target_compile_definitions (spam2 PRIVATE PYTHON2) + +Python3_add_library (spam3 MODULE ../spam.c) +target_compile_definitions (spam3 PRIVATE PYTHON3) + + +add_test (NAME python2_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" + "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") + +add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" + "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt new file mode 100644 index 0000000..bebd23f --- /dev/null +++ b/Tests/FindPython/Python/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestPython C) + +include(CTest) + +find_package(Python 3 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python_FOUND) + message (FATAL_ERROR "Fail to found Python 3") +endif() + +Python_add_library (spam3 MODULE ../spam.c) +target_compile_definitions (spam3 PRIVATE PYTHON3) + +add_test (NAME python_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" + "${Python_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt new file mode 100644 index 0000000..9622b6f --- /dev/null +++ b/Tests/FindPython/Python2/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestPython2 C) + +include(CTest) + +find_package(Python2 3 QUIET) +if (Python2_FOUND) + message (FATAL_ERROR "Wrong python version found: ${Python2_VERSION}") +endif() + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python2_FOUND) + message (FATAL_ERROR "Fail to found Python 2") +endif() + +Python2_add_library (spam2 MODULE ../spam.c) +target_compile_definitions (spam2 PRIVATE PYTHON2) + +add_test (NAME python2_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>" + "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") diff --git a/Tests/FindPython/Python2Fail/CMakeLists.txt b/Tests/FindPython/Python2Fail/CMakeLists.txt new file mode 100644 index 0000000..989688f --- /dev/null +++ b/Tests/FindPython/Python2Fail/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestPython2Fail C) + +include(CTest) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development foobar) + +Python2_add_library (spam2 MODULE ../spam.c) +target_compile_definitions (spam2 PRIVATE PYTHON2) + +add_test (NAME python2_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>" + "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt new file mode 100644 index 0000000..cb86eae --- /dev/null +++ b/Tests/FindPython/Python3/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestPython3 C) + +include(CTest) + +find_package(Python3 2 QUIET) +if (Python3_FOUND) + message (FATAL_ERROR "Wrong python version found: ${Python3_VERSION}") +endif() + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Fail to found Python 3") +endif() + +Python3_add_library (spam3 MODULE ../spam.c) +target_compile_definitions (spam3 PRIVATE PYTHON3) + +add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" + "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/FindPython/Python3Fail/CMakeLists.txt b/Tests/FindPython/Python3Fail/CMakeLists.txt new file mode 100644 index 0000000..cd46c88 --- /dev/null +++ b/Tests/FindPython/Python3Fail/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestPython3Fail C) + +include(CTest) + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development foobar) + +Python3_add_library (spam3 MODULE ../spam.c) +target_compile_definitions (spam3 PRIVATE PYTHON3) + +add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>" + "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/FindPython/spam.c b/Tests/FindPython/spam.c new file mode 100644 index 0000000..1c65d54 --- /dev/null +++ b/Tests/FindPython/spam.c @@ -0,0 +1,41 @@ + +#include <Python.h> + +static PyObject* spam_system(PyObject* self, PyObject* args) +{ + const char* command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + /* return PyLong_FromLong(sts); */ + return Py_BuildValue("i", sts); +} + +static PyMethodDef SpamMethods[] = { + { "system", spam_system, METH_VARARGS, "Execute a shell command." }, + { NULL, NULL, 0, NULL } /* Sentinel */ +}; + +#if defined(PYTHON2) +PyMODINIT_FUNC initspam2(void) +{ + (void)Py_InitModule("spam2", SpamMethods); +} +#endif + +#if defined(PYTHON3) +static struct PyModuleDef spammodule = { + PyModuleDef_HEAD_INIT, "spam3", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + SpamMethods +}; + +PyMODINIT_FUNC PyInit_spam3(void) +{ + return PyModule_Create(&spammodule); +} +#endif diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 19d12e5..3d08704 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -57,6 +57,11 @@ add_custom_target(check-part1 ALL -Dtest_strequal_angle_r_comma=$<STREQUAL:$<ANGLE-R>,$<COMMA>> -Dtest_strequal_both_empty=$<STREQUAL:,> -Dtest_strequal_one_empty=$<STREQUAL:something,> + -Dtest_inlist_true=$<IN_LIST:a,a$<SEMICOLON>b> + -Dtest_inlist_false=$<IN_LIST:c,a$<SEMICOLON>b> + -Dtest_inlist_empty_1=$<IN_LIST:a,> + -Dtest_inlist_empty_2=$<IN_LIST:,a> + -Dtest_inlist_empty_3=$<IN_LIST:,> -Dtest_angle_r=$<ANGLE-R> -Dtest_comma=$<COMMA> -Dtest_semicolon=$<SEMICOLON> diff --git a/Tests/GeneratorExpression/check-part1.cmake b/Tests/GeneratorExpression/check-part1.cmake index 60b193f..41bcd6d 100644 --- a/Tests/GeneratorExpression/check-part1.cmake +++ b/Tests/GeneratorExpression/check-part1.cmake @@ -49,6 +49,11 @@ check(test_strequal_semicolon "1") check(test_strequal_angle_r_comma "0") check(test_strequal_both_empty "1") check(test_strequal_one_empty "0") +check(test_inlist_true "1") +check(test_inlist_false "0") +check(test_inlist_empty_1 "0") +check(test_inlist_empty_2 "0") +check(test_inlist_empty_3 "0") check(test_angle_r ">") check(test_comma ",") check(test_semicolon ";") diff --git a/Tests/Module/ExternalData/Data5/CMakeLists.txt b/Tests/Module/ExternalData/Data5/CMakeLists.txt index 13c7fab..ea67f05 100644 --- a/Tests/Module/ExternalData/Data5/CMakeLists.txt +++ b/Tests/Module/ExternalData/Data5/CMakeLists.txt @@ -2,21 +2,21 @@ ExternalData_Add_Test(Data5.A NAME Data5Check.A COMMAND ${CMAKE_COMMAND} - -D Data5=DATA{../Data.dat} + -D Data5=DATA{Data5.dat} -P ${CMAKE_CURRENT_SOURCE_DIR}/Data5Check.cmake ) ExternalData_Add_Target(Data5.A) ExternalData_Add_Test(Data5.B NAME Data5Check.B COMMAND ${CMAKE_COMMAND} - -D Data5=DATA{../Data.dat} + -D Data5=DATA{Data5.dat} -P ${CMAKE_CURRENT_SOURCE_DIR}/Data5Check.cmake ) ExternalData_Add_Target(Data5.B) ExternalData_Add_Test(Data5.C NAME Data5Check.C COMMAND ${CMAKE_COMMAND} - -D Data5=DATA{../Data.dat} + -D Data5=DATA{Data5.dat} -P ${CMAKE_CURRENT_SOURCE_DIR}/Data5Check.cmake ) ExternalData_Add_Target(Data5.C) diff --git a/Tests/Module/ExternalData/Data5/Data5.dat.md5 b/Tests/Module/ExternalData/Data5/Data5.dat.md5 new file mode 100644 index 0000000..70e39bd --- /dev/null +++ b/Tests/Module/ExternalData/Data5/Data5.dat.md5 @@ -0,0 +1 @@ +8c018830e3efa5caf3c7415028335a57 diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 52d4613..45bb229 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -190,7 +190,7 @@ write_compiler_detection_header( ALLOW_UNKNOWN_COMPILERS ) -# intentionally abuse the TEST_NULLPR variable: this will only work +# intentionally abuse the TEST_NULLPTR 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" @@ -199,3 +199,16 @@ int main() {\n int i = TEST_NULLPTR;\n return 0; }\n" 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() + +# test for BARE_FEATURES + +write_compiler_detection_header( + FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_bare_features.h" + PREFIX TEST + COMPILERS GNU Clang AppleClang MSVC SunPro Intel + VERSION 3.1 + BARE_FEATURES cxx_nullptr cxx_override cxx_noexcept cxx_final +) + +add_executable(WriteCompilerDetectionHeaderBareFeatures main_bare.cpp) +set_property(TARGET WriteCompilerDetectionHeaderBareFeatures PROPERTY CXX_STANDARD 11) diff --git a/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp b/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp new file mode 100644 index 0000000..6954318 --- /dev/null +++ b/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp @@ -0,0 +1,23 @@ +#include "test_compiler_detection_bare_features.h" + +class base +{ +public: + virtual ~base() {} + virtual void baz() = 0; +}; + +class foo final +{ +public: + virtual ~foo() {} + char* bar; + void baz() noexcept override { bar = nullptr; } +}; + +int main() +{ + foo f; + + return 0; +} diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt index 10a2f59..76a93d2 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt +++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt @@ -16,11 +16,11 @@ if ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") # Use a separate variable for computation. set(MAXPATH "${CMAKE_OBJECT_PATH_MAX}") - # VS8 adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the + # VS adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the # path of the source file for no good reason. Reduce the length # limit by 46 characters to account for it. It should still be long # enough to require special object file name conversion. - if(${CMAKE_GENERATOR} MATCHES "Visual Studio (8|10)") + if(${CMAKE_GENERATOR} MATCHES "Visual Studio") math(EXPR MAXPATH "${MAXPATH} - 46") endif() diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt index 2e6a5bd..f9c52b7 100644 --- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt @@ -45,8 +45,7 @@ file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Change a resource files listed in the .qrc file # - Rebuild execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/input.txt") +file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt") execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) if (result) message(SEND_ERROR "Second build of rccDepends failed.") @@ -97,8 +96,7 @@ file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Change a newly added resource files listed in the .qrc file # - Rebuild execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/inputAdded.txt") +file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt") execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) if (result) message(SEND_ERROR "Fourth build of rccDepends failed.") diff --git a/Tests/RunCMake/Android/android_lib.cxx b/Tests/RunCMake/Android/android_lib.cxx new file mode 100644 index 0000000..82f9d27 --- /dev/null +++ b/Tests/RunCMake/Android/android_lib.cxx @@ -0,0 +1,4 @@ +int android_lib() +{ + return 0; +} diff --git a/Tests/RunCMake/Android/check_binary.cmake b/Tests/RunCMake/Android/check_binary.cmake new file mode 100644 index 0000000..1d1b01a --- /dev/null +++ b/Tests/RunCMake/Android/check_binary.cmake @@ -0,0 +1,8 @@ +if(NOT EXISTS "${file}") + message(FATAL_ERROR "Missing file:\n ${file}") +endif() +execute_process(COMMAND "${objdump}" -p ${file} OUTPUT_VARIABLE out) +if(out MATCHES "NEEDED[^\n]*stdc\\+\\+") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "File:\n ${file}\ndepends on libstdc++:\n${out}") +endif() diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index 015f202..f931be1 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -92,6 +92,23 @@ if(CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a") endif() add_executable(android_c android.c) add_executable(android_cxx android.cxx) +add_library(android_cxx_lib SHARED android_lib.cxx) + +set(objdump "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}objdump") +if(NOT EXISTS "${objdump}") + message(FATAL_ERROR "Expected tool missing:\n ${objdump}") +endif() + +if(NOT CMAKE_ANDROID_STL_TYPE MATCHES "^(system|stlport_static|stlport_shared)$") + foreach(tgt android_cxx android_cxx_lib) + add_custom_command(TARGET ${tgt} POST_BUILD + COMMAND ${CMAKE_COMMAND} + -Dobjdump=${objdump} + -Dfile=$<TARGET_FILE:${tgt}> + -P ${CMAKE_CURRENT_SOURCE_DIR}/check_binary.cmake + ) + endforeach() +endif() # Test that an explicit /usr/include is ignored in favor of # appearing as a standard include directory at the end. diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index d5bd297..44a8c45 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -121,6 +121,9 @@ if(CMAKE_GENERATOR STREQUAL "Ninja") -DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION} -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}) + if(CMAKE_Fortran_COMPILER) + list(APPEND Ninja_ARGS -DTEST_Fortran=1) + endif() add_RunCMake_test(Ninja) endif() add_RunCMake_test(CTest) @@ -188,6 +191,7 @@ if (QT4_FOUND) endif() add_RunCMake_test(CompatibleInterface) add_RunCMake_test(Syntax) +add_RunCMake_test(WorkingDirectory) add_RunCMake_test(add_custom_command) add_RunCMake_test(add_custom_target) @@ -305,13 +309,13 @@ endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") add_RunCMake_test(include_external_msproject) - if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([89]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio (9|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) set(NO_USE_FOLDERS 1) endif() add_RunCMake_test(VSSolution -DNO_USE_FOLDERS=${NO_USE_FOLDERS}) endif() -if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^89]|[89][0-9])") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^9]|9[0-9])") add_RunCMake_test(VS10Project) endif() @@ -335,10 +339,14 @@ add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(CommandLineTar) add_RunCMake_test(install) +add_RunCMake_test(CPackCommandLine) add_RunCMake_test(CPackConfig) add_RunCMake_test(CPackInstallProperties) add_RunCMake_test(ExternalProject) add_RunCMake_test(FetchContent) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + set(CTestCommandLine_ARGS -DTEST_AFFINITY=$<TARGET_FILE:testAffinity>) +endif() add_RunCMake_test(CTestCommandLine) add_RunCMake_test(CacheNewline) # Only run this test on unix platforms that support @@ -425,6 +433,6 @@ if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN) set_property(TEST RunCMake.Android PROPERTY TIMEOUT ${CMake_TEST_ANDROID_TIMEOUT}) endif() -if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|9[0-9])") add_RunCMake_test(CSharpCustomCommand) endif() diff --git a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-result.txt b/Tests/RunCMake/CPackCommandLine/NotAGenerator-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-result.txt +++ b/Tests/RunCMake/CPackCommandLine/NotAGenerator-result.txt diff --git a/Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt b/Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt new file mode 100644 index 0000000..fe4e455 --- /dev/null +++ b/Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt @@ -0,0 +1 @@ +^CPack Error: Cannot initialize CPack generator: NotAGenerator diff --git a/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake new file mode 100644 index 0000000..991146c --- /dev/null +++ b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake @@ -0,0 +1,10 @@ +include(RunCMake) +set(RunCMake_TEST_TIMEOUT 60) + +file(WRITE "${RunCMake_BINARY_DIR}/NotAGenerator-build/CPackConfig.cmake" [[ +set(CPACK_PACKAGE_NAME "Test") +set(CPACK_PACKAGE_VERSION "1") +]]) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(NotAGenerator ${CMAKE_CPACK_COMMAND} -G NotAGenerator) +unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 0fafea5..3033c9c 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -141,3 +141,23 @@ function(run_TestOutputSize) ) endfunction() run_TestOutputSize() + +function(run_TestAffinity) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestAffinity) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + # Create a test with affinity enabled. The default PROCESSORS + # value is 1, so our expected output checks that this is the + # number of processors in the mask. + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " + add_test(Affinity \"${TEST_AFFINITY}\") + set_tests_properties(Affinity PROPERTIES PROCESSOR_AFFINITY ON) +") + # Run ctest with a large parallel level so that the value is + # not responsible for capping the number of processors available. + run_cmake_command(TestAffinity ${CMAKE_CTEST_COMMAND} -V -j 64) +endfunction() +if(TEST_AFFINITY) + run_TestAffinity() +endif() diff --git a/Tests/RunCMake/CTestCommandLine/TestAffinity-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestAffinity-stdout.txt new file mode 100644 index 0000000..e23d30b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestAffinity-stdout.txt @@ -0,0 +1 @@ +1: CPU affinity (mask count is '1'|not supported on this platform)\. diff --git a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-OFF.cmake b/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-OFF.cmake deleted file mode 100644 index e69de29..0000000 --- a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-OFF.cmake +++ /dev/null diff --git a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON-stderr.txt deleted file mode 100644 index 2f2cbd3..0000000 --- a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -^CMake Warning: - The "Visual Studio 8 2005" generator is deprecated and will be removed in a - future version of CMake. - - Add CMAKE_WARN_VS8=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 55eac5e..d8dbeec 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -78,13 +78,6 @@ if(RunCMake_GENERATOR STREQUAL "Ninja") unset(RunCMake_TEST_NO_CLEAN) endif() -if(RunCMake_GENERATOR MATCHES "^Visual Studio 8 2005") - set(RunCMake_WARN_VS8 1) - run_cmake(DeprecateVS8-WARN-ON) - unset(RunCMake_WARN_VS8) - run_cmake(DeprecateVS8-WARN-OFF) -endif() - if(UNIX) run_cmake_command(E_create_symlink-no-arg ${CMAKE_COMMAND} -E create_symlink @@ -294,6 +287,10 @@ set(RunCMake_TEST_OPTIONS --trace-expand) run_cmake(trace-expand) unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized) +run_cmake(trace-expand-warn-uninitialized) +unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake) run_cmake(trace-source) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized-stderr.txt b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized-stderr.txt new file mode 100644 index 0000000..74429b6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized-stderr.txt @@ -0,0 +1,2 @@ +^.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.0 \) +.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(2\): project\(trace-expand-warn-uninitialized NONE \) diff --git a/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized.cmake b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized.cmake new file mode 100644 index 0000000..ec3e4d4 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized.cmake @@ -0,0 +1,4 @@ +cmake_policy(SET CMP0053 OLD) +message(STATUS "'${uninitialized_variable}'") +cmake_policy(SET CMP0053 NEW) +message(STATUS "'${uninitialized_variable}'") diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 2486259..5636d00 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -34,6 +34,14 @@ run_cmake(OUTPUT_NAME-recursion) run_cmake(TARGET_PROPERTY-LOCATION) run_cmake(TARGET_PROPERTY-SOURCES) run_cmake(LINK_ONLY-not-linking) +run_cmake(TARGET_EXISTS-no-arg) +run_cmake(TARGET_EXISTS-empty-arg) +run_cmake(TARGET_EXISTS) +run_cmake(TARGET_EXISTS-not-a-target) +run_cmake(TARGET_NAME_IF_EXISTS-no-arg) +run_cmake(TARGET_NAME_IF_EXISTS-empty-arg) +run_cmake(TARGET_NAME_IF_EXISTS) +run_cmake(TARGET_NAME_IF_EXISTS-not-a-target) run_cmake(ImportedTarget-TARGET_BUNDLE_DIR) run_cmake(ImportedTarget-TARGET_BUNDLE_CONTENT_DIR) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-check.cmake new file mode 100644 index 0000000..c4c3a51 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_EXISTS-generated.txt" content) + +set(expected "1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-result.txt diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-stderr.txt new file mode 100644 index 0000000..1df6e28 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at TARGET_EXISTS-empty-arg.cmake:2 \(file\): + Error evaluating generator expression: + + \$<TARGET_EXISTS:> + + \$<TARGET_EXISTS:tgt> expression requires a non-empty valid target name. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg.cmake new file mode 100644 index 0000000..e387abc --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_EXISTS-generated.txt CONTENT "$<TARGET_EXISTS:${empty}>") diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-result.txt diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-stderr.txt new file mode 100644 index 0000000..69e6130 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at TARGET_EXISTS-no-arg.cmake:2 \(file\): + Error evaluating generator expression: + + \$<TARGET_EXISTS> + + \$<TARGET_EXISTS> expression requires exactly one parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg.cmake new file mode 100644 index 0000000..0a5ce32 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_EXISTS-generated.txt CONTENT "$<TARGET_EXISTS>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target-check.cmake new file mode 100644 index 0000000..35ba267 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_EXISTS-not-a-target-generated.txt" content) + +set(expected "0") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target.cmake new file mode 100644 index 0000000..d8a8d3e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_EXISTS-not-a-target-generated.txt CONTENT "$<TARGET_EXISTS:just-random-string>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS.cmake new file mode 100644 index 0000000..9a83b34 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0070 NEW) +add_custom_target(foo) +file(GENERATE OUTPUT TARGET_EXISTS-generated.txt CONTENT "$<TARGET_EXISTS:foo>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake new file mode 100644 index 0000000..2f57430 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_NAME_IF_EXISTS-generated.txt" content) + +set(expected "foo") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt new file mode 100644 index 0000000..5ee13b7 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at TARGET_NAME_IF_EXISTS-empty-arg.cmake:2 \(file\): + Error evaluating generator expression: + + \$<TARGET_NAME_IF_EXISTS:> + + \$<TARGET_NAME_IF_EXISTS:tgt> expression requires a non-empty valid target + name. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake new file mode 100644 index 0000000..f5034f4 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:${empty}>") diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt new file mode 100644 index 0000000..4122425 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at TARGET_NAME_IF_EXISTS-no-arg.cmake:2 \(file\): + Error evaluating generator expression: + + \$<TARGET_NAME_IF_EXISTS> + + \$<TARGET_NAME_IF_EXISTS> expression requires exactly one parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake new file mode 100644 index 0000000..3293094 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake new file mode 100644 index 0000000..2085c16 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake @@ -0,0 +1,5 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_NAME_IF_EXISTS-not-a-target-generated.txt" content) + +if(content) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected an empty string") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake new file mode 100644 index 0000000..a054e6c --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0070 NEW) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-not-a-target-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:just-random-string>") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake new file mode 100644 index 0000000..0ce3b1d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake @@ -0,0 +1,3 @@ +cmake_policy(SET CMP0070 NEW) +add_custom_target(foo) +file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:foo>") diff --git a/Tests/RunCMake/Ninja/RspFileC.cmake b/Tests/RunCMake/Ninja/RspFileC.cmake new file mode 100644 index 0000000..4a40682 --- /dev/null +++ b/Tests/RunCMake/Ninja/RspFileC.cmake @@ -0,0 +1,2 @@ +set(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE} 1) +enable_language(C) diff --git a/Tests/RunCMake/Ninja/RspFileCXX.cmake b/Tests/RunCMake/Ninja/RspFileCXX.cmake new file mode 100644 index 0000000..9e61ffe --- /dev/null +++ b/Tests/RunCMake/Ninja/RspFileCXX.cmake @@ -0,0 +1,2 @@ +set(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE} 1) +enable_language(CXX) diff --git a/Tests/RunCMake/Ninja/RspFileFortran.cmake b/Tests/RunCMake/Ninja/RspFileFortran.cmake new file mode 100644 index 0000000..8c18e37 --- /dev/null +++ b/Tests/RunCMake/Ninja/RspFileFortran.cmake @@ -0,0 +1,2 @@ +set(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE} 1) +enable_language(Fortran) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index b3720fb..3bb2b6b 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -40,6 +40,12 @@ run_CMP0058(NEW-by) run_cmake(CustomCommandDepfile) +run_cmake(RspFileC) +run_cmake(RspFileCXX) +if(TEST_Fortran) + run_cmake(RspFileFortran) +endif() + function(run_CommandConcat) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CommandConcat-build) set(RunCMake_TEST_NO_CLEAN 1) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt deleted file mode 100644 index b91ffd0..0000000 --- a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Error at BadObjSource2.cmake:1 \(add_library\): - OBJECT library "A" contains: - - bad.obj - - but may contain only sources that compile, header files, and other files - that would not affect linking of a normal library. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt index a17c8cd..d1b0d2c 100644 --- a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt +++ b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.10) project(${RunCMake_TEST} C) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-stderr.txt b/Tests/RunCMake/ObjectLibrary/ExportNotSupported-stderr.txt deleted file mode 100644 index 5420159..0000000 --- a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at ExportNotSupported.cmake:[0-9]+ \(export\): - export given OBJECT library "A" which may not be exported under Xcode with - multiple architectures. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/ExportNotSupported.cmake b/Tests/RunCMake/ObjectLibrary/ExportNotSupported.cmake deleted file mode 100644 index a3f104e..0000000 --- a/Tests/RunCMake/ObjectLibrary/ExportNotSupported.cmake +++ /dev/null @@ -1,2 +0,0 @@ -add_library(A OBJECT a.c) -export(TARGETS A FILE AExport.cmake) diff --git a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-result.txt b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-result.txt +++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-result.txt diff --git a/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-stderr.txt b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-stderr.txt new file mode 100644 index 0000000..f2f0f94 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-stderr.txt @@ -0,0 +1 @@ +CMake Error: install\(EXPORT "exp" ...\) includes target "UseA" which requires target "A" that is not in the export set. diff --git a/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1.cmake b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1.cmake new file mode 100644 index 0000000..9e24609 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1.cmake @@ -0,0 +1,6 @@ +add_library(A OBJECT a.c) +add_library(UseA STATIC) +target_link_libraries(UseA PUBLIC A) + +install(TARGETS UseA EXPORT exp ARCHIVE DESTINATION lib) +install(EXPORT exp DESTINATION lib/cmake/exp) diff --git a/Tests/RunCMake/ObjectLibrary/InstallLinkedObj2.cmake b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj2.cmake new file mode 100644 index 0000000..cdda962 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj2.cmake @@ -0,0 +1,6 @@ +add_library(A OBJECT a.c) +add_library(UseA STATIC) +target_link_libraries(UseA PUBLIC A) + +install(TARGETS UseA A EXPORT exp ARCHIVE DESTINATION lib) +install(EXPORT exp DESTINATION lib/cmake/exp) diff --git a/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt b/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt index 35a0e4f..a7004c1 100644 --- a/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt @@ -1,5 +1,5 @@ CMake Error at InstallNotSupported.cmake:[0-9]+ \(install\): - install TARGETS given OBJECT library "A" which may not be installed under - Xcode with multiple architectures. + install TARGETS given OBJECT library "A" whose objects may not be installed + under Xcode with multiple architectures. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt deleted file mode 100644 index 90e828b..0000000 --- a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error at LinkObjLHS.cmake:2 \(target_link_libraries\): - Object library target "AnObjLib" may not link to anything. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake deleted file mode 100644 index 5d7831a..0000000 --- a/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake +++ /dev/null @@ -1,2 +0,0 @@ -add_library(AnObjLib OBJECT a.c) -target_link_libraries(AnObjLib OtherLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake new file mode 100644 index 0000000..4aa7bba --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake @@ -0,0 +1,7 @@ +project(LinkObjLHSShared C) + +add_library(OtherLib SHARED a.c) +target_compile_definitions(OtherLib INTERFACE REQUIRED) + +add_library(AnObjLib OBJECT requires.c) +target_link_libraries(AnObjLib OtherLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHSStatic.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHSStatic.cmake new file mode 100644 index 0000000..261bee7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHSStatic.cmake @@ -0,0 +1,7 @@ +project(LinkObjLHSStatic C) + +add_library(OtherLib STATIC a.c) +target_compile_definitions(OtherLib INTERFACE REQUIRED) + +add_library(AnObjLib OBJECT requires.c) +target_link_libraries(AnObjLib OtherLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt deleted file mode 100644 index d5ee4f9..0000000 --- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at LinkObjRHS1.cmake:3 \(target_link_libraries\): - Target "AnObjLib" of type OBJECT_LIBRARY may not be linked into another - target. One may link only to INTERFACE, STATIC or SHARED libraries, or to - executables with the ENABLE_EXPORTS property set. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake deleted file mode 100644 index 113d6a8..0000000 --- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake +++ /dev/null @@ -1,3 +0,0 @@ -add_library(A STATIC a.c) -add_library(AnObjLib OBJECT a.c) -target_link_libraries(A AnObjLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt deleted file mode 100644 index 3295fca..0000000 --- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at LinkObjRHS2.cmake:1 \(add_library\): - Target "A" links to OBJECT library "AnObjLib" but this is not allowed. One - may link only to STATIC or SHARED libraries, or to executables with the - ENABLE_EXPORTS property set. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake deleted file mode 100644 index 6163729..0000000 --- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake +++ /dev/null @@ -1,3 +0,0 @@ -add_library(A SHARED a.c) -target_link_libraries(A AnObjLib) -add_library(AnObjLib OBJECT a.c) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-result.txt new file mode 100644 index 0000000..e27f06b --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-result.txt @@ -0,0 +1 @@ +[1-9][0-9]* diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-stdout.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-stdout.txt new file mode 100644 index 0000000..4eeb096 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-stdout.txt @@ -0,0 +1 @@ +REQUIRED needs to be defined diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject.cmake new file mode 100644 index 0000000..db571a3 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject.cmake @@ -0,0 +1,12 @@ +cmake_policy(SET CMP0022 NEW) + +enable_language(C) + +add_library(AnObjLib OBJECT a.c) +target_compile_definitions(AnObjLib INTERFACE REQUIRED) + +add_library(AnotherObjLib OBJECT b.c) +target_link_libraries(AnotherObjLib PRIVATE AnObjLib) + +add_executable(exe exe.c) +target_link_libraries(exe AnotherObjLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2-build-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2-build-result.txt new file mode 100644 index 0000000..e27f06b --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2-build-result.txt @@ -0,0 +1 @@ +[1-9][0-9]* diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2.cmake new file mode 100644 index 0000000..6bb8d5e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2.cmake @@ -0,0 +1,12 @@ +cmake_policy(SET CMP0022 NEW) + +enable_language(C) + +add_library(AnObjLib OBJECT a.c) +target_compile_definitions(AnObjLib INTERFACE REQUIRED) + +add_library(AnotherObjLib OBJECT b.c) +target_link_libraries(AnotherObjLib PUBLIC AnObjLib) + +add_executable(exe exe.c) +target_link_libraries(exe AnotherObjLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared.cmake new file mode 100644 index 0000000..b9030b3 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +add_definitions(-DCOMPILE_FOR_SHARED_LIB) + +add_library(AnObjLib OBJECT a.c) +target_compile_definitions(AnObjLib INTERFACE REQUIRED) +set_target_properties(AnObjLib PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_library(A SHARED b.c $<TARGET_OBJECTS:AnObjLib>) +target_link_libraries(A PUBLIC AnObjLib) + +add_executable(exe exe.c) +target_link_libraries(exe A) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared2.cmake new file mode 100644 index 0000000..e2e5fa2 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared2.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +add_definitions(-DCOMPILE_FOR_SHARED_LIB) + +add_library(AnObjLib OBJECT a.c) +target_compile_definitions(AnObjLib INTERFACE REQUIRED) +set_target_properties(AnObjLib PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_library(A SHARED b.c) +target_link_libraries(A PRIVATE AnObjLib) +target_compile_definitions(A INTERFACE $<TARGET_PROPERTY:AnObjLib,INTERFACE_COMPILE_DEFINITIONS>) + +add_executable(exe exe.c) +target_link_libraries(exe A) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic.cmake new file mode 100644 index 0000000..73fad06 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +add_library(AnObjLib OBJECT a.c) +target_compile_definitions(AnObjLib INTERFACE REQUIRED) + +add_library(A STATIC b.c $<TARGET_OBJECTS:AnObjLib>) +target_link_libraries(A PUBLIC AnObjLib) + +add_executable(exe exe.c) +target_link_libraries(exe A) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2.cmake new file mode 100644 index 0000000..9e1ab6d --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2.cmake @@ -0,0 +1,11 @@ +enable_language(C) + +add_library(AnObjLib OBJECT a.c) +target_compile_definitions(AnObjLib INTERFACE REQUIRED) + +add_library(A STATIC b.c) +target_link_libraries(A PRIVATE AnObjLib) +target_compile_definitions(A INTERFACE $<TARGET_PROPERTY:AnObjLib,INTERFACE_COMPILE_DEFINITIONS>) + +add_executable(exe exe.c) +target_link_libraries(exe A) diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt b/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt deleted file mode 100644 index d67b4ae..0000000 --- a/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error at ObjWithObj.cmake:2 \(add_library\): - Only executables and non-OBJECT libraries may reference target objects. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index b8eed73..c73732f 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -6,17 +6,46 @@ run_cmake(BadSourceExpression3) run_cmake(BadObjSource1) run_cmake(BadObjSource2) if(RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") - run_cmake(ExportNotSupported) run_cmake(ImportNotSupported) run_cmake(InstallNotSupported) else() - run_cmake(Export) run_cmake(Import) run_cmake(Install) + run_cmake(InstallLinkedObj1) + run_cmake(InstallLinkedObj2) endif() -run_cmake(LinkObjLHS) -run_cmake(LinkObjRHS1) -run_cmake(LinkObjRHS2) +run_cmake(Export) + +function (run_object_lib_build name) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${name}) + run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .) +endfunction () + +function (run_object_lib_build2 name) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${name}) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .) +endfunction () + +run_object_lib_build(LinkObjLHSShared) +run_object_lib_build(LinkObjLHSStatic) +run_object_lib_build(LinkObjRHSShared) +run_object_lib_build(LinkObjRHSStatic) +run_object_lib_build2(LinkObjRHSObject) +run_object_lib_build(LinkObjRHSShared2) +run_object_lib_build(LinkObjRHSStatic2) +run_object_lib_build2(LinkObjRHSObject2) + run_cmake(MissingSource) run_cmake(ObjWithObj) run_cmake(OwnSources) diff --git a/Tests/RunCMake/ObjectLibrary/a.c b/Tests/RunCMake/ObjectLibrary/a.c index 1636303..5beb3f1 100644 --- a/Tests/RunCMake/ObjectLibrary/a.c +++ b/Tests/RunCMake/ObjectLibrary/a.c @@ -1,4 +1,10 @@ -int a(void) +#if defined(_WIN32) && defined(COMPILE_FOR_SHARED_LIB) +#define EXPORT __declspec(dllexport) +#else +#define EXPORT +#endif + +EXPORT int a(void) { return 0; } diff --git a/Tests/RunCMake/ObjectLibrary/b.c b/Tests/RunCMake/ObjectLibrary/b.c index 6751907..7549abf 100644 --- a/Tests/RunCMake/ObjectLibrary/b.c +++ b/Tests/RunCMake/ObjectLibrary/b.c @@ -1,4 +1,14 @@ -int b(void) +#if defined(_WIN32) && defined(COMPILE_FOR_SHARED_LIB) +#define EXPORT __declspec(dllexport) +#else +#define EXPORT +#endif + +extern int a(void); +EXPORT int b() { - return 0; + return a(); } +#ifndef REQUIRED +#error "REQUIRED needs to be defined" +#endif diff --git a/Tests/RunCMake/ObjectLibrary/exe.c b/Tests/RunCMake/ObjectLibrary/exe.c new file mode 100644 index 0000000..6efdae7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/exe.c @@ -0,0 +1,14 @@ +#if defined(_WIN32) && defined(COMPILE_FOR_SHARED_LIB) +#define IMPORT __declspec(dllimport) +#else +#define IMPORT +#endif + +extern IMPORT int b(void); +int main() +{ + return b(); +} +#ifndef REQUIRED +#error "REQUIRED needs to be defined" +#endif diff --git a/Tests/RunCMake/ObjectLibrary/requires.c b/Tests/RunCMake/ObjectLibrary/requires.c new file mode 100644 index 0000000..d524952 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/requires.c @@ -0,0 +1,8 @@ +#ifdef REQUIRED +int required() +{ + return 0; +} +#else +#error "REQUIRED not defined" +#endif diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index e688830..b2b38ef 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -51,9 +51,6 @@ function(run_cmake test) if(APPLE) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) endif() - if(RunCMake_GENERATOR MATCHES "^Visual Studio 8 2005" AND NOT RunCMake_WARN_VS8) - list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_WARN_VS8=OFF) - endif() if(RunCMake_MAKE_PROGRAM) list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}") endif() @@ -112,6 +109,8 @@ function(run_cmake test) "|clang[^:]*: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled:" "|Error kstat returned" "|Hit xcodebuild bug" + "|ld: 0711-224 WARNING: Duplicate symbol: .__init_aix_libgcc_cxa_atexit" + "|ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information" "|[^\n]*is a member of multiple groups" "|[^\n]*from Time Machine by path" "|[^\n]*Bullseye Testing Technology" diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 8d5139d..5af6fcd 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -23,6 +23,7 @@ \* CMP0065 \* CMP0068 \* CMP0069 + \* CMP0073 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/VS10Project/ExplicitCMakeLists-check.cmake b/Tests/RunCMake/VS10Project/ExplicitCMakeLists-check.cmake new file mode 100644 index 0000000..b671e35 --- /dev/null +++ b/Tests/RunCMake/VS10Project/ExplicitCMakeLists-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(foundCMakeLists 0) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "<([A-Za-z0-9_]+) +Include=.*CMakeLists.txt") + set(rule "${CMAKE_MATCH_1}") + if(NOT rule STREQUAL "CustomBuild") + set(RunCMake_TEST_FAILED "CMakeLists.txt referenced as ${rule} instead of CustomBuild") + return() + endif() + if(foundCMakeLists) + set(RunCMake_TEST_FAILED "CMakeLists.txt referenced multiple times") + return() + endif() + set(foundCMakeLists 1) + endif() +endforeach() +if(NOT foundCMakeLists) + set(RunCMake_TEST_FAILED "CMakeLists.txt not referenced") +endif() diff --git a/Tests/RunCMake/VS10Project/ExplicitCMakeLists.cmake b/Tests/RunCMake/VS10Project/ExplicitCMakeLists.cmake new file mode 100644 index 0000000..c9e4456 --- /dev/null +++ b/Tests/RunCMake/VS10Project/ExplicitCMakeLists.cmake @@ -0,0 +1,3 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +enable_language(CXX) +add_executable(foo foo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 7100b31..e42e662 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,8 +1,12 @@ include(RunCMake) + +run_cmake(ExplicitCMakeLists) + run_cmake(VsConfigurationType) run_cmake(VsTargetsFileReferences) run_cmake(VsCustomProps) run_cmake(VsDebuggerWorkingDir) +run_cmake(VsDebuggerCommand) run_cmake(VsCSharpCustomTags) run_cmake(VsCSharpReferenceProps) run_cmake(VsCSharpWithoutSources) diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake index 45766a0..96be54b 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake @@ -16,8 +16,7 @@ set(fileNames) foreach(e ${fileExtensions}) set(currentFile "${CMAKE_CURRENT_BINARY_DIR}/foo.${e}") list(APPEND fileNames ${currentFile}) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch - "${currentFile}") + file(TOUCH "${currentFile}") string(TOUPPER ${e} eUC) set_source_files_properties("${currentFile}" PROPERTIES diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake new file mode 100644 index 0000000..0ded780 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand-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(debuggerCommandSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command") + message(STATUS "foo.vcxproj has debugger command set") + set(debuggerCommandSet TRUE) + endif() + endif() +endforeach() + +if(NOT debuggerCommandSet) + set(RunCMake_TEST_FAILED "LocalDebuggerCommand not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake new file mode 100644 index 0000000..e29adc4 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + VS_DEBUGGER_COMMAND "my-debugger-command") diff --git a/Tests/RunCMake/WorkingDirectory/CMakeLists.txt.in b/Tests/RunCMake/WorkingDirectory/CMakeLists.txt.in new file mode 100644 index 0000000..46047b8 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/CMakeLists.txt.in @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.11) +project(@CASE_NAME@ NONE) +include("@RunCMake_SOURCE_DIR@/@CASE_NAME@.cmake") diff --git a/Tests/RunCMake/WorkingDirectory/CTestConfig.cmake.in b/Tests/RunCMake/WorkingDirectory/CTestConfig.cmake.in new file mode 100644 index 0000000..0226230 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/CTestConfig.cmake.in @@ -0,0 +1 @@ +set(CTEST_PROJECT_NAME "CTestTestWorkingDir.@CASE_NAME@") diff --git a/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake b/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake new file mode 100644 index 0000000..a7685ae --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCTest) + +run_ctest(dirNotExist) +run_ctest(buildAndTestNoBuildDir + --build-and-test + ${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir + ${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir/CMakeLists.txt # Deliberately a file + --build-generator "${RunCMake_GENERATOR}" +) diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake new file mode 100644 index 0000000..fcfe461 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt) + set(RunCMake_TEST_FAILED "Default build dir ${RunCMake_TEST_BINARY_DIR} was used, should not have been") +endif() diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt new file mode 100644 index 0000000..0617a38 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt @@ -0,0 +1 @@ +^[^0][0-9]*$ diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-stdout.txt b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-stdout.txt new file mode 100644 index 0000000..da89317 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-stdout.txt @@ -0,0 +1 @@ +Failed to change working directory to .*[/\\]buildAndTestNoBuildDir[/\\]CMakeLists.txt : diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake new file mode 100644 index 0000000..ad795c4 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake @@ -0,0 +1,7 @@ +# We want a single test that always passes. We should never actually get to +# configure with this file, so we use a successful configure-build-test +# sequence to denote failure of the test case. +include(CTest) +add_test(NAME willPass + COMMAND ${CMAKE_COMMAND} -E touch someFile.txt +) diff --git a/Tests/RunCMake/WorkingDirectory/dirNotExist-result.txt b/Tests/RunCMake/WorkingDirectory/dirNotExist-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/dirNotExist-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/WorkingDirectory/dirNotExist-stderr.txt b/Tests/RunCMake/WorkingDirectory/dirNotExist-stderr.txt new file mode 100644 index 0000000..3cea890 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/dirNotExist-stderr.txt @@ -0,0 +1 @@ +Failed to change working directory to .*[/\\]dirNotExist-build[/\\]thisDirWillNotExist : diff --git a/Tests/RunCMake/WorkingDirectory/dirNotExist-stdout.txt b/Tests/RunCMake/WorkingDirectory/dirNotExist-stdout.txt new file mode 100644 index 0000000..58aa6e4 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/dirNotExist-stdout.txt @@ -0,0 +1,10 @@ +Test project .*/Tests/RunCMake/WorkingDirectory/dirNotExist-build +.* +Start 1: dirNotExist +1/1 Test #1: dirNotExist +\.+\*\*\*Not Run +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +.* +1 - dirNotExist \(Not Run\)$ diff --git a/Tests/RunCMake/WorkingDirectory/dirNotExist.cmake b/Tests/RunCMake/WorkingDirectory/dirNotExist.cmake new file mode 100644 index 0000000..642386e --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/dirNotExist.cmake @@ -0,0 +1,6 @@ +include(CTest) + +add_test(NAME dirNotExist + COMMAND ${CMAKE_COMMAND} -E touch someFile.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thisDirWillNotExist +) diff --git a/Tests/RunCMake/WorkingDirectory/test.cmake.in b/Tests/RunCMake/WorkingDirectory/test.cmake.in new file mode 100644 index 0000000..8eccd79 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/test.cmake.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.11) + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +ctest_start(Experimental) +ctest_configure() +ctest_build() +ctest_test() diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt index 0445744..f444992 100644 --- a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt +++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt @@ -1,5 +1,6 @@ CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\): Unsupported feature not_a_feature. Call Stack \(most recent call first\): + .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(_check_feature_lists\) InvalidFeature.cmake:4 \(write_compiler_detection_header\) CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake new file mode 100644 index 0000000..3073e0b --- /dev/null +++ b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake @@ -0,0 +1,20 @@ +set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/ExplicitCMakeLists.xcodeproj/project.pbxproj") +if(NOT EXISTS "${xcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.") + return() +endif() + +set(foundCMakeLists 0) +file(STRINGS "${xcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "PBXBuildFile.*fileRef.*CMakeLists.txt") + if(foundCMakeLists) + set(RunCMake_TEST_FAILED "CMakeLists.txt referenced multiple times") + return() + endif() + set(foundCMakeLists 1) + endif() +endforeach() +if(NOT foundCMakeLists) + set(RunCMake_TEST_FAILED "CMakeLists.txt not referenced") +endif() diff --git a/Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake new file mode 100644 index 0000000..678b0ea --- /dev/null +++ b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake @@ -0,0 +1,2 @@ +enable_language(CXX) +add_executable(foo foo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 5eff6b9..1150666 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -4,6 +4,8 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 9) set(IOS_DEPLOYMENT_TARGET "-DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=10") endif() +run_cmake(ExplicitCMakeLists) + run_cmake(XcodeFileType) run_cmake(XcodeAttributeLocation) run_cmake(XcodeAttributeGenex) diff --git a/Tests/RunCMake/add_library/CMP0073-stdout.txt b/Tests/RunCMake/add_library/CMP0073-stdout.txt new file mode 100644 index 0000000..84645b8 --- /dev/null +++ b/Tests/RunCMake/add_library/CMP0073-stdout.txt @@ -0,0 +1,3 @@ +-- warn_LIB_DEPENDS='general;bar;' +-- old_LIB_DEPENDS='general;bar;' +-- new_LIB_DEPENDS='' diff --git a/Tests/RunCMake/add_library/CMP0073.cmake b/Tests/RunCMake/add_library/CMP0073.cmake new file mode 100644 index 0000000..b34f5dc --- /dev/null +++ b/Tests/RunCMake/add_library/CMP0073.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +add_library(warn empty.c) +target_link_libraries(warn bar) +message(STATUS "warn_LIB_DEPENDS='${warn_LIB_DEPENDS}'") + +cmake_policy(SET CMP0073 OLD) +add_library(old empty.c) +target_link_libraries(old bar) +message(STATUS "old_LIB_DEPENDS='${old_LIB_DEPENDS}'") + +cmake_policy(SET CMP0073 NEW) +add_library(new empty.c) +target_link_libraries(new bar) +message(STATUS "new_LIB_DEPENDS='${new_LIB_DEPENDS}'") +if(DEFINED new_LIB_DEPENDS) + message(FATAL_ERROR "new_LIB_DEPENDS set but should not be") +endif() diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt index cd6f1e0..1bcc114 100644 --- a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt +++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt @@ -1,5 +1,4 @@ -^CMake Error at OBJECTwithNoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\): - Object library target \"TestObjectLibWithoutSources\" may not link to - anything. +^CMake Error at OBJECTwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\): + No SOURCES given to target: TestObjectLibWithoutSources Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-stderr.txt deleted file mode 100644 index 77a72f1..0000000 --- a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources-stderr.txt +++ /dev/null @@ -1,16 +0,0 @@ -^CMake Error at OBJECTwithOnlyObjectSources.cmake:[0-9]+ \(add_library\): - OBJECT library \"TestObjectLibWithoutSources\" contains: - - [^ -]*test(\.cpp)?\.o(bj)? - - but may contain only sources that compile, header files, and other files - that would not affect linking of a normal library. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) - - -CMake Error at OBJECTwithOnlyObjectSources.cmake:[0-9]+ \(add_library\): - Only executables and non-OBJECT libraries may reference target objects. -Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_library/RunCMakeTest.cmake b/Tests/RunCMake/add_library/RunCMakeTest.cmake index 0ba6216..dfadb8f 100644 --- a/Tests/RunCMake/add_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_library/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(CMP0073) + run_cmake(INTERFACEwithNoSources) run_cmake(OBJECTwithNoSources) run_cmake(STATICwithNoSources) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON.cmake b/Tests/RunCMake/add_library/empty.c index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON.cmake +++ b/Tests/RunCMake/add_library/empty.c diff --git a/Tests/RunCMake/cmake_minimum_required/Future.cmake b/Tests/RunCMake/cmake_minimum_required/Future.cmake new file mode 100644 index 0000000..2b5c445 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Future.cmake @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.11...99.0 SOME_FUTURE_OPTION) diff --git a/Tests/RunCMake/cmake_minimum_required/Range-stderr.txt b/Tests/RunCMake/cmake_minimum_required/Range-stderr.txt new file mode 100644 index 0000000..7d2bdae --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Range-stderr.txt @@ -0,0 +1,4 @@ +^CMAKE_MINIMUM_REQUIRED_VERSION='3\.10' +CMP0071='NEW' +CMP0072='NEW' +CMP0073=''$ diff --git a/Tests/RunCMake/cmake_minimum_required/Range.cmake b/Tests/RunCMake/cmake_minimum_required/Range.cmake new file mode 100644 index 0000000..0080092 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Range.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.10...3.11) +message("CMAKE_MINIMUM_REQUIRED_VERSION='${CMAKE_MINIMUM_REQUIRED_VERSION}'") +foreach(policy CMP0071 CMP0072 CMP0073) + cmake_policy(GET ${policy} status) + message("${policy}='${status}'") +endforeach() diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt b/Tests/RunCMake/cmake_minimum_required/RangeBad-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt +++ b/Tests/RunCMake/cmake_minimum_required/RangeBad-result.txt diff --git a/Tests/RunCMake/cmake_minimum_required/RangeBad-stderr.txt b/Tests/RunCMake/cmake_minimum_required/RangeBad-stderr.txt new file mode 100644 index 0000000..b2c62fb --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/RangeBad-stderr.txt @@ -0,0 +1,56 @@ +^CMake Error at RangeBad.cmake:1 \(cmake_minimum_required\): + cmake_minimum_required VERSION "3.11..." does not have a version on both + sides of "...". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:2 \(cmake_minimum_required\): + cmake_minimum_required VERSION "...3.11" does not have a version on both + sides of "...". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:3 \(cmake_minimum_required\): + cmake_minimum_required VERSION "..." does not have a version on both sides + of "...". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:4 \(cmake_minimum_required\): + Invalid policy max version value "4". A numeric + major.minor\[.patch\[.tweak\]\] must be given. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:5 \(cmake_minimum_required\): + Policy VERSION range "3.11...3.10" specifies a larger minimum than maximum. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:6 \(cmake_policy\): + cmake_policy VERSION "3.11..." does not have a version on both sides of + "...". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:7 \(cmake_policy\): + cmake_policy VERSION "...3.11" does not have a version on both sides of + "...". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:8 \(cmake_policy\): + cmake_policy VERSION "..." does not have a version on both sides of "...". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:9 \(cmake_policy\): + Invalid policy max version value "4". A numeric + major.minor\[.patch\[.tweak\]\] must be given. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RangeBad.cmake:10 \(cmake_policy\): + Policy VERSION range "3.11...3.10" specifies a larger minimum than maximum. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/cmake_minimum_required/RangeBad.cmake b/Tests/RunCMake/cmake_minimum_required/RangeBad.cmake new file mode 100644 index 0000000..2a2dade --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/RangeBad.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.11...) +cmake_minimum_required(VERSION ...3.11) +cmake_minimum_required(VERSION ...) +cmake_minimum_required(VERSION 3.11...4) +cmake_minimum_required(VERSION 3.11...3.10) +cmake_policy(VERSION 3.11...) +cmake_policy(VERSION ...3.11) +cmake_policy(VERSION ...) +cmake_policy(VERSION 3.11...4) +cmake_policy(VERSION 3.11...3.10) diff --git a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake index e4c65e3..1030211 100644 --- a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake @@ -2,4 +2,8 @@ include(RunCMake) run_cmake(Before24) run_cmake(CompatBefore24) +run_cmake(Future) run_cmake(PolicyBefore24) +run_cmake(Range) +run_cmake(RangeBad) +run_cmake(Unknown) diff --git a/Tests/RunCMake/cmake_minimum_required/Unknown-result.txt b/Tests/RunCMake/cmake_minimum_required/Unknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Unknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_minimum_required/Unknown-stderr.txt b/Tests/RunCMake/cmake_minimum_required/Unknown-stderr.txt new file mode 100644 index 0000000..d698642 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Unknown-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at Unknown.cmake:1 \(cmake_minimum_required\): + cmake_minimum_required called with unknown argument "SOME_UNKNOWN_OPTION". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/cmake_minimum_required/Unknown.cmake b/Tests/RunCMake/cmake_minimum_required/Unknown.cmake new file mode 100644 index 0000000..6c70f91 --- /dev/null +++ b/Tests/RunCMake/cmake_minimum_required/Unknown.cmake @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.11 SOME_UNKNOWN_OPTION) diff --git a/Tests/RunCMake/export/ForbiddenToExportImportedProperties-result.txt b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/export/ForbiddenToExportImportedProperties-stderr.txt b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-stderr.txt new file mode 100644 index 0000000..ab03943 --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-stderr.txt @@ -0,0 +1,3 @@ +CMake Error in CMakeLists.txt: + Target \"foo\" contains property \"IMPORTED_FOOBAR\" in EXPORT_PROPERTIES but + IMPORTED_\* and INTERFACE_\* properties are reserved. diff --git a/Tests/RunCMake/export/ForbiddenToExportImportedProperties.cmake b/Tests/RunCMake/export/ForbiddenToExportImportedProperties.cmake new file mode 100644 index 0000000..9c8653d --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportImportedProperties.cmake @@ -0,0 +1,12 @@ +enable_language(CXX) +add_library(foo empty.cpp) +set_target_properties(foo PROPERTIES + IMPORTED_FOOBAR "Some other string" + EXPORT_PROPERTIES "IMPORTED_FOOBAR" +) +export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-result.txt b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-stderr.txt b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-stderr.txt new file mode 100644 index 0000000..577602b --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-stderr.txt @@ -0,0 +1,3 @@ +CMake Error in CMakeLists.txt: + Target \"foo\" contains property \"INTERFACE_FOOBAR\" in EXPORT_PROPERTIES but + IMPORTED_\* and INTERFACE_\* properties are reserved. diff --git a/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties.cmake b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties.cmake new file mode 100644 index 0000000..bab8de0 --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties.cmake @@ -0,0 +1,12 @@ +enable_language(CXX) +add_library(foo empty.cpp) +set_target_properties(foo PROPERTIES + INTERFACE_FOOBAR "Some string" + EXPORT_PROPERTIES "INTERFACE_FOOBAR" +) +export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-result.txt b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-stderr.txt b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-stderr.txt new file mode 100644 index 0000000..56488e6 --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-stderr.txt @@ -0,0 +1,3 @@ +CMake Error in CMakeLists.txt: + Target \"foo\" contains property \"JUST_A_PROPERTY\" in EXPORT_PROPERTIES but + this property contains a generator expression. This is not allowed. diff --git a/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp.cmake b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp.cmake new file mode 100644 index 0000000..065cdbc --- /dev/null +++ b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp.cmake @@ -0,0 +1,12 @@ +enable_language(CXX) +add_library(foo empty.cpp) +set_target_properties(foo PROPERTIES + JUST_A_PROPERTY "$<C_COMPILER_VERSION:0>" + EXPORT_PROPERTIES "JUST_A_PROPERTY" +) +export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 6d0b7ca..10ced90 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -5,3 +5,6 @@ run_cmake(TargetNotFound) run_cmake(AppendExport) run_cmake(OldIface) run_cmake(NoExportSet) +run_cmake(ForbiddenToExportInterfaceProperties) +run_cmake(ForbiddenToExportImportedProperties) +run_cmake(ForbiddenToExportPropertyWithGenExp) diff --git a/Tests/RunCMake/export/empty.cpp b/Tests/RunCMake/export/empty.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/export/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-build-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-build-stdout.txt new file mode 100644 index 0000000..71ab721 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-build-stdout.txt @@ -0,0 +1 @@ +.*b9fbdd8803c036dbe9f5ea6b74db4b9670c78a72 diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first-stdout.txt new file mode 100644 index 0000000..ff90f9c --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first-stdout.txt @@ -0,0 +1,2 @@ +.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake +.*6bc141b40c0f851d20fa9a1fe5fbdae94acc5de0 diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second-stdout.txt new file mode 100644 index 0000000..cf2a5af --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second-stdout.txt @@ -0,0 +1,2 @@ +.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake +.*0c3ceab9daa7914fde7410c34cae4049e140aa51 diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-stdout.txt new file mode 100644 index 0000000..66b6c44 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-stdout.txt @@ -0,0 +1 @@ +.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake new file mode 100644 index 0000000..fe87c78 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake @@ -0,0 +1,10 @@ +message(STATUS "Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake") +file(GLOB_RECURSE + CONTENT_LIST + CONFIGURE_DEPENDS + LIST_DIRECTORIES false + RELATIVE "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/test/*" + ) +string(SHA1 CONTENT_LIST_HASH "${CONTENT_LIST}") +add_custom_target(CONTENT_ECHO ALL ${CMAKE_COMMAND} -E echo ${CONTENT_LIST_HASH}) diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-result.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-stderr.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-stderr.txt new file mode 100644 index 0000000..40083c1 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-stderr.txt @@ -0,0 +1 @@ +.*CONFIGURE_DEPENDS is invalid for script and find package modes\. diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake new file mode 100644 index 0000000..9dc0f03 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST CONFIGURE_DEPENDS) diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-result.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-stderr.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-stderr.txt new file mode 100644 index 0000000..d7b36eb --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error: The glob expression +.* at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\) +was already present in the glob cache but the directory +contents have changed during the configuration run. +Matching glob expressions: + CONTENT_LIST_1 at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\) + CONTENT_LIST_2 at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\)$ diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified.cmake b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified.cmake new file mode 100644 index 0000000..8d74dea --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified.cmake @@ -0,0 +1,21 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/second") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/third") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "one") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/second/two" "two") +file(GLOB_RECURSE CONTENT_LIST_1 + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/test/*" + ) + +file(GLOB_RECURSE CONTENT_LIST_2 + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/test/*" + ) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/third/three" "three") +file(GLOB_RECURSE CONTENT_LIST_3 + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/test/*" + ) diff --git a/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS-result.txt b/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS-stderr.txt b/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS-stderr.txt new file mode 100644 index 0000000..af3cb2e --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at GLOB-error-FOLLOW_SYMLINKS\.cmake:[0-9]+ \(file\): + file FOLLOW_SYMLINKS is not a valid parameter for GLOB\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS.cmake b/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS.cmake new file mode 100644 index 0000000..6d467a0 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-FOLLOW_SYMLINKS.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST FOLLOW_SYMLINKS) diff --git a/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-result.txt b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-stderr.txt b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-stderr.txt new file mode 100644 index 0000000..30cec89 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at GLOB-error-RELATIVE-no-arg\.cmake:[0-9]+ \(file\): + file GLOB requires a directory after the RELATIVE tag\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg.cmake b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg.cmake new file mode 100644 index 0000000..a555881 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST RELATIVE) diff --git a/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-result.txt b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-stderr.txt b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-stderr.txt new file mode 100644 index 0000000..01d204f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at GLOB-noexp-CONFIGURE_DEPENDS\.cmake:[0-9]+ \(file\): + file GLOB requires a glob expression after CONFIGURE_DEPENDS\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS.cmake b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS.cmake new file mode 100644 index 0000000..9dc0f03 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST CONFIGURE_DEPENDS) diff --git a/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES-result.txt b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES-stderr.txt b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES-stderr.txt new file mode 100644 index 0000000..ee6cb0b --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at GLOB-noexp-LIST_DIRECTORIES\.cmake:[0-9]+ \(file\): + file GLOB requires a glob expression after the bool\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/GLOB-noexp-RELATIVE-result.txt b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB-noexp-RELATIVE-stderr.txt b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-stderr.txt new file mode 100644 index 0000000..9c66631 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at GLOB-noexp-RELATIVE\.cmake:[0-9]+ \(file\): + file GLOB requires a glob expression after the directory\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/GLOB-noexp-RELATIVE.cmake b/Tests/RunCMake/file/GLOB-noexp-RELATIVE.cmake new file mode 100644 index 0000000..7b2d404 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-RELATIVE.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST RELATIVE "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/Tests/RunCMake/file/GLOB-sort-dedup-stderr.txt b/Tests/RunCMake/file/GLOB-sort-dedup-stderr.txt new file mode 100644 index 0000000..d2565e4 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-sort-dedup-stderr.txt @@ -0,0 +1,2 @@ +content: 7[ ] +1aAb/\.hide;1aAb/1\.log;1aAb/1\.txt;1aAb/xkcd\.txt;a/1\.log;a/1\.txt;a/boot\.ini diff --git a/Tests/RunCMake/file/GLOB-sort-dedup.cmake b/Tests/RunCMake/file/GLOB-sort-dedup.cmake new file mode 100644 index 0000000..1e1c579 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-sort-dedup.cmake @@ -0,0 +1,21 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/a") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/a/1.log" "") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/a/1.txt" "") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/a/boot.ini" "") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/.hide" "") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/1.txt" "") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/1.log" "") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/xkcd.txt" "") + +file(GLOB CONTENT_LIST + LIST_DIRECTORIES false + RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test" + "${CMAKE_CURRENT_BINARY_DIR}/test/a/*" + "${CMAKE_CURRENT_BINARY_DIR}/test/*/*" + ) +list(LENGTH CONTENT_LIST CONTENT_COUNT) +message("content: ${CONTENT_COUNT} ") +message("${CONTENT_LIST}") diff --git a/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late-stderr.txt b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late-stderr.txt new file mode 100644 index 0000000..af722a4 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late-stderr.txt @@ -0,0 +1,6 @@ +^CMake Warning \(dev\) at GLOB-warn-CONFIGURE_DEPENDS-late\.cmake:[0-9]+ \(file\): + CONFIGURE_DEPENDS flag was given after a glob expression was already + evaluated\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late.cmake b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late.cmake new file mode 100644 index 0000000..0b69552 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late.cmake @@ -0,0 +1,11 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/second") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "Hi, Mom!") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/second/two" "Love you!") + +file(GLOB CONTENT_LIST + "${CMAKE_CURRENT_BINARY_DIR}/test/first/*" + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/test/second/*" + ) diff --git a/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-result.txt b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-stderr.txt new file mode 100644 index 0000000..d0b2bff --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at GLOB_RECURSE-noexp-FOLLOW_SYMLINKS\.cmake:[0-9]+ \(file\): + file GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS.cmake b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS.cmake new file mode 100644 index 0000000..5e5ce92 --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS.cmake @@ -0,0 +1 @@ +file(GLOB_RECURSE CONTENT_LIST FOLLOW_SYMLINKS) diff --git a/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version-stderr.txt new file mode 100644 index 0000000..8d22332 --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version-stderr.txt @@ -0,0 +1,13 @@ +^CMake Warning \(dev\): + The detected version of Ninja: + + .* + + is less than the version of Ninja required by CMake for adding restat + dependencies to the build\.ninja manifest regeneration target: + + 1\.8 + + Any pre-check scripts, such as those generated for file\(GLOB + CONFIGURE_DEPENDS\), will not be run by Ninja\. +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version.cmake b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version.cmake new file mode 100644 index 0000000..8e80895 --- /dev/null +++ b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version.cmake @@ -0,0 +1,6 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "one") +file(GLOB_RECURSE CONTENT_LIST + CONFIGURE_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/test/*" + ) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 3be4fb7..342606b 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -5,6 +5,9 @@ run_cmake(DOWNLOAD-unused-argument) run_cmake(DOWNLOAD-httpheader-not-set) run_cmake(DOWNLOAD-netrc-bad) run_cmake(DOWNLOAD-pass-not-set) +run_cmake(TOUCH) +run_cmake(TOUCH-error-in-source-directory) +run_cmake(TOUCH-error-missing-directory) run_cmake(UPLOAD-unused-argument) run_cmake(UPLOAD-httpheader-not-set) run_cmake(UPLOAD-netrc-bad) @@ -32,13 +35,87 @@ run_cmake(LOCK-lowercase) run_cmake(READ_ELF) run_cmake(GLOB) run_cmake(GLOB_RECURSE) -# test is valid both for GLOB and GLOB_RECURSE +run_cmake(GLOB_RECURSE-noexp-FOLLOW_SYMLINKS) + +# tests are valid both for GLOB and GLOB_RECURSE +run_cmake(GLOB-sort-dedup) +run_cmake(GLOB-error-FOLLOW_SYMLINKS) 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-error-RELATIVE-no-arg) +run_cmake(GLOB-error-CONFIGURE_DEPENDS-modified) +run_cmake(GLOB-noexp-CONFIGURE_DEPENDS) run_cmake(GLOB-noexp-LIST_DIRECTORIES) +run_cmake(GLOB-noexp-RELATIVE) +run_cmake_command(GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE ${CMAKE_COMMAND} -P + ${RunCMake_SOURCE_DIR}/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake) if(NOT WIN32 OR CYGWIN) run_cmake(GLOB_RECURSE-cyclic-recursion) run_cmake(INSTALL-SYMLINK) endif() + +if(RunCMake_GENERATOR STREQUAL "Ninja") + # Detect ninja version so we know what tests can be supported. + execute_process( + COMMAND "${RunCMake_MAKE_PROGRAM}" --version + OUTPUT_VARIABLE ninja_out + ERROR_VARIABLE ninja_out + RESULT_VARIABLE ninja_res + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(ninja_res EQUAL 0 AND "x${ninja_out}" MATCHES "^x[0-9]+\\.[0-9]+") + set(ninja_version "${ninja_out}") + message(STATUS "ninja version: ${ninja_version}") + else() + message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}") + endif() + + if("${ninja_version}" VERSION_LESS 1.8) + message(STATUS "Ninja is too old for GLOB CONFIGURE_DEPENDS; expect a warning.") + endif() +endif() + +if(RunCMake_GENERATOR STREQUAL "Ninja" AND "${ninja_version}" VERSION_LESS 1.8) + run_cmake(GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version) +else() + run_cmake(GLOB-warn-CONFIGURE_DEPENDS-late) + + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GLOB-CONFIGURE_DEPENDS-RerunCMake-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_DEFAULT_stderr ".*") + if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR + RunCMake_GENERATOR STREQUAL "Watcom WMake") + set(fs_delay 3) + else() + set(fs_delay 1.125) + endif() + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test") + set(tf_1 "${RunCMake_TEST_BINARY_DIR}/test/1.txt") + file(WRITE "${tf_1}" "1") + + message(STATUS "GLOB-RerunCMake: first configuration...") + run_cmake(GLOB-CONFIGURE_DEPENDS-RerunCMake) + run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-build ${CMAKE_COMMAND} --build .) + + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) + message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: add another file...") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test/sub") + set(tf_2 "${RunCMake_TEST_BINARY_DIR}/test/sub/2.txt") + file(WRITE "${tf_2}" "2") + run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first ${CMAKE_COMMAND} --build .) + run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .) + + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) + message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: remove first test file...") + file(REMOVE "${RunCMake_TEST_BINARY_DIR}/test/1.txt") + run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second ${CMAKE_COMMAND} --build .) + run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_DEFAULT_stderr) +endif() diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt b/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt b/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt new file mode 100644 index 0000000..f899c75 --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt @@ -0,0 +1 @@ +.*file attempted to touch a file: diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake b/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake new file mode 100644 index 0000000..9aa7c56 --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake @@ -0,0 +1,2 @@ +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +file(TOUCH "${CMAKE_CURRENT_SOURCE_DIR}/touch_test") diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt b/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt b/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt new file mode 100644 index 0000000..f52e11a --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt @@ -0,0 +1 @@ +.*file problem touching file: diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake b/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake new file mode 100644 index 0000000..0cfb8d9 --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake @@ -0,0 +1 @@ +file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/missing/directory/file.to-touch") diff --git a/Tests/RunCMake/file/TOUCH-result.txt b/Tests/RunCMake/file/TOUCH-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/TOUCH-stderr.txt b/Tests/RunCMake/file/TOUCH-stderr.txt new file mode 100644 index 0000000..9f31676 --- /dev/null +++ b/Tests/RunCMake/file/TOUCH-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at TOUCH\.cmake:[0-9]+ \(file\): + file must be called with at least two arguments\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at TOUCH\.cmake:[0-9]+ \(file\): + file must be called with at least two arguments\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/TOUCH.cmake b/Tests/RunCMake/file/TOUCH.cmake new file mode 100644 index 0000000..8931eb5 --- /dev/null +++ b/Tests/RunCMake/file/TOUCH.cmake @@ -0,0 +1,16 @@ +set(file "${CMAKE_CURRENT_BINARY_DIR}/file-to-touch") + +file(REMOVE "${file}") +file(TOUCH_NOCREATE "${file}") +if(EXISTS "${file}") + message(FATAL_ERROR "error: TOUCH_NOCREATE created a file!") +endif() + +file(TOUCH "${file}") +if(NOT EXISTS "${file}") + message(FATAL_ERROR "error: TOUCH did not create a file!") +endif() +file(REMOVE "${file}") + +file(TOUCH) +file(TOUCH_NOCREATE) diff --git a/Tests/RunCMake/find_package/CMP0074-OLD-stderr.txt b/Tests/RunCMake/find_package/CMP0074-OLD-stderr.txt new file mode 100644 index 0000000..4c2e517 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0074-OLD-stderr.txt @@ -0,0 +1,12 @@ +---------- +Foo_ROOT :<base>/foo/cmake_root +ENV{Foo_ROOT} :<base>/foo/env_root + +find_package\(Foo\) +FOO_TEST_FILE_FOO :FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT :FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO :FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT :FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO :FOO_TEST_PROG_FOO-NOTFOUND + +---------- diff --git a/Tests/RunCMake/find_package/CMP0074-OLD.cmake b/Tests/RunCMake/find_package/CMP0074-OLD.cmake new file mode 100644 index 0000000..4358317 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0074-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0074 OLD) +include(CMP0074-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt new file mode 100644 index 0000000..27fbb86 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt @@ -0,0 +1,32 @@ +---------- +Foo_ROOT :<base>/foo/cmake_root +ENV{Foo_ROOT} :<base>/foo/env_root ++ +CMake Warning \(dev\) at CMP0074-common.cmake:[0-9]+ \(find_package\): + Policy CMP0074 is not set: find_package uses PackageName_ROOT variables. + Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + CMake variable Foo_ROOT is set to: + + .*/Tests/RunCMake/find_package/PackageRoot/foo/cmake_root + + Environment variable Foo_ROOT is set to: + + .*/Tests/RunCMake/find_package/PackageRoot/foo/env_root + + For compatibility, CMake is ignoring the variable. +Call Stack \(most recent call first\): + CMP0074-common.cmake:[0-9]+ \(RunPackageRootTest\) + CMP0074-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +find_package\(Foo\) +FOO_TEST_FILE_FOO :FOO_TEST_FILE_FOO-NOTFOUND +FOO_TEST_FILE_ZOT :FOO_TEST_FILE_ZOT-NOTFOUND +FOO_TEST_PATH_FOO :FOO_TEST_PATH_FOO-NOTFOUND +FOO_TEST_PATH_ZOT :FOO_TEST_PATH_ZOT-NOTFOUND +FOO_TEST_PROG_FOO :FOO_TEST_PROG_FOO-NOTFOUND + +---------- diff --git a/Tests/RunCMake/find_package/CMP0074-WARN.cmake b/Tests/RunCMake/find_package/CMP0074-WARN.cmake new file mode 100644 index 0000000..0d4ada7 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0074-WARN.cmake @@ -0,0 +1,2 @@ +# (do not set CMP0074) +include(CMP0074-common.cmake) diff --git a/Tests/RunCMake/find_package/CMP0074-common.cmake b/Tests/RunCMake/find_package/CMP0074-common.cmake new file mode 100644 index 0000000..bfacd82 --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0074-common.cmake @@ -0,0 +1,46 @@ +# (includer selects CMP0074) +cmake_policy(SET CMP0057 NEW) +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) +set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) + +function(PrintPath label path) + string(REPLACE "${PackageRoot_BASE}" "<base>" out "${path}") + message("${label}${out}") +endfunction() + +macro(CleanUpPackageRootTest) + unset(Foo_ROOT) + unset(ENV{Foo_ROOT}) + unset(FOO_TEST_FILE_FOO) + unset(FOO_TEST_FILE_ZOT) + unset(FOO_TEST_PATH_FOO) + unset(FOO_TEST_PATH_ZOT) + unset(FOO_TEST_PROG_FOO) + unset(FOO_TEST_FILE_FOO CACHE) + unset(FOO_TEST_FILE_ZOT CACHE) + unset(FOO_TEST_PATH_FOO CACHE) + unset(FOO_TEST_PATH_ZOT CACHE) + unset(FOO_TEST_PROG_FOO CACHE) +endmacro() + +macro(RunPackageRootTest) + message("----------") + PrintPath("Foo_ROOT :" "${Foo_ROOT}") + PrintPath("ENV{Foo_ROOT} :" "$ENV{Foo_ROOT}") + message("") + + find_package(Foo) + message("find_package(Foo)") + PrintPath("FOO_TEST_FILE_FOO :" "${FOO_TEST_FILE_FOO}") + PrintPath("FOO_TEST_FILE_ZOT :" "${FOO_TEST_FILE_ZOT}") + PrintPath("FOO_TEST_PATH_FOO :" "${FOO_TEST_PATH_FOO}") + PrintPath("FOO_TEST_PATH_ZOT :" "${FOO_TEST_PATH_ZOT}") + PrintPath("FOO_TEST_PROG_FOO :" "${FOO_TEST_PROG_FOO}") + CleanUpPackageRootTest() + message("") +endmacro() + +set(Foo_ROOT ${PackageRoot_BASE}/foo/cmake_root) +set(ENV{Foo_ROOT} ${PackageRoot_BASE}/foo/env_root) +RunPackageRootTest() +message("----------") diff --git a/Tests/RunCMake/find_package/PackageRoot.cmake b/Tests/RunCMake/find_package/PackageRoot.cmake index 4c4f4c2..aa12e9b 100644 --- a/Tests/RunCMake/find_package/PackageRoot.cmake +++ b/Tests/RunCMake/find_package/PackageRoot.cmake @@ -1,5 +1,5 @@ -set(__UNDOCUMENTED_CMAKE_FIND_PACKAGE_ROOT 1) cmake_policy(SET CMP0057 NEW) +cmake_policy(SET CMP0074 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) diff --git a/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake b/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake index ba06c09..1ef32cb 100644 --- a/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake +++ b/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake @@ -1,5 +1,5 @@ -set(__UNDOCUMENTED_CMAKE_FIND_PACKAGE_ROOT 1) cmake_policy(SET CMP0057 NEW) +cmake_policy(SET CMP0074 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) diff --git a/Tests/RunCMake/find_package/PackageRootNestedModule.cmake b/Tests/RunCMake/find_package/PackageRootNestedModule.cmake index 2795cd4..017834c 100644 --- a/Tests/RunCMake/find_package/PackageRootNestedModule.cmake +++ b/Tests/RunCMake/find_package/PackageRootNestedModule.cmake @@ -1,5 +1,5 @@ -set(__UNDOCUMENTED_CMAKE_FIND_PACKAGE_ROOT 1) cmake_policy(SET CMP0057 NEW) +cmake_policy(SET CMP0074 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index d548da0..c068402 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(CMP0074-WARN) +run_cmake(CMP0074-OLD) run_cmake(ComponentRequiredAndOptional) run_cmake(MissingNormal) run_cmake(MissingNormalRequired) diff --git a/Tests/RunCMake/get_property/directory_properties-stderr.txt b/Tests/RunCMake/get_property/directory_properties-stderr.txt index 6d5bcdb..89f5618 100644 --- a/Tests/RunCMake/get_property/directory_properties-stderr.txt +++ b/Tests/RunCMake/get_property/directory_properties-stderr.txt @@ -19,4 +19,12 @@ get_property: -->[^<;]*/Tests/RunCMake/get_property<-- get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<-- get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<-- get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<-- -get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--$ +get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<-- +get_directory_property: --><-- +get_property: --><-- +get_directory_property: -->test1;test2<-- +get_property: -->test1;test2<-- +get_directory_property: -->test1;test2;test3<-- +get_property: -->test1;test2;test3<-- +get_directory_property: -->Sub/test1;Sub/test2<-- +get_property: -->Sub/test1;Sub/test2<--$ diff --git a/Tests/RunCMake/get_property/directory_properties.cmake b/Tests/RunCMake/get_property/directory_properties.cmake index 4e68738..9b978fd 100644 --- a/Tests/RunCMake/get_property/directory_properties.cmake +++ b/Tests/RunCMake/get_property/directory_properties.cmake @@ -28,3 +28,12 @@ check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BINARY_DIR) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SOURCE_DIR) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BINARY_DIR) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SOURCE_DIR) + +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS) +add_test(NAME test1 COMMAND "${CMAKE_COMMAND}" -E echo "test1") +add_test(NAME test2 COMMAND "${CMAKE_COMMAND}" -E echo "test2") +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS) +add_test(NAME test3 COMMAND "${CMAKE_COMMAND}" -E echo "test3") +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS) + +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" TESTS) diff --git a/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt b/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt index 7318b97..95106ad 100644 --- a/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt +++ b/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt @@ -4,3 +4,6 @@ subdirs(sub2) add_custom_target(CustomSub) add_library(InterfaceSub INTERFACE) add_library(my::InterfaceSub ALIAS InterfaceSub) + +add_test(Sub/test1 COMMAND "${CMAKE_COMMAND}" -E echo "Sub/test1") +add_test(Sub/test2 COMMAND "${CMAKE_COMMAND}" -E echo "Sub/test2") diff --git a/Tests/RunCMake/list/JOIN-NoArguments-result.txt b/Tests/RunCMake/list/JOIN-NoArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/JOIN-NoArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/JOIN-NoArguments-stderr.txt b/Tests/RunCMake/list/JOIN-NoArguments-stderr.txt new file mode 100644 index 0000000..5e1b98f --- /dev/null +++ b/Tests/RunCMake/list/JOIN-NoArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at JOIN-NoArguments.cmake:1 \(list\): + list sub-command JOIN requires three arguments \(1 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/JOIN-NoArguments.cmake b/Tests/RunCMake/list/JOIN-NoArguments.cmake new file mode 100644 index 0000000..2ab449a --- /dev/null +++ b/Tests/RunCMake/list/JOIN-NoArguments.cmake @@ -0,0 +1 @@ +list(JOIN mylist) diff --git a/Tests/RunCMake/list/JOIN-NoVariable-result.txt b/Tests/RunCMake/list/JOIN-NoVariable-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/JOIN-NoVariable-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/JOIN-NoVariable-stderr.txt b/Tests/RunCMake/list/JOIN-NoVariable-stderr.txt new file mode 100644 index 0000000..db1d773 --- /dev/null +++ b/Tests/RunCMake/list/JOIN-NoVariable-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at JOIN-NoVariable.cmake:1 \(list\): + list sub-command JOIN requires three arguments \(2 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/JOIN-NoVariable.cmake b/Tests/RunCMake/list/JOIN-NoVariable.cmake new file mode 100644 index 0000000..b60d8f1 --- /dev/null +++ b/Tests/RunCMake/list/JOIN-NoVariable.cmake @@ -0,0 +1 @@ +list(JOIN mylist "glue") diff --git a/Tests/RunCMake/list/JOIN-TooManyArguments-result.txt b/Tests/RunCMake/list/JOIN-TooManyArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/JOIN-TooManyArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/JOIN-TooManyArguments-stderr.txt b/Tests/RunCMake/list/JOIN-TooManyArguments-stderr.txt new file mode 100644 index 0000000..2b09e22 --- /dev/null +++ b/Tests/RunCMake/list/JOIN-TooManyArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at JOIN-TooManyArguments.cmake:1 \(list\): + list sub-command JOIN requires three arguments \(4 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/JOIN-TooManyArguments.cmake b/Tests/RunCMake/list/JOIN-TooManyArguments.cmake new file mode 100644 index 0000000..dc651f6 --- /dev/null +++ b/Tests/RunCMake/list/JOIN-TooManyArguments.cmake @@ -0,0 +1 @@ +list(JOIN mylist "glue" out one_too_many) diff --git a/Tests/RunCMake/list/JOIN.cmake b/Tests/RunCMake/list/JOIN.cmake new file mode 100644 index 0000000..24a623e --- /dev/null +++ b/Tests/RunCMake/list/JOIN.cmake @@ -0,0 +1,18 @@ +list(JOIN undefList % out) +if(NOT out STREQUAL "") + message(FATAL_ERROR "\"list(JOIN undefList % out)\" set out to \"${out}\"") +endif() +set(myList a) +list(JOIN myList % out) +if(NOT out STREQUAL "a") + message(FATAL_ERROR "\"list(JOIN \"a\" % out)\" set out to \"${out}\"") +endif() +set(myList a b) +list(JOIN myList % out) +if(NOT out STREQUAL "a%b") + message(FATAL_ERROR "\"list(JOIN \"a;b\" % out)\" set out to \"${out}\"") +endif() +list(JOIN myList "" out) +if(NOT out STREQUAL "ab") + message(FATAL_ERROR "\"list(JOIN \"a;b\" \"\" out a)\" set out to \"${out}\"") +endif() diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index b002ab3..3913783 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -13,12 +13,15 @@ run_cmake(FILTER-REGEX-InvalidRegex) run_cmake(GET-InvalidIndex) run_cmake(INSERT-InvalidIndex) run_cmake(REMOVE_AT-InvalidIndex) +run_cmake(SUBLIST-InvalidIndex) run_cmake(FILTER-REGEX-TooManyArguments) +run_cmake(JOIN-TooManyArguments) run_cmake(LENGTH-TooManyArguments) run_cmake(REMOVE_DUPLICATES-TooManyArguments) run_cmake(REVERSE-TooManyArguments) run_cmake(SORT-TooManyArguments) +run_cmake(SUBLIST-TooManyArguments) run_cmake(FILTER-NotList) run_cmake(REMOVE_AT-NotList) @@ -31,3 +34,12 @@ run_cmake(FILTER-REGEX-InvalidMode) run_cmake(FILTER-REGEX-InvalidOperator) run_cmake(FILTER-REGEX-Valid0) run_cmake(FILTER-REGEX-Valid1) + +run_cmake(JOIN-NoArguments) +run_cmake(JOIN-NoVariable) +run_cmake(JOIN) + +run_cmake(SUBLIST-NoArguments) +run_cmake(SUBLIST-NoVariable) +run_cmake(SUBLIST-InvalidLength) +run_cmake(SUBLIST) diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt b/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt b/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt new file mode 100644 index 0000000..5e67b27 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-InvalidIndex.cmake:2 \(list\): + list begin index: 3 is out of range 0 - 2 +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake b/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake new file mode 100644 index 0000000..565b9dc --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(SUBLIST mylist 3 -1 result) diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt b/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt b/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt new file mode 100644 index 0000000..16c6ecb --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-InvalidLength.cmake:2 \(list\): + list length: -2 should be -1 or greater +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake b/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake new file mode 100644 index 0000000..1dab83f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(SUBLIST mylist 0 -2 result) diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt b/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt b/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt new file mode 100644 index 0000000..073173c --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-NoArguments.cmake:1 \(list\): + list sub-command SUBLIST requires four arguments \(1 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments.cmake b/Tests/RunCMake/list/SUBLIST-NoArguments.cmake new file mode 100644 index 0000000..df38b87 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoArguments.cmake @@ -0,0 +1 @@ +list(SUBLIST mylist) diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt b/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt b/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt new file mode 100644 index 0000000..6f80c1a --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-NoVariable.cmake:2 \(list\): + list sub-command SUBLIST requires four arguments \(3 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable.cmake b/Tests/RunCMake/list/SUBLIST-NoVariable.cmake new file mode 100644 index 0000000..83edae9 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-NoVariable.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(SUBLIST mylist 0 -1) diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt b/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt b/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt new file mode 100644 index 0000000..eb46844 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SUBLIST-TooManyArguments.cmake:1 \(list\): + list sub-command SUBLIST requires four arguments \(5 found\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake b/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake new file mode 100644 index 0000000..28f20c1 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake @@ -0,0 +1 @@ +list(SUBLIST mylist 0 -1 result one_too_many) diff --git a/Tests/RunCMake/list/SUBLIST.cmake b/Tests/RunCMake/list/SUBLIST.cmake new file mode 100644 index 0000000..fd15c28 --- /dev/null +++ b/Tests/RunCMake/list/SUBLIST.cmake @@ -0,0 +1,46 @@ +set(mylist alpha bravo charlie delta) +list(SUBLIST mylist 1 2 result) + +if (NOT result STREQUAL "bravo;charlie") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie\"") +endif() + + +unset(result) +list(SUBLIST mylist 0 2 result) + +if (NOT result STREQUAL "alpha;bravo") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"alpha;bravo\"") +endif() + + +unset(result) +list(SUBLIST mylist 3 2 result) + +if (NOT result STREQUAL "delta") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"delta\"") +endif() + + +unset(result) +list(SUBLIST mylist 2 0 result) +list(LENGTH result length) +if (NOT length EQUAL 0) + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is an empty list") +endif() + + +unset(result) +list(SUBLIST mylist 1 5 result) + +if (NOT result STREQUAL "bravo;charlie;delta") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"") +endif() + + +unset(result) +list(SUBLIST mylist 1 -1 result) + +if (NOT result STREQUAL "bravo;charlie;delta") + message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"") +endif() diff --git a/Tests/RunCMake/project/LanguagesUnordered-stderr.txt b/Tests/RunCMake/project/LanguagesUnordered-stderr.txt new file mode 100644 index 0000000..5108670 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesUnordered-stderr.txt @@ -0,0 +1 @@ + the following parameters must be specified after LANGUAGES keyword: C. diff --git a/Tests/RunCMake/project/LanguagesUnordered.cmake b/Tests/RunCMake/project/LanguagesUnordered.cmake new file mode 100644 index 0000000..cd3ba28 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesUnordered.cmake @@ -0,0 +1 @@ +project(ProjectA C LANGUAGES CXX) diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg-stderr.txt b/Tests/RunCMake/project/ProjectDescriptionNoArg-stderr.txt new file mode 100644 index 0000000..910106f --- /dev/null +++ b/Tests/RunCMake/project/ProjectDescriptionNoArg-stderr.txt @@ -0,0 +1,2 @@ + DESCRIPTION keyword not followed by a value or was followed by a value that + expanded to nothing. diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg.cmake b/Tests/RunCMake/project/ProjectDescriptionNoArg.cmake new file mode 100644 index 0000000..25acff8 --- /dev/null +++ b/Tests/RunCMake/project/ProjectDescriptionNoArg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectDescriptionTest VERSION 1.0.0 LANGUAGES NONE DESCRIPTION) diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg2-stderr.txt b/Tests/RunCMake/project/ProjectDescriptionNoArg2-stderr.txt new file mode 100644 index 0000000..910106f --- /dev/null +++ b/Tests/RunCMake/project/ProjectDescriptionNoArg2-stderr.txt @@ -0,0 +1,2 @@ + DESCRIPTION keyword not followed by a value or was followed by a value that + expanded to nothing. diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg2.cmake b/Tests/RunCMake/project/ProjectDescriptionNoArg2.cmake new file mode 100644 index 0000000..f50a2f6 --- /dev/null +++ b/Tests/RunCMake/project/ProjectDescriptionNoArg2.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectDescriptionTest VERSION 1.0.0 DESCRIPTION LANGUAGES NONE) diff --git a/Tests/RunCMake/project/ProjectHomepage-stdout.txt b/Tests/RunCMake/project/ProjectHomepage-stdout.txt new file mode 100644 index 0000000..253990f --- /dev/null +++ b/Tests/RunCMake/project/ProjectHomepage-stdout.txt @@ -0,0 +1,3 @@ +-- PROJECT_HOMEPAGE_URL=http://example.com +-- CMAKE_PROJECT_HOMEPAGE_URL=http://example.com +-- ProjectHomepageTest_HOMEPAGE_URL=http://example.com diff --git a/Tests/RunCMake/project/ProjectHomepage.cmake b/Tests/RunCMake/project/ProjectHomepage.cmake new file mode 100644 index 0000000..3307f1f --- /dev/null +++ b/Tests/RunCMake/project/ProjectHomepage.cmake @@ -0,0 +1,14 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectHomepageTest VERSION 1.0.0 HOMEPAGE_URL "http://example.com" LANGUAGES) +if(NOT PROJECT_HOMEPAGE_URL) + message(FATAL_ERROR "PROJECT_HOMEPAGE_URL expected to be set") +endif() +if(NOT CMAKE_PROJECT_HOMEPAGE_URL) + message(FATAL_ERROR "CMAKE_PROJECT_HOMEPAGE_URL expected to be set") +endif() +if(NOT ProjectHomepageTest_HOMEPAGE_URL) + message(FATAL_ERROR "ProjectHomepageTest_HOMEPAGE_URL expected to be set") +endif() +message(STATUS "PROJECT_HOMEPAGE_URL=${PROJECT_HOMEPAGE_URL}") +message(STATUS "CMAKE_PROJECT_HOMEPAGE_URL=${CMAKE_PROJECT_HOMEPAGE_URL}") +message(STATUS "ProjectHomepageTest_HOMEPAGE_URL=${ProjectHomepageTest_HOMEPAGE_URL}") diff --git a/Tests/RunCMake/project/ProjectHomepage2-result.txt b/Tests/RunCMake/project/ProjectHomepage2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/ProjectHomepage2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/ProjectHomepage2-stderr.txt b/Tests/RunCMake/project/ProjectHomepage2-stderr.txt new file mode 100644 index 0000000..4a0adc2 --- /dev/null +++ b/Tests/RunCMake/project/ProjectHomepage2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at ProjectHomepage2.cmake:2 \(project\): + HOMEPAGE_URL may be specified at most once. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/project/ProjectHomepage2.cmake b/Tests/RunCMake/project/ProjectHomepage2.cmake new file mode 100644 index 0000000..184c392 --- /dev/null +++ b/Tests/RunCMake/project/ProjectHomepage2.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectDescriptionTest VERSION 1.0.0 HOMEPAGE_URL "http://example.com" HOMEPAGE_URL "http://example.com" LANGUAGES) diff --git a/Tests/RunCMake/project/ProjectHomepageNoArg-stderr.txt b/Tests/RunCMake/project/ProjectHomepageNoArg-stderr.txt new file mode 100644 index 0000000..c9503b7 --- /dev/null +++ b/Tests/RunCMake/project/ProjectHomepageNoArg-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning at ProjectHomepageNoArg.cmake:2 \(project\): + HOMEPAGE_URL keyword not followed by a value or was followed by a value + that expanded to nothing. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/project/ProjectHomepageNoArg.cmake b/Tests/RunCMake/project/ProjectHomepageNoArg.cmake new file mode 100644 index 0000000..4605541 --- /dev/null +++ b/Tests/RunCMake/project/ProjectHomepageNoArg.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectDescriptionTest VERSION 1.0.0 LANGUAGES NONE HOMEPAGE_URL) diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index 3d13e2e..e9fb929 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -7,8 +7,14 @@ run_cmake(LanguagesImplicit) run_cmake(LanguagesEmpty) run_cmake(LanguagesNONE) run_cmake(LanguagesTwice) +run_cmake(LanguagesUnordered) run_cmake(ProjectDescription) run_cmake(ProjectDescription2) +run_cmake(ProjectDescriptionNoArg) +run_cmake(ProjectDescriptionNoArg2) +run_cmake(ProjectHomepage) +run_cmake(ProjectHomepage2) +run_cmake(ProjectHomepageNoArg) run_cmake(VersionAndLanguagesEmpty) run_cmake(VersionEmpty) run_cmake(VersionInvalid) diff --git a/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt b/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt index 52433bc..576ac69 100644 --- a/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt +++ b/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt @@ -1,4 +1,5 @@ CMake Error at VersionMissingLanguages.cmake:2 \(project\): - project with VERSION must use LANGUAGES before language names. + project with VERSION, DESCRIPTION or HOMEPAGE_URL must use LANGUAGES before + language names. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/project/VersionMissingValueOkay-stderr.txt b/Tests/RunCMake/project/VersionMissingValueOkay-stderr.txt new file mode 100644 index 0000000..3228df7 --- /dev/null +++ b/Tests/RunCMake/project/VersionMissingValueOkay-stderr.txt @@ -0,0 +1,2 @@ + VERSION keyword not followed by a value or was followed by a value that + expanded to nothing. diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 5b5327d..b966e89 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -9,3 +9,4 @@ run_cmake(LINK_LIBRARIES) run_cmake(SOURCES) run_cmake(TYPE) run_cmake(USER_PROP) +run_cmake(USER_PROP_INHERITED) diff --git a/Tests/RunCMake/set_property/USER_PROP_INHERITED-stdout.txt b/Tests/RunCMake/set_property/USER_PROP_INHERITED-stdout.txt new file mode 100644 index 0000000..dcb0f87 --- /dev/null +++ b/Tests/RunCMake/set_property/USER_PROP_INHERITED-stdout.txt @@ -0,0 +1,29 @@ +-- TopDir-to-nothing chaining: '' +-- TopDir-to-global chaining: 'vGlobal' +-- TopDir no chaining required: 'vTopDir' +-- TopDir unset append chaining: 'aTopDir' +-- TopDir preset append chaining: 'vTopDir;aTopDir' +-- Subdir-to-parent chaining: 'vTopDir' +-- Subdir-to-global chaining: 'vGlobal' +-- Subdir no chaining required: 'vSubdir' +-- Subdir preset append chaining: 'vSubdir;aSubdir' +-- Subdir unset append chaining: 'aSubdir' +-- Subdir undefined append chaining: 'aSubdir' +-- Target-to-directory chaining: 'vTopDir' +-- Target unset append chaining: 'aTarget' +-- Target no chaining required: 'vTarget' +-- Target preset append chaining: 'vTarget;aTarget' +-- Target undefined get chaining: '' +-- Target undefined append chaining: 'aTarget' +-- Source-to-directory chaining: 'vTopDir' +-- Source unset append chaining: 'aSource' +-- Source no chaining required: 'vSource' +-- Source preset append chaining: 'vSource;aSource' +-- Source undefined get chaining: '' +-- Source undefined append chaining: 'aSource' +-- Test-to-directory chaining: 'vTopDir' +-- Test unset append chaining: 'aTest' +-- Test no chaining required: 'vTest' +-- Test preset append chaining: 'vTest;aTest' +-- Test undefined get chaining: '' +-- Test undefined append chaining: 'aTest' diff --git a/Tests/RunCMake/set_property/USER_PROP_INHERITED.cmake b/Tests/RunCMake/set_property/USER_PROP_INHERITED.cmake new file mode 100644 index 0000000..2429866 --- /dev/null +++ b/Tests/RunCMake/set_property/USER_PROP_INHERITED.cmake @@ -0,0 +1,83 @@ +# Needed for source property tests +enable_language(C) + +#================================================= +# Directory property chaining +#================================================= + +foreach(i RANGE 1 5) + foreach(propType DIRECTORY TARGET SOURCE TEST) + define_property(${propType} PROPERTY USER_PROP${i} INHERITED + BRIEF_DOCS "Brief" FULL_DOCS "Full" + ) + endforeach() +endforeach() + +get_property(val DIRECTORY PROPERTY USER_PROP1) +message(STATUS "TopDir-to-nothing chaining: '${val}'") + +set_property(GLOBAL PROPERTY USER_PROP1 vGlobal) +set_property(GLOBAL PROPERTY USER_PROP2 vGlobal) +set_property(DIRECTORY PROPERTY USER_PROP2 vTopDir) +set_property(GLOBAL PROPERTY USER_PROP3 vGlobal) +set_property(DIRECTORY PROPERTY USER_PROP4 vTopDir) + +get_property(val DIRECTORY PROPERTY USER_PROP1) +message(STATUS "TopDir-to-global chaining: '${val}'") + +get_property(val DIRECTORY PROPERTY USER_PROP2) +message(STATUS "TopDir no chaining required: '${val}'") + +set_property(DIRECTORY APPEND PROPERTY USER_PROP3 aTopDir) +get_property(val DIRECTORY PROPERTY USER_PROP3) +message(STATUS "TopDir unset append chaining: '${val}'") + +set_property(DIRECTORY APPEND PROPERTY USER_PROP4 aTopDir) +get_property(val DIRECTORY PROPERTY USER_PROP4) +message(STATUS "TopDir preset append chaining: '${val}'") + +add_subdirectory(USER_PROP_INHERITED) + +#================================================= +# The other property types all chain the same way +#================================================= +macro(__chainToDirTests propType) + string(TOUPPER ${propType} propTypeUpper) + + get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP2) + message(STATUS "${propType}-to-directory chaining: '${val}'") + + set_property(${propTypeUpper} ${propType}1 APPEND PROPERTY USER_PROP2 a${propType}) + get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP2) + message(STATUS "${propType} unset append chaining: '${val}'") + + set_property(${propTypeUpper} ${propType}1 PROPERTY USER_PROP1 v${propType}) + get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP1) + message(STATUS "${propType} no chaining required: '${val}'") + + set_property(${propTypeUpper} ${propType}1 APPEND PROPERTY USER_PROP1 a${propType}) + get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP1) + message(STATUS "${propType} preset append chaining: '${val}'") + + get_property(val ${propTypeUpper} ${propType}2 PROPERTY USER_PROP5) + message(STATUS "${propType} undefined get chaining: '${val}'") + + set_property(${propTypeUpper} ${propType}2 APPEND PROPERTY USER_PROP5 a${propType}) + get_property(val ${propTypeUpper} ${propType}2 PROPERTY USER_PROP5) + message(STATUS "${propType} undefined append chaining: '${val}'") +endmacro() + +add_custom_target(Target1) +add_custom_target(Target2) +__chainToDirTests(Target) + +foreach(i RANGE 1 2) + set(Source${i} "${CMAKE_CURRENT_BINARY_DIR}/src${i}.c") + file(WRITE ${Source${i}} "int foo${i}() { return ${i}; }") +endforeach() +add_library(srcProps OBJECT ${Source1} ${Source2}) +__chainToDirTests(Source) + +add_test(NAME Test1 COMMAND ${CMAKE_COMMAND} -E touch_nocreate iDoNotExist) +add_test(NAME Test2 COMMAND ${CMAKE_COMMAND} -E touch_nocreate iDoNotExist) +__chainToDirTests(Test) diff --git a/Tests/RunCMake/set_property/USER_PROP_INHERITED/CMakeLists.txt b/Tests/RunCMake/set_property/USER_PROP_INHERITED/CMakeLists.txt new file mode 100644 index 0000000..234f4ee --- /dev/null +++ b/Tests/RunCMake/set_property/USER_PROP_INHERITED/CMakeLists.txt @@ -0,0 +1,21 @@ +get_property(val DIRECTORY PROPERTY USER_PROP2) +message(STATUS "Subdir-to-parent chaining: '${val}'") + +get_property(val DIRECTORY PROPERTY USER_PROP1) +message(STATUS "Subdir-to-global chaining: '${val}'") + +set_property(DIRECTORY PROPERTY USER_PROP1 vSubdir) +get_property(val DIRECTORY PROPERTY USER_PROP1) +message(STATUS "Subdir no chaining required: '${val}'") + +set_property(DIRECTORY APPEND PROPERTY USER_PROP1 aSubdir) +get_property(val DIRECTORY PROPERTY USER_PROP1) +message(STATUS "Subdir preset append chaining: '${val}'") + +set_property(DIRECTORY APPEND PROPERTY USER_PROP2 aSubdir) +get_property(val DIRECTORY PROPERTY USER_PROP2) +message(STATUS "Subdir unset append chaining: '${val}'") + +set_property(DIRECTORY APPEND PROPERTY USER_PROP5 aSubdir) +get_property(val DIRECTORY PROPERTY USER_PROP5) +message(STATUS "Subdir undefined append chaining: '${val}'") diff --git a/Tests/RunCMake/string/Join.cmake b/Tests/RunCMake/string/Join.cmake new file mode 100644 index 0000000..081f1e4 --- /dev/null +++ b/Tests/RunCMake/string/Join.cmake @@ -0,0 +1,16 @@ +string(JOIN % out) +if(NOT out STREQUAL "") + message(FATAL_ERROR "\"string(JOIN % out)\" set out to \"${out}\"") +endif() +string(JOIN % out a) +if(NOT out STREQUAL "a") + message(FATAL_ERROR "\"string(JOIN % out a)\" set out to \"${out}\"") +endif() +string(JOIN % out a "b") +if(NOT out STREQUAL "a%b") + message(FATAL_ERROR "\"string(JOIN % out a \"b\")\" set out to \"${out}\"") +endif() +string(JOIN :: out a "b") +if(NOT out STREQUAL "a::b") + message(FATAL_ERROR "\"string(JOIN :: out a \"b\")\" set out to \"${out}\"") +endif() diff --git a/Tests/RunCMake/string/JoinNoArgs-result.txt b/Tests/RunCMake/string/JoinNoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/string/JoinNoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/JoinNoArgs-stderr.txt b/Tests/RunCMake/string/JoinNoArgs-stderr.txt new file mode 100644 index 0000000..d9dcec3 --- /dev/null +++ b/Tests/RunCMake/string/JoinNoArgs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at JoinNoArgs.cmake:1 \(string\): + string sub-command JOIN requires at least two arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/string/JoinNoArgs.cmake b/Tests/RunCMake/string/JoinNoArgs.cmake new file mode 100644 index 0000000..35ba4d9 --- /dev/null +++ b/Tests/RunCMake/string/JoinNoArgs.cmake @@ -0,0 +1 @@ +string(JOIN) diff --git a/Tests/RunCMake/string/JoinNoVar-result.txt b/Tests/RunCMake/string/JoinNoVar-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/string/JoinNoVar-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/string/JoinNoVar-stderr.txt b/Tests/RunCMake/string/JoinNoVar-stderr.txt new file mode 100644 index 0000000..90701a9 --- /dev/null +++ b/Tests/RunCMake/string/JoinNoVar-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at JoinNoVar.cmake:1 \(string\): + string sub-command JOIN requires at least two arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/string/JoinNoVar.cmake b/Tests/RunCMake/string/JoinNoVar.cmake new file mode 100644 index 0000000..35f7b92 --- /dev/null +++ b/Tests/RunCMake/string/JoinNoVar.cmake @@ -0,0 +1 @@ +string(JOIN ";") diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index 513d1e3..211337a 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -9,6 +9,10 @@ run_cmake(PrependNoArgs) run_cmake(Concat) run_cmake(ConcatNoArgs) +run_cmake(Join) +run_cmake(JoinNoArgs) +run_cmake(JoinNoVar) + run_cmake(Timestamp) run_cmake(TimestampEmpty) run_cmake(TimestampInvalid) diff --git a/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt b/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt new file mode 100644 index 0000000..51db19c --- /dev/null +++ b/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt @@ -0,0 +1,2 @@ +var MODIFIED_ACCESS a +var MODIFIED_ACCESS b diff --git a/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake b/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake new file mode 100644 index 0000000..207798e --- /dev/null +++ b/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake @@ -0,0 +1,15 @@ + +function(watch variable access value) + message("${variable} ${access} ${value}") +endfunction () + +# -------------- + +variable_watch(var watch) +set(var "a") + +function(f) + set(var "b" PARENT_SCOPE) +endfunction(f) + +f() diff --git a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake index 2fa6275..3883999 100644 --- a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake +++ b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake @@ -4,3 +4,4 @@ run_cmake(ModifiedAccess) run_cmake(NoWatcher) run_cmake(WatchTwice) run_cmake(ModifyWatchInCallback) +run_cmake(RaiseInParentScope) diff --git a/Tests/Server/CMakeLists.txt b/Tests/Server/CMakeLists.txt index 41d1131..8321edb 100644 --- a/Tests/Server/CMakeLists.txt +++ b/Tests/Server/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.4) project(Server CXX) -find_package(PythonInterp REQUIRED) +find_package(Python REQUIRED) macro(do_test bsname file type) - execute_process(COMMAND ${PYTHON_EXECUTABLE} + execute_process(COMMAND ${Python_EXECUTABLE} -B # no .pyc files "${CMAKE_SOURCE_DIR}/${type}-test.py" "${CMAKE_COMMAND}" diff --git a/Tests/SwigTest/runme.py b/Tests/SwigTest/runme.py deleted file mode 100644 index ed3909e..0000000 --- a/Tests/SwigTest/runme.py +++ /dev/null @@ -1,51 +0,0 @@ -# file: runme.py - -# This file illustrates the shadow-class C++ interface generated -# by SWIG. - -import example - -# ----- Object creation ----- - -print "Creating some objects:" -c = example.Circle(10) -print " Created circle", c -s = example.Square(10) -print " Created square", s - -# ----- Access a static member ----- - -print "\nA total of", example.cvar.Shape_nshapes,"shapes were created" - -# ----- Member data access ----- - -# Set the location of the object - -c.x = 20 -c.y = 30 - -s.x = -10 -s.y = 5 - -print "\nHere is their current position:" -print " Circle = (%f, %f)" % (c.x,c.y) -print " Square = (%f, %f)" % (s.x,s.y) - -# ----- Call some methods ----- - -print "\nHere are some properties of the shapes:" -for o in [c,s]: - print " ", o - print " area = ", o.area() - print " perimeter = ", o.perimeter() - -print "\nGuess I'll clean up now" - -# Note: this invokes the virtual destructor -del c -del s - -s = 3 -print example.cvar.Shape_nshapes,"shapes remain" -print "Goodbye" - diff --git a/Tests/Tutorial/Step7/build2.cmake b/Tests/Tutorial/Step7/build2.cmake deleted file mode 100644 index c2f2e2e..0000000 --- a/Tests/Tutorial/Step7/build2.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(CTEST_SOURCE_DIRECTORY "$ENV{HOME}/Dashboards/My Tests/CMake/Tests/Tutorial/Step7") -set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-build2") -set(CTEST_CMAKE_GENERATOR "Visual Studio 8 2005") - -CTEST_START("Experimental") -CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}") -CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}") -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}") -CTEST_SUBMIT() diff --git a/Tests/UseSWIG/BasicConfiguration.cmake b/Tests/UseSWIG/BasicConfiguration.cmake new file mode 100644 index 0000000..d025d2a --- /dev/null +++ b/Tests/UseSWIG/BasicConfiguration.cmake @@ -0,0 +1,79 @@ + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +# Path separator +if (WIN32) + set (PS "$<SEMICOLON>") +else() + set (PS ":") +endif() + +unset(SWIG_LANG_TYPE) +unset(SWIG_LANG_INCLUDE_DIRECTORIES) +unset(SWIG_LANG_DEFINITIONS) +unset(SWIG_LANG_OPTIONS) +unset(SWIG_LANG_LIBRARIES) + +if(${language} MATCHES python) + find_package(Python REQUIRED COMPONENTS Interpreter Development) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${Python_INCLUDE_DIRS}) + set(SWIG_LANG_LIBRARIES ${Python_LIBRARIES}) +endif() +if(${language} MATCHES perl) + find_package(Perl REQUIRED) + find_package(PerlLibs REQUIRED) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${PERL_INCLUDE_PATH}) + separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}") + set(SWIG_LANG_OPTIONS ${c_flags}) + set(SWIG_LANG_LIBRARIES ${PERL_LIBRARY}) +endif() +if(${language} MATCHES tcl) + find_package(TCL REQUIRED) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${TCL_INCLUDE_PATH}) + set(SWIG_LANG_LIBRARIES ${TCL_LIBRARY}) +endif() +if(${language} MATCHES ruby) + find_package(Ruby REQUIRED) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${RUBY_INCLUDE_PATH}) + set(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY}) +endif() +if(${language} MATCHES php4) + find_package(PHP4 REQUIRED) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${PHP4_INCLUDE_PATH}) + set(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY}) +endif() +if(${language} MATCHES pike) + find_package(Pike REQUIRED) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${PIKE_INCLUDE_PATH}) + set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY}) +endif() +if(${language} MATCHES lua) + find_package(Lua REQUIRED) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR}) + set(SWIG_LANG_TYPE TYPE SHARED) + set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES}) +endif() + +unset(CMAKE_SWIG_FLAGS) + +set (CMAKE_INCLUDE_CURRENT_DIR ON) + +set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY COMPILE_OPTIONS -includeall) + +set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" + PROPERTY GENERATED_INCLUDE_DIRECTORIES ${SWIG_LANG_INCLUDE_DIRECTORIES} + "${CMAKE_CURRENT_LIST_DIR}") +set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" + PROPERTY GENERATED_COMPILE_DEFINITIONS ${SWIG_LANG_DEFINITIONS}) +set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" + PROPERTY GENERATED_COMPILE_OPTIONS ${SWIG_LANG_OPTIONS}) + + +SWIG_ADD_LIBRARY(example + LANGUAGE "${language}" + ${SWIG_LANG_TYPE} + SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i" + "${CMAKE_CURRENT_LIST_DIR}/example.cxx") +TARGET_LINK_LIBRARIES(example PRIVATE ${SWIG_LANG_LIBRARIES}) diff --git a/Tests/UseSWIG/BasicPerl/CMakeLists.txt b/Tests/UseSWIG/BasicPerl/CMakeLists.txt new file mode 100644 index 0000000..476ef0e --- /dev/null +++ b/Tests/UseSWIG/BasicPerl/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestBasicPerl CXX) + +include(CTest) + +set(language "perl") + +include (../BasicConfiguration.cmake) + +add_test (NAME BasicPerl + COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}" + "-I$<TARGET_FILE_DIR:example>" + "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl") diff --git a/Tests/UseSWIG/BasicPython/CMakeLists.txt b/Tests/UseSWIG/BasicPython/CMakeLists.txt new file mode 100644 index 0000000..cf1d821 --- /dev/null +++ b/Tests/UseSWIG/BasicPython/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestBasicPython CXX) + +include(CTest) + +set(language "python") + +include (../BasicConfiguration.cmake) + +add_test (NAME BasicPython + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:example>" + "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt new file mode 100644 index 0000000..0c4ec8a --- /dev/null +++ b/Tests/UseSWIG/CMakeLists.txt @@ -0,0 +1,76 @@ +add_test(NAME UseSWIG.LegacyPython COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPython" + "${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPython" + ${build_generator_args} + --build-project TestLegacyPython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +add_test(NAME UseSWIG.LegacyPerl COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPerl" + "${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPerl" + ${build_generator_args} + --build-project TestLegacyPerl + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + +add_test(NAME UseSWIG.BasicPython COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPython" + "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPython" + ${build_generator_args} + --build-project TestBasicPython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +add_test(NAME UseSWIG.BasicPerl COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPerl" + "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPerl" + ${build_generator_args} + --build-project TestBasicPerl + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + +add_test(NAME UseSWIG.MultipleModules COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultipleModules" + "${CMake_BINARY_DIR}/Tests/UseSWIG/MultipleModules" + ${build_generator_args} + --build-project TestMultipleModules + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +add_test(NAME UseSWIG.MultiplePython COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultiplePython" + "${CMake_BINARY_DIR}/Tests/UseSWIG/MultiplePython" + ${build_generator_args} + --build-project TestMultiplePython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + +add_test(NAME UseSWIG.ModuleVersion2 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleVersion2" + "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleVersion2" + ${build_generator_args} + --build-project TestModuleVersion2 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/SwigTest/CMakeLists.txt b/Tests/UseSWIG/LegacyConfiguration.cmake index 65f5c93..1acc05a 100644 --- a/Tests/SwigTest/CMakeLists.txt +++ b/Tests/UseSWIG/LegacyConfiguration.cmake @@ -1,59 +1,68 @@ -set(language "python") -cmake_minimum_required (VERSION 2.6) - -project(example_${language}_class) +# Prevent deprecated warnings from new UseSWIG module +set (CMAKE_WARN_DEPRECATED FALSE) find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) +# Path separator +if (WIN32) + set (PS "$<SEMICOLON>") +else() + set (PS ":") +endif() + unset(SWIG_LANG_TYPE) if(${language} MATCHES python) - find_package(PythonLibs) + find_package(PythonInterp REQUIRED) + find_package(PythonLibs REQUIRED) include_directories(${PYTHON_INCLUDE_PATH}) set(SWIG_LANG_LIBRARIES ${PYTHON_LIBRARIES}) endif() if(${language} MATCHES perl) - find_package(PerlLibs) + find_package(Perl REQUIRED) + find_package(PerlLibs REQUIRED) include_directories(${PERL_INCLUDE_PATH}) - add_definitions(${PERL_EXTRA_C_FLAGS}) + separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}") + add_compile_options(${c_flags}) set(SWIG_LANG_LIBRARIES ${PERL_LIBRARY}) endif() if(${language} MATCHES tcl) - find_package(TCL) + find_package(TCL REQUIRED) include_directories(${TCL_INCLUDE_PATH}) set(SWIG_LANG_LIBRARIES ${TCL_LIBRARY}) endif() if(${language} MATCHES ruby) - find_package(Ruby) + find_package(Ruby REQUIRED) include_directories(${RUBY_INCLUDE_PATH}) set(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY}) endif() if(${language} MATCHES php4) - find_package(PHP4) + find_package(PHP4 REQUIRED) include_directories(${PHP4_INCLUDE_PATH}) set(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY}) endif() if(${language} MATCHES pike) - find_package(Pike) + find_package(Pike REQUIRED) include_directories(${PIKE_INCLUDE_PATH}) set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY}) endif() if(${language} MATCHES lua) - find_package(Lua) + find_package(Lua REQUIRED) include_directories(${LUA_INCLUDE_DIR}) set(SWIG_LANG_TYPE TYPE SHARED) set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES}) endif() -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +unset(CMAKE_SWIG_FLAGS) -set(CMAKE_SWIG_FLAGS "") +include_directories(${CMAKE_CURRENT_LIST_DIR}) -set_source_files_properties(example.i PROPERTIES CPLUSPLUS ON) -set_source_files_properties(example.i PROPERTIES SWIG_FLAGS "-includeall") +set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES CPLUSPLUS ON) +set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES SWIG_FLAGS "-includeall") SWIG_ADD_LIBRARY(example LANGUAGE "${language}" ${SWIG_LANG_TYPE} - SOURCES example.i example.cxx) + SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i" + "${CMAKE_CURRENT_LIST_DIR}/example.cxx") SWIG_LINK_LIBRARIES(example ${SWIG_LANG_LIBRARIES}) diff --git a/Tests/UseSWIG/LegacyPerl/CMakeLists.txt b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt new file mode 100644 index 0000000..90d92f4 --- /dev/null +++ b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestLegacyPerl CXX) + +include(CTest) + +set(language "perl") + +include (../LegacyConfiguration.cmake) + +add_test (NAME LegacyPerl + COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}" + "-I$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>" + "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl") diff --git a/Tests/UseSWIG/LegacyPython/CMakeLists.txt b/Tests/UseSWIG/LegacyPython/CMakeLists.txt new file mode 100644 index 0000000..03facb1 --- /dev/null +++ b/Tests/UseSWIG/LegacyPython/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestLegacyPython CXX) + +include(CTest) + +set(language "python") + +include (../LegacyConfiguration.cmake) + +add_test (NAME LegacyPython + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>" + "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt new file mode 100644 index 0000000..3f9d363 --- /dev/null +++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestModuleVersion2 CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + +if (WIN32) + set (PS $<SEMICOLON>) +else() + set (PS ":") +endif() + +set (UseSWIG_MODULE_VERSION 2) +unset(CMAKE_SWIG_FLAGS) + +set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall) + +set_property(SOURCE "../example.i" + PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..") + +swig_add_library(example1 + LANGUAGE python + SOURCES ../example.i ../example.cxx) +set_target_properties (example1 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2") +target_link_libraries(example1 PRIVATE Python2::Python) + +# re-use sample interface file for another plugin +swig_add_library(example2 + LANGUAGE python + SOURCES ../example.i ../example.cxx) +set_target_properties (example2 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3") +target_link_libraries(example2 PRIVATE Python3::Python) + + +add_test (NAME ModuleVersion2.example1 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example1,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example1>" + "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") + +add_test (NAME ModuleVersion2.example2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example2,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example2>" + "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/UseSWIG/MultipleModules/CMakeLists.txt b/Tests/UseSWIG/MultipleModules/CMakeLists.txt new file mode 100644 index 0000000..578825f --- /dev/null +++ b/Tests/UseSWIG/MultipleModules/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestMultipleModules CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python REQUIRED COMPONENTS Interpreter Development) + +find_package(Perl REQUIRED) +find_package(PerlLibs REQUIRED) + +# Path separator +if (WIN32) + set (PS "$<SEMICOLON>") +else() + set (PS ":") +endif() + +unset(CMAKE_SWIG_FLAGS) + +set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall) + +set_property(SOURCE "../example.i" + PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..") + +swig_add_library(example1 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python" + SOURCES ../example.i ../example.cxx) +set_target_properties (example1 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python") +target_link_libraries(example1 PRIVATE Python::Python) + +# re-use sample interface file for another plugin +set_property(SOURCE "../example.i" APPEND PROPERTY + GENERATED_INCLUDE_DIRECTORIES ${PERL_INCLUDE_PATH}) +separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}") +set_property(SOURCE "../example.i" PROPERTY GENERATED_COMPILE_OPTIONS ${c_flags}) + +swig_add_library(example2 + LANGUAGE perl + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Perl" + SOURCES ../example.i ../example.cxx) +set_target_properties (example2 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl") +target_link_libraries(example2 PRIVATE ${PERL_LIBRARY}) + + + +add_test (NAME MultipleModules.Python + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python${PS}$<TARGET_FILE_DIR:example1>" + "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") + + +add_test (NAME MultipleModules.Perl + COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}/Perl" + "-I$<TARGET_FILE_DIR:example2>" + "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl") diff --git a/Tests/UseSWIG/MultiplePython/CMakeLists.txt b/Tests/UseSWIG/MultiplePython/CMakeLists.txt new file mode 100644 index 0000000..a5e3eed --- /dev/null +++ b/Tests/UseSWIG/MultiplePython/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestMultiplePython CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + +# Path separator +if (WIN32) + set (PS "$<SEMICOLON>") +else() + set (PS ":") +endif() + +unset(CMAKE_SWIG_FLAGS) + +set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall) + +set_property(SOURCE "../example.i" + PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..") + +swig_add_library(example1 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python2" + SOURCES ../example.i ../example.cxx) +set_target_properties (example1 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2") +target_link_libraries(example1 PRIVATE Python2::Python) + +# re-use sample interface file for another plugin +swig_add_library(example2 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python3" + SOURCES ../example.i ../example.cxx) +set_target_properties (example2 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3") +target_link_libraries(example2 PRIVATE Python3::Python) + + + +add_test (NAME MultiplePython.example1 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>" + "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") + +add_test (NAME MultiplePython.example2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python3${PS}$<TARGET_FILE_DIR:example2>" + "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/SwigTest/example.cxx b/Tests/UseSWIG/example.cxx index 961d6dd..961d6dd 100644 --- a/Tests/SwigTest/example.cxx +++ b/Tests/UseSWIG/example.cxx diff --git a/Tests/SwigTest/example.h b/Tests/UseSWIG/example.h index 366deb0..366deb0 100644 --- a/Tests/SwigTest/example.h +++ b/Tests/UseSWIG/example.h diff --git a/Tests/SwigTest/example.i b/Tests/UseSWIG/example.i index 75700b3..fbdf724 100644 --- a/Tests/SwigTest/example.i +++ b/Tests/UseSWIG/example.i @@ -7,4 +7,3 @@ /* Let's just grab the original header file here */ %include "example.h" - diff --git a/Tests/SwigTest/runme.php4 b/Tests/UseSWIG/runme.php4 index 653ced2..653ced2 100644 --- a/Tests/SwigTest/runme.php4 +++ b/Tests/UseSWIG/runme.php4 diff --git a/Tests/SwigTest/runme.pike b/Tests/UseSWIG/runme.pike index ec28dd7..ec28dd7 100755..100644 --- a/Tests/SwigTest/runme.pike +++ b/Tests/UseSWIG/runme.pike diff --git a/Tests/SwigTest/runme.pl b/Tests/UseSWIG/runme.pl index 5bfb3d8..965e063 100644 --- a/Tests/SwigTest/runme.pl +++ b/Tests/UseSWIG/runme.pl @@ -54,4 +54,3 @@ examplec::delete_Shape($s); print $examplec::Shape_nshapes," shapes remain\n"; print "Goodbye\n"; - diff --git a/Tests/UseSWIG/runme.py b/Tests/UseSWIG/runme.py new file mode 100644 index 0000000..af5e07d --- /dev/null +++ b/Tests/UseSWIG/runme.py @@ -0,0 +1,52 @@ +# file: runme.py + +# This file illustrates the shadow-class C++ interface generated +# by SWIG. + +from __future__ import print_function + +import example + +# ----- Object creation ----- + +print ("Creating some objects:") +c = example.Circle(10) +print (" Created circle", c) +s = example.Square(10) +print (" Created square", s) + +# ----- Access a static member ----- + +print ("\nA total of", example.cvar.Shape_nshapes,"shapes were created") + +# ----- Member data access ----- + +# Set the location of the object + +c.x = 20 +c.y = 30 + +s.x = -10 +s.y = 5 + +print ("\nHere is their current position:") +print (" Circle = (%f, %f)" % (c.x,c.y)) +print (" Square = (%f, %f)" % (s.x,s.y)) + +# ----- Call some methods ----- + +print ("\nHere are some properties of the shapes:") +for o in [c,s]: + print (" ", o) + print (" area = ", o.area()) + print (" perimeter = ", o.perimeter()) + +print ("\nGuess I'll clean up now") + +# Note: this invokes the virtual destructor +del c +del s + +s = 3 +print (example.cvar.Shape_nshapes,"shapes remain") +print ("Goodbye") diff --git a/Tests/SwigTest/runme.rb b/Tests/UseSWIG/runme.rb index de73bcd..de73bcd 100644 --- a/Tests/SwigTest/runme.rb +++ b/Tests/UseSWIG/runme.rb diff --git a/Tests/SwigTest/runme.tcl b/Tests/UseSWIG/runme.tcl index c7f4725..6055cf6 100644 --- a/Tests/SwigTest/runme.tcl +++ b/Tests/UseSWIG/runme.tcl @@ -47,4 +47,3 @@ rename s "" puts "$Shape_nshapes shapes remain" puts "Goodbye" - diff --git a/Tests/SwigTest/runme2.tcl b/Tests/UseSWIG/runme2.tcl index 88ec2f6..d0b5c21 100644 --- a/Tests/SwigTest/runme2.tcl +++ b/Tests/UseSWIG/runme2.tcl @@ -67,4 +67,3 @@ delete_Shape $s puts "$Shape_nshapes shapes remain" puts "Goodbye" - |