diff options
author | Slava Barinov <v.barinov@samsung.com> | 2020-01-28 11:52:09 +0300 |
---|---|---|
committer | Slava Barinov <v.barinov@samsung.com> | 2020-01-28 11:52:09 +0300 |
commit | 5a33b45a98929bb730e6a11818416edd27e8fc00 (patch) | |
tree | 48aa69f9fd46c2519bd57037689d6b1a61765bda /Tests | |
parent | 4f290facafe45c5f05ceff7bc1f6aa9340273ea4 (diff) | |
download | cmake-5a33b45a98929bb730e6a11818416edd27e8fc00.tar.gz cmake-5a33b45a98929bb730e6a11818416edd27e8fc00.tar.bz2 cmake-5a33b45a98929bb730e6a11818416edd27e8fc00.zip |
Version upgrade
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Diffstat (limited to 'Tests')
882 files changed, 8134 insertions, 4122 deletions
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt index e156420db..fc7013598 100644 --- a/Tests/AliasTarget/CMakeLists.txt +++ b/Tests/AliasTarget/CMakeLists.txt @@ -4,13 +4,6 @@ project(AliasTarget) set(CMAKE_CXX_STANDARD 98) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/AliasTarget/bat.cpp b/Tests/AliasTarget/bat.cpp index cb76bfe2f..14942bf1c 100644 --- a/Tests/AliasTarget/bat.cpp +++ b/Tests/AliasTarget/bat.cpp @@ -1,22 +1,22 @@ #ifndef FOO_DEFINE -#error Expected FOO_DEFINE +# error Expected FOO_DEFINE #endif #ifndef BAR_DEFINE -#error Expected Bar_DEFINE +# error Expected Bar_DEFINE #endif #include "commandoutput.h" #ifndef COMMANDOUTPUT_DEFINE -#error Expected COMMANDOUTPUT_DEFINE +# error Expected COMMANDOUTPUT_DEFINE #endif #include "targetoutput.h" #ifndef TARGETOUTPUT_DEFINE -#error Expected TARGETOUTPUT_DEFINE +# error Expected TARGETOUTPUT_DEFINE #endif #ifdef _WIN32 diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 11978dbf8..39a5131fe 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() @@ -345,6 +345,17 @@ is not newer than dependency ${TEST_LINK_DEPENDS} ") endif() + + set(linkdep2 ${BuildDepends_BINARY_DIR}/Project/linkdep2${CMAKE_EXECUTABLE_SUFFIX}) + if(${linkdep2} IS_NEWER_THAN ${TEST_LINK_DEPENDS}) + message("INTERFACE_LINK_DEPENDS worked") + else() + message(SEND_ERROR "INTERFACE_LINK_DEPENDS failed. Executable + ${linkdep2} +is not newer than dependency + ${TEST_LINK_DEPENDS} +") + endif() endif() if(EXISTS "${link_depends_no_shared_check_txt}") diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 3aa57fc9e..3f41b26d0 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -1,30 +1,30 @@ cmake_minimum_required(VERSION 2.6) project(testRebuild) -function(test_for_xcode4 result_var) - set(${result_var} 0 PARENT_SCOPE) - if(APPLE) - execute_process(COMMAND xcodebuild -version - OUTPUT_VARIABLE ov RESULT_VARIABLE rv +if(APPLE) + set(CMake_TEST_XCODE_VERSION 0) + if(XCODE_VERSION) + set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}") + else() + execute_process( + COMMAND xcodebuild -version + OUTPUT_VARIABLE _version ERROR_VARIABLE _version ) - if("${rv}" STREQUAL "0" AND ov MATCHES "^Xcode ([0-9]+)\\.") - if(NOT CMAKE_MATCH_1 VERSION_LESS 4) - set(${result_var} 1 PARENT_SCOPE) - endif() + if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)") + set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}") endif() endif() -endfunction() - -if(APPLE) # only use multi-arch if the sysroot exists on this machine # Ninja needs -M which could not be used with multiple -arch flags if(EXISTS "${CMAKE_OSX_SYSROOT}" AND NOT "${CMAKE_GENERATOR}" MATCHES "Ninja") - set(CMAKE_OSX_ARCHITECTURES "ppc;i386") - test_for_xcode4(is_xcode4) - if(is_xcode4) - # Xcode 4, use modern architectures as defaults - # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 + if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 10) + # Arch 'i386' no longer works in Xcode 10. + set(CMAKE_OSX_ARCHITECTURES x86_64) + elseif(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 4) + # Arch 'ppc' no longer works in Xcode 4. set(CMAKE_OSX_ARCHITECTURES i386 x86_64) + else() + set(CMAKE_OSX_ARCHITECTURES ppc i386) endif() endif() endif() @@ -106,7 +106,12 @@ set_property( if(TEST_LINK_DEPENDS) add_executable(linkdep linkdep.cxx) - set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS}) + set_property(TARGET linkdep PROPERTY LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>) + + add_library(foo_interface INTERFACE) + set_property(TARGET foo_interface PROPERTY INTERFACE_LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>) + add_executable(linkdep2 linkdep.cxx) + target_link_libraries(linkdep2 PRIVATE foo_interface) endif() add_library(link_depends_no_shared_lib SHARED link_depends_no_shared_lib.c diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx index 9ae802f5b..2e4325cf9 100644 --- a/Tests/BundleTest/BundleLib.cxx +++ b/Tests/BundleTest/BundleLib.cxx @@ -8,7 +8,7 @@ int fileExists(char* filename) { #ifndef R_OK -#define R_OK 04 +# define R_OK 04 #endif if (access(filename, R_OK) != 0) { printf("Cannot find file: %s\n", filename); diff --git a/Tests/BundleTest/BundleSubDir/CMakeLists.txt b/Tests/BundleTest/BundleSubDir/CMakeLists.txt index 43c366a09..2f7f2c44b 100644 --- a/Tests/BundleTest/BundleSubDir/CMakeLists.txt +++ b/Tests/BundleTest/BundleSubDir/CMakeLists.txt @@ -1,3 +1,5 @@ +project(BundleSubDir) + add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" COMMAND /bin/cp @@ -34,3 +36,8 @@ install(TARGETS SecondBundle DESTINATION Applications) # bundle does not respect the name. Also the executable will not be found by # the test driver if this does not work. set_target_properties(SecondBundle PROPERTIES OUTPUT_NAME SecondBundleExe) + +# Express one app bundle in terms of another's SOURCES to verify that +# the generators do not expose the Info.plist of one to the other. +add_executable(SubdirBundle1 MACOSX_BUNDLE EXCLUDE_FROM_ALL ../BundleTest.cxx) +add_executable(SubdirBundle2 MACOSX_BUNDLE EXCLUDE_FROM_ALL $<TARGET_PROPERTY:SubdirBundle1,SOURCES>) diff --git a/Tests/BundleUtilities/framework.h b/Tests/BundleUtilities/framework.h index 343317c59..5a3cfc457 100644 --- a/Tests/BundleUtilities/framework.h +++ b/Tests/BundleUtilities/framework.h @@ -3,13 +3,13 @@ #define framework_h #ifdef WIN32 -#ifdef framework_EXPORTS -#define FRAMEWORK_EXPORT __declspec(dllexport) +# ifdef framework_EXPORTS +# define FRAMEWORK_EXPORT __declspec(dllexport) +# else +# define FRAMEWORK_EXPORT __declspec(dllimport) +# endif #else -#define FRAMEWORK_EXPORT __declspec(dllimport) -#endif -#else -#define FRAMEWORK_EXPORT +# define FRAMEWORK_EXPORT #endif void FRAMEWORK_EXPORT framework(); diff --git a/Tests/BundleUtilities/shared.h b/Tests/BundleUtilities/shared.h index 28904fd78..5d5b6335c 100644 --- a/Tests/BundleUtilities/shared.h +++ b/Tests/BundleUtilities/shared.h @@ -3,13 +3,13 @@ #define shared_h #ifdef WIN32 -#ifdef shared_EXPORTS -#define SHARED_EXPORT __declspec(dllexport) +# ifdef shared_EXPORTS +# define SHARED_EXPORT __declspec(dllexport) +# else +# define SHARED_EXPORT __declspec(dllimport) +# endif #else -#define SHARED_EXPORT __declspec(dllimport) -#endif -#else -#define SHARED_EXPORT +# define SHARED_EXPORT #endif void SHARED_EXPORT shared(); diff --git a/Tests/BundleUtilities/shared2.h b/Tests/BundleUtilities/shared2.h index 3f0015c80..3f016c8f0 100644 --- a/Tests/BundleUtilities/shared2.h +++ b/Tests/BundleUtilities/shared2.h @@ -3,13 +3,13 @@ #define shared2_h #ifdef WIN32 -#ifdef shared2_EXPORTS -#define SHARED2_EXPORT __declspec(dllexport) +# ifdef shared2_EXPORTS +# define SHARED2_EXPORT __declspec(dllexport) +# else +# define SHARED2_EXPORT __declspec(dllimport) +# endif #else -#define SHARED2_EXPORT __declspec(dllimport) -#endif -#else -#define SHARED2_EXPORT +# define SHARED2_EXPORT #endif void SHARED2_EXPORT shared2(); diff --git a/Tests/BundleUtilities/testbundleutils1.cpp b/Tests/BundleUtilities/testbundleutils1.cpp index 3eb6a44bf..080157ac2 100644 --- a/Tests/BundleUtilities/testbundleutils1.cpp +++ b/Tests/BundleUtilities/testbundleutils1.cpp @@ -4,9 +4,9 @@ #include "stdio.h" #if defined(WIN32) -#include <windows.h> +# include <windows.h> #else -#include "dlfcn.h" +# include "dlfcn.h" #endif int main(int, char**) diff --git a/Tests/BundleUtilities/testbundleutils2.cpp b/Tests/BundleUtilities/testbundleutils2.cpp index c39eb52c5..e747544db 100644 --- a/Tests/BundleUtilities/testbundleutils2.cpp +++ b/Tests/BundleUtilities/testbundleutils2.cpp @@ -4,9 +4,9 @@ #include "stdio.h" #if defined(WIN32) -#include <windows.h> +# include <windows.h> #else -#include "dlfcn.h" +# include "dlfcn.h" #endif int main(int, char**) diff --git a/Tests/BundleUtilities/testbundleutils3.cpp b/Tests/BundleUtilities/testbundleutils3.cpp index 3bc8a83ec..2dee46fe5 100644 --- a/Tests/BundleUtilities/testbundleutils3.cpp +++ b/Tests/BundleUtilities/testbundleutils3.cpp @@ -4,9 +4,9 @@ #include "stdio.h" #if defined(WIN32) -#include <windows.h> +# include <windows.h> #else -#include "dlfcn.h" +# include "dlfcn.h" #endif int main(int, char**) diff --git a/Tests/CFBundleTest/np_macmain.cpp b/Tests/CFBundleTest/np_macmain.cpp index b5a422687..e5fd0d773 100644 --- a/Tests/CFBundleTest/np_macmain.cpp +++ b/Tests/CFBundleTest/np_macmain.cpp @@ -4,7 +4,7 @@ Based on the default np_macmain.cpp from FireBreath http://firebreath.googlecode.com - This file has been stripped to prevent it from accidently + This file has been stripped to prevent it from accidentally doing anything useful. \***********************************************************/ diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in index 71bcb183e..b4b12863d 100644 --- a/Tests/CMakeBuildTest.cmake.in +++ b/Tests/CMakeBuildTest.cmake.in @@ -29,11 +29,10 @@ if(RESULT) message(FATAL_ERROR "Error running cmake --build") endif() -# check for configuration types -set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@) -# run the executable out of the Debug directory if there -# are configuration types -if(CMAKE_CONFIGURATION_TYPES) +# run the executable out of the Debug directory if using a +# multi-config generator +set(_isMultiConfig @_isMultiConfig@) +if(_isMultiConfig) set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@") else() set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@") diff --git a/Tests/CMakeCommands/add_compile_options/main.cpp b/Tests/CMakeCommands/add_compile_options/main.cpp index 1d5702165..53f54b771 100644 --- a/Tests/CMakeCommands/add_compile_options/main.cpp +++ b/Tests/CMakeCommands/add_compile_options/main.cpp @@ -1,8 +1,8 @@ #ifdef DO_GNU_TESTS -#ifndef TEST_OPTION -#error Expected TEST_OPTION -#endif +# ifndef TEST_OPTION +# error Expected TEST_OPTION +# endif #endif int main(void) diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index f96283d55..a5bc1e1b3 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -26,18 +26,19 @@ target_compile_definitions(consumer PRIVATE ) -if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja") - target_sources(consumer PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" - ) - target_compile_definitions(consumer - PRIVATE - CONSUMER_LANG_$<COMPILE_LANGUAGE> - LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX> - LANG_IS_C=$<COMPILE_LANGUAGE:C> - ) +target_sources(consumer PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" +) +target_compile_definitions(consumer + PRIVATE + CONSUMER_LANG_$<COMPILE_LANGUAGE> + LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX> + LANG_IS_C=$<COMPILE_LANGUAGE:C> + LANG_IS_C_OR_CXX=$<COMPILE_LANGUAGE:C,CXX> +) +if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") target_compile_definitions(consumer - PRIVATE -DTEST_LANG_DEFINES + PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE ) endif() diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.c b/Tests/CMakeCommands/target_compile_definitions/consumer.c index 7931a6f0e..bb65e011b 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.c +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.c @@ -1,20 +1,42 @@ -#ifdef TEST_LANG_DEFINES -#ifdef CONSUMER_LANG_CXX -#error Unexpected CONSUMER_LANG_CXX -#endif +// Visual Studio allows only one set of flags for C and C++. +// In a target using C++ we pick the C++ flags even for C sources. +#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE +# ifndef CONSUMER_LANG_CXX +# error Expected CONSUMER_LANG_CXX +# endif -#ifndef CONSUMER_LANG_C -#error Expected CONSUMER_LANG_C -#endif +# ifdef CONSUMER_LANG_C +# error Unexpected CONSUMER_LANG_C +# endif -#if !LANG_IS_C -#error Expected LANG_IS_C -#endif +# if !LANG_IS_CXX +# error Expected LANG_IS_CXX +# endif + +# if LANG_IS_C +# error Unexpected LANG_IS_C +# endif +#else +# ifdef CONSUMER_LANG_CXX +# error Unexpected CONSUMER_LANG_CXX +# endif -#if LANG_IS_CXX -#error Unexpected LANG_IS_CXX +# ifndef CONSUMER_LANG_C +# error Expected CONSUMER_LANG_C +# endif + +# if !LANG_IS_C +# error Expected LANG_IS_C +# endif + +# if LANG_IS_CXX +# error Unexpected LANG_IS_CXX +# endif #endif + +#if !LANG_IS_C_OR_CXX +# error Expected LANG_IS_C_OR_CXX #endif void consumer_c() diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index 0202c172e..099952666 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -1,36 +1,34 @@ #ifdef MY_PRIVATE_DEFINE -#error Unexpected MY_PRIVATE_DEFINE +# error Unexpected MY_PRIVATE_DEFINE #endif #ifndef MY_PUBLIC_DEFINE -#error Expected MY_PUBLIC_DEFINE +# error Expected MY_PUBLIC_DEFINE #endif #ifndef MY_INTERFACE_DEFINE -#error Expected MY_INTERFACE_DEFINE +# error Expected MY_INTERFACE_DEFINE #endif #ifndef DASH_D_DEFINE -#error Expected DASH_D_DEFINE +# error Expected DASH_D_DEFINE #endif -#ifdef TEST_LANG_DEFINES #ifndef CONSUMER_LANG_CXX -#error Expected CONSUMER_LANG_CXX +# error Expected CONSUMER_LANG_CXX #endif #ifdef CONSUMER_LANG_C -#error Unexpected CONSUMER_LANG_C +# error Unexpected CONSUMER_LANG_C #endif #if !LANG_IS_CXX -#error Expected LANG_IS_CXX +# error Expected LANG_IS_CXX #endif #if LANG_IS_C -#error Unexpected LANG_IS_C -#endif +# error Unexpected LANG_IS_C #endif int main() diff --git a/Tests/CMakeCommands/target_compile_definitions/main.cpp b/Tests/CMakeCommands/target_compile_definitions/main.cpp index bf08b45e3..3f64dc843 100644 --- a/Tests/CMakeCommands/target_compile_definitions/main.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/main.cpp @@ -1,14 +1,14 @@ #ifndef MY_PRIVATE_DEFINE -#error Expected MY_PRIVATE_DEFINE +# error Expected MY_PRIVATE_DEFINE #endif #ifndef MY_PUBLIC_DEFINE -#error Expected MY_PUBLIC_DEFINE +# error Expected MY_PUBLIC_DEFINE #endif #ifdef MY_INTERFACE_DEFINE -#error Unexpected MY_INTERFACE_DEFINE +# error Unexpected MY_INTERFACE_DEFINE #endif int main() diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt index 5096a58bf..9664025a4 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/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt index 35dd276ba..a7055b157 100644 --- a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt @@ -7,9 +7,11 @@ add_executable(target_compile_options "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ) target_compile_options(target_compile_options - PRIVATE $<$<CXX_COMPILER_ID:GNU>:-DMY_PRIVATE_DEFINE> - PUBLIC $<$<CXX_COMPILER_ID:GNU>:-DMY_PUBLIC_DEFINE> + PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang,GNU>:-DMY_PRIVATE_DEFINE> + PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DMY_PUBLIC_DEFINE> + PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang,AppleClang>:-DMY_MUTLI_COMP_PUBLIC_DEFINE> INTERFACE $<$<CXX_COMPILER_ID:GNU>:-DMY_INTERFACE_DEFINE> + INTERFACE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-DMY_MULTI_COMP_INTERFACE_DEFINE> ) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -17,29 +19,35 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") PRIVATE "DO_GNU_TESTS" ) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_definitions(target_compile_options + PRIVATE + "DO_CLANG_TESTS" + ) endif() add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) -if (NOT CMAKE_GENERATOR MATCHES "Visual Studio") - target_sources(consumer PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" - ) - target_compile_options(consumer - PRIVATE - -DCONSUMER_LANG_$<COMPILE_LANGUAGE> - -DLANG_IS_CXX=$<COMPILE_LANGUAGE:CXX> - -DLANG_IS_C=$<COMPILE_LANGUAGE:C> - ) +target_sources(consumer PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" +) +target_compile_options(consumer + PRIVATE + -DCONSUMER_LANG_$<COMPILE_LANGUAGE> + -DLANG_IS_CXX=$<COMPILE_LANGUAGE:CXX> + -DLANG_IS_C=$<COMPILE_LANGUAGE:C> +) + +if(CMAKE_GENERATOR MATCHES "Visual Studio") target_compile_definitions(consumer - PRIVATE -DTEST_LANG_DEFINES + PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO ) endif() target_compile_options(consumer - PRIVATE $<$<CXX_COMPILER_ID:GNU>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>> + PRIVATE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>> ) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -47,6 +55,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") PRIVATE "DO_GNU_TESTS" ) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_definitions(consumer + PRIVATE + "DO_CLANG_TESTS" + ) endif() # Test no items diff --git a/Tests/CMakeCommands/target_compile_options/consumer.c b/Tests/CMakeCommands/target_compile_options/consumer.c index 7931a6f0e..f9b66543a 100644 --- a/Tests/CMakeCommands/target_compile_options/consumer.c +++ b/Tests/CMakeCommands/target_compile_options/consumer.c @@ -1,20 +1,38 @@ -#ifdef TEST_LANG_DEFINES -#ifdef CONSUMER_LANG_CXX -#error Unexpected CONSUMER_LANG_CXX -#endif +// Visual Studio allows only one set of flags for C and C++. +// In a target using C++ we pick the C++ flags even for C sources. +#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO +# ifndef CONSUMER_LANG_CXX +# error Expected CONSUMER_LANG_CXX +# endif -#ifndef CONSUMER_LANG_C -#error Expected CONSUMER_LANG_C -#endif +# ifdef CONSUMER_LANG_C +# error Unexpected CONSUMER_LANG_C +# endif -#if !LANG_IS_C -#error Expected LANG_IS_C -#endif +# if !LANG_IS_CXX +# error Expected LANG_IS_CXX +# endif -#if LANG_IS_CXX -#error Unexpected LANG_IS_CXX -#endif +# if LANG_IS_C +# error Unexpected LANG_IS_C +# endif +#else +# ifdef CONSUMER_LANG_CXX +# error Unexpected CONSUMER_LANG_CXX +# endif + +# ifndef CONSUMER_LANG_C +# error Expected CONSUMER_LANG_C +# endif + +# if !LANG_IS_C +# error Expected LANG_IS_C +# endif + +# if LANG_IS_CXX +# error Unexpected LANG_IS_CXX +# endif #endif void consumer_c() diff --git a/Tests/CMakeCommands/target_compile_options/consumer.cpp b/Tests/CMakeCommands/target_compile_options/consumer.cpp index 71a60986a..78928b42e 100644 --- a/Tests/CMakeCommands/target_compile_options/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_options/consumer.cpp @@ -1,36 +1,58 @@ #ifdef DO_GNU_TESTS -#ifdef MY_PRIVATE_DEFINE -#error Unexpected MY_PRIVATE_DEFINE -#endif +# ifdef MY_PRIVATE_DEFINE +# error Unexpected MY_PRIVATE_DEFINE +# endif -#ifndef MY_PUBLIC_DEFINE -#error Expected MY_PUBLIC_DEFINE -#endif +# ifndef MY_PUBLIC_DEFINE +# error Expected MY_PUBLIC_DEFINE +# endif + +# ifndef MY_INTERFACE_DEFINE +# error Expected MY_INTERFACE_DEFINE +# endif + +# ifndef MY_MULTI_COMP_INTERFACE_DEFINE +# error Expected MY_MULTI_COMP_INTERFACE_DEFINE +# endif + +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif -#ifndef MY_INTERFACE_DEFINE -#error Expected MY_INTERFACE_DEFINE #endif +#ifdef DO_CLANG_TESTS + +# ifdef MY_PRIVATE_DEFINE +# error Unexpected MY_PRIVATE_DEFINE +# endif + +# ifndef MY_MULTI_COMP_INTERFACE_DEFINE +# error Expected MY_MULTI_COMP_INTERFACE_DEFINE +# endif + +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif + #endif -#ifdef TEST_LANG_DEFINES #ifndef CONSUMER_LANG_CXX -#error Expected CONSUMER_LANG_CXX +# error Expected CONSUMER_LANG_CXX #endif #ifdef CONSUMER_LANG_C -#error Unexpected CONSUMER_LANG_C +# error Unexpected CONSUMER_LANG_C #endif #if !LANG_IS_CXX -#error Expected LANG_IS_CXX +# error Expected LANG_IS_CXX #endif #if LANG_IS_C -#error Unexpected LANG_IS_C -#endif +# error Unexpected LANG_IS_C #endif int main() diff --git a/Tests/CMakeCommands/target_compile_options/main.cpp b/Tests/CMakeCommands/target_compile_options/main.cpp index ac472aeda..7608400c4 100644 --- a/Tests/CMakeCommands/target_compile_options/main.cpp +++ b/Tests/CMakeCommands/target_compile_options/main.cpp @@ -1,18 +1,38 @@ #ifdef DO_GNU_TESTS -#ifndef MY_PRIVATE_DEFINE -#error Expected MY_PRIVATE_DEFINE -#endif +# ifndef MY_PRIVATE_DEFINE +# error Expected MY_PRIVATE_DEFINE +# endif -#ifndef MY_PUBLIC_DEFINE -#error Expected MY_PUBLIC_DEFINE -#endif +# ifndef MY_PUBLIC_DEFINE +# error Expected MY_PUBLIC_DEFINE +# endif + +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif + +# ifdef MY_INTERFACE_DEFINE +# error Unexpected MY_INTERFACE_DEFINE +# endif -#ifdef MY_INTERFACE_DEFINE -#error Unexpected MY_INTERFACE_DEFINE #endif +#ifdef DO_CLANG_TESTS + +# ifndef MY_PRIVATE_DEFINE +# error Expected MY_PRIVATE_DEFINE +# endif + +# ifdef MY_PUBLIC_DEFINE +# error Unexpected MY_PUBLIC_DEFINE +# endif + +# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE +# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE +# endif + #endif int main() diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index d57556aad..8713d99dd 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -42,17 +42,17 @@ add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) -if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja") - target_sources(consumer PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" - ) - target_include_directories(consumer - PRIVATE - $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only> - $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only> - ) +target_sources(consumer PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" +) +target_include_directories(consumer + PRIVATE + $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only> + $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only> +) +if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") target_compile_definitions(consumer - PRIVATE -DTEST_LANG_DEFINES + PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE ) endif() diff --git a/Tests/CMakeCommands/target_include_directories/consumer.c b/Tests/CMakeCommands/target_include_directories/consumer.c index ae88f9248..7fd694b08 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.c +++ b/Tests/CMakeCommands/target_include_directories/consumer.c @@ -1,10 +1,18 @@ -#ifdef TEST_LANG_DEFINES -#include "c_only.h" +// Visual Studio allows only one set of flags for C and C++. +// In a target using C++ we pick the C++ flags even for C sources. +#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE +# include "cxx_only.h" -#ifndef C_ONLY_DEFINE -#error Expected C_ONLY_DEFINE -#endif +# ifndef CXX_ONLY_DEFINE +# error Expected CXX_ONLY_DEFINE +# endif +#else +# include "c_only.h" + +# ifndef C_ONLY_DEFINE +# error Expected C_ONLY_DEFINE +# endif #endif int consumer_c() diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 0f8153b83..267b0a342 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -1,41 +1,37 @@ #include "consumer.h" #include "common.h" +#include "cxx_only.h" #include "interfaceinclude.h" #include "publicinclude.h" #include "relative_dir.h" -#ifdef TEST_LANG_DEFINES -#include "cxx_only.h" -#endif #ifdef PRIVATEINCLUDE_DEFINE -#error Unexpected PRIVATEINCLUDE_DEFINE +# error Unexpected PRIVATEINCLUDE_DEFINE #endif #ifndef PUBLICINCLUDE_DEFINE -#error Expected PUBLICINCLUDE_DEFINE +# error Expected PUBLICINCLUDE_DEFINE #endif #ifndef INTERFACEINCLUDE_DEFINE -#error Expected INTERFACEINCLUDE_DEFINE +# error Expected INTERFACEINCLUDE_DEFINE #endif #ifndef CURE_DEFINE -#error Expected CURE_DEFINE +# error Expected CURE_DEFINE #endif #ifndef RELATIVE_DIR_DEFINE -#error Expected RELATIVE_DIR_DEFINE +# error Expected RELATIVE_DIR_DEFINE #endif #ifndef CONSUMER_DEFINE -#error Expected CONSUMER_DEFINE +# error Expected CONSUMER_DEFINE #endif -#ifdef TEST_LANG_DEFINES #ifndef CXX_ONLY_DEFINE -#error Expected CXX_ONLY_DEFINE -#endif +# error Expected CXX_ONLY_DEFINE #endif int main() diff --git a/Tests/CMakeCommands/target_include_directories/main.cpp b/Tests/CMakeCommands/target_include_directories/main.cpp index 71298ceac..dd591bfed 100644 --- a/Tests/CMakeCommands/target_include_directories/main.cpp +++ b/Tests/CMakeCommands/target_include_directories/main.cpp @@ -4,19 +4,19 @@ #include "publicinclude.h" #ifndef PRIVATEINCLUDE_DEFINE -#error Expected PRIVATEINCLUDE_DEFINE +# error Expected PRIVATEINCLUDE_DEFINE #endif #ifndef PUBLICINCLUDE_DEFINE -#error Expected PUBLICINCLUDE_DEFINE +# error Expected PUBLICINCLUDE_DEFINE #endif #ifdef INTERFACEINCLUDE_DEFINE -#error Unexpected INTERFACEINCLUDE_DEFINE +# error Unexpected INTERFACEINCLUDE_DEFINE #endif #ifndef CURE_DEFINE -#error Expected CURE_DEFINE +# error Expected CURE_DEFINE #endif int main() diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index e11f980df..5c704ac83 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -130,3 +130,19 @@ target_link_libraries(newsignature1 PRIVATE depC INTERFACE depD PUBLIC depB PRIV assert_property(newsignature1 INTERFACE_LINK_LIBRARIES "depD;depB") assert_property(newsignature1 LINK_LIBRARIES "depC;depB;subdirlib") + +#---------------------------------------------------------------------------- +# Test cross-directory linking. +cmake_policy(PUSH) +cmake_policy(SET CMP0022 NEW) +cmake_policy(SET CMP0079 NEW) +add_executable(TopDir TopDir.c) +add_subdirectory(SubDirA) +add_subdirectory(SubDirB) +target_link_libraries(SubDirB TopDirImported) +add_subdirectory(SubDirC) +target_link_libraries(SubDirC PRIVATE SubDirC2) +target_link_libraries(TopDir SubDirC) +add_library(TopDirImported IMPORTED INTERFACE) +target_compile_definitions(TopDirImported INTERFACE DEF_TopDirImported) +cmake_policy(POP) diff --git a/Tests/CMakeCommands/target_link_libraries/libgenex.h b/Tests/CMakeCommands/target_link_libraries/libgenex.h index 733f9b6df..59ac18a33 100644 --- a/Tests/CMakeCommands/target_link_libraries/libgenex.h +++ b/Tests/CMakeCommands/target_link_libraries/libgenex.h @@ -2,7 +2,7 @@ #include "libgenex_export.h" #ifndef LIBGENEX_H -#define LIBGENEX_H +# define LIBGENEX_H struct LIBGENEX_EXPORT LibGenex { diff --git a/Tests/CMakeCommands/target_link_libraries/targetC.cpp b/Tests/CMakeCommands/target_link_libraries/targetC.cpp index 7c5c9e426..cae02b9cd 100644 --- a/Tests/CMakeCommands/target_link_libraries/targetC.cpp +++ b/Tests/CMakeCommands/target_link_libraries/targetC.cpp @@ -5,7 +5,7 @@ #include "foo.h" #ifndef TEST_DEF -#error Expected TEST_DEF definition +# error Expected TEST_DEF definition #endif int main(int, char**) diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake index fda8c54b3..d9d85f71b 100644 --- a/Tests/CMakeInstall.cmake +++ b/Tests/CMakeInstall.cmake @@ -14,7 +14,18 @@ if(CMake_TEST_INSTALL) set(CMake_TEST_INSTALL_PREFIX ${CMake_BINARY_DIR}/Tests/CMakeInstall) set(CMAKE_INSTALL_PREFIX "${CMake_TEST_INSTALL_PREFIX}") - if(CMAKE_CONFIGURATION_TYPES) + # 3.9 or later provides a definitive answer to whether we are multi-config + # through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set + # is assumed to mean multi-config, but developers might modify it so it is + # technically not as reliable. + if(NOT CMAKE_VERSION VERSION_LESS 3.9) + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + elseif(CMAKE_CONFIGURATION_TYPES) + set(_isMultiConfig True) + else() + set(_isMultiConfig False) + endif() + if(_isMultiConfig) # There are multiple configurations. Make sure the tested # configuration is the one that is installed. set(CMake_TEST_INSTALL_CONFIG --config $<CONFIGURATION>) diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index d1a1df5ed..a25f25af0 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -5,20 +5,30 @@ include_directories( ) set(CMakeLib_TESTS - testGeneratedFileStream - testRST - testSystemTools - testUTF8 - testXMLParser - testXMLSafe - testFindPackageCommand + testArgumentParser.cxx + testGeneratedFileStream.cxx + testRST.cxx + testRange.cxx + testString.cxx + testSystemTools.cxx + testUTF8.cxx + testXMLParser.cxx + testXMLSafe.cxx + testFindPackageCommand.cxx + testUVProcessChain.cxx + testUVRAII.cxx + testUVStreambuf.cxx ) +add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx) + set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}) +set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>) +set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>) if(WIN32) list(APPEND CMakeLib_TESTS - testVisualStudioSlnParser + testVisualStudioSlnParser.cxx ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testVisualStudioSlnParser.h.in ${CMAKE_CURRENT_BINARY_DIR}/testVisualStudioSlnParser.h @ONLY) @@ -31,11 +41,15 @@ create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) target_link_libraries(CMakeLibTests CMakeLib) +set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "") +set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "") + add_executable(testEncoding testEncoding.cxx) target_link_libraries(testEncoding cmsys) -foreach(test ${CMakeLib_TESTS}) - add_test(CMakeLib.${test} CMakeLibTests ${test} ${${test}_ARGS}) +foreach(testfile ${CMakeLib_TESTS}) + get_filename_component(test "${testfile}" NAME_WE) + add_test(NAME CMakeLib.${test} COMMAND CMakeLibTests ${test} ${${test}_ARGS}) endforeach() if(TEST_CompileCommandOutput) @@ -44,3 +58,6 @@ if(TEST_CompileCommandOutput) endif() add_subdirectory(PseudoMemcheck) + +add_executable(testAffinity testAffinity.cxx) +target_link_libraries(testAffinity CMakeLib) diff --git a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in index b4c6fae44..3183bc0b6 100644 --- a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in +++ b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in @@ -15,15 +15,15 @@ int main(int ac, char** av) std::string logarg; bool nextarg = false; - if (exename.find("valgrind") != exename.npos) { + if (exename.find("valgrind") != std::string::npos) { logarg = "--log-file="; - } else if (exename.find("purify") != exename.npos) { + } else if (exename.find("purify") != std::string::npos) { #ifdef _WIN32 logarg = "/SAVETEXTDATA="; #else logarg = "-log-file="; #endif - } else if (exename.find("BC") != exename.npos) { + } else if (exename.find("BC") != std::string::npos) { nextarg = true; logarg = "/X"; } diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 46431bc33..b49803bd6 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -1,4 +1,4 @@ -#include <cmConfigure.h> +#include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/FStream.hxx" #include <iostream> @@ -144,15 +144,11 @@ int main() cmsys::ifstream file("compile_commands.json"); CompileCommandParser parser(file); parser.Parse(); - for (CompileCommandParser::TranslationUnitsType::const_iterator - it = parser.GetTranslationUnits().begin(), - end = parser.GetTranslationUnits().end(); - it != end; ++it) { + for (auto const& tu : parser.GetTranslationUnits()) { std::vector<std::string> command; - cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command); - if (!cmSystemTools::RunSingleCommand(command, CM_NULLPTR, CM_NULLPTR, - CM_NULLPTR, - it->at("directory").c_str())) { + cmSystemTools::ParseUnixCommandLine(tu.at("command").c_str(), command); + if (!cmSystemTools::RunSingleCommand(command, nullptr, nullptr, nullptr, + tu.at("directory").c_str())) { std::cout << "ERROR: Failed to run command \"" << command[0] << "\"" << std::endl; exit(1); diff --git a/Tests/CMakeLib/testEncoding.cxx b/Tests/CMakeLib/testEncoding.cxx index 5e40638f7..d608e86d7 100644 --- a/Tests/CMakeLib/testEncoding.cxx +++ b/Tests/CMakeLib/testEncoding.cxx @@ -3,7 +3,7 @@ #include <string> #ifdef _WIN32 -#include "cmsys/ConsoleBuf.hxx" +# include "cmsys/ConsoleBuf.hxx" #endif #ifdef _WIN32 @@ -31,7 +31,7 @@ int main(int argc, char* argv[]) } const std::string encoding(argv[1]); #ifdef _WIN32 - if (encoding == "UTF8") { + if ((encoding == "UTF8") || (encoding == "UTF-8")) { setEncoding(consoleOut, CP_UTF8); } else if (encoding == "ANSI") { setEncoding(consoleOut, CP_ACP); diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect index fa436cb91..c19ee9400 100644 --- a/Tests/CMakeLib/testRST.expect +++ b/Tests/CMakeLib/testRST.expect @@ -16,7 +16,14 @@ Variable ``<PLACEHOLDER>_VARIABLE`` with leading placeholder. Variable ``VARIABLE_<PLACEHOLDER>`` with trailing placeholder. Variable ``<PLACEHOLDER>_VARIABLE`` with leading placeholder and target. Variable ``VARIABLE_<PLACEHOLDER>`` with trailing placeholder and target. +Environment variable ``SOME_ENV_VAR``. +Environment variable ``some env var`` with space and target. Generator ``Some Generator`` with space. +Generator ``Some Generator`` with space. +Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``. +Inline link Link Text. +Inline link Link Text <With \-escaped Brackets>. +Inline literal ``__`` followed by inline link Link Text. First TOC entry. @@ -76,6 +83,10 @@ or after a paragraph ending in two colons:: but not after a line ending in two colons:: in the middle of a paragraph. +A literal block can be empty:: + + + .. productionlist:: grammar: `production` production: "content rendered" diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst index 54952dd9f..d2d1140f3 100644 --- a/Tests/CMakeLib/testRST.rst +++ b/Tests/CMakeLib/testRST.rst @@ -23,7 +23,14 @@ Variable :variable:`<PLACEHOLDER>_VARIABLE` with leading placeholder. Variable :variable:`VARIABLE_<PLACEHOLDER>` with trailing placeholder. Variable :variable:`<PLACEHOLDER>_VARIABLE <target>` with leading placeholder and target. Variable :variable:`VARIABLE_<PLACEHOLDER> <target>` with trailing placeholder and target. +Environment variable :envvar:`SOME_ENV_VAR`. +Environment variable :envvar:`some env var <SOME_ENV_VAR>` with space and target. Generator :generator:`Some Generator` with space. +Generator :cpack_gen:`Some Generator` with space. +Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``. +Inline link `Link Text <ExternalDest>`_. +Inline link `Link Text \<With \\-escaped Brackets\> <ExternalDest>`_. +Inline literal ``__`` followed by inline link `Link Text <InternalDest_>`_. .. |not replaced| replace:: not replaced through toctree .. |not replaced in literal| replace:: replaced in parsed literal @@ -83,6 +90,10 @@ or after a paragraph ending in two colons:: but not after a line ending in two colons:: in the middle of a paragraph. +A literal block can be empty:: + + + .. productionlist:: grammar: `production` production: "content rendered" diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index 0dfa326a3..121e63985 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -16,11 +16,13 @@ failed = 1 #define cmAssert(exp, m) \ - if ((exp)) { \ - cmPassed(m); \ - } else { \ - cmFailed(m); \ - } + do { \ + if ((exp)) { \ + cmPassed(m); \ + } else { \ + cmFailed(m); \ + } \ + } while (false) int testSystemTools(int /*unused*/, char* /*unused*/ []) { @@ -52,7 +54,7 @@ int testSystemTools(int /*unused*/, char* /*unused*/ []) cmAssert(cmSystemTools::strverscmp("99999999999999", "99999999999991") > 0, "strverscmp natural overflow"); cmAssert(cmSystemTools::strverscmp("00000000000009", "00000000000001") > 0, - "strverscmp deciaml precision"); + "strverscmp decimal precision"); cmAssert(cmSystemTools::strverscmp("a.b.c.0", "a.b.c.000") > 0, "strverscmp multiple zeros"); cmAssert(cmSystemTools::strverscmp("lib_1.2_10", "lib_1.2_2") > 0, @@ -91,5 +93,22 @@ int testSystemTools(int /*unused*/, char* /*unused*/ []) if (!failed) { cmPassed("cmSystemTools::strverscmp working"); } + + // ---------------------------------------------------------------------- + // Test cmSystemTools::StringToULong + { + unsigned long value; + cmAssert(cmSystemTools::StringToULong("1", &value) && value == 1, + "StringToULong parses a decimal integer."); + cmAssert(cmSystemTools::StringToULong(" 1", &value) && value == 1, + "StringToULong parses a decimal integer after whitespace."); + cmAssert(!cmSystemTools::StringToULong("-1", &value), + "StringToULong rejects a negative number."); + cmAssert(!cmSystemTools::StringToULong(" -1", &value), + "StringToULong rejects a negative number after whitespace."); + cmAssert(!cmSystemTools::StringToULong("1x", &value), + "StringToULong rejects trailing content."); + } + return failed; } diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx index fb5f3d815..a0bb5cd23 100644 --- a/Tests/CMakeLib/testUTF8.cxx +++ b/Tests/CMakeLib/testUTF8.cxx @@ -8,8 +8,24 @@ typedef char test_utf8_char[5]; static void test_utf8_char_print(test_utf8_char const c) { unsigned char const* d = reinterpret_cast<unsigned char const*>(c); - printf("[0x%02X,0x%02X,0x%02X,0x%02X]", (int)d[0], (int)d[1], (int)d[2], - (int)d[3]); + printf("[0x%02X,0x%02X,0x%02X,0x%02X]", static_cast<int>(d[0]), + static_cast<int>(d[1]), static_cast<int>(d[2]), + static_cast<int>(d[3])); +} + +static void byte_array_print(char const* s) +{ + unsigned char const* d = reinterpret_cast<unsigned char const*>(s); + bool started = false; + printf("["); + for (; *d; ++d) { + if (started) { + printf(","); + } + started = true; + printf("0x%02X", static_cast<int>(*d)); + } + printf("]"); } struct test_utf8_entry @@ -20,17 +36,36 @@ struct test_utf8_entry }; static test_utf8_entry const good_entry[] = { - { 1, "\x20\x00\x00\x00", 0x0020 }, /* Space. */ - { 2, "\xC2\xA9\x00\x00", 0x00A9 }, /* Copyright. */ - { 3, "\xE2\x80\x98\x00", 0x2018 }, /* Open-single-quote. */ - { 3, "\xE2\x80\x99\x00", 0x2019 }, /* Close-single-quote. */ - { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629. */ + { 1, "\x20\x00\x00\x00", 0x0020 }, /* Space. */ + { 2, "\xC2\xA9\x00\x00", 0x00A9 }, /* Copyright. */ + { 3, "\xE2\x80\x98\x00", 0x2018 }, /* Open-single-quote. */ + { 3, "\xE2\x80\x99\x00", 0x2019 }, /* Close-single-quote. */ + { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629. */ + { 3, "\xED\x80\x80\x00", 0xD000 }, /* Valid 0xED prefixed codepoint. */ + { 4, "\xF4\x8F\xBF\xBF", 0x10FFFF }, /* Highest valid RFC codepoint. */ { 0, { 0, 0, 0, 0, 0 }, 0 } }; static test_utf8_char const bad_chars[] = { - "\x80\x00\x00\x00", "\xC0\x00\x00\x00", "\xE0\x00\x00\x00", - "\xE0\x80\x80\x00", "\xF0\x80\x80\x80", { 0, 0, 0, 0, 0 } + "\x80\x00\x00\x00", /* Leading continuation byte. */ + "\xC0\x80\x00\x00", /* Overlong encoding. */ + "\xC1\x80\x00\x00", /* Overlong encoding. */ + "\xC2\x00\x00\x00", /* Missing continuation byte. */ + "\xE0\x00\x00\x00", /* Missing continuation bytes. */ + "\xE0\x80\x80\x00", /* Overlong encoding. */ + "\xF0\x80\x80\x80", /* Overlong encoding. */ + "\xED\xA0\x80\x00", /* UTF-16 surrogate half. */ + "\xED\xBF\xBF\x00", /* UTF-16 surrogate half. */ + "\xF4\x90\x80\x80", /* Lowest out-of-range codepoint. */ + "\xF5\x80\x80\x80", /* Prefix forces out-of-range codepoints. */ + { 0, 0, 0, 0, 0 } +}; + +static char const* good_strings[] = { "", "ASCII", "\xC2\xA9 Kitware", 0 }; + +static char const* bad_strings[] = { + "\xC0\x80", /* Modified UTF-8 for embedded 0-byte. */ + 0 }; static void report_good(bool passed, test_utf8_char const c) @@ -86,6 +121,46 @@ static bool decode_bad(test_utf8_char const s) return true; } +static void report_valid(bool passed, char const* s) +{ + printf("%s: validity good ", passed ? "pass" : "FAIL"); + byte_array_print(s); + printf(" (%s) ", s); +} + +static void report_invalid(bool passed, char const* s) +{ + printf("%s: validity bad ", passed ? "pass" : "FAIL"); + byte_array_print(s); + printf(" "); +} + +static bool is_valid(const char* s) +{ + bool valid = cm_utf8_is_valid(s) != 0; + if (!valid) { + report_valid(false, s); + printf("expected valid, reported as invalid\n"); + return false; + } + report_valid(true, s); + printf("valid as expected\n"); + return true; +} + +static bool is_invalid(const char* s) +{ + bool valid = cm_utf8_is_valid(s) != 0; + if (valid) { + report_invalid(false, s); + printf("expected invalid, reported as valid\n"); + return false; + } + report_invalid(true, s); + printf("invalid as expected\n"); + return true; +} + int testUTF8(int /*unused*/, char* /*unused*/ []) { int result = 0; @@ -93,11 +168,27 @@ int testUTF8(int /*unused*/, char* /*unused*/ []) if (!decode_good(*e)) { result = 1; } + if (!is_valid(e->str)) { + result = 1; + } } for (test_utf8_char const* c = bad_chars; (*c)[0]; ++c) { if (!decode_bad(*c)) { result = 1; } + if (!is_invalid(*c)) { + result = 1; + } + } + for (char const** s = good_strings; *s; ++s) { + if (!is_valid(*s)) { + result = 1; + } + } + for (char const** s = bad_strings; *s; ++s) { + if (!is_invalid(*s)) { + result = 1; + } } return result; } diff --git a/Tests/CMakeLib/testVisualStudioSlnParser.cxx b/Tests/CMakeLib/testVisualStudioSlnParser.cxx index f8bcfae85..c7fd585cc 100644 --- a/Tests/CMakeLib/testVisualStudioSlnParser.cxx +++ b/Tests/CMakeLib/testVisualStudioSlnParser.cxx @@ -45,17 +45,55 @@ int testVisualStudioSlnParser(int, char* []) } const std::vector<cmSlnProjectEntry>& projects = data.GetProjects(); const char* const names[] = { - "3rdParty", "ALL_BUILD", "CMakeLib", "CMakeLibTests", - "CMakePredefinedTargets", "CPackLib", "CTestDashboardTargets", - "CTestLib", "Continuous", "Documentation", "Experimental", "INSTALL", - "KWSys", "LIBCURL", "Nightly", "NightlyMemoryCheck", "PACKAGE", - "RUN_TESTS", "Tests", "Utilities", "Win9xCompat", "ZERO_CHECK", - "cmIML_test", "cmake", "cmbzip2", "cmcldeps", "cmcompress", "cmcurl", - "cmexpat", "cmlibarchive", "cmsys", "cmsysEncodeExecutable", - "cmsysProcessFwd9x", "cmsysTestDynload", "cmsysTestProcess", - "cmsysTestSharedForward", "cmsysTestsC", "cmsysTestsCxx", "cmsys_c", - "cmw9xcom", "cmzlib", "cpack", "ctest", "documentation", "memcheck_fail", - "pseudo_BC", "pseudo_purify", "pseudo_valgrind", "test_clean", + "3rdParty", + "ALL_BUILD", + "CMakeLib", + "CMakeLibTests", + "CMakePredefinedTargets", + "CPackLib", + "CTestDashboardTargets", + "CTestLib", + "Continuous", + "Documentation", + "Experimental", + "INSTALL", + "KWSys", + "LIBCURL", + "Nightly", + "NightlyMemoryCheck", + "PACKAGE", + "RUN_TESTS", + "Tests", + "Utilities", + "Win9xCompat", + "ZERO_CHECK", + "cmIML_test", + "cmake", + "cmbzip2", + "cmcldeps", + "cmcompress", + "cmcurl", + "cmexpat", + "cmlibarchive", + "cmsys", + "cmsysEncodeExecutable", + "cmsysProcessFwd9x", + "cmsysTestDynload", + "cmsysTestProcess", + "cmsysTestSharedForward", + "cmsysTestsC", + "cmsysTestsCxx", + "cmsys_c", + "cmw9xcom", + "cmzlib", + "cpack", + "ctest", + "documentation", + "memcheck_fail", + "pseudo_BC", + "pseudo_purify", + "pseudo_valgrind", + "test_clean", "uninstall" /* clang-format needs this comment to break after the opening brace */ }; diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx index fe776c587..21bb95292 100644 --- a/Tests/CMakeLib/testXMLSafe.cxx +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include <cmConfigure.h> +#include "cmConfigure.h" // IWYU pragma: keep #include <sstream> #include <stdio.h> @@ -21,7 +21,7 @@ static test_pair const pairs[] = { { "angles <>", "angles <>" }, { "ampersand &", "ampersand &" }, { "bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]" }, - { CM_NULLPTR, CM_NULLPTR } + { nullptr, nullptr } }; int testXMLSafe(int /*unused*/, char* /*unused*/ []) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d16df1cf5..e73b277f1 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -22,6 +22,7 @@ macro(ADD_TEST_MACRO NAME) endmacro() include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake) # Fake a user home directory to avoid polluting the real one. if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) @@ -31,14 +32,28 @@ if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) set(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. # But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that # need access to the real HOME directory. -set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\") +if(NOT DEFINED ENV{CTEST_REAL_HOME}) + set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\") +endif() set(ENV{HOME} \"${TEST_HOME}\") ") endif() +# 3.9 or later provides a definitive answer to whether we are multi-config +# through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set +# is assumed to mean multi-config, but developers might modify it so it is +# technically not as reliable. +if(NOT CMAKE_VERSION VERSION_LESS 3.9) + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +elseif(CMAKE_CONFIGURATION_TYPES) + set(_isMultiConfig True) +else() + set(_isMultiConfig False) +endif() + # Choose a default configuration for CTest tests. set(CTestTest_CONFIG Debug) -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) +if(NOT _isMultiConfig AND CMAKE_BUILD_TYPE) set(CTestTest_CONFIG ${CMAKE_BUILD_TYPE}) endif() @@ -50,7 +65,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() @@ -131,8 +146,7 @@ if(BUILD_TESTING) set(CPACK_BINARY_RPM OFF) endif() - # Look for rpmbuild to use for tests. - # The tool does not work with spaces in the path. + # Look for dpkg to use for tests. find_program(DPKG_EXECUTABLE NAMES dpkg) if(DPKG_EXECUTABLE) @@ -141,11 +155,65 @@ if(BUILD_TESTING) set(CPACK_BINARY_DEB OFF) endif() + # Look for NuGet to use for tests. + find_program(NUGET_EXECUTABLE NAMES NuGet nuget) + + if(NUGET_EXECUTABLE) + set(CPACK_BINARY_NUGET ON) + else() + set(CPACK_BINARY_NUGET OFF) + endif() + + if(WIN32) + # Macro to search for available Windows CE SDKs in the windows Registry + macro(select_wince_sdk selected_reg selected_sdk) + if(CMAKE_HOST_WIN32) + execute_process(COMMAND reg QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs" + OUTPUT_VARIABLE sdk_reg + ERROR_VARIABLE my_err) + string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}") + list(LENGTH sdk_list sdk_list_len) + if (${sdk_list_len} GREATER 1) + list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above + string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name + endif() + # Build a key to be used by get_filename_component that is pointing to the SDK directory + set(_reg "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs\\${_sdk}]") + # Set return values + set(${selected_reg} ${_reg}) + set(${selected_sdk} ${_sdk}) + endif(CMAKE_HOST_WIN32) + endmacro(select_wince_sdk) + + set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]") + set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]") + set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]") + set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]") + set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]") + set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]") + set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]") + set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]") + set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]") + select_wince_sdk(reg_wince wince_sdk) + set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]") + set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]") + foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) + get_filename_component(r "${reg_${reg}}" ABSOLUTE) + if(IS_DIRECTORY "${r}" AND NOT "${r}" STREQUAL "/registry") + set(${reg} 1) + else() + set(${reg} 0) + endif() + endforeach() + endif() + #--------------------------------------------------------------------------- # Add tests below here. if(NOT CMake_TEST_EXTERNAL_CMAKE) add_subdirectory(CMakeLib) + + add_subdirectory(CMakeServerLib) endif() add_subdirectory(CMakeOnly) add_subdirectory(RunCMake) @@ -228,6 +296,10 @@ if(BUILD_TESTING) set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}") endif() endif() + if(NOT CMake_TEST_XCODE_VERSION VERSION_LESS 10) + # Since Xcode 10 we do not have two supported architectures for the host. + set(CTEST_TEST_OSX_ARCH 0) + endif() if(CMAKE_OSX_SYSROOT) execute_process( COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version ProductName @@ -264,7 +336,7 @@ if(BUILD_TESTING) endif() add_test(NAME CMake.Copyright - COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake) + COMMAND ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake) # add a bunch of standard build-and-test style tests ADD_TEST_MACRO(CommandLineTest CommandLineTest) @@ -294,11 +366,16 @@ if(BUILD_TESTING) ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10))) if(CMAKE_GENERATOR STREQUAL "Xcode") - ADD_TEST_MACRO(SwiftMix SwiftMix) - ADD_TEST_MACRO(SwiftOnly SwiftOnly) + set(CMake_TEST_XCODE_SWIFT 1) endif() endif() endif() + if(CMAKE_Swift_COMPILER OR CMake_TEST_XCODE_SWIFT) + ADD_TEST_MACRO(SwiftOnly SwiftOnly) + if(CMake_TEST_XCODE_SWIFT) + ADD_TEST_MACRO(SwiftMix SwiftMix) + endif() + endif() if(CMAKE_Fortran_COMPILER) ADD_TEST_MACRO(FortranOnly FortranOnly) endif() @@ -325,13 +402,14 @@ if(BUILD_TESTING) set(CMAKE_SKIP_VSGNUFortran TRUE) endif() if(NOT CMAKE_SKIP_VSGNUFortran) - ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake) + ADD_TEST_MACRO(VSGNUFortran ${CMAKE_CMAKE_COMMAND} -P runtest.cmake) 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) @@ -339,6 +417,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CxxSubdirC CxxSubdirC) ADD_TEST_MACRO(IPO COnly/COnly) ADD_TEST_MACRO(OutDir runtime/OutDir) + ADD_TEST_MACRO(OutName exe.OutName.exe) ADD_TEST_MACRO(ObjectLibrary UseCshared) ADD_TEST_MACRO(NewlineArgs NewlineArgs) ADD_TEST_MACRO(SetLang SetLang) @@ -363,10 +442,14 @@ if(BUILD_TESTING) ADD_TEST_MACRO(PolicyScope PolicyScope) ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) ADD_TEST_MACRO(CompileDefinitions CompileDefinitions) + if(CMAKE_Fortran_COMPILER) + set(CompileOptions_BUILD_OPTIONS -DTEST_FORTRAN=1) + endif() ADD_TEST_MACRO(CompileOptions CompileOptions) ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) ADD_TEST_MACRO(AliasTarget AliasTarget) ADD_TEST_MACRO(StagingPrefix StagingPrefix) + ADD_TEST_MACRO(ImportedSameName ImportedSameName) ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug) @@ -374,12 +457,15 @@ if(BUILD_TESTING) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) ADD_TEST_MACRO(SourceFileProperty SourceFileProperty) + if (NOT CMAKE_GENERATOR STREQUAL "Xcode") + ADD_TEST_MACRO(SourceFileIncludeDirProperty SourceFileIncludeDirProperty) + endif() if(CMAKE_CXX_COMPILER_ID STREQUAL GNU AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) set(runCxxDialectTest 1) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL Clang - AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4 AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if(NOT APPLE OR POLICY CMP0025) set(runCxxDialectTest 1) endif() @@ -403,11 +489,14 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) - if(NOT QT4_FOUND) + if(NOT DEFINED CMake_TEST_Qt4) + set(CMake_TEST_Qt4 1) + endif() + if(CMake_TEST_Qt4 AND NOT QT4_FOUND) find_package(Qt4 QUIET) endif() - if(QT4_FOUND) + if(CMake_TEST_Qt4 AND QT4_FOUND) # test whether the Qt4 which has been found works, on some machines # which run nightly builds there were errors like "wrong file format" # for libQtCore.so. So first check it works, and only if it does add @@ -517,7 +606,6 @@ if(BUILD_TESTING) else() if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" - OR CMAKE_SYSTEM_NAME MATCHES "IRIX64" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") set(run_pic_test 0) else() @@ -605,7 +693,6 @@ if(BUILD_TESTING) "CodeLite" "Eclipse CDT4" "Kate" - "KDevelop3" "Sublime Text 2") foreach(extraGenerator ${extraGenerators}) @@ -683,14 +770,14 @@ if(BUILD_TESTING) file(WRITE "${_TEST_DIR}/nightly-cmake.sh" "cd ${_TEST_DIR} ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script} -${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake +${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGHTLY_RELEASES}' ") add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh) if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif() endmacro() - if(CMAKE_BUILD_NIGHTLY_RELEASES) + if(CMake_BUILD_NIGHTLY_RELEASES) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32 win32_release.cmake) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64 @@ -795,6 +882,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} @@ -809,31 +898,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory") - #add_test(SimpleExclude ${CMAKE_CTEST_COMMAND} - # --build-and-test - # "${CMake_SOURCE_DIR}/Tests/SimpleExclude" - # "${CMake_BINARY_DIR}/Tests/SimpleExclude" - # ${build_generator_args} - # --build-project SimpleExclude - # --build-two-config - # --build-options ${build_options} - # --test-command t4 - #--test-command "${CMAKE_COMMAND}" - #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}" - #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake" - #) - -# add_test(SameName ${CMAKE_CTEST_COMMAND} -# --build-and-test -# "${CMake_SOURCE_DIR}/Tests/SameName" -# "${CMake_BINARY_DIR}/Tests/SameName" -# ${build_generator_args} -# --build-project SameName -# --build-two-config -# --build-options ${build_options} -# --test-command -# "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2") - add_test(OutOfSource ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/OutOfSource" @@ -858,33 +922,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends") - set(SimpleInstallInstallDir - "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory") - add_test(SimpleInstall ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/SimpleInstall" - "${CMake_BINARY_DIR}/Tests/SimpleInstall" - ${build_generator_args} - --build-project TestSimpleInstall - --build-two-config - --build-options ${build_options} - "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" - "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}" - --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall") - add_test(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2" - "${CMake_BINARY_DIR}/Tests/SimpleInstallS2" - ${build_generator_args} - --build-project TestSimpleInstall - --build-two-config - --build-options ${build_options} - "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" - "-DSTAGE2:BOOL=1" - --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2") - set(MissingInstallInstallDir "${CMake_BINARY_DIR}/Tests/MissingInstall/InstallDirectory") add_test(MissingInstall ${CMAKE_CTEST_COMMAND} @@ -952,6 +989,44 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() endif() + if(CTEST_TEST_CPACK) + add_test(CPackUseDefaultVersion ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackUseDefaultVersion" + "${CMake_BINARY_DIR}/Tests/CPackUseDefaultVersion" + ${build_generator_args} + --build-project CPackUseDefaultVersion + --build-two-config + --build-options ${build_options} + ${CPackUseDefaultVersion_BUILD_OPTIONS}) + set_tests_properties(CPackUseDefaultVersion PROPERTIES PASS_REGULAR_EXPRESSION "CPACK_PACKAGE_VERSION=0\\.1\\.1") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackUseDefaultVersion") + + add_test(CPackUseProjectVersion ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackUseProjectVersion" + "${CMake_BINARY_DIR}/Tests/CPackUseProjectVersion" + ${build_generator_args} + --build-project CPackUseProjectVersion + --build-two-config + --build-options ${build_options} + ${CPackUseProjectVersion_BUILD_OPTIONS}) + set_tests_properties(CPackUseProjectVersion PROPERTIES PASS_REGULAR_EXPRESSION "CPACK_PACKAGE_VERSION=1\\.2\\.3") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackUseProjectVersion") + + add_test(CPackUseShortProjectVersion ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackUseShortProjectVersion" + "${CMake_BINARY_DIR}/Tests/CPackUseShortProjectVersion" + ${build_generator_args} + --build-project CPackUseShortProjectVersion + --build-two-config + --build-options ${build_options} + ${CPackUseProjectVersion_BUILD_OPTIONS}) + set_tests_properties(CPackUseShortProjectVersion PROPERTIES PASS_REGULAR_EXPRESSION "CPACK_PACKAGE_VERSION=2") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackUseShortProjectVersion") + endif() + if(CTEST_RUN_CPackComponents) set(CPackComponents_BUILD_OPTIONS) if(APPLE) @@ -996,6 +1071,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(CPACK_BINARY_DEB) list(APPEND ACTIVE_CPACK_GENERATORS DEB) endif() + # Check whether if NuGet command is found + # before adding NuGet tests + if(CPACK_BINARY_NUGET) + list(APPEND ACTIVE_CPACK_GENERATORS NUGET) + set(CPACK_GENERATOR_STRING_NUGET NuGet) + endif() # ACTIVE_CPACK_GENERATORS variable # now contains the list of 'active generators' @@ -1015,7 +1096,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release list(APPEND CWAYLST "IgnoreGroup") list(APPEND CWAYLST "AllInOne") foreach(CPackGen IN LISTS ACTIVE_CPACK_GENERATORS) - set(CPackRun_CPackGen "-DCPackGen=${CPackGen}") + if(NOT DEFINED CPACK_GENERATOR_STRING_${CPackGen}) + set(CPACK_GENERATOR_STRING_${CPackGen} ${CPackGen}) + endif() + set(CPackRun_CPackGen "-DCPackGen=${CPACK_GENERATOR_STRING_${CPackGen}}") foreach(CPackComponentWay ${CWAYLST}) set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}") add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay} @@ -1026,7 +1110,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ${build_generator_args} --build-project CPackComponentsForAll --build-options ${build_options} - -DCPACK_GENERATOR:STRING=${CPackGen} + -DCPACK_GENERATOR:STRING=${CPACK_GENERATOR_STRING_${CPackGen}} -DCPACK_BINARY_${CPackGen}:BOOL=ON ${CPackRun_CPackComponentWay} ${CPackComponentsForAll_BUILD_OPTIONS} @@ -1260,80 +1344,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt") - # On Windows there is no RPATH, so while Qt might be available for building, - # the required dlls may not be in the PATH, so we can't run the executables - # on that platform. - if(WIN32) - set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V) - set(run_autouic_test ${CMAKE_CTEST_COMMAND} -V) - else() - set(run_autogen_test complex/QtAutogen) - set(run_autouic_test QtAutoUicInterface) + if(NOT DEFINED CMake_TEST_Qt5) + set(CMake_TEST_Qt5 1) endif() - if(NOT CMAKE_CONFIGURATION_TYPES) - set(QtAutogen_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>) + if(CMake_TEST_Qt5) + find_package(Qt5Widgets QUIET NO_MODULE) endif() - - find_package(Qt5Widgets QUIET NO_MODULE) - if(Qt5Widgets_FOUND) - add_test(NAME Qt5Autogen COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutogen" - "${CMake_BINARY_DIR}/Tests/Qt5Autogen" - ${build_generator_args} - --build-project QtAutogen - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen" - --force-new-ctest-process - --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 - ${QtAutogen_BUILD_OPTIONS} - --test-command ${run_autogen_test} - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen") - - add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" - "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface" - ${build_generator_args} - --build-project QtAutoUicInterface - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface" - --force-new-ctest-process - --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 - --test-command ${run_autouic_test} - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface") + if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) + add_subdirectory(Qt5Autogen) endif() if(QT4_WORKS AND QT_QTGUI_FOUND) - add_test(NAME Qt4Autogen COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutogen" - "${CMake_BINARY_DIR}/Tests/Qt4Autogen" - ${build_generator_args} - --build-project QtAutogen - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen" - --force-new-ctest-process - --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 - ${QtAutogen_BUILD_OPTIONS} - --test-command ${run_autogen_test} - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen") - - add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" - "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface" - ${build_generator_args} - --build-project QtAutoUicInterface - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface" - --force-new-ctest-process - --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 - --test-command ${run_autouic_test} - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface") + add_subdirectory(Qt4Autogen) add_test(Qt4Targets ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1350,18 +1371,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets") if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0) - add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND} + add_test(Qt4And5AutomocForward ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc" - "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc" + "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward" ${build_generator_args} --build-project Qt4And5Automoc - --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward" --force-new-ctest-process --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward") add_test(Qt4And5AutomocReverse ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc" @@ -1377,6 +1398,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() endif() + if(CMake_TEST_FindALSA) + add_subdirectory(FindALSA) + endif() + if(CMake_TEST_CUDA) add_subdirectory(Cuda) add_subdirectory(CudaOnly) @@ -1390,10 +1415,50 @@ ${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_FindCups) + add_subdirectory(FindCups) + endif() + if(CMake_TEST_FindDoxygen) add_subdirectory(FindDoxygen) endif() + if(CMake_TEST_FindEnvModules) + add_subdirectory(FindEnvModules) + endif() + + if(CMake_TEST_FindEXPAT) + add_subdirectory(FindEXPAT) + endif() + + if(CMake_TEST_FindFontconfig) + add_subdirectory(FindFontconfig) + endif() + + if(CMake_TEST_FindFreetype) + add_subdirectory(FindFreetype) + endif() + + if(CMake_TEST_FindGDAL) + add_subdirectory(FindGDAL) + endif() + + if(CMake_TEST_FindGIF) + add_subdirectory(FindGIF) + endif() + + if(CMake_TEST_FindGit) + add_subdirectory(FindGit) + endif() + + if(CMake_TEST_FindGLEW) + add_subdirectory(FindGLEW) + endif() + if(CMake_TEST_FindGSL) add_subdirectory(FindGSL) endif() @@ -1403,26 +1468,54 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(GoogleTest) endif() + if(CMake_TEST_FindGTK2) + add_subdirectory(FindGTK2) + endif() + + if(CMake_TEST_FindIconv) + add_subdirectory(FindIconv) + endif() + if(CMake_TEST_FindICU) add_subdirectory(FindICU) endif() + if(CMake_TEST_FindJPEG) + add_subdirectory(FindJPEG) + endif() + if(CMake_TEST_FindJsonCpp) add_subdirectory(FindJsonCpp) endif() + if(CMake_TEST_FindLibLZMA) + add_subdirectory(FindLibLZMA) + endif() + if(CMake_TEST_FindLibRHash) add_subdirectory(FindLibRHash) endif() + if(CMake_TEST_FindLibinput) + add_subdirectory(FindLibinput) + endif() + if(CMake_TEST_FindLibUV) add_subdirectory(FindLibUV) endif() + if(CMake_TEST_FindLibXml2) + add_subdirectory(FindLibXml2) + endif() + if(CMake_TEST_FindLTTngUST) add_subdirectory(FindLTTngUST) endif() + if(CMake_TEST_FindODBC) + add_subdirectory(FindODBC) + endif() + if(CMake_TEST_FindOpenCL) add_subdirectory(FindOpenCL) endif() @@ -1447,10 +1540,22 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindPNG) endif() + if(CMake_TEST_FindPatch) + add_subdirectory(FindPatch) + endif() + + if(CMake_TEST_FindPostgreSQL) + add_subdirectory(FindPostgreSQL) + endif() + if(CMake_TEST_FindProtobuf) add_subdirectory(FindProtobuf) endif() + if(CMake_TEST_FindSQLite3) + add_subdirectory(FindSQLite3) + endif() + if(CMake_TEST_FindTIFF) add_subdirectory(FindTIFF) endif() @@ -1459,6 +1564,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindVulkan) endif() + if(CMake_TEST_FindX11) + add_subdirectory(FindX11) + endif() + if(CMake_TEST_FindXalanC) add_subdirectory(FindXalanC) endif() @@ -1467,18 +1576,43 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindXercesC) endif() + if(CMake_TEST_FindPython OR CMake_TEST_FindPython_NumPy) + add_subdirectory(FindPython) + endif() + + if(CMake_TEST_UseSWIG) + add_subdirectory(UseSWIG) + endif() + add_subdirectory(FindThreads) # Matlab module - if(CMake_TEST_FindMatlab) + # CMake_TEST_FindMatlab: indicates to look for Matlab (from PATH for Linux) + # CMake_TEST_FindMatlab_ROOT_DIR: indicates an optional root directory for Matlab, allows to select a version. + # CMake_TEST_FindMatlab_MCR: indicates the MCR is installed + # CMake_TEST_FindMatlab_MCR_ROOT_DIR: indicates an optional root directory for the MCR, required on Linux + if(CMake_TEST_FindMatlab OR (NOT "${CMake_TEST_FindMatlab_ROOT_DIR}" STREQUAL "") OR + CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "")) + set(FindMatlab_additional_test_options ) + if(CMake_TEST_FindMatlab_MCR OR NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "") + set(FindMatlab_additional_test_options -DIS_MCR=TRUE) + endif() + if(NOT "${CMake_TEST_FindMatlab_ROOT_DIR}" STREQUAL "") + set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMatlab_ROOT_DIR=${CMake_TEST_FindMatlab_ROOT_DIR}") + endif() + if(NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "") + set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMCR_ROOT:FILEPATH=${CMake_TEST_FindMatlab_MCR_ROOT_DIR}") + endif() + set(FindMatlab.basic_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set(FindMatlab.versions_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set(FindMatlab.components_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) - endif() - - find_package(GTK2 QUIET) - if(GTK2_FOUND) - add_subdirectory(FindGTK2) + set(FindMatlab.failure_reports_BUILD_OPTIONS ${FindMatlab_additional_test_options}) + ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set(FindMatlab.r2018a_check_BUILD_OPTIONS ${FindMatlab_additional_test_options}) + ADD_TEST_MACRO(FindMatlab.r2018a_check ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) endif() add_test(ExternalProject ${CMAKE_CTEST_COMMAND} @@ -1494,6 +1628,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 @@ -1520,6 +1655,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir") + add_test(NAME ExternalProjectSourceSubdirNotCMake + COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ExternalProjectSourceSubdirNotCMake" + "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdirNotCMake" + ${build_generator_args} + --build-project ExternalProjectSourceSubdirNotCMake + --force-new-ctest-process + --build-options ${build_options} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdirNotCMake") + add_test(ExternalProjectLocal ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalProjectLocal" @@ -1533,6 +1680,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} @@ -1548,6 +1696,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 @@ -1562,23 +1711,43 @@ ${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 ) # do each of the tutorial steps - foreach(STP RANGE 1 7) - add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND} + function(add_tutorial_test step_name use_mymath) + set(tutorial_test_name Tutorial${step_name}) + set(tutorial_build_dir "${CMake_BINARY_DIR}/Tests/Tutorial/${step_name}") + if (use_mymath) + set(tutorial_build_options "") + else() + set(tutorial_test_name ${tutorial_test_name}_MYMATH) + set(tutorial_build_dir "${tutorial_build_dir}_MYMATH") + set(tutorial_build_options -DUSE_MYMATH:BOOL=OFF) + endif() + add_test(${tutorial_test_name} ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}" - "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}" - --build-two-config + "${CMake_SOURCE_DIR}/Tests/Tutorial/${step_name}" + ${tutorial_build_dir}_Build ${build_generator_args} --build-project Tutorial - --build-options ${build_options} + --build-options ${build_options} ${tutorial_build_options} --test-command Tutorial 25.0) - endforeach() - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/${tutorial_build_dir}_Build") + endfunction() + + if(NOT CMake_TEST_EXTERNAL_CMAKE) + foreach(STP RANGE 1 11) + add_tutorial_test(Step${STP} TRUE) + endforeach() + add_tutorial_test(Complete TRUE) + foreach(STP RANGE 3 11) + add_tutorial_test(Step${STP} FALSE) + endforeach() + add_tutorial_test(Complete FALSE) + endif() add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test @@ -1763,7 +1932,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1) set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2) set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1) - set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall) # Test static linking on toolchains known to support it. if(CMAKE_C_COMPILER_ID STREQUAL "GNU" @@ -1833,6 +2001,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") ADD_TEST_MACRO(PrecompiledHeader foo) endif() + set(MSVCRuntimeLibrary_BUILD_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + ADD_TEST_MACRO(MSVCRuntimeLibrary) + if(CMAKE_Fortran_COMPILER) + ADD_TEST_MACRO(MSVCRuntimeLibrary.Fortran) + endif() endif() if(MSVC OR "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") @@ -1841,7 +2014,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) - if("${CMAKE_GENERATOR}" MATCHES "Makefile") + if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR + "${CMAKE_GENERATOR}" MATCHES "Ninja") add_test(MakeClean ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MakeClean" @@ -1882,6 +2056,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release message(STATUS ".vcproj file association indicates VCExpress, avoiding MFC test") set(CTEST_RUN_MFC OFF) + elseif( NOT ov ) + message(STATUS + ".vcproj has no file association, avoiding MFC test") + set(CTEST_RUN_MFC OFF) endif() endif() @@ -1961,7 +2139,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) @@ -1972,7 +2150,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() @@ -2046,58 +2224,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() endif() - if(WIN32) - # Macro to search for available Windows CE SDKs in the windows Registry - macro(select_wince_sdk selected_reg selected_sdk) - if(CMAKE_HOST_WIN32) - execute_process(COMMAND reg QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs" - OUTPUT_VARIABLE sdk_reg - ERROR_VARIABLE my_err) - string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}") - list(LENGTH sdk_list sdk_list_len) - if (${sdk_list_len} GREATER 1) - list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above - string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name - endif() - # Build a key to be used by get_filename_component that is pointing to the SDK directory - set(_reg "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs\\${_sdk}]") - - # Set return values - set(${selected_reg} ${_reg}) - set(${selected_sdk} ${_sdk}) - endif(CMAKE_HOST_WIN32) - endmacro(select_wince_sdk) - - set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]") - set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]") - set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]") - set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]") - set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]") - set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]") - set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]") - set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]") - set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]") - select_wince_sdk(reg_wince wince_sdk) - set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]") - set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]") - foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) - get_filename_component(r "${reg_${reg}}" ABSOLUTE) - if(IS_DIRECTORY "${r}") - set(${reg} 1) - else() - set(${reg} 0) - endif() - endforeach() - endif() - get_filename_component(ntver "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion;CurrentVersion]" NAME) if(WIN32 AND ntver VERSION_GREATER 6.1) # Windows >= 8.0 - macro(add_test_VSWinStorePhone name generator systemName systemVersion) + macro(add_test_VSWinStorePhone name generator systemName systemVersion architecture) add_test(NAME VSWinStorePhone.${name} COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VSWinStorePhone" "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}" --build-generator "${generator}" + --build-generator-platform "${architecture}" --build-project VSWinStorePhone --build-config $<CONFIGURATION> --build-options -DCMAKE_SYSTEM_NAME=${systemName} @@ -2107,14 +2242,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endmacro() if(vs11 AND ws80) - add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0) - add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012 ARM" WindowsStore 8.0) - add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012 Win64" WindowsStore 8.0) + add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0 Win32) + add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012" WindowsStore 8.0 ARM) + add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012" WindowsStore 8.0 x64) endif() if(vs12 AND ws81) - add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1) - add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013 ARM" WindowsStore 8.1) - add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013 Win64" WindowsStore 8.1) + add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1 Win32) + add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013" WindowsStore 8.1 ARM) + add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013" WindowsStore 8.1 x64) add_test(NAME VSXaml COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test @@ -2127,18 +2262,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release -DCMAKE_SYSTEM_VERSION=8.1 ) endif() + if(CMake_TEST_VSWinStorePhone_VS_2017 AND ws10_0) + add_test_VSWinStorePhone(vs15-store10_0-X86 "Visual Studio 15 2017" WindowsStore 10.0 Win32) + add_test_VSWinStorePhone(vs15-store10_0-ARM "Visual Studio 15 2017" WindowsStore 10.0 ARM) + add_test_VSWinStorePhone(vs15-store10_0-X64 "Visual Studio 15 2017" WindowsStore 10.0 x64) + add_test_VSWinStorePhone(vs15-store10_0-ARM64 "Visual Studio 15 2017" WindowsStore 10.0 ARM64) + endif() if(vs14 AND ws10_0) - add_test_VSWinStorePhone(vs14-store10_0-X86 "Visual Studio 14 2015" WindowsStore 10.0) - add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015 ARM" WindowsStore 10.0) - add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015 Win64" WindowsStore 10.0) + add_test_VSWinStorePhone(vs14-store10_0-X86 "Visual Studio 14 2015" WindowsStore 10.0 Win32) + add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015" WindowsStore 10.0 ARM) + add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015" WindowsStore 10.0 x64) endif() if(vs11 AND wp80) - add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0) - add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012 ARM" WindowsPhone 8.0) + add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0 Win32) + add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012" WindowsPhone 8.0 ARM) endif() if(vs12 AND wp81) - add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1) - add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013 ARM" WindowsPhone 8.1) + add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1 Win32) + add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013" WindowsPhone 8.1 ARM) endif() endif() @@ -2171,37 +2312,113 @@ ${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() if (CMake_TEST_GreenHillsMULTI) - macro(add_test_GhsMulti name primaryTarget bspName) - add_test(NAME GhsMulti.${name} COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/GhsMulti" - "${CMake_BINARY_DIR}/Tests/GhsMulti/${name}" - --build-generator "Green Hills MULTI" - --build-project ReturnNum - --build-config $<CONFIGURATION> - --build-options -DGHS_PRIMARY_TARGET=${primaryTarget} - -DGHS_BSP_NAME=${bspName} - ) - endmacro () - add_test_GhsMulti("arm_integrity_simarm" "arm_integrity.tgt" "simarm") - add_test_GhsMulti("arm64_integrity_simarm" "arm64_integrity.tgt" "simarm") - add_test(NAME GhsMulti.duplicate_source_filenames + macro(add_test_GhsMulti test_name test_dir bin_sub_dir build_opts) + separate_arguments(_ghs_build_opts UNIX_COMMAND ${build_opts}) + separate_arguments(_ghs_toolset_extra UNIX_COMMAND ${ghs_toolset_extra}) + if(${ARGC} GREATER 4) + set(_ghs_test_command --test-command ${ARGN}) + endif() + if(ghs_config_name STREQUAL "__default__") + set(_ghs_test_name "${test_name}") + else() + set(_ghs_test_name "${ghs_config_name}.${test_name}") + endif() + add_test(NAME GhsMulti.${_ghs_test_name} COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/GhsMultiDuplicateSourceFilenames" - "${CMake_BINARY_DIR}/Tests/GhsMultiDuplicateSourceFilenames" + "${CMake_SOURCE_DIR}/Tests/GhsMulti/${test_dir}" + "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}/${test_dir}/${bin_sub_dir}" --build-generator "Green Hills MULTI" - --build-project ReturnNum + --build-project test --build-config $<CONFIGURATION> - --build-options -DGHS_PRIMARY_TARGET="arm_integrity.tgt" - -DGHS_BSP_NAME="simarm" + --force-new-ctest-process + --build-options ${ghs_target_arch} ${ghs_toolset_name} ${ghs_toolset_root} ${ghs_target_platform} + ${ghs_os_root} ${ghs_os_dir} ${ghs_bsp_name} ${_ghs_build_opts} ${_ghs_toolset_extra} + ${_ghs_test_command} ) - endif () + unset(_ghs_build_opts) + unset(_ghs_toolset_extra) + unset(_ghs_test_command) + unset(_ghs_test_name) + endmacro() + macro(add_test_GhsMulti_rename_install test_name) + add_test_GhsMulti( ${test_name} GhsMultiRenameInstall ${test_name} + "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target install) + endmacro() + #unset ghs config variables + unset(ghs_config_name) + unset(ghs_target_arch) + unset(ghs_toolset_root) + unset(ghs_toolset_name) + unset(ghs_os_root) + unset(ghs_os_dir) + unset(ghs_target_platform) + unset(ghs_bsp_name) + unset(ghs_toolset_extra) + if(NOT CMake_TEST_GreenHillsMULTI_config) + #if list of config settings not defined then just run once as default + set(CMake_TEST_GreenHillsMULTI_config "__default__") + endif() + foreach(ghs_file IN LISTS CMake_TEST_GreenHillsMULTI_config) + # source GHS tools config file + if(NOT ghs_file STREQUAL "__default__") + if(IS_ABSOLUTE ${ghs_file}) + include(${ghs_file}) + else() + include(${CMAKE_BINARY_DIR}/${ghs_file}) + endif() + endif() + if(NOT ghs_config_name) + set(ghs_config_name "__default__") + endif() + # test integrity build + if (NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity")) + add_test_GhsMulti(integrityDDInt GhsMultiIntegrity/GhsMultiIntegrityDDInt "" "") + add_test_GhsMulti(integrityMonolith GhsMultiIntegrity/GhsMultiIntegrityMonolith "" "") + add_test_GhsMulti(integrityDD GhsMultiIntegrity/GhsMultiIntegrityDD "" "") + endif() + add_test_GhsMulti(duplicate_source_filenames GhsMultiDuplicateSourceFilenames "" "") + add_test_GhsMulti_rename_install(SINGLE_EXEC) + add_test_GhsMulti_rename_install(SINGLE_EXEC_RENAMED) + add_test_GhsMulti_rename_install(EXEC_AND_LIB) + add_test_GhsMulti(multiple_source_groups GhsMultiSrcGroups Default "") + add_test_GhsMulti(multiple_source_groups_folders GhsMultiSrcGroups PropFolders "-DTEST_PROP=ON") + add_test_GhsMulti(multiple_source_groups_all_folders GhsMultiSrcGroups AllFolders "-DCMAKE_GHS_NO_SOURCE_GROUP_FILE=ON") + add_test_GhsMulti(unsupported_targets GhsMultiUnsupportedTargets "" "") + add_test_GhsMulti(object_library GhsMultiObjectLibrary "" "") + add_test_GhsMulti(exclude GhsMultiExclude "" "" + ${CMAKE_CMAKE_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/GhsMulti/GhsMultiExclude/verify.cmake) + add_test_GhsMulti(interface GhsMultiInterface "" "") + add_test_GhsMulti(transitive_link_test GhsMultiLinkTest TransitiveLink "-DRUN_TEST=NO_FLAGS") + add_test_GhsMulti(flags_link_test GhsMultiLinkTest FlagsCheck "-DRUN_TEST=CHECK_FLAGS") + add_test_GhsMulti(sub_link_test GhsMultiLinkTestSub "" "") + add_test_GhsMulti(multiple_projects GhsMultiMultipleProjects "" "" + ${CMAKE_CMAKE_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake) + add_test_GhsMulti(compiler_options_none GhsMultiCompilerOptions None "-DRUN_TEST=RELEASE_FLAGS -DRUN_TEST_BUILD_TYPE=\"\"") + add_test_GhsMulti(compiler_options_kernel GhsMultiCompilerOptions Kernel "-DRUN_TEST=KERNEL_FLAGS -DRUN_TEST_BUILD_TYPE=DEBUG") + add_test_GhsMulti(try_compile_copy GhsMultiCopyFile "" "") + add_test_GhsMulti(ghs_platform GhsMultiPlatform "" "") + add_test_GhsMulti(custom_target GhsMultiCustomTarget "" "") + add_test_GhsMulti(dep_order GhsMultiDepOrder "" "") + add_test_GhsMulti(external_project GhsMultiExternalProject "" "") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}") + #unset ghs config variables + unset(ghs_config_name) + unset(ghs_target_arch) + unset(ghs_toolset_root) + unset(ghs_toolset_name) + unset(ghs_os_root) + unset(ghs_os_dir) + unset(ghs_target_platform) + unset(ghs_bsp_name) + unset(ghs_toolset_extra) + endforeach() + endif() if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ") macro(add_test_VSNsightTegra name generator) @@ -2315,24 +2532,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) - # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails - # this test. (See #13371) - # Apparently Visual Studio does not support it either. As the MakeClean - # test above is only run with the Makefiles generator, only run this - # test with the Makefiles generator also. - add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused" - "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" - ${build_generator_args} - --build-project WarnUnusedCliUnused - --build-options ${build_options} - "-DUNUSED_CLI_VARIABLE=Unused") - set_tests_properties(WarnUnusedCliUnused PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") - endif() + add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused" + "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" + ${build_generator_args} + --build-project WarnUnusedCliUnused + --build-options ${build_options} + "-DUNUSED_CLI_VARIABLE=Unused") + set_tests_properties(WarnUnusedCliUnused PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND} --build-and-test @@ -2617,12 +2827,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA" DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage") add_test(NAME CTestGTMCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/MumpsCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestGTMCoverage PROPERTIES PASS_REGULAR_EXPRESSION - "Process file.*ZZCOVTST.m.*Total LOC:.*30.*Percentage Coverage: 80.00*" + "Process file.*ZZCOVTST.m.*Total LOC:.*32.*Percentage Coverage: 81.25*" ENVIRONMENT COVFILE=) configure_file( @@ -2635,12 +2845,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA" DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage") add_test(NAME CTestCacheCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestCacheCoverage PROPERTIES PASS_REGULAR_EXPRESSION - "Process file.*ZZCOVTST.m.*Total LOC:.*29.*Percentage Coverage: 86.21.*" + "Process file.*ZZCOVTST.m.*Total LOC:.*32.*Percentage Coverage: 87.50.*" ENVIRONMENT COVFILE=) # Adding a test case for Python Coverage @@ -2653,7 +2863,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest" DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage") add_test(NAME CTestPythonCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/PythonCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestPythonCoverage PROPERTIES @@ -2671,7 +2881,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src" DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage") add_test(NAME CTestCoberturaCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/CoberturaCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestCoberturaCoverage PROPERTIES @@ -2690,7 +2900,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release configure_file("${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml.in" "${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml") add_test(NAME CTestJacocoCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/JacocoCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestJacocoCoverage PROPERTIES @@ -2709,7 +2919,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release DESTINATION "${CMake_BINARY_DIR}/Testing/JavascriptCoverage" FILES_MATCHING PATTERN "*.js") add_test(NAME CTestJavascriptCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/JavascriptCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestJavascriptCoverage PROPERTIES @@ -2727,7 +2937,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in" "${CMake_BINARY_DIR}/Testing/DelphiCoverage/UTCovTest(UTCovTest.pas).html") add_test(NAME CTestDelphiCoverage - COMMAND cmake -E chdir + COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir ${CMake_BINARY_DIR}/Testing/DelphiCoverage $<TARGET_FILE:ctest> -T Coverage --debug) set_tests_properties(CTestDelphiCoverage PROPERTIES @@ -2779,19 +2989,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log" ) + ADD_TEST_MACRO(CMakeCommands.add_compile_definitions add_compile_definitions) ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options) ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries) ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories) ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions) ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options) + ADD_TEST_MACRO(CMakeCommands.target_sources target_sources) - if(CMake_TEST_SERVER_MODE) - # The cmake server-mode test requires python for a simple client. - find_package(PythonInterp QUIET) - if(PYTHON_EXECUTABLE) - set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}) - ADD_TEST_MACRO(Server Server) - endif() + ADD_TEST_MACRO(CMakeCommands.add_link_options) + ADD_TEST_MACRO(CMakeCommands.target_link_options) + ADD_TEST_MACRO(CMakeCommands.link_directories) + ADD_TEST_MACRO(CMakeCommands.target_link_directories) + + # The cmake server-mode test requires python for a simple client. + find_package(PythonInterp QUIET) + if(PYTHON_EXECUTABLE) + set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}) + ADD_TEST_MACRO(Server Server) endif() configure_file( @@ -2808,7 +3023,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release PASS_REGULAR_EXPRESSION "Failed") else() set_tests_properties(CTestTestCrash PROPERTIES - PASS_REGULAR_EXPRESSION "(Illegal|SegFault)") + PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Child aborted)") endif() configure_file( @@ -3035,8 +3250,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_test(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N) - add_test(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B) - configure_file( "${CMake_SOURCE_DIR}/Tests/CTestTestFdSetSize/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake" @@ -3071,12 +3284,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log" ) - configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) - add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} - -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V - --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" - ) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) + add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" + ) + endif() if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja") configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in" @@ -3108,11 +3323,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif () - get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest2 - PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - endif () + if(NOT CMake_TEST_EXTERNAL_CMAKE) + get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties ( CTestTest2 + PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + endif() + endif() endif () if(CMake_TEST_EXTERNAL_CMAKE) @@ -3176,6 +3393,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} -DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES} + ${CMake_TEST_FortranModules_BUILD_OPTIONS} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules") endif() @@ -3239,37 +3457,71 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + add_test(Java.JarSourceListAndOutput ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput" + ${build_generator_args} + --build-project hello + --build-target hello3 + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput/hello3" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -classpath hello3.jar HelloWorld) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput") - # For next test, java tool must have same architecture as toolchain + # For next tests, java tool must have same architecture as toolchain math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") execute_process( COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result ) if(_result EQUAL 0) - if(CMAKE_CONFIGURATION_TYPES) - set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>) - else() - set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + ## next test is valid only if Java version is less than 1.10 + if ("${Java_VERSION}" VERSION_LESS 1.10) + if(_isMultiConfig) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() + ## next test is valid only if Java is, at least, version 1.8 + if (NOT "${Java_VERSION}" VERSION_LESS 1.8) + if(_isMultiConfig) + set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/$<CONFIGURATION>) + else() + set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders) + endif() + add_test(NAME Java.NativeHeaders COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders" + "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders" + ${build_generator_args} + --build-project helloJavaNativeHeaders + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVANATIVEHEADERS_LIBRARY_PATH} -classpath hello4.jar HelloWorld3) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders") endif() - add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/JavaJavah" - "${CMake_BINARY_DIR}/Tests/JavaJavah" - ${build_generator_args} - --build-project helloJavah - --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" - --build-options ${build_options} - --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") endif() endif() endif() endif() # add some cross compiler tests, for now only with makefile based generators - if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop") + if(CMAKE_GENERATOR MATCHES "Makefiles") # if sdcc is found, build the SimpleCOnly project with sdcc find_program(SDCC_EXECUTABLE sdcc) @@ -3348,35 +3600,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) endif() - add_test(NAME CMakeWizardTest COMMAND cmake -i) - set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION - "The \"cmake -i\" wizard mode is no longer supported.") - - # If the cache variable CMAKE_CONTRACT_PROJECTS is set - # then the dashboard will run a contract with CMake test of that - # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run - # the vtk542 contract test. - # For each Contract test, the project should provide a directory - # with at least one CMakeLists.txt file that uses ExternalProject - # to download and configure the project. The directory should also - # contain a RunTest.cmake file that has a single set of the format: - # set(project_RUN_TEST testToRun) - # The testToRun should be a test executable that can be run to - # smoke test the build. - foreach(project ${CMAKE_CONTRACT_PROJECTS}) - include(Contracts/${project}/RunTest.cmake) - ADD_TEST_MACRO(Contracts.${project} - ${${project}_RUN_TEST}) - # Contract test timeout in seconds. - # Default to 6 hours. - if(DEFINED ${project}_TEST_TIMEOUT) - set(timeout ${${project}_TEST_TIMEOUT}) - elseif(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT) - set(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT}) - else() - set(timeout 21600) + # Define a set of "contract" tests, each activated by a cache entry + # named "CMake_TEST_CONTRACT_<project>". For each Contract test, + # the project should provide a directory with a CMakeLists.txt file + # that uses ExternalProject to download and configure the project. + # The directory should also contain a Configure.cmake file that + # sets "CMake_TEST_CONTRACT_<project>_<var>" variables to configure + # the code below. + foreach(project + PLplot + Trilinos + VTK + ) + if(CMake_TEST_CONTRACT_${project}) + include(Contracts/${project}/Configure.cmake) + ADD_TEST_MACRO(Contracts.${project} ${CMake_TEST_CONTRACT_${project}_RUN_TEST}) + # The external projects may take a long time to build. + if(DEFINED CMake_TEST_CONTRACT_${project}_TIMEOUT) + set(timeout ${CMake_TEST_CONTRACT_${project}_TIMEOUT}) + elseif(CMake_TEST_CONTRACT_DEFAULT_TIMEOUT) + set(timeout ${CMake_TEST_CONTRACT_DEFAULT_TIMEOUT}) + else() + set(timeout 21600) + endif() + set_property(TEST Contracts.${project} PROPERTY TIMEOUT "${timeout}") endif() - set_tests_properties(Contracts.${project} PROPERTIES TIMEOUT ${timeout}) endforeach() if(TEST_CompileCommandOutput) @@ -3397,6 +3645,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --test-command IncludeDirectories) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories") + if(CMAKE_GENERATOR MATCHES "^((Unix|MSYS) Makefiles|Ninja)$" AND + ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4) + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))) + add_test(IncludeDirectoriesCPATH ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/IncludeDirectoriesCPATH" + "${CMake_BINARY_DIR}/Tests/IncludeDirectoriesCPATH" + --build-two-config + ${build_generator_args} + --build-project IncludeDirectoriesCPATH + --build-options ${build_options}) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectoriesCPATH") + set_tests_properties(IncludeDirectoriesCPATH + PROPERTIES + ENVIRONMENT "CPATH=${CMAKE_CURRENT_SOURCE_DIR}/IncludeDirectoriesCPATH/viacpath") + endif() + add_test(InterfaceLinkLibraries ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/InterfaceLinkLibraries" diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 443d366c4..a53e4418b 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -86,7 +86,7 @@ foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG endforeach() foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2 - HDF5 LibArchive OPENSCENEGRAPH RUBY SWIG Protobuf) + HDF5 JPEG LibArchive OPENSCENEGRAPH RUBY SWIG Protobuf) check_version_string(${VTEST} ${VTEST}_VERSION) endforeach() diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index c84fa748c..1aeab8b39 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() @@ -56,7 +56,19 @@ add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake ) -include(${CMAKE_SOURCE_DIR}/Modules/CMakeParseArguments.cmake) +add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectIncludeAny + -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) + +add_test(CMakeOnly.ProjectIncludeBefore ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectIncludeBefore + -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) + +include(CMakeParseArguments) function(add_major_test module) cmake_parse_arguments(MAJOR_TEST "NOLANG" "VERSION_VAR" "VERSIONS" ${ARGN}) diff --git a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt index 9be69f128..1f9d3acb7 100644 --- a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt @@ -57,7 +57,7 @@ else() message("Unhandled Platform") endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") check_cxx_compiler_flag("-x c++" HAVE_X_CXX) if(NOT HAVE_X_CXX) message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed") diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt index f5336dc03..ca4becb77 100644 --- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -7,7 +7,8 @@ set(expect_C 1) set(expect_CXX 1) unset(expect_Fortran) set(expect_NoSuchLanguage 0) -foreach(lang C CXX Fortran NoSuchLanguage) + +foreach(lang C CXX Fortran CUDA NoSuchLanguage) check_language(${lang}) if(NOT DEFINED CMAKE_${lang}_COMPILER) message(FATAL_ERROR "check_language(${lang}) did not set result") diff --git a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt index a9abb4ad7..ffce488f4 100644 --- a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt +++ b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt @@ -1,4 +1,4 @@ -project(ProjectInclude) +project(ProjectInclude LANGUAGES NONE) if(NOT AUTO_INCLUDE) message(FATAL_ERROR "include file not found") endif() diff --git a/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt b/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt index 6d1628ae5..3676b1792 100644 --- a/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt +++ b/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(SelectLibraryConfigurations NONE) @@ -15,7 +15,8 @@ macro(check_slc basename expect) endif () endmacro(check_slc) -if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE) set(NOTYPE_RELONLY_LIBRARY_RELEASE "opt") check_slc(NOTYPE_RELONLY "opt") diff --git a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in index 3294a2f0d..a3c2b055a 100644 --- a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in +++ b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in @@ -22,6 +22,25 @@ try_and_print(TOTAL_VIRTUAL_MEMORY) try_and_print(AVAILABLE_VIRTUAL_MEMORY) try_and_print(TOTAL_PHYSICAL_MEMORY) try_and_print(AVAILABLE_PHYSICAL_MEMORY) +try_and_print(IS_64BIT) +try_and_print(HAS_FPU) +try_and_print(HAS_MMX) +try_and_print(HAS_MMX_PLUS) +try_and_print(HAS_SSE) +try_and_print(HAS_SSE2) +try_and_print(HAS_SSE_FP) +try_and_print(HAS_SSE_MMX) +try_and_print(HAS_AMD_3DNOW) +try_and_print(HAS_AMD_3DNOW_PLUS) +try_and_print(HAS_IA64) +try_and_print(HAS_SERIAL_NUMBER) +try_and_print(PROCESSOR_SERIAL_NUMBER) +try_and_print(PROCESSOR_NAME) +try_and_print(PROCESSOR_DESCRIPTION) +try_and_print(OS_NAME) +try_and_print(OS_RELEASE) +try_and_print(OS_VERSION) +try_and_print(OS_PLATFORM) include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in index 8145db7cb..4f2aaea9c 100644 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -308,13 +308,11 @@ message("======================================================================= if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "") # developers are allowed to have local additions and modifications... - set(is_dashboard 0) message("interactive test run") message("") else() - set(is_dashboard 1) message("dashboard test run") message("") @@ -341,7 +339,7 @@ endif() # Not even developers. # if(nonadditions) - if(in_source_build AND is_dashboard) + if(in_source_build) message(" warning: test results confounded because this is an 'in-source' build - cannot distinguish between non-added files that are in-source build products and diff --git a/Tests/CMakeTests/FileDownloadInput.png b/Tests/CMakeTests/FileDownloadInput.png Binary files differindex 7bbcee413..9ab565a1b 100644 --- a/Tests/CMakeTests/FileDownloadInput.png +++ b/Tests/CMakeTests/FileDownloadInput.png diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index f6d9ad99b..39354490b 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -32,7 +32,7 @@ file(DOWNLOAD ${url} ${dir}/file3.png TIMEOUT 2 - EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 + EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) message(STATUS "FileDownload:4") @@ -41,7 +41,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA1=50c614fc28b39c1281d0517bb6d5858b4359c9b7 + EXPECTED_HASH SHA1=67eee17f79d9ac557284fc0b8ad19f25723fb578 ) message(STATUS "FileDownload:5") @@ -50,7 +50,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA224=73cd5f442b04e8320e4f907f8e1b21d4befff98b5bd77bc32526ea68 + EXPECTED_HASH SHA224=ba283726bbb602776818b463943189afd91836cb7ee5dd6e2c7b5ae4 ) message(STATUS "FileDownload:6") @@ -59,7 +59,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA256=2e067f6c09cbc7cd619c8fbcc44eb64cd6b45a95e4cddb3a585eee1f731c4da9 + EXPECTED_HASH SHA256=cf3334b1275071e1da6e8c396ccb72cf1b2388d8c937526f3af26230affb9423 ) message(STATUS "FileDownload:7") @@ -68,7 +68,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA384=398bf41902a7251c30e522b307e3e41e3fb617c765b3feaa99b2f7d063894708ad399267ccc25d877437a10e5e890d35 + EXPECTED_HASH SHA384=43a5d13978d97c660db44481aee0604cb4ff6ca0775cd5c2cd68cd8000e107e507c4caf6c228941231041e282ffb8950 ) message(STATUS "FileDownload:8") @@ -77,7 +77,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH SHA512=c51854d21052713968b849c2b4263cf54be03bc3a7e9847a6c71c6c8d1d13cd805fe1b9fa95f9ba1d0a5631513974f6fae21e34ab5b171d94bad48df5f073e48 + EXPECTED_HASH SHA512=6984e0909a1018030ccaa418e3be1654223cdccff0fe6adc745f9aea7e377f178be53b9fc7d54a6f81c2b62ef9ddcd38ba1978fedf4c5e7139baaf355eefad5b ) message(STATUS "FileDownload:9") file(DOWNLOAD @@ -85,7 +85,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_HASH MD5=d16778650db435bda3a8c3435c3ff5d1 + EXPECTED_HASH MD5=dbd330d52f4dbd60115d4191904ded92 ) message(STATUS "FileDownload:10") @@ -94,7 +94,7 @@ file(DOWNLOAD ${dir}/file3.png TIMEOUT 2 STATUS status - EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 + EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 ) message(STATUS "${status}") diff --git a/Tests/CMakeTests/FileUploadTest.cmake.in b/Tests/CMakeTests/FileUploadTest.cmake.in index 9e2290988..0e6f08048 100644 --- a/Tests/CMakeTests/FileUploadTest.cmake.in +++ b/Tests/CMakeTests/FileUploadTest.cmake.in @@ -35,7 +35,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png" OUTPUT_VARIABLE sum1 OUTPUT_STRIP_TRAILING_WHITESPACE) -if(NOT sum1 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file1.png$") +if(NOT sum1 MATCHES "^dbd330d52f4dbd60115d4191904ded92 .*/uploads/file1.png$") message(FATAL_ERROR "file1.png did not upload correctly (sum1='${sum1}')") endif() @@ -43,7 +43,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png" OUTPUT_VARIABLE sum2 OUTPUT_STRIP_TRAILING_WHITESPACE) -if(NOT sum2 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file2.png$") +if(NOT sum2 MATCHES "^dbd330d52f4dbd60115d4191904ded92 .*/uploads/file2.png$") message(FATAL_ERROR "file2.png did not upload correctly (sum2='${sum2}')") endif() diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in index d7d881e79..f01e616f0 100644 --- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in +++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in @@ -349,6 +349,12 @@ set(aix_xlf90_64_libs "xlf90;xlopt;xlf;xlomp_ser;m;c") set(aix_xlf90_64_dirs "/usr/lpp/xlf/lib") list(APPEND platforms aix_xlf90_64) +# g++ dummy.c -v +set(aix_g++_text " /prefix/libexec/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/collect2 -bpT:0x10000000 -bpD:0x20000000 -btextro /lib/crt0.o /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/crtcxa.o /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/crtdbase.o -L/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0 -L/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/../../.. /tmp//ccKROJ1f.o -lstdc++ -lm -lgcc_s /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a -lc -lgcc_s /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a") +set(aix_g++_libs "stdc++;m;gcc_s;/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a;c;gcc_s;/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a") +set(aix_g++_dirs "/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0;/prefix/lib") +list(APPEND platforms aix_g++) + #----------------------------------------------------------------------------- # HP @@ -409,78 +415,6 @@ set(hp_f90_64_dirs "/usr/lib/hpux64;/opt/langtools/lib/hpux64") list(APPEND platforms hp_f90_64) #----------------------------------------------------------------------------- -# IRIX - -# cc -o32 dummy.c -v -set(irix64_cc_o32_text "/usr/lib/ld -elf -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o -count dummy.o -nocount -lc /usr/lib/crtn.o") -set(irix64_cc_o32_libs "c") -set(irix64_cc_o32_dirs "/usr/lib") -list(APPEND platforms irix64_cc_o32) - -# cc -n32 dummy.c -v -set(irix64_cc_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") -set(irix64_cc_n32_libs "c") -set(irix64_cc_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") -list(APPEND platforms irix64_cc_n32) - -# cc -64 dummy.c -v -set(irix64_cc_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") -set(irix64_cc_64_libs "c") -set(irix64_cc_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") -list(APPEND platforms irix64_cc_64) - -# CC -o32 dummy.cxx -v -set(irix64_CC_o32_text "/usr/lib/ld -elf -cxx -woff 134 -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o /usr/lib/c++init.o -count dummy.o -nocount -dont_warn_unused -lC -warn_unused -lc /usr/lib/crtn.o") -set(irix64_CC_o32_libs "C;c") -set(irix64_CC_o32_dirs "/usr/lib") -list(APPEND platforms irix64_CC_o32) - -# CC -n32 dummy.cxx -v -set(irix64_CC_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -init _main -fini _fini -no_unresolved -transitive_link -demangle -elf -_SYSTYPE_SVR4 -LANG:std -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 -cxx -woff 134 /usr/lib32/mips4/crt1.o /usr/lib32/c++init.o dummy.o -dont_warn_unused -lCsup -lC -lCio -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") -set(irix64_CC_n32_libs "Csup;C;Cio;c") -set(irix64_CC_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") -list(APPEND platforms irix64_CC_n32) - -# CC -64 dummy.cxx -v -set(irix64_CC_64_text "/usr/lib32/cmplrs/ld64 -call_shared -init _main -fini _fini -no_unresolved -transitive_link -demangle -elf -_SYSTYPE_SVR4 -LANG:std -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 -cxx -woff 134 /usr/lib64/mips4/crt1.o /usr/lib64/c++init.o dummy.o -dont_warn_unused -lCsup -lC -lCio -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") -set(irix64_CC_64_libs "Csup;C;Cio;c") -set(irix64_CC_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") -list(APPEND platforms irix64_CC_64) - -# f77 -o32 dummy.f -v -set(irix64_f77_o32_text "/usr/lib/ld -elf -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o -count dummy.o -nocount -lftn -lm -lc /usr/lib/crtn.o") -set(irix64_f77_o32_libs "ftn;m;c") -set(irix64_f77_o32_dirs "/usr/lib") -list(APPEND platforms irix64_f77_o32) - -# f77 -n32 dummy.f -v -set(irix64_f77_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -lftn -lm -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") -set(irix64_f77_n32_libs "ftn;m;c") -set(irix64_f77_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") -list(APPEND platforms irix64_f77_n32) - -# f77 -64 dummy.f -v -set(irix64_f77_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -lftn -lm -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") -set(irix64_f77_64_libs "ftn;m;c") -set(irix64_f77_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") -list(APPEND platforms irix64_f77_64) - -# f90 -o32 dummy.f -v -#f90 ERROR: specified abi -o32 not supported. - -# f90 -n32 dummy.f -v -set(irix64_f90_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -lfortran -lffio -lftn -lm -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") -set(irix64_f90_n32_libs "fortran;ffio;ftn;m;c") -set(irix64_f90_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") -list(APPEND platforms irix64_f90_n32) - -# f90 -64 dummy.f -v -set(irix64_f90_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -lfortran -lffio -lftn -lm -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") -set(irix64_f90_64_libs "fortran;ffio;ftn;m;c") -set(irix64_f90_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") -list(APPEND platforms irix64_f90_64) - -#----------------------------------------------------------------------------- # Cygwin # gcc dummy.c -v @@ -525,6 +459,27 @@ set(msys_g77_dirs "C:/some-mingw/lib/gcc/mingw32/3.4.5;C:/some-mingw/lib/gcc;/so list(APPEND platforms msys_g77) #----------------------------------------------------------------------------- +# MSYS2 + +# gcc dummy.c -v +set(msys2_gcc_text " C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/collect2.exe -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/liblto_plugin-0.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:/msys64/tmp/ccikz9Wf.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtbegin.o -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../.. C:/msys64/tmp/ccK0dTUv.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtend.o") +set(msys2_gcc_libs "mingw32;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;mingw32;gcc;moldname;mingwex") +set(msys2_gcc_dirs "C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0;C:/msys64/mingw64/lib/gcc;C:/msys64/mingw64/x86_64-w64-mingw32/lib;C:/msys64/mingw64/lib") +list(APPEND platforms msys2_gcc) + +# g++ dummy.cxx -v +set(msys2_g++_text " C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/collect2.exe -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/liblto_plugin-0.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:/msys64/tmp/ccJQgvbN.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtbegin.o -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../.. C:/msys64/tmp/ccqPpuVS.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtend.o") +set(msys2_g++_libs "stdc++;mingw32;gcc_s;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;mingw32;gcc_s;gcc;moldname;mingwex") +set(msys2_g++_dirs "C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0;C:/msys64/mingw64/lib/gcc;C:/msys64/mingw64/x86_64-w64-mingw32/lib;C:/msys64/mingw64/lib") +list(APPEND platforms msys2_g++) + +# gfortran dummy.f90 -v +set(msys2_gfortran_text " C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/collect2.exe -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/liblto_plugin-0.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:/msys64/tmp/cczOKIDy.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtbegin.o -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../.. C:/msys64/tmp/ccyXuCgD.o -lgfortran -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lquadmath -lm -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtend.o") +set(msys2_gfortran_libs "gfortran;mingw32;gcc_s;gcc;moldname;mingwex;quadmath;m;mingw32;gcc_s;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;mingw32;gcc_s;gcc;moldname;mingwex") +set(msys2_gfortran_dirs "C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0;C:/msys64/mingw64/lib/gcc;C:/msys64/mingw64/x86_64-w64-mingw32/lib;C:/msys64/mingw64/lib") +list(APPEND platforms msys2_gfortran) + +#----------------------------------------------------------------------------- # MSVC from NVIDIA CUDA set(nvcc_msvc_text [[cuda-fake-ld cl.exe -nologo "tmp/a_dlink.obj" "tmp/CMakeCUDACompilerId.obj" -link -INCREMENTAL:NO "/LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/../lib/x64" cudadevrt.lib cudart_static.lib -Fe"a.exe"]]) @@ -532,7 +487,6 @@ set(nvcc_msvc_libs "cudadevrt.lib;cudart_static.lib") set(nvcc_msvc_dirs "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64") list(APPEND platforms nvcc_msvc) - #----------------------------------------------------------------------------- # PGI on Windows diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index 76f5e4f6a..f517e64a6 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -53,6 +53,10 @@ set(result andy brad) list(INSERT result -1 bill ken) TEST("INSERT result -1 bill ken" "andy;bill;ken;brad") +set(result andy brad) +list(INSERT result 2 bill ken) +TEST("INSERT result 2 bill ken" "andy;brad;bill;ken") + set(result andy bill brad ken bob) list(REMOVE_ITEM result bob) TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken") diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in index b4c48f4f4..cbd879def 100644 --- a/Tests/CMakeTests/PushCheckStateTest.cmake.in +++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.8) include(CMakePushCheckState) set(CMAKE_EXTRA_INCLUDE_FILES file1) @@ -26,6 +27,27 @@ set(CMAKE_REQUIRED_LIBRARIES lib3) set(CMAKE_REQUIRED_FLAGS flag3) set(CMAKE_REQUIRED_QUIET 3) +cmake_push_check_state(RESET) + +foreach(pair IN ITEMS + EXTRA_INCLUDE_FILES| + REQUIRED_INCLUDES| + REQUIRED_DEFINITIONS| + REQUIRED_LIBRARIES| + REQUIRED_FLAGS| + REQUIRED_QUIET| + ) + string(REPLACE "|" ";" pair "${pair}") + list(GET pair 0 var) + list(GET pair 1 expected) + if (NOT "${CMAKE_${var}}" STREQUAL "${expected}") + set(fatal TRUE) + message("ERROR: CMAKE_${var} is \"${CMAKE_${var}}\" (expected \"${expected}\")" ) + endif() +endforeach() + +cmake_pop_check_state() + cmake_pop_check_state() foreach(pair IN ITEMS diff --git a/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake index a93e7f546..43c93848e 100644 --- a/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake +++ b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake @@ -11,12 +11,12 @@ string(TIMESTAMP days "%j" UTC) # see if we are somewhere in the right region. math(EXPR years_since_epoch "${year} - 1970") -math(EXPR lower_bound "((${years_since_epoch} * 365) + ${days}) * 86400") +math(EXPR lower_bound "((${years_since_epoch} * 365) + ${days} - 1) * 86400") math(EXPR upper_bound "((${years_since_epoch} * 366) + ${days}) * 86400") -if(unix_time GREATER lower_bound AND unix_time LESS upper_bound) +if(unix_time GREATER_EQUAL lower_bound AND unix_time LESS upper_bound) message("~${unix_time}~") else() - message(FATAL_ERROR "${timestamp} unix time not in expected range [${lower_bound}, ${upper_bound}]") + message(FATAL_ERROR "${timestamp} unix time not in expected range [${lower_bound}, ${upper_bound})") endif() diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 83655dae5..154afa7f8 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -47,7 +47,7 @@ set(TIMESTAMP-AllSpecifiers-STDERR "~[0-9]+(;[0-9]+)*~") set(TIMESTAMP-MonthWeekNames-RESULT 0) set(TIMESTAMP-MonthWeekNames-STDERR "~[^%]+;[^%]+~") set(TIMESTAMP-UnixTime-RESULT 0) -set(TIMESTAMP-UnixTime-STDERR "~[1-9][0-9]+~") +set(TIMESTAMP-UnixTime-STDERR "~[0-9]+~") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(String @@ -81,7 +81,7 @@ check_cmake_test(String # Execute each test listed in StringTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake") -set(number_of_tests_expected 70) +set(number_of_tests_expected 74) include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") execute_all_script_tests(${scriptname} number_of_tests_executed) diff --git a/Tests/CMakeTests/StringTestScript.cmake b/Tests/CMakeTests/StringTestScript.cmake index 44d56531f..e069897b6 100644 --- a/Tests/CMakeTests/StringTestScript.cmake +++ b/Tests/CMakeTests/StringTestScript.cmake @@ -1,5 +1,18 @@ message(STATUS "testname='${testname}'") +function(test_configure_line_number EXPRESSION POLICY) + cmake_policy(PUSH) + cmake_policy(SET CMP0053 ${POLICY}) + string(CONFIGURE + "${EXPRESSION}" v) # line should indicate string() call + math(EXPR vplus3 "${v} + 3") + if(NOT ${CMAKE_CURRENT_LIST_LINE} EQUAL ${vplus3}) + message(SEND_ERROR "Couldn't configure CMAKE_CURRENT_LIST_LINE, evaluated into '${v}'") + endif() + message(STATUS "v='${v}'") + cmake_policy(POP) +endfunction() + if(testname STREQUAL empty) # fail string() @@ -32,6 +45,18 @@ elseif(testname STREQUAL configure_escape_quotes) # pass string(CONFIGURE "this is @testname@" v ESCAPE_QUOTES) message(STATUS "v='${v}'") +elseif(testname STREQUAL configure_line_number_CMP0053_old) # pass + test_configure_line_number("\${CMAKE_CURRENT_LIST_LINE}" OLD) + +elseif(testname STREQUAL configure_line_number_CMP0053_new) # pass + test_configure_line_number("\${CMAKE_CURRENT_LIST_LINE}" NEW) + +elseif(testname STREQUAL configure_line_number_CMP0053_old_use_at) # pass + test_configure_line_number("\@CMAKE_CURRENT_LIST_LINE\@" OLD) + +elseif(testname STREQUAL configure_line_number_CMP0053_new_use_at) # pass + test_configure_line_number("\@CMAKE_CURRENT_LIST_LINE\@" NEW) + elseif(testname STREQUAL configure_bogus) # fail string(CONFIGURE "this is @testname@" v ESCAPE_QUOTES BOGUS) diff --git a/Tests/COnly/CMakeLists.txt b/Tests/COnly/CMakeLists.txt index b3cc43813..3037f13cb 100644 --- a/Tests/COnly/CMakeLists.txt +++ b/Tests/COnly/CMakeLists.txt @@ -7,7 +7,7 @@ add_library(testc1 STATIC libc1.c) add_library(testc2 SHARED libc2.c) add_executable (COnly conly.c foo.c foo.h) target_link_libraries(COnly testc1 testc2) -if(MSVC_VERSION) +if(MSVC_VERSION AND NOT CMAKE_C_COMPILER_ID STREQUAL Clang OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set_target_properties(COnly PROPERTIES LINK_FLAGS " /NODEFAULTLIB:\"libcdg.lib\" /NODEFAULTLIB:\"libcmtg.lib\" /NODEFAULTLIB:\"foomsvcrt.lib\" /NODEFAULTLIB:\"libbar.lib\" /NODEFAULTLIB:\"libfooba.lib\"") endif() diff --git a/Tests/COnly/libc2.h b/Tests/COnly/libc2.h index 7bc4fb1c8..43ebce914 100644 --- a/Tests/COnly/libc2.h +++ b/Tests/COnly/libc2.h @@ -1,11 +1,11 @@ #ifdef _WIN32 -#ifdef testc2_EXPORTS -#define CM_TEST_LIB_EXPORT __declspec(dllexport) +# ifdef testc2_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec(dllexport) +# else +# define CM_TEST_LIB_EXPORT __declspec(dllimport) +# endif #else -#define CM_TEST_LIB_EXPORT __declspec(dllimport) -#endif -#else -#define CM_TEST_LIB_EXPORT +# define CM_TEST_LIB_EXPORT #endif CM_TEST_LIB_EXPORT float LibC2Func(); diff --git a/Tests/COnly/testCModule.c b/Tests/COnly/testCModule.c index 4381bd746..edeb2b1fd 100644 --- a/Tests/COnly/testCModule.c +++ b/Tests/COnly/testCModule.c @@ -1,7 +1,7 @@ #ifdef _WIN32 -#define TEST_EXPORT __declspec(dllexport) +# define TEST_EXPORT __declspec(dllexport) #else -#define TEST_EXPORT +# define TEST_EXPORT #endif TEST_EXPORT int testCModule(void) { diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake index 70d6edf49..73fd0abe2 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake index 415d5360a..81dbbc515 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) set(config_verbose -V) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake index 337cc1675..ad52f56b7 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake index 35ca74cdd..af27c5183 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake @@ -7,7 +7,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake index f1391cd73..ec75d618a 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake @@ -4,8 +4,8 @@ endif() include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) -# TODO: currently debian doens't produce lower cased names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +# TODO: currently debian doesn't produce lower cased names +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake index fcfc7eaee..e57488cbb 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake @@ -9,7 +9,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # requirements # debian now produces lower case names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake index 351bf2148..5ee057a3d 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2_*.deb") set(expected_count 3) set(config_verbose -V) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake index c97ecb019..8c0bc4bd1 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake @@ -4,8 +4,8 @@ endif() include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) -# TODO: currently debian doens't produce lower cased names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2-1_*.deb") +# TODO: currently debian doesn't produce lower cased names +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2_*.deb") set(expected_count 1) set(actual_output) diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt index 344084317..e49138a58 100644 --- a/Tests/CPackComponentsForAll/CMakeLists.txt +++ b/Tests/CPackComponentsForAll/CMakeLists.txt @@ -168,6 +168,18 @@ set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}" # set CPACK_DEBIAN_FILE_NAME to use default package name format set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +# set some tags for NuGet packages +# 1. all in one package +set(CPACK_NUGET_PACKAGE_TAGS "nuget" "unit" "test" "all-in-one") +# 2. per component packages +set(CPACK_NUGET_APPLICATIONS_PACKAGE_TAGS "nuget" "unit" "test" "applications") +set(CPACK_NUGET_LIBRARIES_PACKAGE_TAGS "nuget" "unit" "test" "libraries") +set(CPACK_NUGET_HEADERS_PACKAGE_TAGS "nuget" "unit" "test" "headers") +set(CPACK_NUGET_UNSPECIFIED_PACKAGE_TAGS "nuget" "unit" "test" "uNsP3c1FiEd") +# 3. per group packages +set(CPACK_NUGET_RUNTIME_PACKAGE_TAGS "nuget" "unit" "test" "run-time") +set(CPACK_NUGET_DEVELOPMENT_PACKAGE_TAGS "nuget" "unit" "test" "development") + # We may use the CPack specific config file in order # to tailor CPack behavior on a CPack generator specific way # (Behavior would be different for RPM or TGZ or DEB ...) diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in index 0bfbf1467..1b9e6584d 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in @@ -13,6 +13,10 @@ if(CPACK_GENERATOR MATCHES "DEB") set(CPACK_DEB_COMPONENT_INSTALL "ON") endif() +if(CPACK_GENERATOR MATCHES "NuGet") + set(CPACK_NUGET_COMPONENT_INSTALL "ON") +endif() + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in index 0ffe44d3a..a6f6ea9e8 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in @@ -52,6 +52,10 @@ if(CPACK_GENERATOR MATCHES "DEB") set(CPACK_DEB_COMPONENT_INSTALL "ON") endif() +if(CPACK_GENERATOR MATCHES "NuGet") + set(CPACK_NUGET_COMPONENT_INSTALL "ON") +endif() + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in index ac65dc996..d41225d1f 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in @@ -18,6 +18,10 @@ if(CPACK_GENERATOR MATCHES "DragNDrop") set(CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP") endif() +if(CPACK_GENERATOR MATCHES "NuGet") + set(CPACK_NUGET_COMPONENT_INSTALL "ON") +endif() + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index a5b38fdb6..253d128f1 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -38,57 +38,69 @@ set(config_verbose ) if(CPackGen MATCHES "ZIP") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip") - if (${CPackComponentWay} STREQUAL "default") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () -elseif (CPackGen MATCHES "RPM") + endif() +elseif(CPackGen MATCHES "RPM") set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm") - if (${CPackComponentWay} STREQUAL "default") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () -elseif (CPackGen MATCHES "DEB") - set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb") - if (${CPackComponentWay} STREQUAL "default") + endif() +elseif(CPackGen MATCHES "DEB") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2_*.deb") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () + endif() +elseif(CPackGen MATCHES "NuGet") + set(config_verbose -D "CPACK_NUGET_PACKAGE_DEBUG=1") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib*1.0.2.nupkg") + if(${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif(${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif() endif() if(CPackGen MATCHES "DragNDrop") set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg") - if (${CPackComponentWay} STREQUAL "default") + if(${CPackComponentWay} STREQUAL "default") set(expected_count 1) - elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup") set(expected_count 3) - elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + elseif(${CPackComponentWay} STREQUAL "IgnoreGroup") set(expected_count 4) - elseif (${CPackComponentWay} STREQUAL "AllInOne") + elseif(${CPackComponentWay} STREQUAL "AllInOne") set(expected_count 1) - endif () + endif() endif() # clean-up previously CPack generated files if(expected_file_mask) file(GLOB expected_file "${expected_file_mask}") - if (expected_file) + if(expected_file) file(REMOVE ${expected_file}) endif() endif() @@ -101,7 +113,7 @@ execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${config_verbose} -G ${CPackGen} ERROR_VARIABLE CPack_error WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR}) -if (CPack_result) +if(CPack_result) message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}") else () message(STATUS "CPack_output=${CPack_output}") diff --git a/Tests/CSharpLinkToCxx/CMakeLists.txt b/Tests/CSharpLinkToCxx/CMakeLists.txt index 153c57c90..a3067afa2 100644 --- a/Tests/CSharpLinkToCxx/CMakeLists.txt +++ b/Tests/CSharpLinkToCxx/CMakeLists.txt @@ -21,3 +21,9 @@ target_link_libraries(CSharpLinkToCxx CLIApp) # because it is unmanaged add_library(CppNativeApp SHARED cpp_native.hpp cpp_native.cpp) target_link_libraries(CSharpLinkToCxx CppNativeApp) + +# Link a static C++ library into the CSharp executable. +# We do not actually use any symbols but this helps cover +# link language selection. +add_library(CppStaticLib STATIC cpp_static.cpp) +target_link_libraries(CSharpLinkToCxx CppStaticLib) diff --git a/Tests/CSharpOnly/CMakeLists.txt b/Tests/CSharpOnly/CMakeLists.txt index 0e3e39e21..82049c78d 100644 --- a/Tests/CSharpOnly/CMakeLists.txt +++ b/Tests/CSharpOnly/CMakeLists.txt @@ -8,3 +8,6 @@ add_library(lib2 SHARED lib2.cs) add_executable(CSharpOnly csharponly.cs) target_link_libraries(CSharpOnly lib1 lib2) + +add_custom_target(CSharpCustom ALL SOURCES empty.cs) +add_custom_target(custom.cs ALL DEPENDS empty.txt) diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in index 670a8745f..0f5678160 100644 --- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in +++ b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8.10) set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested") set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -set(CTEST_PROJECT_NAME "VSProjectInSubdir") set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@") ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) diff --git a/Tests/CTestConfig/CMakeLists.txt b/Tests/CTestConfig/CMakeLists.txt index f46d89a55..8c19adbe2 100644 --- a/Tests/CTestConfig/CMakeLists.txt +++ b/Tests/CTestConfig/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(CTestConfig) include(CTest) @@ -8,32 +8,41 @@ include(CTest) # 'ctest -S script.cmake' call. # # In either case, we expect CMAKE_BUILD_TYPE to be defined for single-configuration -# build trees and not defined for multi-configuration build trees. +# build trees and not defined for multi-configuration build trees. The value of +# CMAKE_CONFIGURATION_TYPES should not be relied upon to determine whether we +# are using a multi-config generator or not, the GENERATOR_IS_MULTI_CONFIG +# global property is the canonical way to do that as of CMake 3.9. # -if(CMAKE_CONFIGURATION_TYPES) - # multi-configuration: expect not defined, error if defined +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + if(NOT DEFINED CMAKE_CONFIGURATION_TYPES OR CMAKE_CONFIGURATION_TYPES STREQUAL "") + message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES is not defined or is empty " + "(but must be defined and non-empty for a multi-configuration generator)") + endif() if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") - message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}' CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty (but should not be for a multi-configuration generator)") + message(FATAL_ERROR "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty " + "(but should not be for a multi-configuration generator)") endif() + set(_configs ${CMAKE_CONFIGURATION_TYPES}) else() - # single-configuration: expect defined, error if not defined + # Populating CMAKE_CONFIGURATION_TYPES even for single config generators is + # common enough for user projects that we don't want to consider it an error. + # We just need CMAKE_BUILD_TYPE to be set and ignore CMAKE_CONFIGURATION_TYPES. if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") - message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty (but should be defined and non-empty for a single-configuration generator)") + message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty " + "(but should be defined and non-empty for a single-configuration generator)") endif() -endif() - - -if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}") + set(_configs ${CMAKE_BUILD_TYPE}) endif() add_executable(ctc CTestConfig.cxx) -foreach(cfg ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) +foreach(cfg ${_configs}) add_test(NAME ctc-${cfg} CONFIGURATIONS ${cfg} COMMAND ctc --config $<CONFIGURATION>) - if(CMAKE_CONFIGURATION_TYPES) + if(_isMultiConfig) set_property(TEST ctc-${cfg} PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_INTDIR is ${cfg}") set_property(TEST ctc-${cfg} diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in index 143fe717a..4bb1262c0 100644 --- a/Tests/CTestConfig/dashboard.cmake.in +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -1,4 +1,4 @@ -set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") +set(_isMultiConfig "@_isMultiConfig@") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-dashboard") @@ -11,7 +11,7 @@ message("CMAKE_COMMAND='${CMAKE_COMMAND}'") message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'") set(arg "") -if(NOT CMAKE_CONFIGURATION_TYPES) +if(NOT _isMultiConfig) set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@") endif() diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in index b6ccedb57..973c7b8c4 100644 --- a/Tests/CTestConfig/script.cmake.in +++ b/Tests/CTestConfig/script.cmake.in @@ -1,7 +1,6 @@ set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@") set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") -set(CTEST_PROJECT_NAME "CTestConfig") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script") diff --git a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake index b0c3a9b9f..6df429256 100644 --- a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake +++ b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake @@ -1,14 +1,17 @@ +function(create_gcov_file gcda_full_path) + get_filename_component(gcda_name ${gcda_full_path} NAME) + string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}") + + file(STRINGS "${gcda_full_path}" source_file LIMIT_COUNT 1 ENCODING UTF-8) + + file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}" + " -: 0:Source:${source_file}" + ) +endfunction() + foreach(I RANGE 0 ${CMAKE_ARGC}) if("${CMAKE_ARGV${I}}" MATCHES ".*\\.gcda") set(gcda_file "${CMAKE_ARGV${I}}") + create_gcov_file(${gcda_file}) endif() endforeach() - -get_filename_component(gcda_name ${gcda_file} NAME) -string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}") - -file(STRINGS "${gcda_file}" source_file LIMIT_COUNT 1 ENCODING UTF-8) - -file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}" - " -: 0:Source:${source_file}" -) diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in index d48ef6130..2c98876b3 100644 --- a/Tests/CTestCoverageCollectGCOV/test.cmake.in +++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 2.8.12) -set(CTEST_PROJECT_NAME "TestProject") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/TestProject") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestCoverageCollectGCOV/TestProject") set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") diff --git a/Tests/CTestTest/test.cmake.in b/Tests/CTestTest/test.cmake.in index bb6346b8a..23166a7e3 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 envionment varibles here +# set any extra environment variables here set (CTEST_ENVIRONMENT ) diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in index 825b957d7..a9bbc527d 100644 --- a/Tests/CTestTest2/test.cmake.in +++ b/Tests/CTestTest2/test.cmake.in @@ -34,6 +34,7 @@ CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ +KWSYS_ENCODING_DEFAULT_CODEPAGE:STRING=CP_UTF8 # This one is needed for testing advanced ctest features CTEST_TEST_KWSYS:BOOL=ON diff --git a/Tests/CTestTestBadExe/CTestConfig.cmake b/Tests/CTestTestBadExe/CTestConfig.cmake index c7286e2c5..5bc1e9e16 100644 --- a/Tests/CTestTestBadExe/CTestConfig.cmake +++ b/Tests/CTestTestBadExe/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestBadExe") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestBadGenerator/CTestConfig.cmake b/Tests/CTestTestBadGenerator/CTestConfig.cmake index 1e61bf441..5bc1e9e16 100644 --- a/Tests/CTestTestBadGenerator/CTestConfig.cmake +++ b/Tests/CTestTestBadGenerator/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestBadGenerator") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestCostSerial/CTestConfig.cmake b/Tests/CTestTestCostSerial/CTestConfig.cmake index 3ab99ac5e..bd265f981 100644 --- a/Tests/CTestTestCostSerial/CTestConfig.cmake +++ b/Tests/CTestTestCostSerial/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestCostSerial") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestCostSerial/sleep.c b/Tests/CTestTestCostSerial/sleep.c index b7abe946b..8a174c9b8 100644 --- a/Tests/CTestTestCostSerial/sleep.c +++ b/Tests/CTestTestCostSerial/sleep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif /* sleeps for 1 second */ diff --git a/Tests/CTestTestCrash/CTestConfig.cmake b/Tests/CTestTestCrash/CTestConfig.cmake index 5c2ca0ea9..5bc1e9e16 100644 --- a/Tests/CTestTestCrash/CTestConfig.cmake +++ b/Tests/CTestTestCrash/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestCrash") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestCycle/CTestConfig.cmake b/Tests/CTestTestCycle/CTestConfig.cmake index 8aeb09b70..5bc1e9e16 100644 --- a/Tests/CTestTestCycle/CTestConfig.cmake +++ b/Tests/CTestTestCycle/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestCycle") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestDepends/CTestConfig.cmake b/Tests/CTestTestDepends/CTestConfig.cmake index 7af9200e2..5bc1e9e16 100644 --- a/Tests/CTestTestDepends/CTestConfig.cmake +++ b/Tests/CTestTestDepends/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestDepends") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestFailure/CTestConfig.cmake b/Tests/CTestTestFailure/CTestConfig.cmake index 07e1be00c..5bc1e9e16 100644 --- a/Tests/CTestTestFailure/CTestConfig.cmake +++ b/Tests/CTestTestFailure/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestFailure") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestFdSetSize/sleep.c b/Tests/CTestTestFdSetSize/sleep.c index 6676488fb..2fb6490aa 100644 --- a/Tests/CTestTestFdSetSize/sleep.c +++ b/Tests/CTestTestFdSetSize/sleep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif /* sleeps for 0.1 second */ diff --git a/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake index 669b0fb68..c08eded76 100644 --- a/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake +++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake @@ -1,8 +1,5 @@ set(CTEST_USE_LAUNCHERS 1) -set(CTEST_PROJECT_NAME "CTestTestLaunchers") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake index 669b0fb68..c08eded76 100644 --- a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake +++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake @@ -1,8 +1,5 @@ set(CTEST_USE_LAUNCHERS 1) -set(CTEST_PROJECT_NAME "CTestTestLaunchers") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake index 669b0fb68..c08eded76 100644 --- a/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake +++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake @@ -1,8 +1,5 @@ set(CTEST_USE_LAUNCHERS 1) -set(CTEST_PROJECT_NAME "CTestTestLaunchers") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestParallel/CTestConfig.cmake b/Tests/CTestTestParallel/CTestConfig.cmake index fc5b6668e..bd265f981 100644 --- a/Tests/CTestTestParallel/CTestConfig.cmake +++ b/Tests/CTestTestParallel/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestParallel") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestResourceLock/CTestConfig.cmake b/Tests/CTestTestResourceLock/CTestConfig.cmake index c1187778d..bd265f981 100644 --- a/Tests/CTestTestResourceLock/CTestConfig.cmake +++ b/Tests/CTestTestResourceLock/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestResourceLock") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestScheduler/CTestConfig.cmake b/Tests/CTestTestScheduler/CTestConfig.cmake index 797387bdd..bd265f981 100644 --- a/Tests/CTestTestScheduler/CTestConfig.cmake +++ b/Tests/CTestTestScheduler/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestScheduler") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestScheduler/sleep.c b/Tests/CTestTestScheduler/sleep.c index 41a5d450b..327bff57e 100644 --- a/Tests/CTestTestScheduler/sleep.c +++ b/Tests/CTestTestScheduler/sleep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif /* sleeps for 4n seconds, where n is the argument to the program */ diff --git a/Tests/CTestTestSkipReturnCode/CTestConfig.cmake b/Tests/CTestTestSkipReturnCode/CTestConfig.cmake index da0c76b73..5bc1e9e16 100644 --- a/Tests/CTestTestSkipReturnCode/CTestConfig.cmake +++ b/Tests/CTestTestSkipReturnCode/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestSkipReturnCode") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestStopTime/CTestConfig.cmake b/Tests/CTestTestStopTime/CTestConfig.cmake index 412283e69..5bc1e9e16 100644 --- a/Tests/CTestTestStopTime/CTestConfig.cmake +++ b/Tests/CTestTestStopTime/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestStopTime") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestStopTime/GetDate.cmake b/Tests/CTestTestStopTime/GetDate.cmake index 46ab2fbac..64a4fb9b3 100644 --- a/Tests/CTestTestStopTime/GetDate.cmake +++ b/Tests/CTestTestStopTime/GetDate.cmake @@ -68,7 +68,7 @@ macro(GET_DATE) # # Extract six individual components by matching a regex with paren groupings. - # Use the replace functionality and \\1 thru \\6 to extract components. + # Use the replace functionality and \\1 through \\6 to extract components. # set(${GD_PREFIX}REGEX "([^/]+)/([^/]+)/([^ ]+) +([^:]+):([^:]+):([^\\.]+)") diff --git a/Tests/CTestTestStopTime/sleep.c b/Tests/CTestTestStopTime/sleep.c index 3baad9ea0..b9b6e897b 100644 --- a/Tests/CTestTestStopTime/sleep.c +++ b/Tests/CTestTestStopTime/sleep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif /* sleeps for n seconds, where n is the argument to the program */ diff --git a/Tests/CTestTestSubdir/CTestConfig.cmake b/Tests/CTestTestSubdir/CTestConfig.cmake index 47ebb925c..bd265f981 100644 --- a/Tests/CTestTestSubdir/CTestConfig.cmake +++ b/Tests/CTestTestSubdir/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestSubdir") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestTimeout/CTestConfig.cmake b/Tests/CTestTestTimeout/CTestConfig.cmake index 13114f1ca..bd265f981 100644 --- a/Tests/CTestTestTimeout/CTestConfig.cmake +++ b/Tests/CTestTestTimeout/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestTimeout") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestTimeout/sleep.c b/Tests/CTestTestTimeout/sleep.c index a4872b52e..ebe127430 100644 --- a/Tests/CTestTestTimeout/sleep.c +++ b/Tests/CTestTestTimeout/sleep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif #include <stdio.h> diff --git a/Tests/CTestTestTimeout/timeout.cmake b/Tests/CTestTestTimeout/timeout.cmake index 0989b65df..ba2f58b7d 100644 --- a/Tests/CTestTestTimeout/timeout.cmake +++ b/Tests/CTestTestTimeout/timeout.cmake @@ -1,6 +1,6 @@ # Remove the log file. file(REMOVE ${Log}) -# Run a child that sleeps longer than the timout of this test. +# Run a child that sleeps longer than the timeout of this test. # Log its output so check.cmake can verify it dies. execute_process(COMMAND ${Sleep} ERROR_FILE ${Log}) diff --git a/Tests/CTestTestUpload/CTestConfig.cmake b/Tests/CTestTestUpload/CTestConfig.cmake index a54708838..21318b4fc 100644 --- a/Tests/CTestTestUpload/CTestConfig.cmake +++ b/Tests/CTestTestUpload/CTestConfig.cmake @@ -1,7 +1,4 @@ -set (CTEST_PROJECT_NAME "CTestTestUpload") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set (CTEST_DROP_METHOD "http") set (CTEST_DROP_SITE "open.cdash.org") set (CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set (CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestUpload/sleep.c b/Tests/CTestTestUpload/sleep.c index 3baad9ea0..b9b6e897b 100644 --- a/Tests/CTestTestUpload/sleep.c +++ b/Tests/CTestTestUpload/sleep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif /* sleeps for n seconds, where n is the argument to the program */ diff --git a/Tests/CTestTestVerboseOutput/CTestConfig.cmake b/Tests/CTestTestVerboseOutput/CTestConfig.cmake index 4f96c79a9..bd265f981 100644 --- a/Tests/CTestTestVerboseOutput/CTestConfig.cmake +++ b/Tests/CTestTestVerboseOutput/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestVerboseOutput") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestZeroTimeout/CTestConfig.cmake b/Tests/CTestTestZeroTimeout/CTestConfig.cmake index 60948647f..bd265f981 100644 --- a/Tests/CTestTestZeroTimeout/CTestConfig.cmake +++ b/Tests/CTestTestZeroTimeout/CTestConfig.cmake @@ -1,7 +1,4 @@ -set(CTEST_PROJECT_NAME "CTestTestZeroTimeout") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestZeroTimeout/sleep.c b/Tests/CTestTestZeroTimeout/sleep.c index 0be7bbc4f..5d0b89bf7 100644 --- a/Tests/CTestTestZeroTimeout/sleep.c +++ b/Tests/CTestTestZeroTimeout/sleep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) -#include <windows.h> +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif /* sleeps for 5 seconds */ diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index 61aa13b94..0f8ec8e27 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -130,7 +130,6 @@ function(create_content dir) # An example CTest project configuration file. file(WRITE ${TOP}/${dir}/CTestConfig.cmake "# CTest Configuration File -set(CTEST_PROJECT_NAME TestProject) set(CTEST_NIGHTLY_START_TIME \"21:00:00 EDT\") ") diff --git a/Tests/CheckFortran.cmake b/Tests/CheckFortran.cmake index b1652baf1..16a8ed2c6 100644 --- a/Tests/CheckFortran.cmake +++ b/Tests/CheckFortran.cmake @@ -15,11 +15,18 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" \"set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 \\\"\${CMAKE_Fortran_COMPILER_SUPPORTS_F90}\\\")\\n\" ) ") + if(CMAKE_GENERATOR_INSTANCE) + set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}") + else() + set(_D_CMAKE_GENERATOR_INSTANCE "") + endif() execute_process( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} -A "${CMAKE_GENERATOR_PLATFORM}" -T "${CMAKE_GENERATOR_TOOLSET}" + ${_D_CMAKE_GENERATOR_INSTANCE} + TIMEOUT 60 OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE result diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp index 93723afa0..0bccb8206 100644 --- a/Tests/CompatibleInterface/main.cpp +++ b/Tests/CompatibleInterface/main.cpp @@ -1,26 +1,26 @@ #ifndef BOOL_PROP1 -#error Expected BOOL_PROP1 +# error Expected BOOL_PROP1 #endif #ifndef BOOL_PROP2 -#error Expected BOOL_PROP2 +# error Expected BOOL_PROP2 #endif #ifndef BOOL_PROP3 -#error Expected BOOL_PROP3 +# error Expected BOOL_PROP3 #endif #ifndef STRING_PROP1 -#error Expected STRING_PROP1 +# error Expected STRING_PROP1 #endif #ifndef STRING_PROP2 -#error Expected STRING_PROP2 +# error Expected STRING_PROP2 #endif #ifndef STRING_PROP3 -#error Expected STRING_PROP3 +# error Expected STRING_PROP3 #endif template <bool test> diff --git a/Tests/CompileCommandOutput/relative.h b/Tests/CompileCommandOutput/relative.h index 221e35453..fa6eefff6 100644 --- a/Tests/CompileCommandOutput/relative.h +++ b/Tests/CompileCommandOutput/relative.h @@ -1,11 +1,11 @@ #if defined(_WIN32) -#ifdef test2_EXPORTS -#define TEST2_EXPORT __declspec(dllexport) +# ifdef test2_EXPORTS +# define TEST2_EXPORT __declspec(dllexport) +# else +# define TEST2_EXPORT __declspec(dllimport) +# endif #else -#define TEST2_EXPORT __declspec(dllimport) -#endif -#else -#define TEST2_EXPORT +# define TEST2_EXPORT #endif TEST2_EXPORT void relative(); diff --git a/Tests/CompileDefinitions/compiletest.c b/Tests/CompileDefinitions/compiletest.c index 8871750af..66248668a 100644 --- a/Tests/CompileDefinitions/compiletest.c +++ b/Tests/CompileDefinitions/compiletest.c @@ -1,20 +1,20 @@ #ifndef LINK_C_DEFINE -#error Expected LINK_C_DEFINE +# error Expected LINK_C_DEFINE #endif #ifndef LINK_LANGUAGE_IS_C -#error Expected LINK_LANGUAGE_IS_C +# error Expected LINK_LANGUAGE_IS_C #endif #ifdef LINK_CXX_DEFINE -#error Unexpected LINK_CXX_DEFINE +# error Unexpected LINK_CXX_DEFINE #endif #ifdef LINK_LANGUAGE_IS_CXX -#error Unexpected LINK_LANGUAGE_IS_CXX +# error Unexpected LINK_LANGUAGE_IS_CXX #endif #ifdef DEBUG_MODE -#error Unexpected DEBUG_MODE +# error Unexpected DEBUG_MODE #endif int main(void) diff --git a/Tests/CompileDefinitions/compiletest.cpp b/Tests/CompileDefinitions/compiletest.cpp index 640e7cf56..328e72e91 100644 --- a/Tests/CompileDefinitions/compiletest.cpp +++ b/Tests/CompileDefinitions/compiletest.cpp @@ -1,10 +1,10 @@ #ifndef CMAKE_IS_FUN -#error Expect CMAKE_IS_FUN definition +# error Expect CMAKE_IS_FUN definition #endif #if CMAKE_IS != Fun -#error Expect CMAKE_IS=Fun definition +# error Expect CMAKE_IS=Fun definition #endif template <bool test> @@ -43,67 +43,67 @@ enum }; #ifdef TEST_GENERATOR_EXPRESSIONS -#ifndef CMAKE_IS_DECLARATIVE -#error Expect declarative definition -#endif -#ifdef GE_NOT_DEFINED -#error Expect not defined generator expression -#endif - -#ifndef ARGUMENT -#error Expected define expanded from list -#endif -#ifndef LIST -#error Expected define expanded from list -#endif - -#ifndef PREFIX_DEF1 -#error Expect PREFIX_DEF1 -#endif - -#ifndef PREFIX_DEF2 -#error Expect PREFIX_DEF2 -#endif - -#ifndef LINK_CXX_DEFINE -#error Expected LINK_CXX_DEFINE -#endif -#ifndef LINK_LANGUAGE_IS_CXX -#error Expected LINK_LANGUAGE_IS_CXX -#endif - -#ifdef LINK_C_DEFINE -#error Unexpected LINK_C_DEFINE -#endif -#ifdef LINK_LANGUAGE_IS_C -#error Unexpected LINK_LANGUAGE_IS_C -#endif +# ifndef CMAKE_IS_DECLARATIVE +# error Expect declarative definition +# endif +# ifdef GE_NOT_DEFINED +# error Expect not defined generator expression +# endif + +# ifndef ARGUMENT +# error Expected define expanded from list +# endif +# ifndef LIST +# error Expected define expanded from list +# endif + +# ifndef PREFIX_DEF1 +# error Expect PREFIX_DEF1 +# endif + +# ifndef PREFIX_DEF2 +# error Expect PREFIX_DEF2 +# endif + +# ifndef LINK_CXX_DEFINE +# error Expected LINK_CXX_DEFINE +# endif +# ifndef LINK_LANGUAGE_IS_CXX +# error Expected LINK_LANGUAGE_IS_CXX +# endif + +# ifdef LINK_C_DEFINE +# error Unexpected LINK_C_DEFINE +# endif +# ifdef LINK_LANGUAGE_IS_C +# error Unexpected LINK_LANGUAGE_IS_C +# endif // TEST_GENERATOR_EXPRESSIONS #endif #ifndef BUILD_IS_DEBUG -#error "BUILD_IS_DEBUG not defined!" +# error "BUILD_IS_DEBUG not defined!" #endif #ifndef BUILD_IS_NOT_DEBUG -#error "BUILD_IS_NOT_DEBUG not defined!" +# error "BUILD_IS_NOT_DEBUG not defined!" #endif // Check per-config definitions. #ifdef TEST_CONFIG_DEBUG -#if !BUILD_IS_DEBUG -#error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!" -#endif -#if BUILD_IS_NOT_DEBUG -#error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!" -#endif +# if !BUILD_IS_DEBUG +# error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!" +# endif +# if BUILD_IS_NOT_DEBUG +# error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!" +# endif #else -#if BUILD_IS_DEBUG -#error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!" -#endif -#if !BUILD_IS_NOT_DEBUG -#error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!" -#endif +# if BUILD_IS_DEBUG +# error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!" +# endif +# if !BUILD_IS_NOT_DEBUG +# error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!" +# endif #endif int main(int argc, char** argv) diff --git a/Tests/CompileDefinitions/compiletest_mixed_c.c b/Tests/CompileDefinitions/compiletest_mixed_c.c index 5fbe45f92..e4adef322 100644 --- a/Tests/CompileDefinitions/compiletest_mixed_c.c +++ b/Tests/CompileDefinitions/compiletest_mixed_c.c @@ -1,20 +1,20 @@ #ifndef LINK_CXX_DEFINE -#error Expected LINK_CXX_DEFINE +# error Expected LINK_CXX_DEFINE #endif #ifndef LINK_LANGUAGE_IS_CXX -#error Expected LINK_LANGUAGE_IS_CXX +# error Expected LINK_LANGUAGE_IS_CXX #endif #ifdef LINK_C_DEFINE -#error Unexpected LINK_C_DEFINE +# error Unexpected LINK_C_DEFINE #endif #ifdef LINK_LANGUAGE_IS_C -#error Unexpected LINK_LANGUAGE_IS_C +# error Unexpected LINK_LANGUAGE_IS_C #endif #ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C -#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define +# error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define #endif void someFunc(void) diff --git a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp index 4eab0999c..b50b4bf10 100644 --- a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp +++ b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp @@ -1,20 +1,20 @@ #ifndef LINK_CXX_DEFINE -#error Expected LINK_CXX_DEFINE +# error Expected LINK_CXX_DEFINE #endif #ifndef LINK_LANGUAGE_IS_CXX -#error Expected LINK_LANGUAGE_IS_CXX +# error Expected LINK_LANGUAGE_IS_CXX #endif #ifdef LINK_C_DEFINE -#error Unexpected LINK_C_DEFINE +# error Unexpected LINK_C_DEFINE #endif #ifdef LINK_LANGUAGE_IS_C -#error Unexpected LINK_LANGUAGE_IS_C +# error Unexpected LINK_LANGUAGE_IS_C #endif #ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C -#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define +# error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define #endif int main(int argc, char** argv) diff --git a/Tests/CompileDefinitions/runtest.c b/Tests/CompileDefinitions/runtest.c index 7c28ab90e..c6dac4dfc 100644 --- a/Tests/CompileDefinitions/runtest.c +++ b/Tests/CompileDefinitions/runtest.c @@ -3,7 +3,7 @@ #include <string.h> #ifndef BUILD_CONFIG_NAME -#error "BUILD_CONFIG_NAME not defined!" +# error "BUILD_CONFIG_NAME not defined!" #endif int main() diff --git a/Tests/CompileDefinitions/target_prop/usetgt.c b/Tests/CompileDefinitions/target_prop/usetgt.c index 8408a908c..56823b089 100644 --- a/Tests/CompileDefinitions/target_prop/usetgt.c +++ b/Tests/CompileDefinitions/target_prop/usetgt.c @@ -1,11 +1,11 @@ #ifndef TGT_DEF -#error TGT_DEF incorrectly not defined +# error TGT_DEF incorrectly not defined #endif #ifndef TGT_TYPE_STATIC_LIBRARY -#error TGT_TYPE_STATIC_LIBRARY incorrectly not defined +# error TGT_TYPE_STATIC_LIBRARY incorrectly not defined #endif #ifdef TGT_TYPE_EXECUTABLE -#error TGT_TYPE_EXECUTABLE incorrectly defined +# error TGT_TYPE_EXECUTABLE incorrectly defined #endif int main(void) { diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 4a5558d48..060fb4940 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -15,17 +15,21 @@ macro(run_test feature lang) endif() endmacro() -get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) -list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") -foreach(feature ${c_features}) - run_test(${feature} C) -endforeach() +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) + list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") + foreach(feature ${c_features}) + run_test(${feature} C) + endforeach() +endif() -get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) -list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") -foreach(feature ${cxx_features}) - run_test(${feature} CXX) -endforeach() +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) + list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") + foreach(feature ${cxx_features}) + run_test(${feature} CXX) + endforeach() +endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) @@ -48,6 +52,16 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" endif() if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.15) + # SunPro 5.14 accepts -std=c++14 and compiles two features but does + # not define __cplusplus to a value different than with -std=c++11. + list(REMOVE_ITEM CXX_non_features + cxx_aggregate_default_initializers + cxx_digit_separators + ) + endif() + + # FIXME: Do any of these work correctly on SunPro 5.13 or above? list(REMOVE_ITEM CXX_non_features cxx_attribute_deprecated cxx_contextual_conversions @@ -224,54 +238,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 +262,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,136 +301,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 + 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 - ) - 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 - ) - 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) + 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} ALLOW_LATER_STANDARDS=1) add_library(std_11_iface INTERFACE) target_compile_features(std_11_iface INTERFACE cxx_std_11) add_executable(CompileFeaturesGenex3 genex_test.cpp) target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface) - target_compile_definitions(CompileFeaturesGenex3 PRIVATE - 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} ALLOW_LATER_STANDARDS=1) endif() diff --git a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp index 5482db8ca..8faeca870 100644 --- a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp +++ b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp @@ -1,8 +1,5 @@ -[[deprecated]] int foo() -{ - return 0; -} +[[deprecated]] int foo() { return 0; } int someFunc() { diff --git a/Tests/CompileFeatures/cxx_contextual_conversions.cpp b/Tests/CompileFeatures/cxx_contextual_conversions.cpp index cbc730417..247f13f9f 100644 --- a/Tests/CompileFeatures/cxx_contextual_conversions.cpp +++ b/Tests/CompileFeatures/cxx_contextual_conversions.cpp @@ -17,6 +17,7 @@ public: } operator T&() { return val; } operator T() const { return val; } + private: T val; }; diff --git a/Tests/CompileFeatures/cxx_digit_separators.cpp b/Tests/CompileFeatures/cxx_digit_separators.cpp index a40ac0aac..abcd1c8fa 100644 --- a/Tests/CompileFeatures/cxx_digit_separators.cpp +++ b/Tests/CompileFeatures/cxx_digit_separators.cpp @@ -1,5 +1,6 @@ int someFunc() { - int one_thousand = 1'000; return one_thousand - 1000; + int one_thousand = 1'000; + return one_thousand - 1000; } diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp index cfe9d9852..bfe0d415e 100644 --- a/Tests/CompileFeatures/cxx_generalized_initializers.cpp +++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp @@ -1,5 +1,5 @@ #if defined(_MSC_VER) && _MSC_VER == 1800 && _MSC_FULL_VER < 180030723 -#error "VS 2013 safely supports this only with Update 3 or greater" +# error "VS 2013 safely supports this only with Update 3 or greater" #endif // Dummy implementation. Test only the compiler feature. @@ -11,11 +11,17 @@ class initializer_list const _E* __begin_; size_t __size_; +#ifdef __INTEL_COMPILER + // The Intel compiler internally asserts the constructor overloads, so + // reproduce the constructor used in its <initializer_list> header. + initializer_list(const _E*, size_t) {} +#else public: template <typename T1, typename T2> initializer_list(T1, T2) { } +#endif }; } diff --git a/Tests/CompileFeatures/cxx_lambda_init_captures.cpp b/Tests/CompileFeatures/cxx_lambda_init_captures.cpp index 46f22cb51..7e337faf4 100644 --- a/Tests/CompileFeatures/cxx_lambda_init_captures.cpp +++ b/Tests/CompileFeatures/cxx_lambda_init_captures.cpp @@ -2,6 +2,5 @@ int someFunc() { int a = 0; - return [b = static_cast<int&&>(a)]() { return b; } - (); + return [b = static_cast<int&&>(a)]() { return b; }(); } diff --git a/Tests/CompileFeatures/cxx_raw_string_literals.cpp b/Tests/CompileFeatures/cxx_raw_string_literals.cpp index ea4d2312c..0f83a7c9a 100644 --- a/Tests/CompileFeatures/cxx_raw_string_literals.cpp +++ b/Tests/CompileFeatures/cxx_raw_string_literals.cpp @@ -1,7 +1,7 @@ void someFunc() { -const char p[] = R"(a\ + const char p[] = R"(a\ b c)"; } diff --git a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp index 7b3602cd5..953148d75 100644 --- a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp +++ b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp @@ -22,6 +22,7 @@ constexpr int g(const int (&is)[4]) int someFunc() { - constexpr int k3 = g({ 4, 5, 6, 7 }); + constexpr int values[4] = { 4, 5, 6, 7 }; + constexpr int k3 = g(values); return k3 - 42; } diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp index 3dc25704d..627b8d939 100644 --- a/Tests/CompileFeatures/cxx_variadic_templates.cpp +++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp @@ -1,5 +1,5 @@ #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) < 407) -#define OLD_GNU +# define OLD_GNU #endif #ifdef OLD_GNU @@ -35,7 +35,7 @@ struct eval }; template <template <typename...> class T, typename... U> -struct eval<T<U...> > +struct eval<T<U...>> { enum { @@ -62,11 +62,11 @@ struct D // Note: This test assumes that a compiler supporting this feature // supports static_assert. Add a workaround if that does not hold. -static_assert(eval<A<> >::Matched, "A Matches"); -static_assert(eval<A<int> >::Matched, "A Matches"); -static_assert(eval<A<int, char> >::Matched, "A Matches"); -static_assert(eval<B<int> >::Matched, "B Matches"); -static_assert(eval<C<int, char> >::Matched, "C Matches"); -static_assert(eval<D<int, char> >::Matched, "D Matches"); -static_assert(eval<D<int, char, bool> >::Matched, "D Matches"); -static_assert(eval<D<int, char, bool, double> >::Matched, "D Matches"); +static_assert(eval<A<>>::Matched, "A Matches"); +static_assert(eval<A<int>>::Matched, "A Matches"); +static_assert(eval<A<int, char>>::Matched, "A Matches"); +static_assert(eval<B<int>>::Matched, "B Matches"); +static_assert(eval<C<int, char>>::Matched, "C Matches"); +static_assert(eval<D<int, char>>::Matched, "D Matches"); +static_assert(eval<D<int, char, bool>>::Matched, "D Matches"); +static_assert(eval<D<int, char, bool, double>>::Matched, "D Matches"); diff --git a/Tests/CompileFeatures/default_dialect.c b/Tests/CompileFeatures/default_dialect.c index 4debd9410..6160c2f44 100644 --- a/Tests/CompileFeatures/default_dialect.c +++ b/Tests/CompileFeatures/default_dialect.c @@ -1,20 +1,20 @@ #if DEFAULT_C11 -#if __STDC_VERSION__ != 201112L -#error Unexpected value for __STDC_VERSION__. -#endif +# if __STDC_VERSION__ < 201112L +# error Unexpected value for __STDC_VERSION__. +# endif #elif DEFAULT_C99 -#if __STDC_VERSION__ != 199901L -#error Unexpected value for __STDC_VERSION__. -#endif +# if __STDC_VERSION__ != 199901L +# error Unexpected value for __STDC_VERSION__. +# endif #else -#if !DEFAULT_C90 -#error Buildsystem error -#endif -#if defined(__STDC_VERSION__) && \ - !(defined(__SUNPRO_C) && __STDC_VERSION__ == 199409L) -#error Unexpected __STDC_VERSION__ definition -#endif +# if !DEFAULT_C90 +# error Buildsystem error +# endif +# if defined(__STDC_VERSION__) && \ + !(defined(__SUNPRO_C) && __STDC_VERSION__ == 199409L) +# error Unexpected __STDC_VERSION__ definition +# endif #endif int main() diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 9b65b424a..3ee60a65e 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -2,26 +2,36 @@ template <long l> struct Outputter; -#if DEFAULT_CXX17 -#if __cplusplus <= 201402L -Outputter<__cplusplus> o; +#if defined(_MSC_VER) && defined(_MSVC_LANG) +# define CXX_STD _MSVC_LANG +#else +# define CXX_STD __cplusplus #endif + +#if DEFAULT_CXX20 +# if CXX_STD <= 201703L +Outputter<CXX_STD> o; +# endif +#elif DEFAULT_CXX17 +# if CXX_STD <= 201402L +Outputter<CXX_STD> o; +# endif #elif DEFAULT_CXX14 -#if __cplusplus != 201402L -Outputter<__cplusplus> o; -#endif +# if CXX_STD != 201402L +Outputter<CXX_STD> o; +# endif #elif DEFAULT_CXX11 -#if __cplusplus != 201103L -Outputter<__cplusplus> o; -#endif +# if CXX_STD != 201103L +Outputter<CXX_STD> o; +# endif #else -#if !DEFAULT_CXX98 -#error Buildsystem error -#endif -#if __cplusplus != 199711L && __cplusplus != 1 && \ - !defined(__GXX_EXPERIMENTAL_CXX0X__) -Outputter<__cplusplus> o; -#endif +# if !DEFAULT_CXX98 +# error Buildsystem error +# endif +# if CXX_STD != 199711L && CXX_STD != 1 && \ + !defined(__GXX_EXPERIMENTAL_CXX0X__) +Outputter<CXX_STD> o; +# endif #endif int main() diff --git a/Tests/CompileFeatures/genex_test.c b/Tests/CompileFeatures/genex_test.c index 1d548406f..de408ce32 100644 --- a/Tests/CompileFeatures/genex_test.c +++ b/Tests/CompileFeatures/genex_test.c @@ -1,35 +1,41 @@ #ifndef EXPECT_C_STATIC_ASSERT -#error EXPECT_C_STATIC_ASSERT not defined +# error EXPECT_C_STATIC_ASSERT not defined #endif #ifndef EXPECT_C_FUNCTION_PROTOTYPES -#error EXPECT_C_FUNCTION_PROTOTYPES not defined +# error EXPECT_C_FUNCTION_PROTOTYPES not defined #endif #ifndef EXPECT_C_RESTRICT -#error EXPECT_C_RESTRICT not defined +# error EXPECT_C_RESTRICT not defined #endif -#if !EXPECT_C_STATIC_ASSERT -#if EXPECT_C_STATIC_ASSERT -#error "Expect c_static_assert feature" -#endif +#if !HAVE_C_STATIC_ASSERT +# if EXPECT_C_STATIC_ASSERT +# error "Expect c_static_assert feature" +# endif #else -#if !EXPECT_C_STATIC_ASSERT -#error "Expect no c_static_assert feature" -#endif +# if !EXPECT_C_STATIC_ASSERT +# error "Expect no c_static_assert feature" +# endif #endif -#if !EXPECT_C_FUNCTION_PROTOTYPES -#error Expect c_function_prototypes support +#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 EXPECT_C_RESTRICT -#error Expect c_restrict support -#endif +#if !HAVE_C_RESTRICT +# if EXPECT_C_RESTRICT +# error Expect c_restrict support +# endif #else -#if !EXPECT_C_RESTRICT -#error Expect no c_restrict support -#endif +# if !EXPECT_C_RESTRICT +# error Expect no c_restrict support +# endif #endif int main() diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index 5ae8a7880..53dce625a 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -1,69 +1,70 @@ #ifndef EXPECT_FINAL -#error EXPECT_FINAL not defined +# error EXPECT_FINAL not defined #endif #ifndef EXPECT_INHERITING_CONSTRUCTORS -#error EXPECT_INHERITING_CONSTRUCTORS not defined +# error EXPECT_INHERITING_CONSTRUCTORS not defined #endif #ifndef EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL -#error EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL not defined +# error EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL not defined #endif #ifndef EXPECT_OVERRIDE_CONTROL -#error EXPECT_OVERRIDE_CONTROL not defined +# error EXPECT_OVERRIDE_CONTROL not defined #endif -#if !HAVE_OVERRIDE_CONTROL -#if EXPECT_OVERRIDE_CONTROL -#error "Expect override control feature" -#endif -#else -#if !EXPECT_OVERRIDE_CONTROL -#error "Expect no override control feature" +#ifdef TEST_CXX_STD +# if !HAVE_CXX_STD_11 +# error HAVE_CXX_STD_11 is false with CXX_STANDARD == 11 +# endif +# if HAVE_CXX_STD_14 && !defined(ALLOW_LATER_STANDARDS) +# error HAVE_CXX_STD_14 is true with CXX_STANDARD == 11 +# endif +# if HAVE_CXX_STD_17 && !defined(ALLOW_LATER_STANDARDS) +# error HAVE_CXX_STD_17 is true with CXX_STANDARD == 11 +# endif #endif -struct A -{ - virtual int getA() { return 7; } -}; - -struct B final : A -{ - int getA() override { return 42; } -}; - +#if !HAVE_OVERRIDE_CONTROL +# if EXPECT_OVERRIDE_CONTROL +# error "Expect override control feature" +# endif +#else +# if !EXPECT_OVERRIDE_CONTROL +# error "Expect no override control feature" +# endif #endif #if !HAVE_AUTO_TYPE -#error Expect cxx_auto_type support +# error Expect cxx_auto_type support #endif #if !HAVE_INHERITING_CONSTRUCTORS -#if EXPECT_INHERITING_CONSTRUCTORS -#error Expect cxx_inheriting_constructors support -#endif +# if EXPECT_INHERITING_CONSTRUCTORS +# error Expect cxx_inheriting_constructors support +# endif #else -#if !EXPECT_INHERITING_CONSTRUCTORS -#error Expect no cxx_inheriting_constructors support -#endif +# if !EXPECT_INHERITING_CONSTRUCTORS +# error Expect no cxx_inheriting_constructors support +# endif #endif #if !HAVE_FINAL -#if EXPECT_FINAL -#error Expect cxx_final support -#endif +# if EXPECT_FINAL +# error Expect cxx_final support +# endif #else -#if !EXPECT_FINAL -#error Expect no cxx_final support -#endif +# if !EXPECT_FINAL +# error Expect no cxx_final support +# endif #endif #if !HAVE_INHERITING_CONSTRUCTORS_AND_FINAL -#if EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL -#error Expect cxx_inheriting_constructors and cxx_final support -#endif +# if EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL +# error Expect cxx_inheriting_constructors and cxx_final support +# endif #else -#if !EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL -#error Expect no combined cxx_inheriting_constructors and cxx_final support -#endif +# if !EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL +# error Expect no combined cxx_inheriting_constructors and cxx_final support +# endif #endif int main() diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index 692e0de0c..1433462ba 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -4,6 +4,10 @@ project(CompileOptions) add_library(testlib other.cpp) +if(TEST_FORTRAN) + enable_language(Fortran) +endif() + add_executable(CompileOptions main.cpp) macro(get_compiler_test_genex lst lang) @@ -13,16 +17,33 @@ endmacro() get_compiler_test_genex(c_tests C) get_compiler_test_genex(cxx_tests CXX) +if(TEST_FORTRAN) + get_compiler_test_genex(fortran_tests Fortran) +endif() set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "-DTEST_DEFINE" "-DNEEDS_ESCAPE=\"E$CAPE\"" "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>" + "$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DTEST_DEFINE_CXX_AND_GNU>" + "SHELL:" # produces no options ${c_tests} ${cxx_tests} + ${fortran_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") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS "-DTEST_OCTOTHORPE=\"#\"" ) @@ -42,3 +63,12 @@ target_compile_definitions(CompileOptions "EXPECTED_C_COMPILER_VERSION=\"${CMAKE_C_COMPILER_VERSION}\"" "EXPECTED_CXX_COMPILER_VERSION=\"${CMAKE_CXX_COMPILER_VERSION}\"" ) + +if(TEST_FORTRAN) + # Definitions for the C++ code to test the values + target_compile_definitions(CompileOptions + PRIVATE + "TEST_FORTRAN" + "EXPECTED_Fortran_COMPILER_VERSION=\"${CMAKE_Fortran_COMPILER_VERSION}\"" + ) +endif() diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp index 63a0480cc..ebc101762 100644 --- a/Tests/CompileOptions/main.cpp +++ b/Tests/CompileOptions/main.cpp @@ -1,15 +1,40 @@ #ifndef TEST_DEFINE -#error Expected definition TEST_DEFINE +# error Expected definition TEST_DEFINE #endif #ifndef NEEDS_ESCAPE -#error Expected definition NEEDS_ESCAPE +# error Expected definition NEEDS_ESCAPE #endif #ifdef DO_GNU_TESTS -#ifndef TEST_DEFINE_GNU -#error Expected definition TEST_DEFINE_GNU +# ifndef TEST_DEFINE_GNU +# error Expected definition TEST_DEFINE_GNU +# endif +# ifndef TEST_DEFINE_CXX_AND_GNU +# error Expected definition TEST_DEFINE_CXX_AND_GNU +# endif #endif + +#ifndef NO_DEF_TESTS +# 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> @@ -20,12 +45,22 @@ 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) == - 0 && - TEST_C_COMPILER_VERSION_EQUALITY == 1 && - TEST_CXX_COMPILER_VERSION_EQUALITY == 1) + strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == 0 +#ifdef TEST_FORTRAN + && strcmp(EXPECTED_Fortran_COMPILER_VERSION, + TEST_Fortran_COMPILER_VERSION) == 0 +#endif + && TEST_C_COMPILER_VERSION_EQUALITY == 1 && + TEST_CXX_COMPILER_VERSION_EQUALITY == 1 +#ifdef TEST_FORTRAN + && TEST_Fortran_COMPILER_VERSION_EQUALITY == 1 +#endif + ) ? 0 : 1; } diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 075faa768..2e4175442 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -356,6 +356,8 @@ endwhile() set(SHOULD_BE_ZERO ) set(SHOULD_BE_ONE 1) +set(SHOULD_BE_ZERO_AND_INDENTED ) +set(SHOULD_BE_ONE_AND_INDENTED 1) # test elseif functionality, the mess below tries to catch problem # of clauses being executed early or late etc @@ -438,13 +440,6 @@ set(CMAKE_CXX_STANDARD 98) # set(CMAKE_CXX_EXTENSIONS TRUE) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/Complex/Cache/CMakeCache.txt b/Tests/Complex/Cache/CMakeCache.txt index 17c55aa01..727faa2e7 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/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 3b09229ba..9ddf00538 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -17,7 +17,7 @@ extern "C" { #include <stdio.h> #include <sys/stat.h> #if !defined(S_ISDIR) -#define S_ISDIR(mode) ((mode)&_S_IFDIR) +# define S_ISDIR(mode) ((mode)&_S_IFDIR) #endif #ifdef COMPLEX_TEST_LINK_STATIC @@ -45,23 +45,23 @@ void cmPassed(const char* Message, const char* m2 = "") } #ifndef COMPLEX_DEFINED_PRE -#error "COMPLEX_DEFINED_PRE not defined!" +# error "COMPLEX_DEFINED_PRE not defined!" #endif #ifdef COMPLEX_DEFINED -#error "COMPLEX_DEFINED is defined but it should not!" +# error "COMPLEX_DEFINED is defined but it should not!" #endif #ifndef COMPLEX_DEFINED_POST -#error "COMPLEX_DEFINED_POST not defined!" +# error "COMPLEX_DEFINED_POST not defined!" #endif #ifndef CMAKE_IS_REALLY_FUN -#error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work +# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work #endif #if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) -#error Per-configuration directory-level definition not inherited. +# error Per-configuration directory-level definition not inherited. #endif // ====================================================================== @@ -200,8 +200,8 @@ int main() cmFailed(msg); } -// ---------------------------------------------------------------------- -// Test ADD_DEFINITIONS + // ---------------------------------------------------------------------- + // Test ADD_DEFINITIONS #ifndef CMAKE_IS_FUN cmFailed("CMake is not fun, so it is broken and should be fixed."); @@ -240,8 +240,8 @@ int main() cmPassed("CMake found the listfile stack properly"); #endif -// ---------------------------------------------------------------------- -// Test SET, VARIABLE_REQUIRES + // ---------------------------------------------------------------------- + // Test SET, VARIABLE_REQUIRES #ifdef SHOULD_NOT_BE_DEFINED cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined."); @@ -261,6 +261,12 @@ int main() cmPassed("ONE_VAR is defined."); #endif +#ifndef ONE_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ONE_VAR_AND_INDENTED is not defined."); +#else + cmPassed("ONE_VAR_AND_INDENTED is defined."); +#endif + #ifndef ONE_VAR_IS_DEFINED cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, " "ONE_VAR_IS_DEFINED is not defined."); @@ -274,6 +280,12 @@ int main() cmPassed("ZERO_VAR is not defined."); #endif +#ifdef ZERO_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ZERO_VAR_AND_INDENTED is defined."); +#else + cmPassed("ZERO_VAR_AND_INDENTED is not defined."); +#endif + #ifndef STRING_VAR cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined."); #else @@ -285,8 +297,8 @@ int main() } #endif -// ---------------------------------------------------------------------- -// Test various IF/ELSE combinations + // ---------------------------------------------------------------------- + // Test various IF/ELSE combinations #ifdef SHOULD_NOT_BE_DEFINED_NOT cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined."); @@ -728,8 +740,8 @@ int main() cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is defined."); #endif -// ---------------------------------------------------------------------- -// Test FOREACH + // ---------------------------------------------------------------------- + // Test FOREACH #ifndef FOREACH_VAR1 cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " @@ -779,8 +791,8 @@ int main() cmPassed("WHILE command is working"); } -// ---------------------------------------------------------------------- -// Test LOAD_CACHE + // ---------------------------------------------------------------------- + // Test LOAD_CACHE #ifndef CACHE_TEST_VAR1 cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " @@ -889,8 +901,8 @@ int main() TestAndRemoveFile("Executable/Temp/complex-required.txt"); -// ---------------------------------------------------------------------- -// Test FIND_LIBRARY + // ---------------------------------------------------------------------- + // Test FIND_LIBRARY #ifndef FIND_DUMMY_LIB cmFailed("the CONFIGURE_FILE command is broken, " @@ -905,8 +917,8 @@ int main() } #endif -// ---------------------------------------------------------------------- -// Test SET_SOURCE_FILES_PROPERTIES + // ---------------------------------------------------------------------- + // Test SET_SOURCE_FILES_PROPERTIES #ifndef FILE_HAS_EXTRA_COMPILE_FLAGS cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting " @@ -917,9 +929,9 @@ int main() #endif #if 0 // Disable until implemented everywhere. -#ifndef FILE_DEFINE_STRING +# ifndef FILE_DEFINE_STRING cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag"); -#else +# else if(strcmp(FILE_DEFINE_STRING, "hello") != 0) { cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly"); @@ -928,7 +940,7 @@ int main() { cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag"); } -#endif +# endif #endif #ifndef FILE_HAS_ABSTRACT @@ -961,10 +973,10 @@ int main() // ---------------------------------------------------------------------- // Test registry (win32) #if defined(_WIN32) && !defined(__CYGWIN__) -#ifndef REGISTRY_TEST_PATH +# ifndef REGISTRY_TEST_PATH cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not " "defined."); -#else +# else std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n"; if (stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) { cmFailed("the 'read registry value' function or CONFIGURE_FILE command is " @@ -973,7 +985,7 @@ int main() } else { cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH); } -#endif +# endif #endif // defined(_WIN32) && !defined(__CYGWIN__) if (strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) { @@ -1030,6 +1042,16 @@ int main() } else { cmFailed("cmakedefine01 is not working for 1"); } + if (SHOULD_BE_ZERO_AND_INDENTED == 0) { + cmPassed("cmakedefine01 is working for 0 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 0 and indented"); + } + if (SHOULD_BE_ONE_AND_INDENTED == 1) { + cmPassed("cmakedefine01 is working for 1 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 1 and indented"); + } #ifdef FORCE_TEST cmFailed("CMake SET CACHE FORCE"); #else diff --git a/Tests/Complex/Executable/complex.file.cxx b/Tests/Complex/Executable/complex.file.cxx index cfba9ed42..55964302d 100644 --- a/Tests/Complex/Executable/complex.file.cxx +++ b/Tests/Complex/Executable/complex.file.cxx @@ -1,5 +1,5 @@ #if 0 -#include "cmMissingHeader.h" +# include "cmMissingHeader.h" #endif int main(int, char**) diff --git a/Tests/Complex/Executable/notInAllExe.cxx b/Tests/Complex/Executable/notInAllExe.cxx index 2685073d6..2b857b47c 100644 --- a/Tests/Complex/Executable/notInAllExe.cxx +++ b/Tests/Complex/Executable/notInAllExe.cxx @@ -6,5 +6,5 @@ int main() } #if 1 -#error "This target should not be compiled by ALL." +# error "This target should not be compiled by ALL." #endif diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index dbf806e4f..64f6dc854 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -48,7 +48,7 @@ add_library(CMakeTestCLibraryShared SHARED testConly.c) define_property( TARGET PROPERTY FOO BRIEF_DOCS "a test property" - FULL_DOCS "A simple etst proerty that means nothign and is used for nothing" + FULL_DOCS "A simple test property that means nothing and is used for nothing" ) set_target_properties(CMakeTestCLibraryShared PROPERTIES FOO BAR) if(NOT BEOS AND NOT WIN32 AND NOT HAIKU) # No libm on BeOS. diff --git a/Tests/Complex/Library/notInAllLib.cxx b/Tests/Complex/Library/notInAllLib.cxx index e66ea056f..033988fd8 100644 --- a/Tests/Complex/Library/notInAllLib.cxx +++ b/Tests/Complex/Library/notInAllLib.cxx @@ -4,5 +4,5 @@ int notInAllLibFunc() } #if 1 -#error "This target should not be compiled by ALL." +# error "This target should not be compiled by ALL." #endif diff --git a/Tests/Complex/Library/sharedFile.h b/Tests/Complex/Library/sharedFile.h index e32fcb760..830cbd5e8 100644 --- a/Tests/Complex/Library/sharedFile.h +++ b/Tests/Complex/Library/sharedFile.h @@ -1,12 +1,12 @@ #if defined(_WIN32) || defined(WIN32) /* Win32 version */ -#ifdef CMakeTestLibraryShared_EXPORTS -#define CMakeTest_EXPORT __declspec(dllexport) -#else -#define CMakeTest_EXPORT __declspec(dllimport) -#endif +# ifdef CMakeTestLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +# else +# define CMakeTest_EXPORT __declspec(dllimport) +# endif #else /* unix needs nothing */ -#define CMakeTest_EXPORT +# define CMakeTest_EXPORT #endif CMakeTest_EXPORT int sharedFunction(); diff --git a/Tests/Complex/Library/testConly.h b/Tests/Complex/Library/testConly.h index 9b0fb73ff..02b28ccab 100644 --- a/Tests/Complex/Library/testConly.h +++ b/Tests/Complex/Library/testConly.h @@ -1,12 +1,12 @@ #if defined(_WIN32) || defined(WIN32) /* Win32 version */ -#ifdef CMakeTestCLibraryShared_EXPORTS -#define CMakeTest_EXPORT __declspec(dllexport) -#else -#define CMakeTest_EXPORT __declspec(dllimport) -#endif +# ifdef CMakeTestCLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +# else +# define CMakeTest_EXPORT __declspec(dllimport) +# endif #else /* unix needs nothing */ -#define CMakeTest_EXPORT +# define CMakeTest_EXPORT #endif CMakeTest_EXPORT int CsharedFunction(); diff --git a/Tests/Complex/VarTests.cmake b/Tests/Complex/VarTests.cmake index 8be59be5e..9761986ab 100644 --- a/Tests/Complex/VarTests.cmake +++ b/Tests/Complex/VarTests.cmake @@ -2,6 +2,7 @@ # Test SET # set (ZERO_VAR 0) +set (ZERO_VAR_AND_INDENTED 0) set (ZERO_VAR2 0) if(ZERO_VAR) @@ -11,6 +12,7 @@ else() endif() set(ONE_VAR 1) +set(ONE_VAR_AND_INDENTED 1) set(ONE_VAR2 1) set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable") diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in index d7424b184..72317bcc8 100644 --- a/Tests/Complex/cmTestConfigure.h.in +++ b/Tests/Complex/cmTestConfigure.h.in @@ -1,8 +1,10 @@ // Test SET, VARIABLE_REQUIRES #cmakedefine ONE_VAR +# cmakedefine ONE_VAR_AND_INDENTED #cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ZERO_VAR +# cmakedefine ZERO_VAR_AND_INDENTED #define STRING_VAR "${STRING_VAR}" @@ -32,6 +34,8 @@ #cmakedefine01 SHOULD_BE_ZERO #cmakedefine01 SHOULD_BE_ONE +# cmakedefine01 SHOULD_BE_ZERO_AND_INDENTED +# cmakedefine01 SHOULD_BE_ONE_AND_INDENTED // Needed to check for files #define BINARY_DIR "${Complex_BINARY_DIR}" diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 1b833b241..628cd4ec3 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -313,6 +313,8 @@ endwhile() set(SHOULD_BE_ZERO ) set(SHOULD_BE_ONE 1) +set(SHOULD_BE_ZERO_AND_INDENTED ) +set(SHOULD_BE_ONE_AND_INDENTED 1) # test elseif functionality, the mess below tries to catch problem # of clauses being executed early or late etc @@ -395,13 +397,6 @@ set(CMAKE_CXX_STANDARD 98) # set(CMAKE_CXX_EXTENSIONS TRUE) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/ComplexOneConfig/Cache/CMakeCache.txt b/Tests/ComplexOneConfig/Cache/CMakeCache.txt index 17c55aa01..727faa2e7 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/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 9e4eaadf7..5b5089960 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -17,7 +17,7 @@ extern "C" { #include <stdio.h> #include <sys/stat.h> #if !defined(S_ISDIR) -#define S_ISDIR(mode) ((mode)&_S_IFDIR) +# define S_ISDIR(mode) ((mode)&_S_IFDIR) #endif #ifdef COMPLEX_TEST_LINK_STATIC @@ -45,23 +45,23 @@ void cmPassed(const char* Message, const char* m2 = "") } #ifndef COMPLEX_DEFINED_PRE -#error "COMPLEX_DEFINED_PRE not defined!" +# error "COMPLEX_DEFINED_PRE not defined!" #endif #ifdef COMPLEX_DEFINED -#error "COMPLEX_DEFINED is defined but it should not!" +# error "COMPLEX_DEFINED is defined but it should not!" #endif #ifndef COMPLEX_DEFINED_POST -#error "COMPLEX_DEFINED_POST not defined!" +# error "COMPLEX_DEFINED_POST not defined!" #endif #ifndef CMAKE_IS_REALLY_FUN -#error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work +# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work #endif #if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) -#error Per-configuration directory-level definition not inherited. +# error Per-configuration directory-level definition not inherited. #endif // ====================================================================== @@ -200,8 +200,8 @@ int main() cmFailed(msg); } -// ---------------------------------------------------------------------- -// Test ADD_DEFINITIONS + // ---------------------------------------------------------------------- + // Test ADD_DEFINITIONS #ifndef CMAKE_IS_FUN cmFailed("CMake is not fun, so it is broken and should be fixed."); @@ -240,8 +240,8 @@ int main() cmPassed("CMake found the listfile stack properly"); #endif -// ---------------------------------------------------------------------- -// Test SET, VARIABLE_REQUIRES + // ---------------------------------------------------------------------- + // Test SET, VARIABLE_REQUIRES #ifdef SHOULD_NOT_BE_DEFINED cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined."); @@ -261,6 +261,12 @@ int main() cmPassed("ONE_VAR is defined."); #endif +#ifndef ONE_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ONE_VAR_AND_INDENTED is not defined."); +#else + cmPassed("ONE_VAR_AND_INDENTED is defined."); +#endif + #ifndef ONE_VAR_IS_DEFINED cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, " "ONE_VAR_IS_DEFINED is not defined."); @@ -274,6 +280,12 @@ int main() cmPassed("ZERO_VAR is not defined."); #endif +#ifdef ZERO_VAR_AND_INDENTED + cmFailed("cmakedefine is broken, ZERO_VAR_AND_INDENTED is defined."); +#else + cmPassed("ZERO_VAR_AND_INDENTED is not defined."); +#endif + #ifndef STRING_VAR cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined."); #else @@ -285,8 +297,8 @@ int main() } #endif -// ---------------------------------------------------------------------- -// Test various IF/ELSE combinations + // ---------------------------------------------------------------------- + // Test various IF/ELSE combinations #ifdef SHOULD_NOT_BE_DEFINED_NOT cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined."); @@ -728,8 +740,8 @@ int main() cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is defined."); #endif -// ---------------------------------------------------------------------- -// Test FOREACH + // ---------------------------------------------------------------------- + // Test FOREACH #ifndef FOREACH_VAR1 cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " @@ -779,8 +791,8 @@ int main() cmPassed("WHILE command is working"); } -// ---------------------------------------------------------------------- -// Test LOAD_CACHE + // ---------------------------------------------------------------------- + // Test LOAD_CACHE #ifndef CACHE_TEST_VAR1 cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " @@ -889,8 +901,8 @@ int main() TestAndRemoveFile("Executable/Temp/complex-required.txt"); -// ---------------------------------------------------------------------- -// Test FIND_LIBRARY + // ---------------------------------------------------------------------- + // Test FIND_LIBRARY #ifndef FIND_DUMMY_LIB cmFailed("the CONFIGURE_FILE command is broken, " @@ -905,8 +917,8 @@ int main() } #endif -// ---------------------------------------------------------------------- -// Test SET_SOURCE_FILES_PROPERTIES + // ---------------------------------------------------------------------- + // Test SET_SOURCE_FILES_PROPERTIES #ifndef FILE_HAS_EXTRA_COMPILE_FLAGS cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting " @@ -917,9 +929,9 @@ int main() #endif #if 0 // Disable until implemented everywhere. -#ifndef FILE_DEFINE_STRING +# ifndef FILE_DEFINE_STRING cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag"); -#else +# else if(strcmp(FILE_DEFINE_STRING, "hello") != 0) { cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly"); @@ -928,7 +940,7 @@ int main() { cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag"); } -#endif +# endif #endif #ifndef FILE_HAS_ABSTRACT @@ -961,10 +973,10 @@ int main() // ---------------------------------------------------------------------- // Test registry (win32) #if defined(_WIN32) && !defined(__CYGWIN__) -#ifndef REGISTRY_TEST_PATH +# ifndef REGISTRY_TEST_PATH cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not " "defined."); -#else +# else std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n"; if (stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) { cmFailed("the 'read registry value' function or CONFIGURE_FILE command is " @@ -973,7 +985,7 @@ int main() } else { cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH); } -#endif +# endif #endif // defined(_WIN32) && !defined(__CYGWIN__) if (strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) { @@ -1030,6 +1042,16 @@ int main() } else { cmFailed("cmakedefine01 is not working for 1"); } + if (SHOULD_BE_ZERO_AND_INDENTED == 0) { + cmPassed("cmakedefine01 is working for 0 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 0 and indented"); + } + if (SHOULD_BE_ONE_AND_INDENTED == 1) { + cmPassed("cmakedefine01 is working for 1 and indented"); + } else { + cmFailed("cmakedefine01 is not working for 1 and indented"); + } #ifdef FORCE_TEST cmFailed("CMake SET CACHE FORCE"); #else diff --git a/Tests/ComplexOneConfig/Executable/complex.file.cxx b/Tests/ComplexOneConfig/Executable/complex.file.cxx index cfba9ed42..55964302d 100644 --- a/Tests/ComplexOneConfig/Executable/complex.file.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.file.cxx @@ -1,5 +1,5 @@ #if 0 -#include "cmMissingHeader.h" +# include "cmMissingHeader.h" #endif int main(int, char**) diff --git a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx index 2685073d6..2b857b47c 100644 --- a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx +++ b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx @@ -6,5 +6,5 @@ int main() } #if 1 -#error "This target should not be compiled by ALL." +# error "This target should not be compiled by ALL." #endif diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index dbf806e4f..64f6dc854 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -48,7 +48,7 @@ add_library(CMakeTestCLibraryShared SHARED testConly.c) define_property( TARGET PROPERTY FOO BRIEF_DOCS "a test property" - FULL_DOCS "A simple etst proerty that means nothign and is used for nothing" + FULL_DOCS "A simple test property that means nothing and is used for nothing" ) set_target_properties(CMakeTestCLibraryShared PROPERTIES FOO BAR) if(NOT BEOS AND NOT WIN32 AND NOT HAIKU) # No libm on BeOS. diff --git a/Tests/ComplexOneConfig/Library/notInAllLib.cxx b/Tests/ComplexOneConfig/Library/notInAllLib.cxx index e66ea056f..033988fd8 100644 --- a/Tests/ComplexOneConfig/Library/notInAllLib.cxx +++ b/Tests/ComplexOneConfig/Library/notInAllLib.cxx @@ -4,5 +4,5 @@ int notInAllLibFunc() } #if 1 -#error "This target should not be compiled by ALL." +# error "This target should not be compiled by ALL." #endif diff --git a/Tests/ComplexOneConfig/Library/sharedFile.h b/Tests/ComplexOneConfig/Library/sharedFile.h index e32fcb760..830cbd5e8 100644 --- a/Tests/ComplexOneConfig/Library/sharedFile.h +++ b/Tests/ComplexOneConfig/Library/sharedFile.h @@ -1,12 +1,12 @@ #if defined(_WIN32) || defined(WIN32) /* Win32 version */ -#ifdef CMakeTestLibraryShared_EXPORTS -#define CMakeTest_EXPORT __declspec(dllexport) -#else -#define CMakeTest_EXPORT __declspec(dllimport) -#endif +# ifdef CMakeTestLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +# else +# define CMakeTest_EXPORT __declspec(dllimport) +# endif #else /* unix needs nothing */ -#define CMakeTest_EXPORT +# define CMakeTest_EXPORT #endif CMakeTest_EXPORT int sharedFunction(); diff --git a/Tests/ComplexOneConfig/Library/testConly.h b/Tests/ComplexOneConfig/Library/testConly.h index 9b0fb73ff..02b28ccab 100644 --- a/Tests/ComplexOneConfig/Library/testConly.h +++ b/Tests/ComplexOneConfig/Library/testConly.h @@ -1,12 +1,12 @@ #if defined(_WIN32) || defined(WIN32) /* Win32 version */ -#ifdef CMakeTestCLibraryShared_EXPORTS -#define CMakeTest_EXPORT __declspec(dllexport) -#else -#define CMakeTest_EXPORT __declspec(dllimport) -#endif +# ifdef CMakeTestCLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +# else +# define CMakeTest_EXPORT __declspec(dllimport) +# endif #else /* unix needs nothing */ -#define CMakeTest_EXPORT +# define CMakeTest_EXPORT #endif CMakeTest_EXPORT int CsharedFunction(); diff --git a/Tests/ComplexOneConfig/VarTests.cmake b/Tests/ComplexOneConfig/VarTests.cmake index 7dd851974..42afd19ea 100644 --- a/Tests/ComplexOneConfig/VarTests.cmake +++ b/Tests/ComplexOneConfig/VarTests.cmake @@ -2,6 +2,7 @@ # Test SET # set (ZERO_VAR 0) +set (ZERO_VAR_AND_INDENTED 0) set (ZERO_VAR2 0) if(ZERO_VAR) @@ -11,6 +12,7 @@ else() endif() set(ONE_VAR 1) +set(ONE_VAR_AND_INDENTED 1) set(ONE_VAR2 1) set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable") diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in index d7424b184..72317bcc8 100644 --- a/Tests/ComplexOneConfig/cmTestConfigure.h.in +++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in @@ -1,8 +1,10 @@ // Test SET, VARIABLE_REQUIRES #cmakedefine ONE_VAR +# cmakedefine ONE_VAR_AND_INDENTED #cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ZERO_VAR +# cmakedefine ZERO_VAR_AND_INDENTED #define STRING_VAR "${STRING_VAR}" @@ -32,6 +34,8 @@ #cmakedefine01 SHOULD_BE_ZERO #cmakedefine01 SHOULD_BE_ONE +# cmakedefine01 SHOULD_BE_ZERO_AND_INDENTED +# cmakedefine01 SHOULD_BE_ONE_AND_INDENTED // Needed to check for files #define BINARY_DIR "${Complex_BINARY_DIR}" diff --git a/Tests/Contracts/Trilinos/CMakeLists.txt b/Tests/Contracts/Trilinos/CMakeLists.txt index 8d74ca574..4d7062bbd 100644 --- a/Tests/Contracts/Trilinos/CMakeLists.txt +++ b/Tests/Contracts/Trilinos/CMakeLists.txt @@ -6,24 +6,7 @@ include(ExternalProject) include("${CMAKE_CURRENT_SOURCE_DIR}/LocalOverrides.cmake" OPTIONAL) include("${CMAKE_CURRENT_BINARY_DIR}/LocalOverrides.cmake" OPTIONAL) -if(NOT DEFINED HOME) - if(DEFINED ENV{CTEST_REAL_HOME}) - set(HOME "$ENV{CTEST_REAL_HOME}") - else() - set(HOME "$ENV{HOME}") - endif() - - if(NOT HOME AND WIN32) - # Try for USERPROFILE as HOME equivalent: - string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}") - - # But just use root of SystemDrive if USERPROFILE contains any spaces: - # (Default on XP and earlier...) - if(HOME MATCHES " ") - string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}") - endif() - endif() -endif() +include(${CMAKE_CURRENT_SOURCE_DIR}/../Home.cmake) message(STATUS "HOME='${HOME}'") if(NOT DEFINED url) diff --git a/Tests/Contracts/VTK/CMakeLists.txt b/Tests/Contracts/VTK/CMakeLists.txt index ef19325a4..c946499b6 100644 --- a/Tests/Contracts/VTK/CMakeLists.txt +++ b/Tests/Contracts/VTK/CMakeLists.txt @@ -5,24 +5,7 @@ project(VTK) include(ExternalProject) # find "HOME". VTK will be downloaded & built within a subdirectory. -if(NOT DEFINED HOME) - if(DEFINED ENV{CTEST_REAL_HOME}) - set(HOME "$ENV{CTEST_REAL_HOME}") - else() - set(HOME "$ENV{HOME}") - endif() - - if(NOT HOME AND WIN32) - # Try for USERPROFILE as HOME equivalent: - string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}") - - # But just use root of SystemDrive if USERPROFILE contains any spaces: - # (Default on XP and earlier...) - if(HOME MATCHES " ") - string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}") - endif() - endif() -endif() +include(${CMAKE_CURRENT_SOURCE_DIR}/../Home.cmake) set(base_dir "${HOME}/.cmake/Contracts/VTK") diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index de4850158..a30071fd3 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -2,6 +2,9 @@ ADD_TEST_MACRO(Cuda.Complex CudaComplex) ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures) ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary) +ADD_TEST_MACRO(Cuda.MixedStandardLevels MixedStandardLevels) +ADD_TEST_MACRO(Cuda.NotEnabled CudaNotEnabled) ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude) +ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries) ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) ADD_TEST_MACRO(Cuda.WithC CudaWithC) diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt index 450ef487c..d3d4b7c28 100644 --- a/Tests/Cuda/Complex/CMakeLists.txt +++ b/Tests/Cuda/Complex/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaComplex CXX CUDA) +project (Complex CXX CUDA) #Goal for this example: #build a cpp dynamic library base @@ -12,7 +12,7 @@ project (CudaComplex CXX CUDA) #lastly build a cpp executable that uses this last cuda dynamic library #this tests that we can properly handle linking cuda and cpp together -#and also bulding cpp targets that need cuda implicit libraries +#and also building cpp targets that need cuda implicit libraries #verify that we can pass explicit cuda arch flags string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") @@ -42,7 +42,6 @@ add_executable(CudaComplex main.cpp) target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib) if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaComplex PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaComplex PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/Cuda/Complex/dynamic.cpp b/Tests/Cuda/Complex/dynamic.cpp index 3848ce7b5..38da6a6a8 100644 --- a/Tests/Cuda/Complex/dynamic.cpp +++ b/Tests/Cuda/Complex/dynamic.cpp @@ -1,8 +1,8 @@ #ifdef _WIN32 -#define EXPORT __declspec(dllexport) +# define EXPORT __declspec(dllexport) #else -#define EXPORT +# define EXPORT #endif EXPORT int dynamic_base_func(int x) diff --git a/Tests/Cuda/Complex/dynamic.cu b/Tests/Cuda/Complex/dynamic.cu index a76973d62..c3d8affa8 100644 --- a/Tests/Cuda/Complex/dynamic.cu +++ b/Tests/Cuda/Complex/dynamic.cu @@ -4,9 +4,9 @@ #include <string> #ifdef _WIN32 -#define EXPORT __declspec(dllexport) +# define EXPORT __declspec(dllexport) #else -#define EXPORT +# define EXPORT #endif int dynamic_base_func(int); diff --git a/Tests/Cuda/Complex/main.cpp b/Tests/Cuda/Complex/main.cpp index 249823535..6ca5952a5 100644 --- a/Tests/Cuda/Complex/main.cpp +++ b/Tests/Cuda/Complex/main.cpp @@ -4,9 +4,9 @@ #include "file2.h" #ifdef _WIN32 -#define IMPORT __declspec(dllimport) +# define IMPORT __declspec(dllimport) #else -#define IMPORT +# define IMPORT #endif IMPORT int choose_cuda_device(); diff --git a/Tests/Cuda/Complex/mixed.cpp b/Tests/Cuda/Complex/mixed.cpp index bd32e5199..38a1f0c75 100644 --- a/Tests/Cuda/Complex/mixed.cpp +++ b/Tests/Cuda/Complex/mixed.cpp @@ -1,10 +1,10 @@ #ifdef _WIN32 -#define EXPORT __declspec(dllexport) -#define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +# define IMPORT __declspec(dllimport) #else -#define EXPORT -#define IMPORT +# define EXPORT +# define IMPORT #endif int dynamic_base_func(int); diff --git a/Tests/Cuda/Complex/mixed.cu b/Tests/Cuda/Complex/mixed.cu index a81ccb731..5b85aecce 100644 --- a/Tests/Cuda/Complex/mixed.cu +++ b/Tests/Cuda/Complex/mixed.cu @@ -5,11 +5,11 @@ #include "file2.h" #ifdef _WIN32 -#define EXPORT __declspec(dllexport) -#define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +# define IMPORT __declspec(dllimport) #else -#define EXPORT -#define IMPORT +# define EXPORT +# define IMPORT #endif result_type __device__ file1_func(int x); diff --git a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt index 9fda2d02b..7098a7df5 100644 --- a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt +++ b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaConsumeCompileFeatures CXX CUDA) +project (ConsumeCompileFeatures CXX CUDA) #Goal for this example: #build a c++11 library that express a c++11 public compile feature diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt index 1d93be732..395bd3881 100644 --- a/Tests/Cuda/ObjectLibrary/CMakeLists.txt +++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt @@ -1,17 +1,20 @@ cmake_minimum_required(VERSION 3.7) -project (CudaObjectLibrary CUDA CXX) +project (ObjectLibrary CUDA CXX) #Goal for this example: - -#build a object files some with cuda and some without than -#embed these into an executable +# +#Build C++ and CUDA object files and than use them to make an executable +#Make sure that CMake logic to handle object output when multiple files +#with the same name works +add_subdirectory(Conflicts) add_library(CudaMixedObjectLib OBJECT static.cu static.cpp) add_executable(CudaObjectLibrary main.cpp - $<TARGET_OBJECTS:CudaMixedObjectLib>) + $<TARGET_OBJECTS:CudaMixedObjectLib> + $<TARGET_OBJECTS:CudaConflicts>) + if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaObjectLibrary PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaObjectLibrary PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/Cuda/ObjectLibrary/main.cpp b/Tests/Cuda/ObjectLibrary/main.cpp index 4d2f89028..e28f08851 100644 --- a/Tests/Cuda/ObjectLibrary/main.cpp +++ b/Tests/Cuda/ObjectLibrary/main.cpp @@ -1,22 +1,18 @@ #include <iostream> -int static_func(int); -int file1_sq_func(int); +int cpp_sq_func(int); +int cu1_sq_func(int); +int cu2_sq_func(int); -int test_functions() +bool test_functions() { - return file1_sq_func(static_func(42)); + return (cu1_sq_func(42) == cpp_sq_func(42)) && + (cu2_sq_func(42) == cpp_sq_func(42)); } int main(int argc, char** argv) { - if (test_functions() == 1) { - return 1; - } - std::cout - << "this executable doesn't use cuda code, just call methods defined" - << std::endl; - std::cout << "in object files that have cuda code" << std::endl; - return 0; + int result = test_functions() ? 0 : 1; + return result; } diff --git a/Tests/Cuda/ObjectLibrary/static.cpp b/Tests/Cuda/ObjectLibrary/static.cpp index 6db1f914f..527f7f554 100644 --- a/Tests/Cuda/ObjectLibrary/static.cpp +++ b/Tests/Cuda/ObjectLibrary/static.cpp @@ -1,6 +1,6 @@ int file1_sq_func(int); -int static_func(int x) +int cpp_sq_func(int x) { - return file1_sq_func(x); + return x * x; } diff --git a/Tests/Cuda/ObjectLibrary/static.cu b/Tests/Cuda/ObjectLibrary/static.cu index aa357295a..37bb8391e 100644 --- a/Tests/Cuda/ObjectLibrary/static.cu +++ b/Tests/Cuda/ObjectLibrary/static.cu @@ -3,7 +3,7 @@ #include <cuda_runtime.h> #include <iostream> -int __host__ file1_sq_func(int x) +int __host__ cu1_sq_func(int x) { cudaError_t err; int nDevices = 0; @@ -13,9 +13,5 @@ int __host__ file1_sq_func(int x) std::cerr << "err: " << err << std::endl; return 1; } - std::cout << "this library uses cuda code" << std::endl; - std::cout << "you have " << nDevices << " devices that support cuda" - << std::endl; - return x * x; } diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt index 1f25ab43e..69aa3f992 100644 --- a/Tests/Cuda/WithC/CMakeLists.txt +++ b/Tests/Cuda/WithC/CMakeLists.txt @@ -1,12 +1,11 @@ cmake_minimum_required(VERSION 3.7) -project(CudaComplex CUDA C) +project(WithC CUDA C) string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") add_executable(CudaWithC main.c cuda.cu) if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaWithC PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaWithC PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/Cuda/WithC/main.c b/Tests/Cuda/WithC/main.c index cb5fddc1f..5f3c781b0 100644 --- a/Tests/Cuda/WithC/main.c +++ b/Tests/Cuda/WithC/main.c @@ -1,7 +1,7 @@ extern int use_cuda(void); #ifdef _WIN32 -#include <windows.h> +# include <windows.h> #endif int main() diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 5f456fcf4..f1fd34487 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -1,6 +1,23 @@ +ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) +ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) +ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) -ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) + +add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}/DontResolveDeviceSymbols/" + "${CMAKE_CURRENT_BINARY_DIR}/DontResolveDeviceSymbols/" + ${build_generator_args} + --build-project DontResolveDeviceSymbols + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + +if(MSVC) + ADD_TEST_MACRO(CudaOnly.PDB CudaOnlyPDB) +endif() diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt index 35a1deb69..54e2c1413 100644 --- a/Tests/CudaOnly/EnableStandard/CMakeLists.txt +++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlyEnableStandard CUDA) +project (EnableStandard CUDA) #Goal for this example: #build cuda sources that require C++11 to be enabled. diff --git a/Tests/CudaOnly/EnableStandard/main.cu b/Tests/CudaOnly/EnableStandard/main.cu index f21958371..740c832a6 100644 --- a/Tests/CudaOnly/EnableStandard/main.cu +++ b/Tests/CudaOnly/EnableStandard/main.cu @@ -2,9 +2,9 @@ #include <iostream> #ifdef _WIN32 -#define IMPORT __declspec(dllimport) +# define IMPORT __declspec(dllimport) #else -#define IMPORT +# define IMPORT #endif int static_cuda11_func(int); diff --git a/Tests/CudaOnly/EnableStandard/shared.cu b/Tests/CudaOnly/EnableStandard/shared.cu index ccdd0b28e..004cb8372 100644 --- a/Tests/CudaOnly/EnableStandard/shared.cu +++ b/Tests/CudaOnly/EnableStandard/shared.cu @@ -2,9 +2,9 @@ #include <type_traits> #ifdef _WIN32 -#define EXPORT __declspec(dllexport) +# define EXPORT __declspec(dllexport) #else -#define EXPORT +# define EXPORT #endif using tt = std::true_type; diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt index 10249c614..ff6e77c33 100644 --- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt +++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project (CudaOnlyExportPTX CUDA) +project (ExportPTX CUDA) #Goal for this example: # How to generate PTX files instead of OBJECT files @@ -67,9 +67,8 @@ target_compile_definitions(CudaOnlyExportPTX PRIVATE "CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>") if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaOnlyExportPTX PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyExportPTX PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() #Verify that we can install object targets properly diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index b96bb984b..796e13382 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlyResolveDeviceSymbols CUDA) +project (ResolveDeviceSymbols CUDA) # Find nm and dumpbin if(CMAKE_NM) @@ -16,12 +16,12 @@ else() endif() #Goal for this example: -#Build a static library that defines multiple methods and kernels that -#use each other. -#Use a custom command to build an executable that uses this static library -#We do these together to verify that we can get a static library to do -#device symbol linking, and not have it done when the executable is made -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +# Build a static library that defines multiple methods and kernels that +# use each other. +# Resolve the device symbols into that static library +# Verify that we can't use those device symbols from anything that links +# to the static library +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30] -gencode arch=compute_50,code=\\\"compute_50\\\"") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) @@ -43,10 +43,13 @@ add_custom_command(TARGET CUDAResolveDeviceLib POST_BUILD endif() add_executable(CudaOnlyResolveDeviceSymbols main.cu) +set_target_properties(CudaOnlyResolveDeviceSymbols + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) + target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib) if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE -Wl,-rpath,/usr/local/cuda/lib) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyResolveDeviceSymbols PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/main.cu b/Tests/CudaOnly/ResolveDeviceSymbols/main.cu index b4b5b9eac..d464f964e 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/main.cu +++ b/Tests/CudaOnly/ResolveDeviceSymbols/main.cu @@ -62,17 +62,8 @@ int main(int argc, char** argv) return 0; } - cudaError_t err; - file2_launch_kernel(42); - err = cudaGetLastError(); - if (err != cudaSuccess) { - std::cerr << "file2_launch_kernel: kernel launch failed: " - << cudaGetErrorString(err) << std::endl; - return 1; - } - main_launch_kernel(1); - err = cudaGetLastError(); + cudaError_t err = cudaGetLastError(); if (err == cudaSuccess) { // This kernel launch should fail as the file2_func was device linked // into the static library and is not usable by the executable diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index 3d4a17073..1e574d6cc 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlySeparateCompilation CUDA) +project (SeparateCompilation CUDA) #Goal for this example: #Build a static library that defines multiple methods and kernels that @@ -9,11 +9,18 @@ project (CudaOnlySeparateCompilation CUDA) #and executables. #We complicate the matter by also testing that multiple static libraries #all containing cuda separable compilation code links properly -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=\\\"compute_30,sm_30,sm_35\\\"") +string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu) +get_property(sep_comp TARGET CUDASeparateLibA PROPERTY CUDA_SEPARABLE_COMPILATION) +if(NOT sep_comp) + message(FATAL_ERROR "CUDA_SEPARABLE_COMPILATION not initialized") +endif() +unset(CMAKE_CUDA_SEPARABLE_COMPILATION) if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC") # Test adding a flag that is not in our CUDA flag table for VS. @@ -48,8 +55,7 @@ if (CMAKE_GENERATOR MATCHES "^Visual Studio") PROPERTIES CUDA_SEPARABLE_COMPILATION ON) endif() -if (APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - target_link_libraries(CudaOnlySeparateCompilation PRIVATE -Wl,-rpath,/usr/local/cuda/lib) +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index e25f141ea..00fd7d24c 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -1,10 +1,14 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlyWithDefs CUDA) +project (WithDefs CUDA) #verify that we can pass explicit cuda arch flags string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") -set(debug_compile_flags --generate-code arch=compute_20,code=sm_20) +if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 9) + set(debug_compile_flags --generate-code arch=compute_32,code=sm_32) +else() + set(debug_compile_flags --generate-code arch=compute_20,code=sm_20) +endif() if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC") list(APPEND debug_compile_flags -Xcompiler=-WX) else() @@ -17,17 +21,13 @@ set(release_compile_defs DEFREL) #this verifies we can pass things such as '_','(' to nvcc add_definitions("-DPACKED_DEFINE=__attribute__((packed))") -if(CMAKE_GENERATOR MATCHES "Visual Studio") - # CUDA MSBuild rules do not pass '-x cu' to nvcc - set(main main_for_vs.cu) -else() - set(main main.notcu) - set_source_files_properties(main.notcu PROPERTIES LANGUAGE CUDA) -endif() -add_executable(CudaOnlyWithDefs ${main}) +add_executable(CudaOnlyWithDefs main.notcu) +set_source_files_properties(main.notcu PROPERTIES LANGUAGE CUDA) target_compile_options(CudaOnlyWithDefs PRIVATE + -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE> + -DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> -Xcompiler=-DHOST_DEFINE $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>> ) @@ -35,10 +35,18 @@ target_compile_options(CudaOnlyWithDefs target_compile_definitions(CudaOnlyWithDefs PRIVATE $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>> + -DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE> + -DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> + -DDEF_CUDA_COMPILER=$<CUDA_COMPILER_ID> + -DDEF_CUDA_COMPILER_VERSION=$<CUDA_COMPILER_VERSION> ) -#we need to add an rpath for the cuda library so that everything -#loads properly on the mac -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - set_target_properties(CudaOnlyWithDefs PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") +target_include_directories(CudaOnlyWithDefs + PRIVATE + $<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CURRENT_SOURCE_DIR}/inc_cuda> +) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) endif() diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu index d2eff3f4b..68a296b2c 100644 --- a/Tests/CudaOnly/WithDefs/main.notcu +++ b/Tests/CudaOnly/WithDefs/main.notcu @@ -2,12 +2,49 @@ #include <cuda_runtime.h> #include <iostream> +#include <inc_cuda.h> +#ifndef INC_CUDA +# error "INC_CUDA not defined!" +#endif + #ifndef HOST_DEFINE -#error "HOST_DEFINE not defined!" +# error "HOST_DEFINE not defined!" #endif #ifndef PACKED_DEFINE -#error "PACKED_DEFINE not defined!" +# error "PACKED_DEFINE not defined!" +#endif + +#ifndef FLAG_COMPILE_LANG_CUDA +# error "FLAG_COMPILE_LANG_CUDA not defined!" +#endif + +#ifndef FLAG_LANG_IS_CUDA +# error "FLAG_LANG_IS_CUDA not defined!" +#endif + +#if !FLAG_LANG_IS_CUDA +# error "Expected FLAG_LANG_IS_CUDA" +#endif + +#ifndef DEF_COMPILE_LANG_CUDA +# error "DEF_COMPILE_LANG_CUDA not defined!" +#endif + +#ifndef DEF_LANG_IS_CUDA +# error "DEF_LANG_IS_CUDA not defined!" +#endif + +#if !DEF_LANG_IS_CUDA +# error "Expected DEF_LANG_IS_CUDA" +#endif + +#ifndef DEF_CUDA_COMPILER +# error "DEF_CUDA_COMPILER not defined!" +#endif + +#ifndef DEF_CUDA_COMPILER_VERSION +# error "DEF_CUDA_COMPILER_VERSION not defined!" #endif static __global__ void DetermineIfValidCudaDevice() @@ -15,20 +52,20 @@ static __global__ void DetermineIfValidCudaDevice() } #ifdef _MSC_VER -#pragma pack(push, 1) -#undef PACKED_DEFINE -#define PACKED_DEFINE +# pragma pack(push, 1) +# undef PACKED_DEFINE +# define PACKED_DEFINE #endif struct PACKED_DEFINE result_type { bool valid; int value; #if defined(NDEBUG) && !defined(DEFREL) -#error missing DEFREL flag +# error missing DEFREL flag #endif }; #ifdef _MSC_VER -#pragma pack(pop) +# pragma pack(pop) #endif result_type can_launch_kernel() diff --git a/Tests/CustComDepend/bar.h b/Tests/CustComDepend/bar.h index c072b81a9..b0a690b57 100644 --- a/Tests/CustComDepend/bar.h +++ b/Tests/CustComDepend/bar.h @@ -1,9 +1,9 @@ #ifdef _WIN32 -#ifdef bar_EXPORTS -#define BAR_EXPORT __declspec(dllexport) +# ifdef bar_EXPORTS +# define BAR_EXPORT __declspec(dllexport) +# else +# define BAR_EXPORT __declspec(dllimport) +# endif #else -#define BAR_EXPORT __declspec(dllimport) -#endif -#else -#define BAR_EXPORT +# define BAR_EXPORT #endif diff --git a/Tests/CustomCommand/wrapper.cxx b/Tests/CustomCommand/wrapper.cxx index c38093816..33412f8b6 100644 --- a/Tests/CustomCommand/wrapper.cxx +++ b/Tests/CustomCommand/wrapper.cxx @@ -17,9 +17,10 @@ int main(int argc, char* argv[]) #ifdef CMAKE_INTDIR const char* cfg = (argc >= 4) ? argv[3] : ""; if (strcmp(cfg, CMAKE_INTDIR) != 0) { - fprintf(stderr, "Did not receive expected configuration argument:\n" - " expected [" CMAKE_INTDIR "]\n" - " received [%s]\n", + fprintf(stderr, + "Did not receive expected configuration argument:\n" + " expected [" CMAKE_INTDIR "]\n" + " received [%s]\n", cfg); return 1; } diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index 3289e8f9f..d0bf6487e 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0058 OLD) project(CustomCommandByproducts C) # Generate a byproduct in a rule that runs in the target consuming it. @@ -81,7 +82,8 @@ add_custom_command(OUTPUT timestamp8.txt # Generate the library file of an imported target as a byproduct # of an external project. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(cfg /${CMAKE_CFG_INTDIR}) else() set(cfg) @@ -105,7 +107,7 @@ add_dependencies(ExternalLibrary ExternalTarget) # Generate the library file of an imported target as a byproduct # of an external project. The byproduct uses <BINARY_DIR> that is substituted # by the real binary path -if(CMAKE_CONFIGURATION_TYPES) +if(_isMultiConfig) set(cfg /${CMAKE_CFG_INTDIR}) else() set(cfg) diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt index 4975feb2d..3bab1fec0 100644 --- a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt +++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt @@ -9,17 +9,17 @@ add_custom_command( ) set_source_files_properties( - "${TestWorkingDir_BINARY_DIR}/customTarget.c" + "${TestWorkingDir_BINARY_DIR}/customTarget1.c" "${TestWorkingDir_BINARY_DIR}/customTarget2.c" PROPERTIES GENERATED 1) add_executable(working "${TestWorkingDir_BINARY_DIR}/working.c" - "${TestWorkingDir_BINARY_DIR}/customTarget.c") + "${TestWorkingDir_BINARY_DIR}/customTarget1.c") add_custom_target( Custom ALL - COMMAND "${CMAKE_COMMAND}" -E copy_if_different ./customTarget.c "${TestWorkingDir_BINARY_DIR}/customTarget.c" - BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget.c" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ./customTarget.c "${TestWorkingDir_BINARY_DIR}/customTarget1.c" + BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget1.c" WORKING_DIRECTORY "${TestWorkingDir_SOURCE_DIR}" ) @@ -42,3 +42,23 @@ add_custom_target( ) add_dependencies(working2 Custom2) + +file(MAKE_DIRECTORY ${TestWorkingDir_BINARY_DIR}/genex) +add_custom_command( + OUTPUT "${TestWorkingDir_BINARY_DIR}/genex/working.c" + COMMAND "${CMAKE_COMMAND}" -E copy "${TestWorkingDir_SOURCE_DIR}/working.c.in" "${TestWorkingDir_BINARY_DIR}/genex/working.c" + WORKING_DIRECTORY "$<0:not_used/>${TestWorkingDir_BINARY_DIR}/$<1:genex>/" + COMMENT "custom command" +) + +add_executable(workinggenex "${TestWorkingDir_BINARY_DIR}/genex/working.c" + "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c") + +add_custom_target( + CustomGenex ALL + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${TestWorkingDir_SOURCE_DIR}/customTarget.c" "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c" + BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c" + WORKING_DIRECTORY "$<0:not_used/>${TestWorkingDir_BINARY_DIR}/$<1:genex>/" +) + +add_dependencies(workinggenex CustomGenex) diff --git a/Tests/CxxOnly/libcxx2.h b/Tests/CxxOnly/libcxx2.h index 1d97fa0ac..774e4e897 100644 --- a/Tests/CxxOnly/libcxx2.h +++ b/Tests/CxxOnly/libcxx2.h @@ -1,11 +1,11 @@ #ifdef _WIN32 -#ifdef testcxx2_EXPORTS -#define CM_TEST_LIB_EXPORT __declspec(dllexport) +# ifdef testcxx2_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec(dllexport) +# else +# define CM_TEST_LIB_EXPORT __declspec(dllimport) +# endif #else -#define CM_TEST_LIB_EXPORT __declspec(dllimport) -#endif -#else -#define CM_TEST_LIB_EXPORT +# define CM_TEST_LIB_EXPORT #endif class CM_TEST_LIB_EXPORT LibCxx2Class diff --git a/Tests/CxxOnly/testCxxModule.cxx b/Tests/CxxOnly/testCxxModule.cxx index 039e8bba6..5015d07f8 100644 --- a/Tests/CxxOnly/testCxxModule.cxx +++ b/Tests/CxxOnly/testCxxModule.cxx @@ -1,7 +1,7 @@ #ifdef _WIN32 -#define TEST_EXPORT __declspec(dllexport) +# define TEST_EXPORT __declspec(dllexport) #else -#define TEST_EXPORT +# define TEST_EXPORT #endif TEST_EXPORT int testCxxModule(void) { diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index 8c0817cd6..b7587aa47 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -18,9 +18,20 @@ if(NOT CTEST_CONFIGURATION_TYPE) endif() endforeach() if(NOT CTEST_CONFIGURATION_TYPE) - set(CTEST_CONFIGURATION_TYPE NoConfig) + if("@CMAKE_C_COMPILER_ID@;@CMAKE_C_SIMULATE_ID@;@CMAKE_C_COMPILER_FRONTEND_VARIANT@" STREQUAL "Clang;MSVC;GNU") + # A valid configuration is required for this compiler in tests that do not set CMP0091 to NEW. + set(CTEST_CONFIGURATION_TYPE Debug) + else() + set(CTEST_CONFIGURATION_TYPE NoConfig) + endif() endif() message("Guessing configuration ${CTEST_CONFIGURATION_TYPE}") endif() +# Isolate tests from user configuration in the environment. +unset(ENV{CMAKE_GENERATOR}) +unset(ENV{CMAKE_GENERATOR_INSTANCE}) +unset(ENV{CMAKE_GENERATOR_PLATFORM}) +unset(ENV{CMAKE_GENERATOR_TOOLSET}) + @TEST_HOME_ENV_CODE@ diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index eaad3d46c..dc621eb27 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.7.20090711) +cmake_minimum_required (VERSION 3.9) project(ExportImport C CXX) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") @@ -15,7 +15,8 @@ set_property( PROPERTY SYMBOLIC 1 ) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index eeae3f006..c6b7dbc95 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 @@ -143,6 +155,13 @@ add_library(testStaticLibRequiredPrivate testStaticLibRequiredPrivate.c) target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate) cmake_policy(POP) +cmake_policy(PUSH) +cmake_policy(SET CMP0079 NEW) +add_library(TopDirLib STATIC testTopDirLib.c) +add_subdirectory(SubDirLinkA) +add_subdirectory(SubDirLinkB) +cmake_policy(POP) + macro(add_include_lib _libName) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "/* no content */\n") add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c") @@ -344,6 +363,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,19 +510,26 @@ 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 + TopDirLib SubDirLinkA systemlib EXPORT exp - RUNTIME DESTINATION $<1:bin> - LIBRARY DESTINATION $<1:lib> NAMELINK_SKIP - ARCHIVE DESTINATION $<1:lib> - OBJECTS DESTINATION $<1:lib> + RUNTIME DESTINATION $<1:bin>$<0:/wrong> + LIBRARY DESTINATION $<1:lib>$<0:/wrong> NAMELINK_SKIP + ARCHIVE DESTINATION $<1:lib>$<0:/wrong> + ${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) @@ -540,12 +574,14 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 testSharedLibRequired testSharedLibRequiredUser testSharedLibRequiredUser2 testSharedLibDepends renamed_on_export cmp0022NEW cmp0022OLD + TopDirLib SubDirLinkA systemlib NAMESPACE bld_ 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 @@ -570,3 +606,39 @@ install( ) install(DIRECTORY $<1:include/abs>$<0:/wrong> DESTINATION $<1:include>$<0:/wrong>) install(EXPORT expAbs NAMESPACE expAbs_ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/expAbs) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_OPTIONS +add_library(testLinkOptions INTERFACE) +target_link_options(testLinkOptions INTERFACE INTERFACE_FLAG) + +install(TARGETS testLinkOptions + EXPORT RequiredExp DESTINATION lib) +export(TARGETS testLinkOptions NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_DIRECTORIES +add_library(testLinkDirectories INTERFACE) +target_link_directories(testLinkDirectories INTERFACE + $<BUILD_INTERFACE:/interface/build> + $<INSTALL_INTERFACE:interface/install>) + +install(TARGETS testLinkDirectories + EXPORT RequiredExp DESTINATION lib) +export(TARGETS testLinkDirectories NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_DEPENDS +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + add_library(testLinkDepends INTERFACE) + set_property(TARGET testLinkDepends PROPERTY INTERFACE_LINK_DEPENDS + $<BUILD_INTERFACE:BUILD_LINK_DEPENDS> + $<INSTALL_INTERFACE:INSTALL_LINK_DEPENDS>) + + install(TARGETS testLinkDepends + EXPORT RequiredExp DESTINATION lib) + export(TARGETS testLinkDepends NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) +endif() diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index fd55c423c..22a4ef600 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -41,6 +41,8 @@ install(FILES add_library(cmakeonly INTERFACE) set_property(TARGET cmakeonly PROPERTY INTERFACE_COMPILE_DEFINITIONS [[DEF="\"\$\B"]]) +set_property(TARGET cmakeonly PROPERTY custom_property CustomPropertyValue) +set_property(TARGET cmakeonly PROPERTY EXPORT_PROPERTIES custom_property) install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target cmakeonly diff --git a/Tests/ExportImport/Export/Interface/source_target.cpp b/Tests/ExportImport/Export/Interface/source_target.cpp index 037191cf6..1eb5b1307 100644 --- a/Tests/ExportImport/Export/Interface/source_target.cpp +++ b/Tests/ExportImport/Export/Interface/source_target.cpp @@ -1,10 +1,10 @@ #ifndef USE_FROM_BUILD_DIR -#error Expected define USE_FROM_BUILD_DIR +# error Expected define USE_FROM_BUILD_DIR #endif #ifdef USE_FROM_INSTALL_DIR -#error Unexpected define USE_FROM_INSTALL_DIR +# error Unexpected define USE_FROM_INSTALL_DIR #endif int source_symbol() diff --git a/Tests/ExportImport/Export/Interface/source_target_for_install.cpp b/Tests/ExportImport/Export/Interface/source_target_for_install.cpp index 64514edb2..2f8819052 100644 --- a/Tests/ExportImport/Export/Interface/source_target_for_install.cpp +++ b/Tests/ExportImport/Export/Interface/source_target_for_install.cpp @@ -1,10 +1,10 @@ #ifdef USE_FROM_BUILD_DIR -#error Unexpected define USE_FROM_BUILD_DIR +# error Unexpected define USE_FROM_BUILD_DIR #endif #ifndef USE_FROM_INSTALL_DIR -#error Expected define USE_FROM_INSTALL_DIR +# error Expected define USE_FROM_INSTALL_DIR #endif int source_symbol() diff --git a/Tests/ExportImport/Export/systemlib.h b/Tests/ExportImport/Export/systemlib.h index 6fd00d503..8ec055bb0 100644 --- a/Tests/ExportImport/Export/systemlib.h +++ b/Tests/ExportImport/Export/systemlib.h @@ -3,9 +3,9 @@ #define SYSTEMLIB_H #if defined(_WIN32) || defined(__CYGWIN__) -#define systemlib_EXPORT __declspec(dllexport) +# define systemlib_EXPORT __declspec(dllexport) #else -#define systemlib_EXPORT +# define systemlib_EXPORT #endif struct systemlib_EXPORT SystemStruct diff --git a/Tests/ExportImport/Export/testExe2.c b/Tests/ExportImport/Export/testExe2.c index f8976c46a..958e4d2bc 100644 --- a/Tests/ExportImport/Export/testExe2.c +++ b/Tests/ExportImport/Export/testExe2.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2_EXPORT __declspec(dllexport) +# define testExe2_EXPORT __declspec(dllexport) #else -#define testExe2_EXPORT +# define testExe2_EXPORT #endif testExe2_EXPORT int testExe2Func(void) diff --git a/Tests/ExportImport/Export/testExe2lib.c b/Tests/ExportImport/Export/testExe2lib.c index 2a5a77bd5..905e6c7f5 100644 --- a/Tests/ExportImport/Export/testExe2lib.c +++ b/Tests/ExportImport/Export/testExe2lib.c @@ -1,9 +1,9 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2lib_EXPORT __declspec(dllexport) -#define testExe2libImp_IMPORT __declspec(dllimport) +# define testExe2lib_EXPORT __declspec(dllexport) +# define testExe2libImp_IMPORT __declspec(dllimport) #else -#define testExe2lib_EXPORT -#define testExe2libImp_IMPORT +# define testExe2lib_EXPORT +# define testExe2libImp_IMPORT #endif testExe2libImp_IMPORT int testExe2libImp(void); diff --git a/Tests/ExportImport/Export/testExe2libImp.c b/Tests/ExportImport/Export/testExe2libImp.c index aba914b88..8892c8553 100644 --- a/Tests/ExportImport/Export/testExe2libImp.c +++ b/Tests/ExportImport/Export/testExe2libImp.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2libImp_EXPORT __declspec(dllexport) +# define testExe2libImp_EXPORT __declspec(dllexport) #else -#define testExe2libImp_EXPORT +# define testExe2libImp_EXPORT #endif testExe2libImp_EXPORT int testExe2libImp(void) diff --git a/Tests/ExportImport/Export/testLib3.c b/Tests/ExportImport/Export/testLib3.c index cacac810f..016fae0b1 100644 --- a/Tests/ExportImport/Export/testLib3.c +++ b/Tests/ExportImport/Export/testLib3.c @@ -1,9 +1,9 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib3_EXPORT __declspec(dllexport) -#define testLib3Imp_IMPORT __declspec(dllimport) +# define testLib3_EXPORT __declspec(dllexport) +# define testLib3Imp_IMPORT __declspec(dllimport) #else -#define testLib3_EXPORT -#define testLib3Imp_IMPORT +# define testLib3_EXPORT +# define testLib3Imp_IMPORT #endif testLib3Imp_IMPORT int testLib3Imp(void); diff --git a/Tests/ExportImport/Export/testLib3Imp.c b/Tests/ExportImport/Export/testLib3Imp.c index 3d836daf1..877d0b6bf 100644 --- a/Tests/ExportImport/Export/testLib3Imp.c +++ b/Tests/ExportImport/Export/testLib3Imp.c @@ -1,9 +1,9 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib3Imp_EXPORT __declspec(dllexport) -#define testLib3ImpDep_IMPORT __declspec(dllimport) +# define testLib3Imp_EXPORT __declspec(dllexport) +# define testLib3ImpDep_IMPORT __declspec(dllimport) #else -#define testLib3Imp_EXPORT -#define testLib3ImpDep_IMPORT +# define testLib3Imp_EXPORT +# define testLib3ImpDep_IMPORT #endif testLib3ImpDep_IMPORT int testLib3ImpDep(void); diff --git a/Tests/ExportImport/Export/testLib3ImpDep.c b/Tests/ExportImport/Export/testLib3ImpDep.c index b824e03de..4fc97836b 100644 --- a/Tests/ExportImport/Export/testLib3ImpDep.c +++ b/Tests/ExportImport/Export/testLib3ImpDep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib3ImpDep_EXPORT __declspec(dllexport) +# define testLib3ImpDep_EXPORT __declspec(dllexport) #else -#define testLib3ImpDep_EXPORT +# define testLib3ImpDep_EXPORT #endif testLib3ImpDep_EXPORT int testLib3ImpDep(void) diff --git a/Tests/ExportImport/Export/testLib4.c b/Tests/ExportImport/Export/testLib4.c index 0e583b176..2031a4fd7 100644 --- a/Tests/ExportImport/Export/testLib4.c +++ b/Tests/ExportImport/Export/testLib4.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib4_EXPORT __declspec(dllexport) +# define testLib4_EXPORT __declspec(dllexport) #else -#define testLib4_EXPORT +# define testLib4_EXPORT #endif testLib4_EXPORT int testLib4(void) diff --git a/Tests/ExportImport/Export/testLib5.c b/Tests/ExportImport/Export/testLib5.c index 7c61fc030..edd02ebd1 100644 --- a/Tests/ExportImport/Export/testLib5.c +++ b/Tests/ExportImport/Export/testLib5.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib5_EXPORT __declspec(dllexport) +# define testLib5_EXPORT __declspec(dllexport) #else -#define testLib5_EXPORT +# define testLib5_EXPORT #endif testLib5_EXPORT int testLib5(void) diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c index c896c10ef..6100da1dc 100644 --- a/Tests/ExportImport/Export/testLibDepends.c +++ b/Tests/ExportImport/Export/testLibDepends.c @@ -4,15 +4,15 @@ #include "testLibIncludeRequired4.h" #ifndef testLibRequired_IFACE_DEFINE -#error Expected testLibRequired_IFACE_DEFINE +# error Expected testLibRequired_IFACE_DEFINE #endif #ifndef BuildOnly_DEFINE -#error Expected BuildOnly_DEFINE +# error Expected BuildOnly_DEFINE #endif #ifdef InstallOnly_DEFINE -#error Unexpected InstallOnly_DEFINE +# error Unexpected InstallOnly_DEFINE #endif extern int testLibRequired(void); diff --git a/Tests/ExportImport/Export/testLibNoSONAME.c b/Tests/ExportImport/Export/testLibNoSONAME.c index 4d98562df..955284852 100644 --- a/Tests/ExportImport/Export/testLibNoSONAME.c +++ b/Tests/ExportImport/Export/testLibNoSONAME.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLibNoSONAME_EXPORT __declspec(dllexport) +# define testLibNoSONAME_EXPORT __declspec(dllexport) #else -#define testLibNoSONAME_EXPORT +# define testLibNoSONAME_EXPORT #endif testLibNoSONAME_EXPORT int testLibNoSoName(void) diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 01960ea19..b5df96168 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -1,3 +1,9 @@ +# Prepare imported targets that the exported project itself imported. +add_library(SubDirLinkAImported IMPORTED INTERFACE) +target_compile_definitions(SubDirLinkAImported INTERFACE DEF_SubDirLinkAImportedForImport) +add_library(SubDirLinkBImported IMPORTED INTERFACE) +target_compile_definitions(SubDirLinkBImported INTERFACE DEF_SubDirLinkBImportedForImport) + # Import targets from the exported build tree. include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake) @@ -32,6 +38,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 @@ -144,6 +164,11 @@ target_link_libraries(cmp0022OLD_exp_test exp_cmp0022OLD) add_executable(cmp0022NEW_exp_test cmp0022NEW_test_vs6_2.cpp) target_link_libraries(cmp0022NEW_exp_test exp_cmp0022NEW) +add_executable(SubDirLink_bld SubDirLink.c) +target_link_libraries(SubDirLink_bld PRIVATE bld_TopDirLib bld_SubDirLinkA) +add_executable(SubDirLink_exp SubDirLink.c) +target_link_libraries(SubDirLink_exp PRIVATE exp_TopDirLib exp_SubDirLinkA) + # Try building a plugin to an executable imported from the build tree. add_library(imp_mod1b MODULE imp_mod1.c) target_link_libraries(imp_mod1b bld_testExe2) @@ -229,15 +254,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 @@ -278,7 +332,6 @@ if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") else() if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" - OR CMAKE_SYSTEM_NAME MATCHES "IRIX64" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") set(run_pic_test 0) else() @@ -354,7 +407,7 @@ endforeach() unset(_configs) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR CMAKE_C_COMPILER_ID STREQUAL Clang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) @@ -429,3 +482,20 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA endif() endif() endif() + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_OPTIONS property +checkForProperty(bld_testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG") +checkForProperty(Req::testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG") + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_DIRECTORIES property +checkForProperty(bld_testLinkDirectories "INTERFACE_LINK_DIRECTORIES" "/interface/build") +checkForProperty(Req::testLinkDirectories "INTERFACE_LINK_DIRECTORIES" "${CMAKE_INSTALL_PREFIX}/interface/install") + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_DEPENDS property +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + checkForProperty(bld_testLinkDepends "INTERFACE_LINK_DEPENDS" "BUILD_LINK_DEPENDS") + checkForProperty(Req::testLinkDepends "INTERFACE_LINK_DEPENDS" "${CMAKE_INSTALL_PREFIX}/INSTALL_LINK_DEPENDS") +endif() diff --git a/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp index 587834987..778b8287e 100644 --- a/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp +++ b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp @@ -1,9 +1,9 @@ #ifndef USING_TESTLIB2 -#error Expected USING_TESTLIB2 +# error Expected USING_TESTLIB2 #endif #ifdef USING_TESTLIB3 -#error Unexpected USING_TESTLIB3 +# error Unexpected USING_TESTLIB3 #endif int main(void) diff --git a/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp index e50158b76..9eaaee9b4 100644 --- a/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp +++ b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp @@ -1,9 +1,9 @@ #ifdef USING_TESTLIB2 -#error Unexpected USING_TESTLIB2 +# error Unexpected USING_TESTLIB2 #endif #ifndef USING_TESTLIB3 -#error Expected USING_TESTLIB3 +# error Expected USING_TESTLIB3 #endif int main(void) diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c index 1539bcb68..e2d973c2f 100644 --- a/Tests/ExportImport/Import/A/deps_iface.c +++ b/Tests/ExportImport/Import/A/deps_iface.c @@ -14,15 +14,15 @@ #include "installIncludesTest8.h" #ifndef testLibRequired_IFACE_DEFINE -#error Expected testLibRequired_IFACE_DEFINE +# error Expected testLibRequired_IFACE_DEFINE #endif #ifdef BuildOnly_DEFINE -#error Unexpected BuildOnly_DEFINE +# error Unexpected BuildOnly_DEFINE #endif #ifndef InstallOnly_DEFINE -#error Expected InstallOnly_DEFINE +# error Expected InstallOnly_DEFINE #endif extern int testLibDepends(void); diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 3658ab548..d239fb418 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -3,32 +3,32 @@ #include "testSharedLibDepends.h" #ifdef CHECK_PIC_WORKS -#if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) -#error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency -#endif +# if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) +# error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency +# endif #endif #ifndef PIC_PROPERTY_IS_ON -#error Expected PIC_PROPERTY_IS_ON +# error Expected PIC_PROPERTY_IS_ON #endif #ifndef CUSTOM_PROPERTY_IS_ON -#error Expected CUSTOM_PROPERTY_IS_ON +# error Expected CUSTOM_PROPERTY_IS_ON #endif #ifndef CUSTOM_STRING_IS_MATCH -#error Expected CUSTOM_STRING_IS_MATCH +# error Expected CUSTOM_STRING_IS_MATCH #endif #ifdef TEST_SUBDIR_LIB -#include "renamed.h" -#include "subdir.h" +# include "renamed.h" +# include "subdir.h" #endif #ifdef DO_GNU_TESTS -#ifndef CUSTOM_COMPILE_OPTION -#error Expected CUSTOM_COMPILE_OPTION -#endif +# ifndef CUSTOM_COMPILE_OPTION +# error Expected CUSTOM_COMPILE_OPTION +# endif #endif int main(int, char**) diff --git a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp index 357f64f02..ddb8c4b35 100644 --- a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp +++ b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp @@ -2,5 +2,5 @@ #include <testLib4/testLib4.h> #ifndef TESTLIB4_H -#error Expected define TESTLIB4_H +# error Expected define TESTLIB4_H #endif diff --git a/Tests/ExportImport/Import/A/iface_test.cpp b/Tests/ExportImport/Import/A/iface_test.cpp index fa4474bdb..4428c1c50 100644 --- a/Tests/ExportImport/Import/A/iface_test.cpp +++ b/Tests/ExportImport/Import/A/iface_test.cpp @@ -1,6 +1,6 @@ #ifndef USING_TESTSHAREDLIBREQUIRED -#error Expected USING_TESTSHAREDLIBREQUIRED +# error Expected USING_TESTSHAREDLIBREQUIRED #endif #include "excludedFromAll.h" diff --git a/Tests/ExportImport/Import/A/imp_mod1.c b/Tests/ExportImport/Import/A/imp_mod1.c index 89d754595..9385d5519 100644 --- a/Tests/ExportImport/Import/A/imp_mod1.c +++ b/Tests/ExportImport/Import/A/imp_mod1.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2_IMPORT __declspec(dllimport) +# define testExe2_IMPORT __declspec(dllimport) #else -#define testExe2_IMPORT +# define testExe2_IMPORT #endif testExe2_IMPORT int testExe2Func(void); diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 348843928..8173557cd 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -14,9 +14,9 @@ extern int testLibPerConfigDest(void); /* Switch a symbol between debug and optimized builds to make sure the proper library is found from the testLib4 link interface. */ #ifdef EXE_DBG -#define testLib4libcfg testLib4libdbg +# define testLib4libcfg testLib4libdbg #else -#define testLib4libcfg testLib4libopt +# define testLib4libcfg testLib4libopt #endif extern testLib4libcfg(void); diff --git a/Tests/ExportImport/Import/A/imp_testExeAbs1.c b/Tests/ExportImport/Import/A/imp_testExeAbs1.c index 629b891f1..fd0524206 100644 --- a/Tests/ExportImport/Import/A/imp_testExeAbs1.c +++ b/Tests/ExportImport/Import/A/imp_testExeAbs1.c @@ -2,10 +2,10 @@ #include "testLibAbs1a.h" #include "testLibAbs1b.h" #ifndef testLibAbs1a -#error "testLibAbs1a not defined" +# error "testLibAbs1a not defined" #endif #ifndef testLibAbs1b -#error "testLibAbs1b not defined" +# error "testLibAbs1b not defined" #endif int main() { diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index c850508e5..a07a5b3c4 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -109,4 +109,12 @@ foreach(ns exp bld) "not\n" " " [[DEF="\"\$\B"]] "\n") endif() + get_property(custom TARGET ${ns}::cmakeonly PROPERTY custom_property) + if(NOT custom STREQUAL "CustomPropertyValue") + message(SEND_ERROR + "${ns}::cmakeonly property custom_property is:\n" + " ${custom}\n" + "not\n" + " CustomPropertyValue\n") + endif() endforeach() diff --git a/Tests/ExportImport/Import/Interface/headeronlytest.cpp b/Tests/ExportImport/Import/Interface/headeronlytest.cpp index 0e754e9e3..7b63a0496 100644 --- a/Tests/ExportImport/Import/Interface/headeronlytest.cpp +++ b/Tests/ExportImport/Import/Interface/headeronlytest.cpp @@ -2,11 +2,11 @@ #include "headeronly.h" #ifndef HEADERONLY_DEFINE -#error Expected HEADERONLY_DEFINE +# error Expected HEADERONLY_DEFINE #endif #ifdef SHAREDLIB_DEFINE -#error Unexpected SHAREDLIB_DEFINE +# error Unexpected SHAREDLIB_DEFINE #endif int main(int, char**) diff --git a/Tests/ExportImport/Import/Interface/interfacetest.cpp b/Tests/ExportImport/Import/Interface/interfacetest.cpp index 7be816286..c1e29c246 100644 --- a/Tests/ExportImport/Import/Interface/interfacetest.cpp +++ b/Tests/ExportImport/Import/Interface/interfacetest.cpp @@ -2,15 +2,15 @@ #include "sharedlib.h" #ifndef SHAREDLIB_DEFINE -#error Expected SHAREDLIB_DEFINE +# error Expected SHAREDLIB_DEFINE #endif #ifdef HEADERONLY_DEFINE -#error Unexpected HEADERONLY_DEFINE +# error Unexpected HEADERONLY_DEFINE #endif #ifndef DEFINE_IFACE_DEFINE -#error Expected DEFINE_IFACE_DEFINE +# error Expected DEFINE_IFACE_DEFINE #endif int main(int, char**) diff --git a/Tests/ExternalOBJ/CMakeLists.txt b/Tests/ExternalOBJ/CMakeLists.txt index 458c88bfd..4ff75b8cc 100644 --- a/Tests/ExternalOBJ/CMakeLists.txt +++ b/Tests/ExternalOBJ/CMakeLists.txt @@ -55,7 +55,7 @@ message("${EXTERNAL_OBJECT}") # Build an executable using the external object file. add_executable(ExternalOBJ executable.cxx ${CUSTOM_OBJECT}) # A bug showed up in VS2010 where an object file that was -# part of a custom commad output worked, but ones that were +# part of a custom command output worked, but ones that were # not didn't work. So, repeat the executable using the object # directly and not from the output of the copy. add_executable(ExternalOBJ2 executable.cxx ${EXTERNAL_OBJECT}) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 6b7356340..5adcbd9e2 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -631,3 +631,21 @@ ExternalProject_Add(${proj} LOG_BUILD 1 LOG_INSTALL 1 ) + +set(proj ExternalProject-log-dir) +ExternalProject_Add(${proj} + DOWNLOAD_COMMAND "${download_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "download" + PATCH_COMMAND "${patch_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "patch" + UPDATE_COMMAND "${update_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "update" + CONFIGURE_COMMAND "${configure_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "configure" + BUILD_COMMAND "${build_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "build" + INSTALL_COMMAND "${install_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "install" + LOG_MERGED_STDOUTERR 1 + LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/different_log + LOG_DOWNLOAD 1 + LOG_PATCH 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index 5b941630a..1075a9d07 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/Tests/ExternalProjectLocal/CMakeLists.txt @@ -20,71 +20,55 @@ set(binary_base "${base}/Build") set_property(DIRECTORY PROPERTY EP_BASE ${base}) set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) -if(NOT DEFINED can_build_tutorial_step5) - set(can_build_tutorial_step5 1) - - # The ExternalProject builds of Tutorial Step5 cannot be built - # correctly 2nd and later times in an in-source build... - # (because the CMakeCache.txt from the real in-source build of - # the Tests/Tutorial/Step5 directory gets copied when we do - # the "source directory copy" step... but it still refers to - # its original path which yields a configure error.) So: - # - if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - set(can_build_tutorial_step5 0) - endif() -endif() # Local DIR: # -if(can_build_tutorial_step5) - set(proj TutorialStep5-Local) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> - CMAKE_ARGS -G ${CMAKE_GENERATOR} <SOURCE_DIR> - TEST_BEFORE_INSTALL 1 - LOG_INSTALL 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") - ExternalProject_Get_Property(${proj} install_dir) - set(TutorialStep5_install_dir ${install_dir}) - - set(proj TutorialStep5-Local-TestAfterInstall) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> - CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF - TEST_AFTER_INSTALL 1 - LOG_TEST 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") - - set(proj TutorialStep5-Local-TestExcludeFromMainBefore) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> - CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF - TEST_BEFORE_INSTALL 1 - TEST_EXCLUDE_FROM_MAIN 1 - STEP_TARGETS test - LOG_TEST 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") - - set(proj TutorialStep5-Local-TestExcludeFromMainAfter) - ExternalProject_Add(${proj} - URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> - CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF - TEST_AFTER_INSTALL 1 - TEST_EXCLUDE_FROM_MAIN 1 - STEP_TARGETS test - LOG_TEST 1 - ) - set_property(TARGET ${proj} PROPERTY FOLDER "Local") +set(proj TutorialStep5-Local) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> +CMAKE_ARGS -G ${CMAKE_GENERATOR} <SOURCE_DIR> +TEST_BEFORE_INSTALL 1 +LOG_INSTALL 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") +ExternalProject_Get_Property(${proj} install_dir) +set(TutorialStep5_install_dir ${install_dir}) + +set(proj TutorialStep5-Local-TestAfterInstall) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> +CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF +TEST_AFTER_INSTALL 1 +LOG_TEST 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") + +set(proj TutorialStep5-Local-TestExcludeFromMainBefore) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> +CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF +TEST_BEFORE_INSTALL 1 +TEST_EXCLUDE_FROM_MAIN 1 +STEP_TARGETS test +LOG_TEST 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") + +set(proj TutorialStep5-Local-TestExcludeFromMainAfter) +ExternalProject_Add(${proj} +URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5" +CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> +CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF +TEST_AFTER_INSTALL 1 +TEST_EXCLUDE_FROM_MAIN 1 +STEP_TARGETS test +LOG_TEST 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local") -endif() # Local TAR: @@ -100,6 +84,7 @@ ExternalProject_Add(${proj} -DTEST_LIST:STRING=A::B::C INSTALL_COMMAND "" LOG_CONFIGURE 1 + LOG_PATCH 1 ) set_property(TARGET ${proj} PROPERTY FOLDER "Local/TAR") @@ -208,12 +193,10 @@ enable_testing() # # BuildTree tests: # -if(can_build_tutorial_step5) - add_test(TutorialStep5-Local-BuildTreeTest - "${binary_base}/TutorialStep5-Local/Tutorial" 42) - set_property(TEST TutorialStep5-Local-BuildTreeTest - APPEND PROPERTY LABELS Step5 BuildTree) -endif() +add_test(TutorialStep5-Local-BuildTreeTest +"${binary_base}/TutorialStep5-Local/Tutorial" 42) +set_property(TEST TutorialStep5-Local-BuildTreeTest +APPEND PROPERTY LABELS Step5 BuildTree) add_test(TutorialStep1-LocalTAR-BuildTreeTest "${binary_base}/TutorialStep1-LocalTAR/EP-Tutorial" 36) @@ -233,12 +216,7 @@ add_test(TutorialStep1-LocalNoDirTGZ-BuildTreeTest # InstallTree tests: # -if(can_build_tutorial_step5) - add_test(TutorialStep5-InstallTreeTest - "${TutorialStep5_install_dir}/bin/Tutorial" 49) - set_property(TEST TutorialStep5-InstallTreeTest - APPEND PROPERTY LABELS Step5 InstallTree) -endif() - - -message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'") +add_test(TutorialStep5-InstallTreeTest +"${TutorialStep5_install_dir}/bin/Tutorial" 49) +set_property(TEST TutorialStep5-InstallTreeTest +APPEND PROPERTY LABELS Step5 InstallTree) diff --git a/Tests/FindBoost/CMakeLists.txt b/Tests/FindBoost/CMakeLists.txt index 0e9527de0..8489d859c 100644 --- a/Tests/FindBoost/CMakeLists.txt +++ b/Tests/FindBoost/CMakeLists.txt @@ -9,6 +9,21 @@ add_test(NAME FindBoost.Test COMMAND --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) +add_test(NAME FindBoost.TestFail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBoost/TestFail" + "${CMake_BINARY_DIR}/Tests/FindBoost/TestFail" + ${build_generator_args} + --build-project TestFailFindBoost + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + +set_tests_properties(FindBoost.TestFail PROPERTIES + WILL_FAIL ON + PASS_REGULAR_EXPRESSION "Could NOT find Boost (missing: foobar)") + add_test(NAME FindBoost.TestHeaders COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -19,3 +34,16 @@ add_test(NAME FindBoost.TestHeaders COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + +if (CMake_TEST_FindBoost_Python) + add_test(NAME FindBoost.TestPython COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBoost/TestPython" + "${CMake_BINARY_DIR}/Tests/FindBoost/TestPython" + ${build_generator_args} + --build-project TestFindBoostPython + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +endif () diff --git a/Tests/FindBoost/Test/CMakeLists.txt b/Tests/FindBoost/Test/CMakeLists.txt index ce50fc775..f60ccfa00 100644 --- a/Tests/FindBoost/Test/CMakeLists.txt +++ b/Tests/FindBoost/Test/CMakeLists.txt @@ -2,7 +2,20 @@ cmake_minimum_required(VERSION 3.1) project(TestFindBoost CXX) include(CTest) -find_package(Boost REQUIRED COMPONENTS filesystem thread) +set(Boost_NO_BOOST_CMAKE ON) +find_package(Boost REQUIRED COMPONENTS filesystem thread + OPTIONAL_COMPONENTS program_options foobar) + +if(Boost_FOOBAR_FOUND) + message(FATAL_ERROR "Optional inexistent Boost component \"foobar\" found which is unexpected") +endif(Boost_FOOBAR_FOUND) + +if(NOT Boost_PROGRAM_OPTIONS_FOUND) + message(FATAL_ERROR "Optional Boost component \"program_options\" not found which is unexpected") +endif(NOT Boost_PROGRAM_OPTIONS_FOUND) + +add_definitions(-DCMAKE_EXPECTED_BOOST_VERSION="${Boost_VERSION}") +add_definitions(-DCMAKE_EXPECTED_BOOST_VERSION_COMPONENTS="${Boost_VERSION_STRING}") add_executable(test_boost_tgt main.cxx) target_link_libraries(test_boost_tgt diff --git a/Tests/FindBoost/Test/main.cxx b/Tests/FindBoost/Test/main.cxx index 6e8b5da63..50ddadfba 100644 --- a/Tests/FindBoost/Test/main.cxx +++ b/Tests/FindBoost/Test/main.cxx @@ -20,5 +20,20 @@ int main() boost::thread foo(threadmain); foo.join(); - return 0; + int version = BOOST_VERSION; + int major = version / 100000; + int minor = version / 100 % 1000; + int patch = version % 100; + char version_string[100]; + snprintf(version_string, sizeof(version_string), "%d.%d.%d", major, minor, + patch); + printf("Found Boost version %s, expected version %s\n", version_string, + CMAKE_EXPECTED_BOOST_VERSION_COMPONENTS); + int ret = strcmp(version_string, CMAKE_EXPECTED_BOOST_VERSION_COMPONENTS); + char raw_version_string[100]; + snprintf(raw_version_string, sizeof(raw_version_string), "%d", + BOOST_VERSION); + printf("Found Boost version %s, expected version %s\n", raw_version_string, + CMAKE_EXPECTED_BOOST_VERSION); + return ret | strcmp(raw_version_string, CMAKE_EXPECTED_BOOST_VERSION); } diff --git a/Tests/FindDoxygen/CMakeLists.txt b/Tests/FindDoxygen/CMakeLists.txt index daceaa3e9..7ce98d59b 100644 --- a/Tests/FindDoxygen/CMakeLists.txt +++ b/Tests/FindDoxygen/CMakeLists.txt @@ -8,6 +8,26 @@ add_test(NAME FindDoxygen.SimpleTest COMMAND --build-options ${build_options} ) +add_test(NAME FindDoxygen.QuotingTest COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindDoxygen/QuotingTest" + "${CMake_BINARY_DIR}/Tests/FindDoxygen/QuotingTest" + --build-target allDocTargets + ${build_generator_args} + --build-options ${build_options} +) + +add_test(NAME FindDoxygen.AllTarget COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindDoxygen/AllTarget" + "${CMake_BINARY_DIR}/Tests/FindDoxygen/AllTarget" + ${build_generator_args} + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> +) + if(CMake_TEST_FindDoxygen_Dot) add_test(NAME FindDoxygen.DotComponentTest COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> diff --git a/Tests/FindGTK2/cairomm/main.cpp b/Tests/FindGTK2/cairomm/main.cpp index 1a669c36e..44326012b 100644 --- a/Tests/FindGTK2/cairomm/main.cpp +++ b/Tests/FindGTK2/cairomm/main.cpp @@ -5,7 +5,7 @@ * et. al. */ #if defined(_MSC_VER) -#define _USE_MATH_DEFINES +# define _USE_MATH_DEFINES #endif #include <cairomm/context.h> diff --git a/Tests/FindGTest/Test/main.cxx b/Tests/FindGTest/Test/main.cxx index 0572a5ddc..19d29675b 100644 --- a/Tests/FindGTest/Test/main.cxx +++ b/Tests/FindGTest/Test/main.cxx @@ -2,5 +2,7 @@ TEST(FindCMake, LinksAndRuns) { + using namespace testing; + EXPECT_FALSE(GTEST_FLAG(list_tests)); ASSERT_TRUE(true); } diff --git a/Tests/FindLTTngUST/Test/main.c b/Tests/FindLTTngUST/Test/main.c index 1f313c1a9..01d73cb73 100644 --- a/Tests/FindLTTngUST/Test/main.c +++ b/Tests/FindLTTngUST/Test/main.c @@ -4,11 +4,11 @@ #include <string.h> #ifdef CMAKE_LTTNGUST_HAS_TRACEF -#include <lttng/tracef.h> +# include <lttng/tracef.h> #endif #ifdef CMAKE_LTTNGUST_HAS_TRACELOG -#include <lttng/tracelog.h> +# include <lttng/tracelog.h> #endif int main(void) diff --git a/Tests/FindMPI/Test/CMakeLists.txt b/Tests/FindMPI/Test/CMakeLists.txt index 3910c254f..efe8c6261 100644 --- a/Tests/FindMPI/Test/CMakeLists.txt +++ b/Tests/FindMPI/Test/CMakeLists.txt @@ -20,12 +20,17 @@ foreach(c C CXX Fortran) endif() endforeach() +set(MPI_CXX_SKIP_MPICXX TRUE) +set(MPI_CXX_VALIDATE_SKIP_MPICXX TRUE) find_package(MPI REQUIRED) foreach(c C CXX Fortran) if(NOT "${MPI_TEST_${c}}") continue() endif() + if(${c} STREQUAL CXX AND MPI_MPICXX_FOUND) + message(FATAL_ERROR "Could not suppress MPI-2 C++ bindings for this MPI.") + endif() source_code_mapper_helper(${c}) add_executable(test_tgt_${c} ${MPITEST_SOURCE_FILE}) target_link_libraries(test_tgt_${c} MPI::MPI_${c}) diff --git a/Tests/FindMatlab/basic_checks/CMakeLists.txt b/Tests/FindMatlab/basic_checks/CMakeLists.txt index bf5442767..c5be1ea25 100644 --- a/Tests/FindMatlab/basic_checks/CMakeLists.txt +++ b/Tests/FindMatlab/basic_checks/CMakeLists.txt @@ -8,8 +8,22 @@ set(MATLAB_FIND_DEBUG TRUE) # the success of the following command is dependent on the current configuration: # - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab # - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab -find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY MAIN_PROGRAM) +if(IS_MCR) + set(RUN_UNIT_TESTS FALSE) +else() + set(RUN_UNIT_TESTS TRUE) + set(components MAIN_PROGRAM) +endif() + +if(NOT "${MCR_ROOT}" STREQUAL "") + set(Matlab_ROOT_DIR "${MCR_ROOT}") + if(NOT EXISTS "${MCR_ROOT}") + message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}") + endif() +endif() + +find_package(Matlab REQUIRED COMPONENTS ${components}) matlab_add_mex( @@ -19,39 +33,41 @@ matlab_add_mex( OUTPUT_NAME cmake_matlab_mex1 SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt - ) - - -matlab_add_unit_test( - NAME ${PROJECT_NAME}_matlabtest-1 - TIMEOUT 90 - UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m - ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> ) -matlab_add_unit_test( - NAME ${PROJECT_NAME}_matlabtest-2 - TIMEOUT 15 - UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests_timeout.m - ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> - ) -set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE) +if(RUN_UNIT_TESTS) + matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-1 + 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 + UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests_timeout.m + ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> + ) + 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 - NO_UNITTEST_FRAMEWORK - UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests2.m - ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> - ) -matlab_add_unit_test( - NAME ${PROJECT_NAME}_matlabtest-4 - TIMEOUT 30 - NO_UNITTEST_FRAMEWORK - UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests3.m - ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> - ) -set_tests_properties(${PROJECT_NAME}_matlabtest-4 PROPERTIES WILL_FAIL TRUE) + # testing the test without the unittest framework of Matlab + matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-3 + 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> + ) + + matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-4 + 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> + ) + set_tests_properties(${PROJECT_NAME}_matlabtest-4 PROPERTIES WILL_FAIL TRUE) +endif() diff --git a/Tests/FindMatlab/components_checks/CMakeLists.txt b/Tests/FindMatlab/components_checks/CMakeLists.txt index 3dec0931c..f5d488060 100644 --- a/Tests/FindMatlab/components_checks/CMakeLists.txt +++ b/Tests/FindMatlab/components_checks/CMakeLists.txt @@ -5,10 +5,18 @@ project(component_checks) set(MATLAB_FIND_DEBUG TRUE) +if(NOT "${MCR_ROOT}" STREQUAL "") + set(Matlab_ROOT_DIR "${MCR_ROOT}") + if(NOT EXISTS "${MCR_ROOT}") + message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}") + endif() +endif() + # the success of the following command is dependent on the current configuration: # - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab # - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab -find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY ENG_LIBRARY MAT_LIBRARY MAIN_PROGRAM) +find_package(Matlab REQUIRED COMPONENTS ENG_LIBRARY MAT_LIBRARY + OPTIONAL_COMPONENTS MAIN_PROGRAM) message(STATUS "FindMatlab libraries: ${Matlab_LIBRARIES}") @@ -20,4 +28,4 @@ matlab_add_mex( SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt LINK_TO ${Matlab_LIBRARIES} - ) + ) diff --git a/Tests/FindMatlab/versions_checks/CMakeLists.txt b/Tests/FindMatlab/versions_checks/CMakeLists.txt index 5d20685c2..d015730b0 100644 --- a/Tests/FindMatlab/versions_checks/CMakeLists.txt +++ b/Tests/FindMatlab/versions_checks/CMakeLists.txt @@ -7,6 +7,13 @@ set(MATLAB_FIND_DEBUG TRUE) set(MATLAB_ADDITIONAL_VERSIONS "dummy=14.9") +if(NOT "${MCR_ROOT}" STREQUAL "") + set(Matlab_ROOT_DIR "${MCR_ROOT}") + if(NOT EXISTS "${MCR_ROOT}") + message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}") + endif() +endif() + # the success of the following command is dependent on the current configuration # in this case, we are only interested in the version macros find_package(Matlab) diff --git a/Tests/FindOpenCL/Test/main.c b/Tests/FindOpenCL/Test/main.c index dc7763645..2fe949bd0 100644 --- a/Tests/FindOpenCL/Test/main.c +++ b/Tests/FindOpenCL/Test/main.c @@ -1,7 +1,7 @@ #ifdef __APPLE__ -#include <OpenCL/opencl.h> +# include <OpenCL/opencl.h> #else -#include <CL/cl.h> +# include <CL/cl.h> #endif int main() diff --git a/Tests/FindOpenGL/CMakeLists.txt b/Tests/FindOpenGL/CMakeLists.txt index 9aa3abafb..97c9e6052 100644 --- a/Tests/FindOpenGL/CMakeLists.txt +++ b/Tests/FindOpenGL/CMakeLists.txt @@ -1,3 +1,9 @@ +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMake_TEST_FindOpenGL_VND) + set(_vnd_testing TRUE) +else() + set(_vnd_testing FALSE) +endif() + add_test(NAME FindOpenGL.Test COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test @@ -6,5 +12,6 @@ add_test(NAME FindOpenGL.Test COMMAND ${build_generator_args} --build-project TestFindOpenGL --build-options ${build_options} + -DOpenGL_TEST_VND=${_vnd_testing} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt index cac342488..9004a9860 100644 --- a/Tests/FindOpenGL/Test/CMakeLists.txt +++ b/Tests/FindOpenGL/Test/CMakeLists.txt @@ -1,14 +1,71 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.10) +cmake_policy(SET CMP0072 NEW) project(TestFindOpenGL C) include(CTest) find_package(OpenGL REQUIRED) +# import target for GLU add_executable(test_tgt main.c) target_link_libraries(test_tgt OpenGL::GLU) add_test(NAME test_tgt COMMAND test_tgt) +# OPENGL_LIBRARIES should be whatever libraries are needed to link. add_executable(test_var main.c) target_include_directories(test_var PRIVATE ${OPENGL_INGLUDE_DIRS}) target_link_libraries(test_var PRIVATE ${OPENGL_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +# VND support adds an ::OpenGL import target. This can be used for OpenGL-only +# code (code that does not manipulate contexts, like our 'main.c'). Without +# VND, ::GL can be used for both context and non-context OpenGL code. +if(OpenGL_TEST_VND) + add_executable(test_comp_none main.c) + target_link_libraries(test_comp_none PRIVATE OpenGL::OpenGL) + add_test(NAME test_comp_none COMMAND test_comp_none) +else() + add_executable(test_comp_none main.c) + target_link_libraries(test_comp_none PRIVATE OpenGL::GL) + add_test(NAME test_comp_none COMMAND test_comp_none) +endif() + +# GLX +if(OpenGL_TEST_VND) + find_package(OpenGL REQUIRED COMPONENTS OpenGL GLX) + add_executable(test_comp_glx main.c) + target_link_libraries(test_comp_glx PRIVATE OpenGL::OpenGL OpenGL::GLX) + add_test(NAME test_comp_glx COMMAND test_comp_glx) +else() + # non-VND systems won't have it, but an optional search for GLX should still + # be okay. + find_package(OpenGL COMPONENTS GLX) + add_executable(test_comp_glx_novnd main.c) + target_link_libraries(test_comp_glx_novnd PRIVATE OpenGL::GL) + add_test(NAME test_comp_glx_novnd COMMAND test_comp_glx_novnd) +endif() + +# EGL is only available on Linux+GLVND at present. +if(OpenGL_TEST_VND) + find_package(OpenGL COMPONENTS OpenGL EGL) + if(OpenGL_EGL_FOUND) + add_executable(test_comp_egl main.c) + target_link_libraries(test_comp_egl PRIVATE OpenGL::OpenGL OpenGL::EGL) + add_test(NAME test_comp_egl COMMAND test_comp_egl) + # EGL-only code should not link to GLX. + execute_process(COMMAND ldd test_comp_egl + OUTPUT_VARIABLE LDD_OUT + ERROR_VARIABLE LDD_ERR) + if("${LDD_OUT}" MATCHES "GLX") + message(FATAL_ERROR "EGL-only code links to GLX!") + endif() + endif() + + # all three COMPONENTS together. + find_package(OpenGL COMPONENTS OpenGL EGL GLX) + if(OpenGL_EGL_FOUND AND OpenGL_GLX_FOUND) + add_executable(test_comp_both main.c) + target_link_libraries(test_comp_both PRIVATE OpenGL::OpenGL OpenGL::EGL + OpenGL::GLX) + add_test(NAME test_comp_both COMMAND test_comp_both) + endif() +endif() diff --git a/Tests/FindOpenGL/Test/main.c b/Tests/FindOpenGL/Test/main.c index bca3d7e3f..e1f25c630 100644 --- a/Tests/FindOpenGL/Test/main.c +++ b/Tests/FindOpenGL/Test/main.c @@ -1,10 +1,10 @@ #ifdef _WIN32 -#include <windows.h> +# include <windows.h> #endif #ifdef __APPLE__ -#include <OpenGL/gl.h> +# include <OpenGL/gl.h> #else -#include <GL/gl.h> +# include <GL/gl.h> #endif #include <stdio.h> diff --git a/Tests/FindOpenMP/Test/scaltest.c b/Tests/FindOpenMP/Test/scaltest.c index 2ee57f833..4678b87a4 100644 --- a/Tests/FindOpenMP/Test/scaltest.c +++ b/Tests/FindOpenMP/Test/scaltest.c @@ -1,8 +1,8 @@ #ifdef __cplusplus -#include <iostream> +# include <iostream> extern "C" #else -#include <stdio.h> +# include <stdio.h> #endif int scalprod(int n, double* x, double* y, double* res); diff --git a/Tests/FindOpenSSL/rand/main.cc b/Tests/FindOpenSSL/rand/main.cc index d81b31898..147044ba3 100644 --- a/Tests/FindOpenSSL/rand/main.cc +++ b/Tests/FindOpenSSL/rand/main.cc @@ -9,7 +9,7 @@ int main() unsigned char buf[1024]; // random bytes - int rezval = RAND_bytes(buf, sizeof(buf)); /* 1 succes, 0 otherwise */ + int rezval = RAND_bytes(buf, sizeof(buf)); /* 1 success, 0 otherwise */ // check result if (rezval == 1) { diff --git a/Tests/FindPackageModeMakefileTest/foo.cpp b/Tests/FindPackageModeMakefileTest/foo.cpp index 6aea22629..7cb9381ed 100644 --- a/Tests/FindPackageModeMakefileTest/foo.cpp +++ b/Tests/FindPackageModeMakefileTest/foo.cpp @@ -1,3 +1,5 @@ +#include "foo.h" + int foo() { return 1477; diff --git a/Tests/FindPackageModeMakefileTest/foo.h b/Tests/FindPackageModeMakefileTest/foo.h index 4ec598ad5..7051edac4 100644 --- a/Tests/FindPackageModeMakefileTest/foo.h +++ b/Tests/FindPackageModeMakefileTest/foo.h @@ -1,6 +1,14 @@ #ifndef FOO_H #define FOO_H +#ifdef __cplusplus +extern "C" { +#endif + int foo(); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 1a6f20429..1b9c973b1 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -188,7 +188,43 @@ find_package(ArchC 3.1 EXACT NAMES zot) find_package(ArchD 4.0 EXACT NAMES zot) unset(CMAKE_LIBRARY_ARCHITECTURE) -# Test <Package>_DIR environment variable. +# Test find_package() with CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS enabled +if(UNIX) + # Create ./symlink pointing back here. + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + . "${CMAKE_CURRENT_SOURCE_DIR}/symlink") + # Make find_package search through the symlink + set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/symlink") + + # First, test the default behavior where symlinks are preserved. + set(SetFoundResolved_DIR "") + find_package(SetFoundResolved) + # The result must preserve the /symlink/ path. + set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/symlink/cmake") + if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") + message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + endif() + + # This part of the test only works if there are no symlinks in our path. + get_filename_component(real_src_dir "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH) + if(real_src_dir STREQUAL CMAKE_CURRENT_SOURCE_DIR) + # Resolve symlinks when finding the package. + set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) + set(SetFoundResolved_DIR "") + find_package(SetFoundResolved) + # ./symlink points back here so it should be gone when resolved. + set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") + message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + endif() + endif() + + # Cleanup. + unset(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS) + file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/symlink") +endif() + +# Test <PackageName>_DIR environment variable. # We erase the main prefix path to ensure the env var is used. set(CMAKE_PREFIX_PATH) set(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1") @@ -349,6 +385,7 @@ try_compile(EXPORTER_COMPILED ${FindPackageTest_SOURCE_DIR}/Exporter CMakeTestExportPackage dummy CMAKE_FLAGS "-UCMAKE_EXPORT_NO_PACKAGE_REGISTRY" + "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=OLD" -Dversion=${version} OUTPUT_VARIABLE output) message(STATUS "Searching for export(PACKAGE) test project") @@ -386,6 +423,25 @@ if(CMakeTestExportPackage_FOUND) message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!") endif() +message(STATUS "Remove export(PACKAGE) test project") +file(REMOVE_RECURSE ${FindPackageTest_BINARY_DIR}/Exporter-build) + +message(STATUS "Preparing export(PACKAGE) test project with POLICY CMP0090=NEW") +try_compile(EXPORTER_COMPILED + ${FindPackageTest_BINARY_DIR}/Exporter-build + ${FindPackageTest_SOURCE_DIR}/Exporter + CMakeTestExportPackage dummy + CMAKE_FLAGS + "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=NEW" + -Dversion=${version} + OUTPUT_VARIABLE output) +message(STATUS "Searching for export(PACKAGE) test project") +find_package(CMakeTestExportPackage 1.${version} EXACT QUIET) +if(CMakeTestExportPackage_FOUND) + message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!") +endif() + + #----------------------------------------------------------------------------- # Test configure_package_config_file(). @@ -461,205 +517,117 @@ if(Relocatable_FOUND) endif() +############################################################################ +##Test FIND_PACKAGE using sorting +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +SET(CMAKE_FIND_PACKAGE_SORT_ORDER NAME) +SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC) -#----------------------------------------------------------------------------- -# Test write_basic_config_version_file(). - -# also test that an empty CMAKE_SIZEOF_VOID_P is accepted: -set(_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) -set(CMAKE_SIZEOF_VOID_P "") - -write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake - VERSION 1.2.3 - COMPATIBILITY AnyNewerVersion) - -set(CMAKE_SIZEOF_VOID_P ${_CMAKE_SIZEOF_VOID_P}) - -set(PACKAGE_FIND_VERSION 2.3.4) -include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) -if(PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !") -endif() - -set(PACKAGE_FIND_VERSION 0.0.1) -include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !") -endif() - -if(PACKAGE_VERSION_UNSUITABLE) - message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") +set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +FIND_PACKAGE(SortLib CONFIG) +IF (NOT "${SortLib_VERSION}" STREQUAL "3.1.1") + message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}") endif() +unset(SortLib_VERSION) -set(PACKAGE_FIND_VERSION 1.0.0) -include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.0.0 was requested) !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") -endif() -set(PACKAGE_FIND_VERSION 1.2.3) -include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !") -endif() -if(NOT PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) +SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) +FIND_PACKAGE(SortLib CONFIG) +IF (NOT "${SortLib_VERSION}" STREQUAL "3.10.1") + message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Natural! Dec ${SortLib_VERSION}") endif() +set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +unset(SortLib_VERSION) +unset(CMAKE_FIND_PACKAGE_SORT_ORDER) +unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION) +set(CMAKE_PREFIX_PATH ) -####################### -include(WriteBasicConfigVersionFile) +############################################################################ +##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG -write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake - VERSION 1.2.3 - COMPATIBILITY SameMajorVersion) +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig) -unset(PACKAGE_VERSION_UNSUITABLE) -set(PACKAGE_VERSION_EXACT FALSE) -set(PACKAGE_FIND_VERSION 2.3.4) -set(PACKAGE_FIND_VERSION_MAJOR 2) -include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) -if(PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") -endif() +# prefer module mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +unset(ABC_FOUND) +unset(ABC_CONFIG) -set(PACKAGE_FIND_VERSION 0.0.1) -set(PACKAGE_FIND_VERSION_MAJOR 0) -include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) -if(PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !") +find_package(ABC) +if(NOT ABC_FOUND) + message(SEND_ERROR "Did not find ABC package") endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +if(ABC_CONFIG) + message(SEND_ERROR "Incorrectly found ABC in CONFIG mode, expected to find it with MODULE mode") endif() -set(PACKAGE_FIND_VERSION 1.0.0) -set(PACKAGE_FIND_VERSION_MAJOR 1) -include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.0.0 was requested) !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") -endif() +# Now prefer config mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +unset(ABC_FOUND) +unset(ABC_CONFIG) -set(PACKAGE_FIND_VERSION 1.2.3) -set(PACKAGE_FIND_VERSION_MAJOR 1) -include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !") +find_package(ABC) +if(NOT ABC_FOUND) + message(SEND_ERROR "Did not find ABC package") endif() -if(NOT PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +if(NOT ABC_CONFIG) + message(SEND_ERROR "Incorrectly found ABC in MODULE mode, expected to find it with CONFIG mode") endif() -if(PACKAGE_VERSION_UNSUITABLE) - message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") -endif() +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +set(CMAKE_PREFIX_PATH) +set(CMAKE_MODULE_PATH) -####################### +############################################################################ +##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG - Do not recurse -write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake - VERSION 1.2.3.17 - COMPATIBILITY ExactVersion) +# No CMAKE_PREFIX_PATH +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigRecurse) -unset(PACKAGE_VERSION_UNSUITABLE) -set(PACKAGE_VERSION_EXACT FALSE) -set(PACKAGE_FIND_VERSION 2.3.4) -include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) -if(PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Found Bar123 with version 1.2.3 (2.3.4 was requested) !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") -endif() +# Now prefer config mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +unset(ACME_FOUND) +unset(ACME_CONFIG) -set(PACKAGE_FIND_VERSION 1.2) -include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) -if(PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Found Bar123 with version 1.2.3 (1.2 was requested) !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +find_package(ACME) +if(ACME_FOUND AND ACME_CONFIG) + message(SEND_ERROR "Incorrectly found ACME in CONFIG mode, from the MODULE package") endif() -set(PACKAGE_FIND_VERSION 1) -include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) -if(PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Found Bar123 with version 1.2.3 (1 was requested) !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") -endif() +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +set(CMAKE_MODULE_PATH) -set(PACKAGE_FIND_VERSION 1.2.3.4) -include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.4 was requested) !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") -endif() +############################################################################ +##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with module fallback -set(PACKAGE_FIND_VERSION 1.2.3) -set(PACKAGE_VERSION_EXACT FALSE) -set(PACKAGE_VERSION_COMPATIBLE FALSE) -include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3 was requested) !") -endif() -if(PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") -endif() +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigOnlyModule) +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) -set(PACKAGE_FIND_VERSION 1.2.3.17) -set(PACKAGE_VERSION_EXACT FALSE) -set(PACKAGE_VERSION_COMPATIBLE FALSE) -include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) -if(NOT PACKAGE_VERSION_COMPATIBLE) - message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.17 was requested) !") -endif() -if(NOT PACKAGE_VERSION_EXACT) - message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") -endif() +find_package(ACME REQUIRED) -if(PACKAGE_VERSION_UNSUITABLE) - message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") +if(NOT ACME_FOUND) + message(SEND_ERROR "Did not find ACME package") endif() - ############################################################################ -##Test FIND_PACKAGE using sorting -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -SET(CMAKE_FIND_PACKAGE_SORT_ORDER NAME) -SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC) +##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with NO_MODULE -set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) -FIND_PACKAGE(SortLib CONFIG) -IF (NOT "${SortLib_VERSION}" STREQUAL "3.1.1") - message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}") -endif() -unset(SortLib_VERSION) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigOnlyModule) +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) -set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) -SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) -SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) -FIND_PACKAGE(SortLib CONFIG) -IF (NOT "${SortLib_VERSION}" STREQUAL "3.10.1") - message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Natural! Dec ${SortLib_VERSION}") +find_package(ACME NO_MODULE) + +if(ACME_FOUND) + message(SEND_ERROR "Should not find ACME package") endif() -set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) -unset(SortLib_VERSION) +############################################################################ +##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with unknown package -unset(CMAKE_FIND_PACKAGE_SORT_ORDER) -unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION) -set(CMAKE_PREFIX_PATH ) +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +find_package(DoesNotExist) diff --git a/Tests/FindProtobuf/Test/CMakeLists.txt b/Tests/FindProtobuf/Test/CMakeLists.txt index 8b6e38a8e..bc89190b3 100644 --- a/Tests/FindProtobuf/Test/CMakeLists.txt +++ b/Tests/FindProtobuf/Test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.8) project(TestFindProtobuf CXX) include(CTest) @@ -30,3 +30,21 @@ add_executable(test_var_protoc main-protoc.cxx) target_include_directories(test_var_protoc PRIVATE ${Protobuf_INCLUDE_DIRS}) target_link_libraries(test_var_protoc PRIVATE ${Protobuf_PROTOC_LIBRARIES}) add_test(NAME test_var_protoc COMMAND test_var_protoc) + +add_test(NAME test_tgt_protoc_version COMMAND protobuf::protoc --version) + +set(Protobuf_IMPORT_DIRS ${Protobuf_INCLUDE_DIRS}) +PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER msgs/example.proto) +PROTOBUF_GENERATE_CPP(DESC_PROTO_SRC DESC_PROTO_HEADER DESCRIPTORS DESC_PROTO_DESC msgs/example_desc.proto) +add_library(msgs ${PROTO_SRC} ${PROTO_HEADER}) + +add_executable(test_generate main-generate.cxx ${PROTO_SRC}) +target_include_directories(test_generate PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(test_generate msgs ${Protobuf_LIBRARIES}) +add_test(NAME test_generate COMMAND test_generate) + +add_executable(test_desc main-desc.cxx ${DESC_PROTO_SRC}) +target_compile_features(test_desc PRIVATE cxx_std_11) +target_include_directories(test_desc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(test_desc msgs ${Protobuf_LIBRARIES}) +add_test(NAME test_desc COMMAND test_desc ${DESC_PROTO_DESC}) diff --git a/Tests/FindThreads/C-only/CMakeLists.txt b/Tests/FindThreads/C-only/CMakeLists.txt index ab4ca0ddd..ee2a5f991 100644 --- a/Tests/FindThreads/C-only/CMakeLists.txt +++ b/Tests/FindThreads/C-only/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) project(FindThreads_C-only C) -set(CMAKE_THREAD_PREFER_PTHREAD On) find_package(Threads REQUIRED) if (NOT WIN32) diff --git a/Tests/FindThreads/CXX-only/CMakeLists.txt b/Tests/FindThreads/CXX-only/CMakeLists.txt index 999312322..3c6cc1e55 100644 --- a/Tests/FindThreads/CXX-only/CMakeLists.txt +++ b/Tests/FindThreads/CXX-only/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) project(FindThreads_CXX-only CXX) -set(CMAKE_THREAD_PREFER_PTHREAD On) find_package(Threads REQUIRED) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/CheckForPthreads.c diff --git a/Tests/ForceInclude/foo.c b/Tests/ForceInclude/foo.c index 7f550d0f9..2a26c6f33 100644 --- a/Tests/ForceInclude/foo.c +++ b/Tests/ForceInclude/foo.c @@ -1,8 +1,8 @@ #ifndef FOO_1 -#error "foo1.h not included by /FI" +# error "foo1.h not included by /FI" #endif #ifndef FOO_2 -#error "foo2.h not included by /FI" +# error "foo2.h not included by /FI" #endif int main(void) { diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 740e6f594..929fa4ddf 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -46,7 +46,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale|Absoft") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) @@ -99,6 +99,11 @@ function(test_fortran_c_interface_module) target_link_libraries(myc myfort) set_property(TARGET myc PROPERTY COMPILE_DEFINITIONS ${MYC_DEFS}) + add_library(myfort_obj OBJECT mysub.f) + add_library(myc_use_obj myc.c $<TARGET_OBJECTS:myfort_obj>) + add_executable(mainc_use_obj mainc.c) + target_link_libraries(mainc_use_obj myc_use_obj) + add_library(mycxx mycxx.cxx) target_link_libraries(mycxx myc) @@ -123,7 +128,7 @@ else() message("Fortran = ${CMAKE_Fortran_COMPILER_ID}") message("C = ${CMAKE_C_COMPILER_ID}") # hack to make g77 work after CL has been enabled - # as a languge, cmake needs language specific versions + # as a language, cmake needs language specific versions # of these variables.... if(WIN32 AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_CREATE_CONSOLE_EXE ) diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index 399660002..d056b4379 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.1) +cmake_minimum_required (VERSION 3.9) project(FortranModules Fortran) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") @@ -56,7 +56,8 @@ add_executable(test_non_pp_include test_non_pp_include_main.f90) # Build the external project separately using a custom target. # Make sure it uses the same build configuration as this test. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") set(External_BUILD_TYPE) else() diff --git a/Tests/FortranModules/Submodules/CMakeLists.txt b/Tests/FortranModules/Submodules/CMakeLists.txt index bf0152f63..ab8e0f9e5 100644 --- a/Tests/FortranModules/Submodules/CMakeLists.txt +++ b/Tests/FortranModules/Submodules/CMakeLists.txt @@ -1 +1,23 @@ -add_executable(submod main.f90 provide.f90) +# The program units in this file consist of a module/submodule +# tree represented by the following graph: +# +# parent +# | +# / \ +# / \ +# child sibling +# | +# grandchild +# | +# GreatGrandChild +# +# where the parent node is a module and all other nodes are submodules. + +add_executable(submod + main.f90 + parent.f90 + child.f90 + grandchild.f90 + greatgrandchild.f90 + sibling.f90 + ) diff --git a/Tests/FortranModules/Submodules/main.f90 b/Tests/FortranModules/Submodules/main.f90 index 3c750ce38..3cd29892c 100644 --- a/Tests/FortranModules/Submodules/main.f90 +++ b/Tests/FortranModules/Submodules/main.f90 @@ -1,5 +1,7 @@ program main use parent, only : child_function,grandchild_subroutine + use parent, only : sibling_function,GreatGrandChild_subroutine implicit none if (child_function()) call grandchild_subroutine + if (sibling_function()) call GreatGrandChild_subroutine end program diff --git a/Tests/FortranModules/test_preprocess.F90 b/Tests/FortranModules/test_preprocess.F90 index 3a09976c5..c5a5ec32d 100644 --- a/Tests/FortranModules/test_preprocess.F90 +++ b/Tests/FortranModules/test_preprocess.F90 @@ -1,5 +1,5 @@ MODULE Available -! no conent +! no content END MODULE PROGRAM PPTEST diff --git a/Tests/FortranModules/test_preprocess_module.F90 b/Tests/FortranModules/test_preprocess_module.F90 index 5849b62b4..fdbc051e0 100644 --- a/Tests/FortranModules/test_preprocess_module.F90 +++ b/Tests/FortranModules/test_preprocess_module.F90 @@ -1,5 +1,5 @@ #ifdef FOO MODULE PPAvailable -! no conent +! no content END MODULE #endif diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index 9bf03033a..45372ddb9 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -12,6 +12,12 @@ add_executable(FortranOnly1 testf.f) set_property(TARGET FortranOnly1 PROPERTY OUTPUT_NAME FortranOnly) target_link_libraries(FortranOnly1 FortranOnlylib) +# Test that Fortran+RC work together. +# FIXME: Add .rc in more cases. +if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(test_rc testRC.rc) +endif() + # create a custom command that runs FortranOnly1 and puts # the output into the file testfhello.txt add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt @@ -20,7 +26,7 @@ add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt # create a second executable FortranOnly2 that has # testfhello.txt has an source file so that it will # run the above custom command. -add_executable(FortranOnly2 testfhello.txt testf.f) +add_executable(FortranOnly2 testfhello.txt testf.f ${test_rc}) target_link_libraries(FortranOnly2 FortranOnlylib) # create a custom target to check the content of testfhello.txt # by running the cmake script checktestf2.cmake @@ -28,7 +34,7 @@ add_custom_target(checktestf2 ALL COMMAND ${CMAKE_COMMAND} -P ${FortranOnly_SOURCE_DIR}/checktestf2.cmake) -# create a custom target that runs FortranOnly1 exectuable and creates +# create a custom target that runs FortranOnly1 executable and creates # a file out.txt that should have hello world in it. add_custom_target(sayhello ALL COMMAND FortranOnly1 > out.txt @@ -38,7 +44,7 @@ add_dependencies(checktestf2 FortranOnly2) add_dependencies(sayhello FortranOnly1) add_dependencies(FortranOnly2 FortranOnly1) -# add a custom target that checkes that out.txt has the correct +# add a custom target that checks that out.txt has the correct # content add_custom_target(checksayhello ALL COMMAND ${CMAKE_COMMAND} -P ${FortranOnly_SOURCE_DIR}/checksayhello.cmake @@ -70,8 +76,15 @@ if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL XL) include(CheckFortranCompilerFlag) CHECK_Fortran_COMPILER_FLAG(-_this_is_not_a_flag_ Fortran_BOGUS_FLAG) if (Fortran_BOGUS_FLAG) - message (SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed") - endif () + message(SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed") + endif() + + unset(Fortran_RUN_FLAG CACHE) + include(CheckFortranSourceRuns) + check_fortran_source_runs("program a; end program" Fortran_RUN_FLAG SRC_EXT F90) + if(NOT Fortran_RUN_FLAG) + message(SEND_ERROR "CHECK_Fortran_SOURCE_RUNS() failed") + endif() endif() # Test generation of preprocessed sources. diff --git a/Tests/Framework/foo.cxx b/Tests/Framework/foo.cxx index c3520c1dd..a4d15f609 100644 --- a/Tests/Framework/foo.cxx +++ b/Tests/Framework/foo.cxx @@ -1,8 +1,8 @@ #include <stdio.h> #if defined(_WIN32) && defined(foo_EXPORTS) -#define CM_TEST_LIB_EXPORT __declspec(dllexport) +# define CM_TEST_LIB_EXPORT __declspec(dllexport) #else -#define CM_TEST_LIB_EXPORT +# define CM_TEST_LIB_EXPORT #endif CM_TEST_LIB_EXPORT void foo() { diff --git a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp index 233eb57e4..2812b0d6f 100644 --- a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp +++ b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp @@ -1,24 +1,24 @@ #ifdef Type_Is_ -#if !Result -#error Result should be 1 in WARN mode -#endif +# if !Result +# error Result should be 1 in WARN mode +# endif #endif #ifdef Type_Is_NEW -#if Result -#error Result should be 0 in NEW mode -#endif +# if Result +# error Result should be 0 in NEW mode +# endif #endif #ifdef Type_Is_OLD -#if !Result -#error Result should be 1 in OLD mode -#endif +# if !Result +# error Result should be 1 in OLD mode +# endif #endif #if !defined(Type_Is_) && !defined(Type_Is_OLD) && !defined(Type_Is_NEW) -#error No expected definition present +# error No expected definition present #endif void foo(void) diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 8ac341912..3ff2b8595 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -3,11 +3,26 @@ project(GeneratorExpression) include(CTest) +# Real projects normally want the MSYS shell path conversion, but for this test +# we need to verify that the command line is constructed with the proper string. +set(msys1_prefix "") +set(msys2_no_conv "") +if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") + execute_process(COMMAND "uname" OUTPUT_VARIABLE uname) + if("${uname}" MATCHES "^MINGW32") + # MinGW.org MSYS 1.0 does not support generic path conversion suppression + set(msys1_prefix MSYS1_PREFIX) + else() + # msys2 supports generic path conversion suppression + set(msys2_no_conv env MSYS2_ARG_CONV_EXCL=-D) + endif() +endif() + # This test is split into multiple parts as needed to avoid NMake command # length limits. add_custom_target(check-part1 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_0=$<0:nothing> -Dtest_0_with_comma=$<0:-Wl,--no-undefined> -Dtest_1=$<1:content> @@ -57,6 +72,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> @@ -92,7 +112,7 @@ add_library(empty5 empty.cpp) target_include_directories(empty5 PRIVATE /empty5/private1 /empty5/private2) add_custom_target(check-part2 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_incomplete_1=$< -Dtest_incomplete_2=$<something -Dtest_incomplete_3=$<something: @@ -183,7 +203,7 @@ set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_DEBUG "" DEBUG set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_RELEASE "") add_custom_target(check-part3 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} -Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1> -Dtest_version_greater_2=$<VERSION_GREATER:1.1.1,1.0> -Dtest_version_less_1=$<VERSION_LESS:1.1.1,1.0> @@ -200,6 +220,7 @@ add_custom_target(check-part3 ALL -Dtest_early_termination_2=$<$<1:>:, -Dsystem_name=${CMAKE_HOST_SYSTEM_NAME} -Dtest_platform_id=$<PLATFORM_ID> + -Dtest_platform_id_supported=$<PLATFORM_ID:Linux,Windows,Darwin> -Dtest_platform_id_Linux=$<PLATFORM_ID:Linux> -Dtest_platform_id_Windows=$<PLATFORM_ID:Windows> -Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin> @@ -236,17 +257,19 @@ add_custom_target(check-part3 ALL if(WIN32) set(test_shell_path c:/shell/path) + set(test_shell_path2 c:/shell/path d:/another/path) else() set(test_shell_path /shell/path) + set(test_shell_path2 /shell/path /another/path) endif() -set(path_prefix BYPASS_FURTHER_CONVERSION) add_custom_target(check-part4 ALL - COMMAND ${CMAKE_COMMAND} + COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} # Prefix path to bypass its further conversion when being processed by # CMake as command-line argument - -Dtest_shell_path=${path_prefix}$<SHELL_PATH:${test_shell_path}> - -Dpath_prefix=${path_prefix} + -Dmsys1_prefix=${msys1_prefix} + -Dtest_shell_path=${msys1_prefix}$<SHELL_PATH:${test_shell_path}> + "-Dtest_shell_path2=$<SHELL_PATH:${test_shell_path2}>" -Dif_1=$<IF:1,a,b> -Dif_2=$<IF:0,a,b> -Dif_3=$<IF:$<EQUAL:10,30>,a,b> @@ -259,10 +282,55 @@ add_custom_target(check-part4 ALL ) #----------------------------------------------------------------------------- +# Cover source file properties with generator expressions. +## generate various source files +foreach (item IN ITEMS flags flags_COMPILE_LANGUAGE + options options_COMPILE_LANGUAGE + defs defs_COMPILE_LANGUAGE) + set(TARGET_NAME srcgenex_${item}) + configure_file(srcgenex.c.in ${TARGET_NAME}.c @ONLY) +endforeach() +add_executable(srcgenex_flags "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c" + PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>") +add_executable(srcgenex_flags_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_FLAGS "$<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>") + +add_executable(srcgenex_options "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c" + PROPERTY COMPILE_OPTIONS -DUNUSED -DNAME=$<TARGET_PROPERTY:NAME>) +add_executable(srcgenex_options_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>) + +add_executable(srcgenex_defs "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c" + PROPERTY COMPILE_DEFINITIONS UNUSED NAME=$<TARGET_PROPERTY:NAME>) +add_executable(srcgenex_defs_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>) + +foreach (item IN ITEMS basic COMPILE_LANGUAGE) + set(TARGET_NAME srcgenex_includes_${item}) + configure_file(srcgenex_includes.h.in "sf_includes_${item}/${TARGET_NAME}.h" @ONLY) + configure_file(srcgenex_includes.c.in ${TARGET_NAME}.c @ONLY) +endforeach() +add_executable(srcgenex_includes_basic "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_basic.c") +# first include directory is useless but ensure list aspect is tested +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_basic.c" + PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/sf_includes_basic") +if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake") + add_executable(srcgenex_includes_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c") + # first include directory is useless but ensure list aspect is tested + set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c" + PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/sf_includes_COMPILE_LANGUAGE>) +endif() + +#----------------------------------------------------------------------------- # Cover test properties with generator expressions. add_executable(echo echo.c) add_executable(pwd pwd.c) -set_property(SOURCE echo.c PROPERTY COMPILE_FLAGS $<1:-DSRC_GENEX_WORKS>) add_test(NAME echo-configuration COMMAND echo $<CONFIGURATION>) set_property(TEST echo-configuration PROPERTY @@ -307,4 +375,49 @@ if(NOT CMAKE_GENERATOR STREQUAL Xcode OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[; -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" DEPENDS objlib ) + + + add_library(sharedlib SHARED objlib1.c objlib2.c) + file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>" + CONTENT "$<JOIN:$<TARGET_OBJECTS:sharedlib>,\n>\n" + ) + + add_custom_target(check_sharedlib_objs ALL + COMMAND ${CMAKE_COMMAND} + "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>" + -DEXPECTED_NUM_OBJECTFILES=2 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS sharedlib + ) + + + add_library(staticlib STATIC objlib1.c objlib2.c) + file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>" + CONTENT "$<JOIN:$<TARGET_OBJECTS:staticlib>,\n>\n" + ) + + add_custom_target(check_staticlib_objs ALL + COMMAND ${CMAKE_COMMAND} + "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>" + -DEXPECTED_NUM_OBJECTFILES=2 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS staticlib + ) + + + add_executable(execobjs objlib1.c objlib2.c echo.c) + file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>" + CONTENT "$<JOIN:$<TARGET_OBJECTS:execobjs>,\n>\n" + ) + + add_custom_target(check_exec_objs ALL + COMMAND ${CMAKE_COMMAND} + "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>" + -DEXPECTED_NUM_OBJECTFILES=3 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS execobjs + ) endif() diff --git a/Tests/GeneratorExpression/check-part1.cmake b/Tests/GeneratorExpression/check-part1.cmake index 60b193f58..41bcd6d99 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/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 9014406c2..4fb730887 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -28,11 +28,16 @@ check(test_early_termination_2 "$<:,") check(test_platform_id "${system_name}") foreach(system Linux Windows Darwin) if(system_name STREQUAL system) + check(test_platform_id_supported 1) check(test_platform_id_${system} 1) + set(platform_supported 1) else() check(test_platform_id_${system} 0) endif() endforeach() +if(NOT platform_supported) + check(test_platform_id_supported 0) +endif() check(lower_case "mi,xed") check(upper_case "MIX,ED") check(make_c_identifier "_4f_oo__bar__") diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake index f5d14dd45..a7e09445e 100644 --- a/Tests/GeneratorExpression/check-part4.cmake +++ b/Tests/GeneratorExpression/check-part4.cmake @@ -1,6 +1,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake) -string(REPLACE ${path_prefix} "" test_shell_path ${test_shell_path}) +if(msys1_prefix) + string(REPLACE "${msys1_prefix}" "" test_shell_path ${test_shell_path}) +endif() if(WIN32) if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") @@ -13,6 +15,17 @@ if(WIN32) else() check(test_shell_path [[/shell/path]]) endif() +if(WIN32) + if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles" AND NOT msys1_prefix) + check(test_shell_path2 [[/c/shell/path:/d/another/path]]) + elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + check(test_shell_path2 [[c:/shell/path;d:/another/path]]) + else() + check(test_shell_path2 [[c:\shell\path;d:\another\path]]) + endif() +else() + check(test_shell_path2 [[/shell/path:/another/path]]) +endif() check(if_1 "a") check(if_2 "b") diff --git a/Tests/GeneratorExpression/echo.c b/Tests/GeneratorExpression/echo.c index 41596a21d..06b0844b3 100644 --- a/Tests/GeneratorExpression/echo.c +++ b/Tests/GeneratorExpression/echo.c @@ -3,9 +3,6 @@ int main(int argc, char* argv[]) { -#ifndef SRC_GENEX_WORKS -#error SRC_GENEX_WORKS not defined -#endif printf("%s\n", argv[1]); return EXIT_SUCCESS; } diff --git a/Tests/GeneratorExpression/pwd.c b/Tests/GeneratorExpression/pwd.c index ed2304370..31ebe493a 100644 --- a/Tests/GeneratorExpression/pwd.c +++ b/Tests/GeneratorExpression/pwd.c @@ -3,11 +3,11 @@ #include <stdlib.h> #ifdef _WIN32 -#include <direct.h> -#define getcurdir _getcwd +# include <direct.h> +# define getcurdir _getcwd #else -#include <unistd.h> -#define getcurdir getcwd +# include <unistd.h> +# define getcurdir getcwd #endif int main(int argc, char* argv[]) diff --git a/Tests/GoogleTest/Test/CMakeLists.txt b/Tests/GoogleTest/Test/CMakeLists.txt index f798d313c..baf00d53f 100644 --- a/Tests/GoogleTest/Test/CMakeLists.txt +++ b/Tests/GoogleTest/Test/CMakeLists.txt @@ -44,12 +44,13 @@ endif() set_tests_properties(set2.GoogleTest.ConditionalFail.foo PROPERTIES WILL_FAIL YES) -# Search specific sources to get the test list -add_executable(test_gtest2 main2.cxx) +# Search specific sources to get the test list. Include an empty file +# to ensure they are handled correctly too. +add_executable(test_gtest2 main2.cxx empty.cxx) target_link_libraries(test_gtest2 GTest::Main) gtest_add_tests(TARGET test_gtest2 TEST_LIST testList - SOURCES main2.h + SOURCES main2.h empty.cxx ) set(expectedTests GoogleTest.SomethingElse diff --git a/Tests/IncludeDirectories/CMP0021/main.cpp b/Tests/IncludeDirectories/CMP0021/main.cpp index f638ed14a..0f87dd997 100644 --- a/Tests/IncludeDirectories/CMP0021/main.cpp +++ b/Tests/IncludeDirectories/CMP0021/main.cpp @@ -2,7 +2,7 @@ #include "cmp0021.h" #ifndef CMP0021_DEFINE -#error Expected CMP0021_DEFINE +# error Expected CMP0021_DEFINE #endif int main(int, char**) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index db18462a8..761c405b1 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6) project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja" OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) @@ -65,6 +65,10 @@ else() PROPERTIES COMPILE_FLAGS "-ITarProp") endif() +add_library(ordertest ordertest.cpp) +target_include_directories(ordertest SYSTEM PUBLIC SystemIncludeDirectories/systemlib) +target_include_directories(ordertest PUBLIC SystemIncludeDirectories/userlib) + add_subdirectory(StandardIncludeDirectories) add_subdirectory(TargetIncludeDirectories) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index 5078f3099..20bd60196 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -32,7 +32,9 @@ target_link_libraries(consumer upstream config_specific) target_compile_options(consumer PRIVATE -Werror=unused-variable) add_library(iface IMPORTED INTERFACE) -set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only") +set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES + "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only>" + ) add_library(imported_consumer imported_consumer.cpp) target_link_libraries(imported_consumer iface) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 5b99ea7b3..a9edf9a97 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -17,7 +17,8 @@ create_header(bing) create_header(bung) create_header(arguments) create_header(list) -create_header(target) +create_header(target1) +create_header(target2) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -69,14 +70,23 @@ set_property(TARGET lib4 APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BI set_property(TARGET lib4 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foh;$<TARGET_PROPERTY:lib3,INTERFACE_INCLUDE_DIRECTORIES>") add_library(somelib::withcolons UNKNOWN IMPORTED) -set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target") -set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target") +set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target1") +set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target1") set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:somelib::withcolons,INTERFACE_INCLUDE_DIRECTORIES>" ) +add_library(somelib_aliased UNKNOWN IMPORTED GLOBAL) +set_property(TARGET somelib_aliased PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target2") +add_library(somelib::withcolons2 ALIAS somelib_aliased) + +set_property(TARGET TargetIncludeDirectories + APPEND PROPERTY INCLUDE_DIRECTORIES + "$<TARGET_PROPERTY:somelib::withcolons2,INTERFACE_INCLUDE_DIRECTORIES>" +) + add_custom_target(test_custom_target "some_bogus_custom_tool" $<TARGET_PROPERTY:TargetIncludeDirectories,COMPILE_DEFINITIONS> diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp index 2ee05e2ee..541ef92c2 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -10,7 +10,8 @@ #include "foo.h" #include "list.h" #include "prefix_foo_bar_bat.h" -#include "target.h" +#include "target1.h" +#include "target2.h" #include "ting.h" int main(int, char**) diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 33c4b9073..954c02d51 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -31,6 +31,7 @@ add_library(item_real STATIC item.cpp) add_library(item_iface INTERFACE IMPORTED) set_property(TARGET item_iface PROPERTY IMPORTED_LIBNAME item_real) add_dependencies(item_iface item_real) +get_property(item_iface_dependencies TARGET item_iface PROPERTY MANUALLY_ADDED_DEPENDENCIES) link_directories(${CMAKE_CURRENT_BINARY_DIR}) add_executable(InterfaceLibrary definetestexe.cpp) @@ -46,6 +47,7 @@ target_link_libraries(InterfaceLibrary add_dependencies(InterfaceLibrary item_fake_tgt) add_subdirectory(libsdir) +add_subdirectory(excluded EXCLUDE_FROM_ALL) add_executable(sharedlibtestexe sharedlibtestexe.cpp) target_link_libraries(sharedlibtestexe shared_iface imported::iface) @@ -64,7 +66,6 @@ target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTO add_executable(exec_whitelist dummy.cpp) target_link_libraries(exec_whitelist iface_whitelist) -set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1) add_library(iface_imported INTERFACE IMPORTED) set_property(TARGET iface_imported PROPERTY INTERFACE_COMPILE_DEFINITIONS diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp index 098502c4c..9156426cd 100644 --- a/Tests/InterfaceLibrary/definetestexe.cpp +++ b/Tests/InterfaceLibrary/definetestexe.cpp @@ -1,18 +1,18 @@ #ifndef IFACE_DEFINE -#error Expected IFACE_DEFINE +# error Expected IFACE_DEFINE #endif #include "iface_header.h" #ifndef IFACE_HEADER_SRCDIR -#error Expected IFACE_HEADER_SRCDIR +# error Expected IFACE_HEADER_SRCDIR #endif #include "iface_header_builddir.h" #ifndef IFACE_HEADER_BUILDDIR -#error Expected IFACE_HEADER_BUILDDIR +# error Expected IFACE_HEADER_BUILDDIR #endif extern int obj(); diff --git a/Tests/InterfaceLibrary/map_config.cpp b/Tests/InterfaceLibrary/map_config.cpp index 232a18e88..d0356327d 100644 --- a/Tests/InterfaceLibrary/map_config.cpp +++ b/Tests/InterfaceLibrary/map_config.cpp @@ -1,12 +1,12 @@ #ifdef DEBUG_MODE -#ifndef SPECIAL_MODE -#error Special configuration should be mapped to debug configuration. -#endif +# ifndef SPECIAL_MODE +# error Special configuration should be mapped to debug configuration. +# endif #else -#ifdef SPECIAL_MODE -#error Special configuration should not be enabled if not debug configuration -#endif +# ifdef SPECIAL_MODE +# error Special configuration should not be enabled if not debug configuration +# endif #endif int main(int, char**) diff --git a/Tests/InterfaceLibrary/sharedlibtestexe.cpp b/Tests/InterfaceLibrary/sharedlibtestexe.cpp index 44f160da8..97b5aa900 100644 --- a/Tests/InterfaceLibrary/sharedlibtestexe.cpp +++ b/Tests/InterfaceLibrary/sharedlibtestexe.cpp @@ -1,14 +1,14 @@ #ifndef SHAREDLIB_DEFINE -#error Expected SHAREDLIB_DEFINE +# error Expected SHAREDLIB_DEFINE #endif #ifndef SHAREDDEPENDLIB_DEFINE -#error Expected SHAREDDEPENDLIB_DEFINE +# error Expected SHAREDDEPENDLIB_DEFINE #endif -#include "sharedlib.h" #include "shareddependlib.h" +#include "sharedlib.h" int main(int, char**) { diff --git a/Tests/InterfaceLinkLibraries/bang.cpp b/Tests/InterfaceLinkLibraries/bang.cpp index 2e950986b..722af9f18 100644 --- a/Tests/InterfaceLinkLibraries/bang.cpp +++ b/Tests/InterfaceLinkLibraries/bang.cpp @@ -1,10 +1,10 @@ #ifdef FOO_LIBRARY -#error Unexpected FOO_LIBRARY +# error Unexpected FOO_LIBRARY #endif #ifdef BAR_LIBRARY -#error Unexpected BAR_LIBRARY +# error Unexpected BAR_LIBRARY #endif #include "bang.h" diff --git a/Tests/InterfaceLinkLibraries/bar.cpp b/Tests/InterfaceLinkLibraries/bar.cpp index 228ed803a..c1d95ab6e 100644 --- a/Tests/InterfaceLinkLibraries/bar.cpp +++ b/Tests/InterfaceLinkLibraries/bar.cpp @@ -1,17 +1,17 @@ #ifdef FOO_LIBRARY -#error Unexpected FOO_LIBRARY +# error Unexpected FOO_LIBRARY #endif #ifdef BAR_USE_BANG -#ifndef BANG_LIBRARY -#error Expected BANG_LIBRARY -#endif -#include "bang.h" +# ifndef BANG_LIBRARY +# error Expected BANG_LIBRARY +# endif +# include "bang.h" #else -#ifdef BANG_LIBRARY -#error Unexpected BANG_LIBRARY -#endif +# ifdef BANG_LIBRARY +# error Unexpected BANG_LIBRARY +# endif #endif #include "bar.h" diff --git a/Tests/InterfaceLinkLibraries/foo.cpp b/Tests/InterfaceLinkLibraries/foo.cpp index 5295707b5..c1e93e849 100644 --- a/Tests/InterfaceLinkLibraries/foo.cpp +++ b/Tests/InterfaceLinkLibraries/foo.cpp @@ -1,10 +1,10 @@ #ifdef BAR_LIBRARY -#error Unexpected BAR_LIBRARY +# error Unexpected BAR_LIBRARY #endif #ifdef BANG_LIBRARY -#error Unexpected BANG_LIBRARY +# error Unexpected BANG_LIBRARY #endif #include "foo.h" diff --git a/Tests/InterfaceLinkLibraries/main.cpp b/Tests/InterfaceLinkLibraries/main.cpp index 6e1295a10..e8298d41c 100644 --- a/Tests/InterfaceLinkLibraries/main.cpp +++ b/Tests/InterfaceLinkLibraries/main.cpp @@ -1,18 +1,18 @@ #ifndef FOO_LIBRARY -#error Expected FOO_LIBRARY +# error Expected FOO_LIBRARY #endif #ifndef BAR_LIBRARY -#error Expected BAR_LIBRARY +# error Expected BAR_LIBRARY #endif #ifdef BANG_LIBRARY -#error Unexpected BANG_LIBRARY +# error Unexpected BANG_LIBRARY #endif #ifdef ZOT_LIBRARY -#error Unexpected ZOT_LIBRARY +# error Unexpected ZOT_LIBRARY #endif #include "zot.h" diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index e1bcf3c20..0b8269bb7 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -11,3 +11,6 @@ add_jar(hello A.java HelloWorld.java) # use listing file to specify sources file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/java_fileslist "A.java\nHelloWorld.java\n") add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist) + +# use listing file to specify sources and specify output directory (issue #17316) +add_jar(hello3 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/hello3") diff --git a/Tests/JavaExportImport/CMakeLists.txt b/Tests/JavaExportImport/CMakeLists.txt index a075301f9..c70704a04 100644 --- a/Tests/JavaExportImport/CMakeLists.txt +++ b/Tests/JavaExportImport/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.9) project(JavaExportImport) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") @@ -17,7 +17,8 @@ set_property( PROPERTY SYMBOLIC 1 ) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/Jump/Executable/jumpExecutable.cxx b/Tests/Jump/Executable/jumpExecutable.cxx index 6fa268377..2c5961c5d 100644 --- a/Tests/Jump/Executable/jumpExecutable.cxx +++ b/Tests/Jump/Executable/jumpExecutable.cxx @@ -1,7 +1,7 @@ #ifdef _WIN32 -#define JUMP_IMPORT __declspec(dllimport) +# define JUMP_IMPORT __declspec(dllimport) #else -#define JUMP_IMPORT extern +# define JUMP_IMPORT extern #endif extern int jumpStatic(); diff --git a/Tests/Jump/Library/Shared/jumpShared.cxx b/Tests/Jump/Library/Shared/jumpShared.cxx index 7c4dee9a8..87484b795 100644 --- a/Tests/Jump/Library/Shared/jumpShared.cxx +++ b/Tests/Jump/Library/Shared/jumpShared.cxx @@ -1,7 +1,7 @@ #ifdef _WIN32 -#define JUMP_EXPORT __declspec(dllexport) +# define JUMP_EXPORT __declspec(dllexport) #else -#define JUMP_EXPORT +# define JUMP_EXPORT #endif JUMP_EXPORT int jumpShared() diff --git a/Tests/LinkDirectory/External/CMakeLists.txt b/Tests/LinkDirectory/External/CMakeLists.txt index f7c840f9a..d2a1f9f77 100644 --- a/Tests/LinkDirectory/External/CMakeLists.txt +++ b/Tests/LinkDirectory/External/CMakeLists.txt @@ -1,6 +1,20 @@ cmake_minimum_required(VERSION 2.8) project(LinkDirectoryExternal C) + +add_executable(myexe2 myexe.c) +set_property(TARGET myexe2 PROPERTY OUTPUT_NAME LinkDirectory2) +target_link_directories(myexe2 PRIVATE lib "${CMAKE_CURRENT_SOURCE_DIR}/../lib") +target_link_libraries(myexe2 PRIVATE mylibA mylibB) + +add_library (mylibs INTERFACE) +target_link_directories(mylibs INTERFACE lib "${CMAKE_CURRENT_SOURCE_DIR}/../lib") +target_link_libraries(mylibs INTERFACE mylibA mylibB) +add_executable(myexe3 myexe.c) +set_property(TARGET myexe3 PROPERTY OUTPUT_NAME LinkDirectory3) +target_link_libraries(myexe3 PRIVATE mylibs) + + # Test CMP0015 OLD behavior: -L../lib cmake_policy(SET CMP0015 OLD) link_directories(../lib) diff --git a/Tests/LinkFlags/LinkFlagsExe.c b/Tests/LinkFlags/LinkFlagsExe.c index 4d441469f..202d34d26 100644 --- a/Tests/LinkFlags/LinkFlagsExe.c +++ b/Tests/LinkFlags/LinkFlagsExe.c @@ -5,5 +5,5 @@ int main(void) /* Intel compiler does not reject bad flags or objects! */ #if defined(__INTEL_COMPILER) -#error BADFLAG +# error BADFLAG #endif diff --git a/Tests/LinkFlags/LinkFlagsLib.c b/Tests/LinkFlags/LinkFlagsLib.c index f35420666..bd288e908 100644 --- a/Tests/LinkFlags/LinkFlagsLib.c +++ b/Tests/LinkFlags/LinkFlagsLib.c @@ -5,5 +5,5 @@ int flags_lib(void) /* Intel compiler does not reject bad flags or objects! */ #if defined(__INTEL_COMPILER) -#error BADFLAG +# error BADFLAG #endif diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt index 03a3b4942..cfaebade4 100644 --- a/Tests/LoadCommand/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeLists.txt @@ -22,13 +22,6 @@ else() ${LoadCommand_SOURCE_DIR}/CMakeCommands CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO OUTPUT_VARIABLE OUTPUT ) -# do another TRY_COMPILE to get around make -# problem on hp - try_compile(COMPILE_OK - ${LoadCommand_BINARY_DIR}/CMakeCommands - ${LoadCommand_SOURCE_DIR}/CMakeCommands - CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO - OUTPUT_VARIABLE OUTPUT ) endif() message("Output from try compile: ${OUTPUT}") diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt index 6affd343f..65de04230 100644 --- a/Tests/LoadCommandOneConfig/CMakeLists.txt +++ b/Tests/LoadCommandOneConfig/CMakeLists.txt @@ -28,13 +28,6 @@ else() ${LoadCommand_SOURCE_DIR}/CMakeCommands CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO OUTPUT_VARIABLE OUTPUT ) -# do another TRY_COMPILE to get around make -# problem on hp - try_compile(COMPILE_OK - ${LoadCommand_BINARY_DIR}/CMakeCommands - ${LoadCommand_SOURCE_DIR}/CMakeCommands - CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO - OUTPUT_VARIABLE OUTPUT ) endif() message("Output from try compile: ${OUTPUT}") diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in index e6bfabd33..bf98e918c 100644 --- a/Tests/MFC/CMakeLists.txt.in +++ b/Tests/MFC/CMakeLists.txt.in @@ -45,6 +45,11 @@ set(files set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@") +FIND_PACKAGE(MFC) +IF (NOT MFC_FOUND) + MESSAGE(FATAL_ERROR "MFC Could not be found during the MFC test") +ENDIF() + if("${CMAKE_MFC_FLAG}" STREQUAL "1") msvc_link_to_static_crt() else() diff --git a/Tests/MFC/mfc1/ChildFrm.cpp b/Tests/MFC/mfc1/ChildFrm.cpp index ddb19c620..a415229d7 100644 --- a/Tests/MFC/mfc1/ChildFrm.cpp +++ b/Tests/MFC/mfc1/ChildFrm.cpp @@ -8,7 +8,7 @@ #include "ChildFrm.h" #ifdef _DEBUG -#define new DEBUG_NEW +# define new DEBUG_NEW #endif // CChildFrame diff --git a/Tests/MFC/mfc1/MainFrm.cpp b/Tests/MFC/mfc1/MainFrm.cpp index c5510657b..6bd2b3d9a 100644 --- a/Tests/MFC/mfc1/MainFrm.cpp +++ b/Tests/MFC/mfc1/MainFrm.cpp @@ -8,7 +8,7 @@ #include "MainFrm.h" #ifdef _DEBUG -#define new DEBUG_NEW +# define new DEBUG_NEW #endif // CMainFrame @@ -21,7 +21,9 @@ END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, }; // CMainFrame construction/destruction @@ -40,9 +42,10 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | - CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | - CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, + WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | + CBRS_TOOLTIPS | CBRS_FLYBY | + CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create diff --git a/Tests/MFC/mfc1/Resource.h b/Tests/MFC/mfc1/Resource.h index 7184e3064..e3a04f11e 100644 --- a/Tests/MFC/mfc1/Resource.h +++ b/Tests/MFC/mfc1/Resource.h @@ -11,10 +11,10 @@ // Next default values for new objects // #ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 130 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 32771 -#endif +# ifndef APSTUDIO_READONLY_SYMBOLS +# define _APS_NEXT_RESOURCE_VALUE 130 +# define _APS_NEXT_CONTROL_VALUE 1000 +# define _APS_NEXT_SYMED_VALUE 101 +# define _APS_NEXT_COMMAND_VALUE 32771 +# endif #endif diff --git a/Tests/MFC/mfc1/mfc1.cpp b/Tests/MFC/mfc1/mfc1.cpp index 664c6c4ec..892a89d27 100644 --- a/Tests/MFC/mfc1/mfc1.cpp +++ b/Tests/MFC/mfc1/mfc1.cpp @@ -11,7 +11,7 @@ #include "mfc1View.h" #ifdef _DEBUG -#define new DEBUG_NEW +# define new DEBUG_NEW #endif // Cmfc1App diff --git a/Tests/MFC/mfc1/mfc1.h b/Tests/MFC/mfc1/mfc1.h index 15e970ba0..f4fcadb45 100644 --- a/Tests/MFC/mfc1/mfc1.h +++ b/Tests/MFC/mfc1/mfc1.h @@ -3,7 +3,7 @@ #pragma once #ifndef __AFXWIN_H__ -#error include 'stdafx.h' before including this file for PCH +# error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols diff --git a/Tests/MFC/mfc1/mfc1Doc.cpp b/Tests/MFC/mfc1/mfc1Doc.cpp index 08ab1580a..e69b61c71 100644 --- a/Tests/MFC/mfc1/mfc1Doc.cpp +++ b/Tests/MFC/mfc1/mfc1Doc.cpp @@ -8,7 +8,7 @@ #include "mfc1Doc.h" #ifdef _DEBUG -#define new DEBUG_NEW +# define new DEBUG_NEW #endif // Cmfc1Doc diff --git a/Tests/MFC/mfc1/mfc1View.cpp b/Tests/MFC/mfc1/mfc1View.cpp index 6169ce524..3de55cf6e 100644 --- a/Tests/MFC/mfc1/mfc1View.cpp +++ b/Tests/MFC/mfc1/mfc1View.cpp @@ -9,7 +9,7 @@ #include "mfc1View.h" #ifdef _DEBUG -#define new DEBUG_NEW +# define new DEBUG_NEW #endif // Cmfc1View diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h index 56f8a6ab4..2680f2632 100644 --- a/Tests/MFC/mfc1/stdafx.h +++ b/Tests/MFC/mfc1/stdafx.h @@ -5,7 +5,7 @@ #pragma once #ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +# define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif // See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info @@ -17,39 +17,41 @@ // platforms. #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 // or later. -#if _MSC_VER < 1600 -#define WINVER \ - 0x0400 // Change this to the appropriate value to target Windows 98 and - // Windows 2000 or later. -#else -#define WINVER 0x0501 // Target Windows XP and later with VS 10 and later -#endif +# if _MSC_VER < 1600 +# define WINVER \ + 0x0400 // Change this to the appropriate value to target Windows 98 and + // Windows 2000 or later. +# else +# define WINVER 0x0501 // Target Windows XP and later with VS 10 and later +# endif #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or // later. -#if _MSC_VER < 1600 -#define _WIN32_WINNT \ - 0x0400 // Change this to the appropriate value to target Windows 98 and - // Windows 2000 or later. -#else -#define _WIN32_WINNT 0x0501 // Target Windows XP and later with VS 10 and later -#endif +# if _MSC_VER < 1600 +# define _WIN32_WINNT \ + 0x0400 // Change this to the appropriate value to target Windows 98 and + // Windows 2000 or later. +# else +# define _WIN32_WINNT \ + 0x0501 // Target Windows XP and later with VS 10 and later +# endif #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or // later. -#if _MSC_VER < 1600 -#define _WIN32_WINDOWS \ - 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif +# if _MSC_VER < 1600 +# define _WIN32_WINDOWS \ + 0x0410 // Change this to the appropriate value to target Windows Me or + // later. +# endif #endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -#if _MSC_VER < 1600 -#define _WIN32_IE \ - 0x0400 // Change this to the appropriate value to target IE 5.0 or later. -#endif +# if _MSC_VER < 1600 +# define _WIN32_IE \ + 0x0400 // Change this to the appropriate value to target IE 5.0 or later. +# endif #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be @@ -65,5 +67,5 @@ #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT -#include <afxcmn.h> // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT +# include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT diff --git a/Tests/MacRuntimePath/A/framework.h b/Tests/MacRuntimePath/A/framework.h index 343317c59..5a3cfc457 100644 --- a/Tests/MacRuntimePath/A/framework.h +++ b/Tests/MacRuntimePath/A/framework.h @@ -3,13 +3,13 @@ #define framework_h #ifdef WIN32 -#ifdef framework_EXPORTS -#define FRAMEWORK_EXPORT __declspec(dllexport) +# ifdef framework_EXPORTS +# define FRAMEWORK_EXPORT __declspec(dllexport) +# else +# define FRAMEWORK_EXPORT __declspec(dllimport) +# endif #else -#define FRAMEWORK_EXPORT __declspec(dllimport) -#endif -#else -#define FRAMEWORK_EXPORT +# define FRAMEWORK_EXPORT #endif void FRAMEWORK_EXPORT framework(); diff --git a/Tests/MacRuntimePath/A/framework2.h b/Tests/MacRuntimePath/A/framework2.h index 7f45f4d2f..2562396f9 100644 --- a/Tests/MacRuntimePath/A/framework2.h +++ b/Tests/MacRuntimePath/A/framework2.h @@ -3,13 +3,13 @@ #define framework2_h #ifdef WIN32 -#ifdef framework2_EXPORTS -#define FRAMEWORK2_EXPORT __declspec(dllexport) +# ifdef framework2_EXPORTS +# define FRAMEWORK2_EXPORT __declspec(dllexport) +# else +# define FRAMEWORK2_EXPORT __declspec(dllimport) +# endif #else -#define FRAMEWORK2_EXPORT __declspec(dllimport) -#endif -#else -#define FRAMEWORK2_EXPORT +# define FRAMEWORK2_EXPORT #endif void FRAMEWORK2_EXPORT framework2(); diff --git a/Tests/MacRuntimePath/A/shared.h b/Tests/MacRuntimePath/A/shared.h index 28904fd78..5d5b6335c 100644 --- a/Tests/MacRuntimePath/A/shared.h +++ b/Tests/MacRuntimePath/A/shared.h @@ -3,13 +3,13 @@ #define shared_h #ifdef WIN32 -#ifdef shared_EXPORTS -#define SHARED_EXPORT __declspec(dllexport) +# ifdef shared_EXPORTS +# define SHARED_EXPORT __declspec(dllexport) +# else +# define SHARED_EXPORT __declspec(dllimport) +# endif #else -#define SHARED_EXPORT __declspec(dllimport) -#endif -#else -#define SHARED_EXPORT +# define SHARED_EXPORT #endif void SHARED_EXPORT shared(); diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt index 3e9ab8a55..a3c6fd9a9 100644 --- a/Tests/MacRuntimePath/CMakeLists.txt +++ b/Tests/MacRuntimePath/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 3.9) project(MacRuntimePath) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") @@ -18,7 +18,8 @@ set_property( configure_file(${MacRuntimePath_SOURCE_DIR}/InitialCache.cmake.in ${MacRuntimePath_BINARY_DIR}/InitialCache.cmake @ONLY) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt index d0e24cefe..a05c38b22 100644 --- a/Tests/MakeClean/ToClean/CMakeLists.txt +++ b/Tests/MakeClean/ToClean/CMakeLists.txt @@ -1,42 +1,122 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.14) project(ToClean) -# Build a simple project. -add_executable(toclean toclean.cxx) +# Utility variables +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) +set(CLEAN_FILE_CONTENT "File registered for cleaning.\n") + +# Lists build-time-generated files that should be cleaned away +set_property(GLOBAL PROPERTY TOCLEAN_FILES "") +function(addCleanFile FILENAME) + set_property(GLOBAL APPEND PROPERTY TOCLEAN_FILES "${FILENAME}") +endfunction() +function(writeCleanFile FILENAME) + file(WRITE "${FILENAME}" ${CLEAN_FILE_CONTENT}) +endfunction() -# List some build-time-generated files. -set(TOCLEAN_FILES ${TOCLEAN_FILES} - "${ToClean_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") +set(DUMMY_CONTENT_FILE ${CSD}/toclean.cxx) -# Create a file that must be registered for cleaning. -file(WRITE "${ToClean_BINARY_DIR}/Registered.txt" - "File registered for cleaning.\n") -set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${ToClean_BINARY_DIR}/Registered.txt") -set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/Registered.txt") +# Build a simple project whose compiled objects should be cleaned. +add_executable(toclean toclean.cxx) +addCleanFile( + "${CBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") + +# Create a post build custom command that copies a dummy file +# to a custom location +function(addPostBuildFile TARGET FILENAME) + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${DUMMY_CONTENT_FILE} ${FILENAME}) +endfunction() # Create a custom command whose output should be cleaned. -add_custom_command(OUTPUT ${ToClean_BINARY_DIR}/generated.txt - DEPENDS ${ToClean_SOURCE_DIR}/toclean.cxx +set(CustomCommandFile "${CBD}/CustomCommandFile.txt") +add_custom_command(OUTPUT ${CustomCommandFile} + DEPENDS ${DUMMY_CONTENT_FILE} COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${ToClean_SOURCE_DIR}/toclean.cxx - ${ToClean_BINARY_DIR}/generated.txt - ) -add_custom_target(generate ALL DEPENDS ${ToClean_BINARY_DIR}/generated.txt) -set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/generated.txt") + ARGS -E copy ${DUMMY_CONTENT_FILE} ${CustomCommandFile}) +add_custom_target(customTarget ALL DEPENDS ${CustomCommandFile}) +addCleanFile(${CustomCommandFile}) + + +### Tests ADDITIONAL_MAKE_CLEAN_FILES directory property +if("${CMAKE_GENERATOR}" MATCHES "Makefile") + # Create a file that must be registered for cleaning. + set(MakeDirPropFileAbs "${CBD}/MakeDirPropFile.txt") + writeCleanFile("${MakeDirPropFileAbs}") + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MakeDirPropFileAbs}") + addCleanFile(${MakeDirPropFileAbs}) + + # Create a custom command whose output should be cleaned, but whose name + # is not known until generate-time + set(MakeDirPropExpFileRel "MakeDirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") + set(MakeDirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${MakeDirPropExpFileRel}") + addPostBuildFile(toclean "${MakeDirPropExpFileAbs}") + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MakeDirPropExpFileAbs}) + addCleanFile("${CBD}/${MakeDirPropExpFileRel}") +endif() + + +### Tests ADDITIONAL_CLEAN_FILES directory property + +# Register a file path relative to the build directory +set(DirPropFileRel "DirPropFileRel.txt") +writeCleanFile("${CBD}/${DirPropFileRel}") +set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel}) +addCleanFile("${CBD}/${DirPropFileRel}") + +# Register an absolute file path +set(DirPropFileAbs "${CBD}/DirPropFileAbs.txt") +writeCleanFile("${DirPropFileAbs}") +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs}) +addCleanFile("${DirPropFileAbs}") # Create a custom command whose output should be cleaned, but whose name # is not known until generate-time -set(copied_exe "$<TARGET_FILE_DIR:toclean>/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}") -add_custom_command(TARGET toclean POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy $<TARGET_FILE:toclean> - ${copied_exe} - ) -set_property(DIRECTORY APPEND PROPERTY - ADDITIONAL_MAKE_CLEAN_FILES ${copied_exe}) -list(APPEND TOCLEAN_FILES "${ToClean_BINARY_DIR}/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}") +set(DirPropExpFileRel "DirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") +set(DirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${DirPropExpFileRel}") +addPostBuildFile(toclean "${DirPropExpFileAbs}") +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropExpFileAbs}) +addCleanFile("${CBD}/${DirPropExpFileRel}") + + +### Tests ADDITIONAL_CLEAN_FILES target property + +function(test_target_property TARGET) + # Register a file path relative to the build directory + set(TgtPropFileRel "${TARGET}_TargetPropFileRel.txt") + writeCleanFile("${CBD}/${TgtPropFileRel}") + set_target_properties(${TARGET} PROPERTIES ADDITIONAL_CLEAN_FILES ${TgtPropFileRel}) + addCleanFile("${CBD}/${TgtPropFileRel}") + + # Register an absolute file path + set(TgtPropFileAbs "${CBD}/${TARGET}_TargetPropFileAbs.txt") + writeCleanFile("${TgtPropFileAbs}") + set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropFileAbs}) + addCleanFile("${TgtPropFileAbs}") + + # Create a custom command whose output should be cleaned, but whose name + # is not known until generate-time + set(TgtPropExpFileRel "${TARGET}_TargetPropGenExp.txt") + set(TgtPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${TgtPropExpFileRel}") + addPostBuildFile(${TARGET} "${TgtPropExpFileAbs}") + set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropExpFileAbs}) + addCleanFile("${CBD}/${TgtPropExpFileRel}") +endfunction() + +# Test target property for various target types +add_executable(acf_exec toclean.cxx) +test_target_property(acf_exec) +add_library(acf_lib toclean.cxx) +test_target_property(acf_lib) +add_custom_target(acf_custom ALL DEPENDS ${CustomCommandFile}) +test_target_property(acf_custom) + +# Process subdirectory without targets +add_subdirectory(EmptySubDir) + # Configure a file listing these build-time-generated files. -configure_file(${ToClean_SOURCE_DIR}/ToCleanFiles.cmake.in - ${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY) +get_property(TOCLEAN_FILES GLOBAL PROPERTY TOCLEAN_FILES) +configure_file(${CSD}/ToCleanFiles.cmake.in ${CBD}/ToCleanFiles.cmake @ONLY) diff --git a/Tests/MakeClean/check_clean.c.in b/Tests/MakeClean/check_clean.c.in index 5bc4ab880..e5a7945af 100644 --- a/Tests/MakeClean/check_clean.c.in +++ b/Tests/MakeClean/check_clean.c.in @@ -18,7 +18,7 @@ int main() if(pf) { fclose(pf); - fprintf(stderr, "File \"%s\" exists!", *f); + fprintf(stderr, "File \"%s\" still exists!\n", *f); result = 1; } } diff --git a/Tests/MathTest/CMakeLists.txt b/Tests/MathTest/CMakeLists.txt index f764b3a4f..5403d297c 100644 --- a/Tests/MathTest/CMakeLists.txt +++ b/Tests/MathTest/CMakeLists.txt @@ -13,14 +13,35 @@ set(expressions "-1 + +1" "+1 - -1" "+1 - - + + -(-3 + - - +1)" + "1000 -12*5" + "1000 +12*-5" + "1000 -12*-5" ) -set(FILE_EXPRESSIONS "") -foreach(expression - ${expressions}) - math(EXPR expr "${expression}") - string(APPEND FILE_EXPRESSIONS "TEST_EXPRESSION(${expression}, ${expr})\n") -endforeach() +set(FILE_EXPRESSIONS "extern void test_expression(int x, int y, const char * text);\n") + + +macro(add_math_test expression) + math(EXPR result ${expression} ${ARGV1} ${ARGV2}) + set(CODE "test_expression(${expression}, ${result}, \"${expression}\");") + string(APPEND FILE_EXPRESSIONS "${CODE}\n") +endmacro() + +macro(add_math_tests) + foreach (expression ${expressions}) + add_math_test(${expression} ${ARGV0} ${ARGV1}) + endforeach () +endmacro() + +add_math_tests() +add_math_tests("OUTPUT_FORMAT" "DECIMAL") +add_math_tests("OUTPUT_FORMAT" "HEXADECIMAL") + +# Avoid the test with negative result and hexadecimal formatting +# therefore more tests with a negative result +add_math_test("-12*5") +add_math_test("12*-5") + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/MathTestTests.h.in" diff --git a/Tests/MathTest/MathTestExec.cxx b/Tests/MathTest/MathTestExec.cxx index 124eba46f..fbcddc4ed 100644 --- a/Tests/MathTest/MathTestExec.cxx +++ b/Tests/MathTest/MathTestExec.cxx @@ -1,21 +1,43 @@ #include <stdio.h> +#include <stdlib.h> +#include <string.h> -#define TEST_EXPRESSION(x, y) \ - if ((x) != (y)) { \ - printf("Problem with EXPR: Expression: \"%s\" in C returns %d while in " \ - "CMake returns: %d\n", \ - #x, (x), (y)); \ - res++; \ +int res = 0; +bool print = false; + +void test_expression(int x, int y, const char* text) +{ + bool fail = (x) != (y); + if (fail) { + res++; + printf("Problem with EXPR:"); + } + if (fail || print) { + printf("Expression: \"%s\" in CMake returns %d", text, (y)); + if (fail) { + printf(" while in C returns: %d", (x)); + } + printf("\n"); } +} int main(int argc, char* argv[]) { - if (argc > 1) { - printf("Usage: %s\n", argv[0]); + if (argc > 2) { + printf("Usage: %s [print]\n", argv[0]); return 1; } - int res = 0; + + if (argc > 1) { + if (strcmp(argv[1], "print") != 0) { + printf("Usage: %s [print]\n", argv[0]); + return 1; + } + print = true; + } + #include "MathTestTests.h" + if (res != 0) { printf("%s: %d math tests failed\n", argv[0], res); return 1; diff --git a/Tests/MissingInstall/CMakeLists.txt b/Tests/MissingInstall/CMakeLists.txt index 91624f710..365b31f62 100644 --- a/Tests/MissingInstall/CMakeLists.txt +++ b/Tests/MissingInstall/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.12) +cmake_minimum_required (VERSION 3.9) project(TestMissingInstall) set(CMAKE_SKIP_INSTALL_RULES ON) @@ -8,11 +8,7 @@ set(CMAKE_SKIP_INSTALL_RULES ON) set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1) -if(CMAKE_CONFIGURATION_TYPES) - set(MULTI_CONFIG ON) -else() - set(MULTI_CONFIG OFF) -endif() +get_property(MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) add_executable(mybin mybin.cpp) install(TARGETS mybin RUNTIME DESTINATION bin) diff --git a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt index 607dcd33a..4a41a988d 100644 --- a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-C LANGUAGES C) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_C) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.c) diff --git a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt index 2dede930b..1bb2b8496 100644 --- a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-CXX LANGUAGES CXX) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_CXX) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.cpp) diff --git a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt index dee5c25bd..3872b567b 100644 --- a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt @@ -4,11 +4,12 @@ project(CheckIPOSupported-Fortran LANGUAGES Fortran) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) -check_ipo_supported(RESULT ipo_supported) +check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) elseif(CMake_TEST_IPO_WORKS_Fortran) - message(FATAL_ERROR "IPO expected to work") + string(REPLACE "\n" "\n " ipo_output "${ipo_output}") + message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() add_library(foo foo.f) diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.c b/Tests/Module/CheckTypeSize/CheckTypeSize.c index 05c798b05..adfd2fc2a 100644 --- a/Tests/Module/CheckTypeSize/CheckTypeSize.c +++ b/Tests/Module/CheckTypeSize/CheckTypeSize.c @@ -2,13 +2,13 @@ #include "somestruct.h" #ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> +# include <sys/types.h> #endif #ifdef HAVE_STDINT_H -#include <stdint.h> +# include <stdint.h> #endif #ifdef HAVE_STDDEF_H -#include <stddef.h> +# include <stddef.h> #endif #include <stdio.h> @@ -86,17 +86,17 @@ int main() /* long long */ #if defined(SIZEOF_LONG_LONG) CHECK(long long, SIZEOF_LONG_LONG); -#if !defined(HAVE_SIZEOF_LONG_LONG) +# if !defined(HAVE_SIZEOF_LONG_LONG) NODEF(HAVE_SIZEOF_LONG_LONG); -#endif +# endif #endif /* __int64 */ #if defined(SIZEOF___INT64) CHECK(__int64, SIZEOF___INT64); -#if !defined(HAVE_SIZEOF___INT64) +# if !defined(HAVE_SIZEOF___INT64) NODEF(HAVE_SIZEOF___INT64); -#endif +# endif #elif defined(HAVE_SIZEOF___INT64) NODEF(SIZEOF___INT64); #endif @@ -114,9 +114,9 @@ int main() /* ssize_t */ #if defined(SIZEOF_SSIZE_T) CHECK(ssize_t, SIZEOF_SSIZE_T); -#if !defined(HAVE_SIZEOF_SSIZE_T) +# if !defined(HAVE_SIZEOF_SSIZE_T) NODEF(HAVE_SIZEOF_SSIZE_T); -#endif +# endif #elif defined(HAVE_SIZEOF_SSIZE_T) NODEF(SIZEOF_SSIZE_T); #endif @@ -125,9 +125,9 @@ int main() #if defined(SIZEOF_STRUCTMEMBER_INT) CHECK(x.someint, SIZEOF_STRUCTMEMBER_INT); CHECK(x.someint, SIZEOF_INT); -#if !defined(HAVE_SIZEOF_STRUCTMEMBER_INT) +# if !defined(HAVE_SIZEOF_STRUCTMEMBER_INT) NODEF(HAVE_SIZEOF_STRUCTMEMBER_INT); -#endif +# endif #elif defined(HAVE_SIZEOF_STRUCTMEMBER_INT) NODEF(SIZEOF_STRUCTMEMBER_INT); #endif @@ -136,9 +136,9 @@ int main() #if defined(SIZEOF_STRUCTMEMBER_PTR) CHECK(x.someptr, SIZEOF_STRUCTMEMBER_PTR); CHECK(x.someptr, SIZEOF_DATA_PTR); -#if !defined(HAVE_SIZEOF_STRUCTMEMBER_PTR) +# if !defined(HAVE_SIZEOF_STRUCTMEMBER_PTR) NODEF(HAVE_SIZEOF_STRUCTMEMBER_PTR); -#endif +# endif #elif defined(HAVE_SIZEOF_STRUCTMEMBER_PTR) NODEF(SIZEOF_STRUCTMEMBER_PTR); #endif @@ -147,9 +147,9 @@ int main() #if defined(SIZEOF_STRUCTMEMBER_CHAR) CHECK(x.somechar, SIZEOF_STRUCTMEMBER_CHAR); CHECK(x.somechar, SIZEOF_CHAR); -#if !defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR) +# if !defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR) NODEF(HAVE_SIZEOF_STRUCTMEMBER_CHAR); -#endif +# endif #elif defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR) NODEF(SIZEOF_STRUCTMEMBER_CHAR); #endif diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx index 2ae84a32f..15dc890c8 100644 --- a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx +++ b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx @@ -3,13 +3,13 @@ #include "someclass.hxx" #ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> +# include <sys/types.h> #endif #ifdef HAVE_STDINT_H -#include <stdint.h> +# include <stdint.h> #endif #ifdef HAVE_STDDEF_H -#include <stddef.h> +# include <stddef.h> #endif #include <stdio.h> @@ -87,17 +87,17 @@ int main() /* long long */ #if defined(SIZEOF_LONG_LONG) CHECK(long long, SIZEOF_LONG_LONG); -#if !defined(HAVE_SIZEOF_LONG_LONG) +# if !defined(HAVE_SIZEOF_LONG_LONG) NODEF(HAVE_SIZEOF_LONG_LONG); -#endif +# endif #endif /* __int64 */ #if defined(SIZEOF___INT64) CHECK(__int64, SIZEOF___INT64); -#if !defined(HAVE_SIZEOF___INT64) +# if !defined(HAVE_SIZEOF___INT64) NODEF(HAVE_SIZEOF___INT64); -#endif +# endif #elif defined(HAVE_SIZEOF___INT64) NODEF(SIZEOF___INT64); #endif @@ -115,9 +115,9 @@ int main() /* ssize_t */ #if defined(SIZEOF_SSIZE_T) CHECK(ssize_t, SIZEOF_SSIZE_T); -#if !defined(HAVE_SIZEOF_SSIZE_T) +# if !defined(HAVE_SIZEOF_SSIZE_T) NODEF(HAVE_SIZEOF_SSIZE_T); -#endif +# endif #elif defined(HAVE_SIZEOF_SSIZE_T) NODEF(SIZEOF_SSIZE_T); #endif @@ -126,9 +126,9 @@ int main() #if defined(SIZEOF_NS_CLASSMEMBER_INT) CHECK(y.someint, SIZEOF_NS_CLASSMEMBER_INT); CHECK(y.someint, SIZEOF_INT); -#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_INT) +# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_INT) NODEF(HAVE_SIZEOF_STRUCTMEMBER_INT); -#endif +# endif #elif defined(HAVE_SIZEOF_STRUCTMEMBER_INT) NODEF(SIZEOF_STRUCTMEMBER_INT); #endif @@ -137,9 +137,9 @@ int main() #if defined(SIZEOF_NS_CLASSMEMBER_PTR) CHECK(y.someptr, SIZEOF_NS_CLASSMEMBER_PTR); CHECK(y.someptr, SIZEOF_DATA_PTR); -#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR) +# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR) NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_PTR); -#endif +# endif #elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR) NODEF(SIZEOF_NS_CLASSMEMBER_PTR); #endif @@ -148,9 +148,9 @@ int main() #if defined(SIZEOF_NS_CLASSMEMBER_CHAR) CHECK(y.somechar, SIZEOF_NS_CLASSMEMBER_CHAR); CHECK(y.somechar, SIZEOF_CHAR); -#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR) +# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR) NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR); -#endif +# endif #elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR) NODEF(SIZEOF_NS_CLASSMEMBER_CHAR); #endif @@ -159,9 +159,9 @@ int main() #if defined(SIZEOF_NS_CLASSMEMBER_BOOL) CHECK(y.somechar, SIZEOF_NS_CLASSMEMBER_BOOL); CHECK(y.somechar, SIZEOF_BOOL); -#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL) +# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL) NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL); -#endif +# endif #elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL) NODEF(SIZEOF_NS_CLASSMEMBER_BOOL); #endif diff --git a/Tests/Module/ExternalData/Data5/CMakeLists.txt b/Tests/Module/ExternalData/Data5/CMakeLists.txt index 13c7fabed..ea67f05af 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/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt index dcb998a4b..06d7dce9a 100644 --- a/Tests/Module/FindDependency/CMakeLists.txt +++ b/Tests/Module/FindDependency/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages") find_package(Pack1 REQUIRED) find_package(Pack4 4.3 EXACT REQUIRED) +find_package(Pack7 REQUIRED) +find_package(Pack8 REQUIRED) add_executable(FindDependency main.cpp) -target_link_libraries(FindDependency Pack1::Lib Pack4::Lib) +target_link_libraries(FindDependency Pack1::Lib Pack4::Lib Pack8::Lib) diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp index 50c5958ca..4ee460fbf 100644 --- a/Tests/Module/FindDependency/main.cpp +++ b/Tests/Module/FindDependency/main.cpp @@ -1,26 +1,38 @@ #ifndef HAVE_PACK1 -#error Expected HAVE_PACK1 +# error Expected HAVE_PACK1 #endif #ifndef HAVE_PACK2 -#error Expected HAVE_PACK2 +# error Expected HAVE_PACK2 #endif #ifndef HAVE_PACK3 -#error Expected HAVE_PACK3 +# error Expected HAVE_PACK3 #endif #ifndef HAVE_PACK4 -#error Expected HAVE_PACK4 +# error Expected HAVE_PACK4 #endif #ifndef HAVE_PACK5 -#error Expected HAVE_PACK5 +# error Expected HAVE_PACK5 #endif #ifndef HAVE_PACK6 -#error Expected HAVE_PACK6 +# error Expected HAVE_PACK6 +#endif + +#ifndef HAVE_PACK7 +# error Expected HAVE_PACK7 +#endif + +#ifndef HAVE_PACK7_COMP1 +# error Expected HAVE_PACK7_COMP1 +#endif + +#ifndef HAVE_PACK8 +# error Expected HAVE_PACK8 #endif int main(int argc, char** argv) diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 52d461350..cffef5a0b 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -52,8 +52,10 @@ endmacro() # detailed features tables, not just meta-features if (CMAKE_C_COMPILE_FEATURES) - set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) - list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") + if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) + list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") + endif() endif() if (C_expected_features) string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJOR "${CMAKE_C_COMPILER_VERSION}") @@ -61,7 +63,7 @@ if (C_expected_features) string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_C_COMPILER_VERSION}") if (CMAKE_C_COMPILER_ID STREQUAL "GNU" - OR CMAKE_C_COMPILER_ID STREQUAL "Clang" + OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_C_COMPILER_ID STREQUAL "Intel") add_executable(WriteCompilerDetectionHeader_C11 main.c) @@ -93,8 +95,10 @@ if (C_expected_features) endif() if (CMAKE_CXX_COMPILE_FEATURES) - set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) - list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") + if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) + list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") + endif() endif() if (NOT CXX_expected_features) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" @@ -118,7 +122,7 @@ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINO string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_CXX_COMPILER_VERSION}") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel") @@ -128,7 +132,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" endif() # for msvc the compiler version determines which c++11 features are available. -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) if(";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;") list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) @@ -190,7 +195,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 +204,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/compile_tests.h b/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h index d3c2a2d39..0da8bab94 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h +++ b/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h @@ -7,21 +7,21 @@ JOIN(EXPECTED_COMPILER_, FEATURE)) #if !CHECK(CXX_DELEGATING_CONSTRUCTORS) -#error cxx_delegating_constructors expected availability did not match. +# error cxx_delegating_constructors expected availability did not match. #endif #if !CHECK(CXX_VARIADIC_TEMPLATES) -#error cxx_variadic_templates expected availability did not match. +# error cxx_variadic_templates expected availability did not match. #endif #if !CHECK(VERSION_MAJOR) -#error Compiler major version did not match. +# error Compiler major version did not match. #endif #if !CHECK(VERSION_MINOR) -#error Compiler minor version did not match. +# error Compiler minor version did not match. #endif #if !CHECK(VERSION_PATCH) -#error Compiler patch version did not match. +# error Compiler patch version did not match. #endif diff --git a/Tests/Module/WriteCompilerDetectionHeader/main.c b/Tests/Module/WriteCompilerDetectionHeader/main.c index ee6abdb92..3420c6750 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/main.c +++ b/Tests/Module/WriteCompilerDetectionHeader/main.c @@ -3,25 +3,25 @@ #if !defined(TEST_COMPILER_C_FUNCTION_PROTOTYPES) || \ !TEST_COMPILER_C_FUNCTION_PROTOTYPES -#error Expected TEST_COMPILER_C_FUNCTION_PROTOTYPES +# error Expected TEST_COMPILER_C_FUNCTION_PROTOTYPES #endif #if !EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES -#error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES +# error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES #endif #if !defined(TEST_COMPILER_C_RESTRICT) || !TEST_COMPILER_C_RESTRICT -#if EXPECTED_COMPILER_C_RESTRICT -#error Expected TEST_COMPILER_C_RESTRICT -#endif +# if EXPECTED_COMPILER_C_RESTRICT +# error Expected TEST_COMPILER_C_RESTRICT +# endif #else -#if !EXPECTED_COMPILER_C_RESTRICT -#error Expect no TEST_COMPILER_C_RESTRICT -#endif +# if !EXPECTED_COMPILER_C_RESTRICT +# error Expect no TEST_COMPILER_C_RESTRICT +# endif #endif #ifdef TEST_COMPILER_CXX_STATIC_ASSERT -#error Expect no CXX features defined +# error Expect no CXX features defined #endif int main() diff --git a/Tests/Module/WriteCompilerDetectionHeader/main.cpp b/Tests/Module/WriteCompilerDetectionHeader/main.cpp index 9979cbae6..97116a5a8 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/main.cpp +++ b/Tests/Module/WriteCompilerDetectionHeader/main.cpp @@ -5,7 +5,7 @@ #include "compile_tests.h" #ifdef TEST_COMPILER_C_STATIC_ASSERT -#error Expect no C features defined +# error Expect no C features defined #endif TEST_STATIC_ASSERT(true); diff --git a/Tests/Module/WriteCompilerDetectionHeader/main_multi.c b/Tests/Module/WriteCompilerDetectionHeader/main_multi.c index 6e13fd762..28f9daea2 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/main_multi.c +++ b/Tests/Module/WriteCompilerDetectionHeader/main_multi.c @@ -3,25 +3,25 @@ #if !defined(MULTI_COMPILER_C_FUNCTION_PROTOTYPES) || \ !MULTI_COMPILER_C_FUNCTION_PROTOTYPES -#error Expected MULTI_COMPILER_C_FUNCTION_PROTOTYPES +# error Expected MULTI_COMPILER_C_FUNCTION_PROTOTYPES #endif #if !EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES -#error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES +# error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES #endif #if !defined(MULTI_COMPILER_C_RESTRICT) || !MULTI_COMPILER_C_RESTRICT -#if EXPECTED_COMPILER_C_RESTRICT -#error Expected MULTI_COMPILER_C_RESTRICT -#endif +# if EXPECTED_COMPILER_C_RESTRICT +# error Expected MULTI_COMPILER_C_RESTRICT +# endif #else -#if !EXPECTED_COMPILER_C_RESTRICT -#error Expect no MULTI_COMPILER_C_RESTRICT -#endif +# if !EXPECTED_COMPILER_C_RESTRICT +# error Expect no MULTI_COMPILER_C_RESTRICT +# endif #endif #ifdef MULTI_COMPILER_CXX_STATIC_ASSERT -#error Expect no CXX features defined +# error Expect no CXX features defined #endif int main() diff --git a/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp b/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp index d1f178f7c..44f4d17c7 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp +++ b/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp @@ -5,7 +5,7 @@ #include "compile_tests.h" #ifdef MULTI_COMPILER_C_STATIC_ASSERT -#error Expect no C features defined +# error Expect no C features defined #endif MULTI_STATIC_ASSERT(true); diff --git a/Tests/ModuleDefinition/example_mod_1.c b/Tests/ModuleDefinition/example_mod_1.c index 6b355cf6b..8afdb31e7 100644 --- a/Tests/ModuleDefinition/example_mod_1.c +++ b/Tests/ModuleDefinition/example_mod_1.c @@ -1,7 +1,7 @@ #ifdef __WATCOMC__ -#define MODULE_CCONV __cdecl +# define MODULE_CCONV __cdecl #else -#define MODULE_CCONV +# define MODULE_CCONV #endif int __declspec(dllimport) example_exe_function(void); diff --git a/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m b/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m index ee7068240..5567c4eef 100644 --- a/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m +++ b/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m @@ -12,6 +12,9 @@ EN ; This entry point shouldn't be found without fixing ; This line not executable D T6^ZZCOVTST ; +% ; a line to test for a problem where % was dropped + N Do,Re,Mi + S Do="A#" T1 ; This line should always be found N D S D=2 diff --git a/Tests/MumpsCoverage/ZZCOVTST.cmcov b/Tests/MumpsCoverage/ZZCOVTST.cmcov index 7a5df6105..515f822cc 100644 --- a/Tests/MumpsCoverage/ZZCOVTST.cmcov +++ b/Tests/MumpsCoverage/ZZCOVTST.cmcov @@ -13,33 +13,36 @@ ZZCOVTST,1,1,"ZZCOVTST;OSEHRA/JPS -- Test routine for Coverage Parsing;4/28/2014 ,12,1," Q"
,13,0," ; This line not executable"
,14,0," ;"
-,15,0,"T1 ; This line should always be found"
-,16,1," N D"
-,17,1," S D=2"
-,18,1," W !,D,!,""This is the second entry point"",!"
-,19,1," D T2^ZZCOVTST(D)"
-,20,1," Q"
-,21,0," ;"
-,22,0,"T2(EQ) ; This is debatable and only called with ENT^ROU notation"
-,23,1," N D"
-,24,1," S D=3"
-,25,1," W !,D,!,EQ,""This is the third entry point"",!"
-,26,1," D T3^ZZCOVTST"
-,27,1," Q"
-,28,0," ;"
-,29,1,"T3 N D S D=4 W D,!,""Fourth Entry point"",! Q"
-,30,0," ;"
-,31,0,"T4 N D S D=5 W ""Shouldn't be executed"""
-,32,0," W ""Lots to not do"""
-,33,0," Q"
-,34,1,"T5(EQ) ;this entry point is called with a $$ notation"
-,35,1," W ""THIS IS THE $$ NOTATION!"",!"
-,36,1," Q 0"
-,37,0,"T6 ; An entry point to show comments inside of ""DO"" blocks"
-,38,1," D"
-,39,1," . W ""This is executable code"",!"
-,40,0," . ; This is a comment inside the do block, not executable"
-,41,1," . S ZZBLAH=""blah"""
-,42,1," W ""Ending T6"",!"
-,43,0," ;"
-Totals for ZZCOVTST,,25,
\ No newline at end of file +,15,1,"% ; a line to test for a problem where % was dropped"
+,16,1,"N Do,Re,Mi"
+,17,1,"S Do=""A#"""
+,18,0,"T1 ; This line should always be found"
+,19,1," N D"
+,20,1," S D=2"
+,21,1," W !,D,!,""This is the second entry point"",!"
+,22,1," D T2^ZZCOVTST(D)"
+,23,1," Q"
+,24,0," ;"
+,25,0,"T2(EQ) ; This is debatable and only called with ENT^ROU notation"
+,26,1," N D"
+,27,1," S D=3"
+,28,1," W !,D,!,EQ,""This is the third entry point"",!"
+,29,1," D T3^ZZCOVTST"
+,30,1," Q"
+,31,0," ;"
+,32,1,"T3 N D S D=4 W D,!,""Fourth Entry point"",! Q"
+,33,0," ;"
+,34,0,"T4 N D S D=5 W ""Shouldn't be executed"""
+,35,0," W ""Lots to not do"""
+,36,0," Q"
+,37,1,"T5(EQ) ;this entry point is called with a $$ notation"
+,38,1," W ""THIS IS THE $$ NOTATION!"",!"
+,39,1," Q 0"
+,40,0,"T6 ; An entry point to show comments inside of ""DO"" blocks"
+,41,1," D"
+,42,1," . W ""This is executable code"",!"
+,43,0," . ; This is a comment inside the do block, not executable"
+,44,1," . S ZZBLAH=""blah"""
+,45,1," W ""Ending T6"",!"
+,46,0," ;"
+Toals for ZZCOVTST,,28,
diff --git a/Tests/MumpsCoverage/ZZCOVTST.mcov b/Tests/MumpsCoverage/ZZCOVTST.mcov index b2608d952..e1fa18cad 100644 --- a/Tests/MumpsCoverage/ZZCOVTST.mcov +++ b/Tests/MumpsCoverage/ZZCOVTST.mcov @@ -9,6 +9,9 @@ GT.M 15-AUG-2014 10:14:32 ZWR ^ZZCOVERAGE("ZZCOVTST","EN",4)="1:0:0:0:74" ^ZZCOVERAGE("ZZCOVTST","EN",5)="1:0:0:0:66" ^ZZCOVERAGE("ZZCOVTST","EN",6)="1:0:0:0:40" +^ZZCOVERAGE("ZZCOVTST","%")="2:0:0:0:208" +^ZZCOVERAGE("ZZCOVTST","%",1)="2:0:0:0:208" +^ZZCOVERAGE("ZZCOVTST","%",2)="2:0:0:0:208" ^ZZCOVERAGE("ZZCOVTST","T1")="1:0:0:0:208" ^ZZCOVERAGE("ZZCOVTST","T1",1)="1:0:0:0:23" ^ZZCOVERAGE("ZZCOVTST","T1",2)="1:0:0:0:24" diff --git a/Tests/NewlineArgs/libcxx1.cxx b/Tests/NewlineArgs/libcxx1.cxx index 72f171d5c..b3c219247 100644 --- a/Tests/NewlineArgs/libcxx1.cxx +++ b/Tests/NewlineArgs/libcxx1.cxx @@ -1,10 +1,10 @@ #include "libcxx1.h" #ifdef TEST_FLAG_1 -#ifdef TEST_FLAG_2 +# ifdef TEST_FLAG_2 float LibCxx1Class::Method() { return 2.0; } -#endif +# endif #endif diff --git a/Tests/NewlineArgs/libcxx1.h b/Tests/NewlineArgs/libcxx1.h index ea094d758..8bb09cdc2 100644 --- a/Tests/NewlineArgs/libcxx1.h +++ b/Tests/NewlineArgs/libcxx1.h @@ -2,8 +2,8 @@ class LibCxx1Class { public: #ifdef TEST_FLAG_1 -#ifdef TEST_FLAG_2 +# ifdef TEST_FLAG_2 static float Method(); -#endif +# endif #endif }; diff --git a/Tests/ObjectLibrary/A/a.h b/Tests/ObjectLibrary/A/a.h index b1fd42fac..184df3ced 100644 --- a/Tests/ObjectLibrary/A/a.h +++ b/Tests/ObjectLibrary/A/a.h @@ -1,6 +1,6 @@ #ifndef A_DEF -#error "A_DEF not defined" +# error "A_DEF not defined" #endif #ifdef B_DEF -#error "B_DEF must not be defined" +# error "B_DEF must not be defined" #endif diff --git a/Tests/ObjectLibrary/B/b.h b/Tests/ObjectLibrary/B/b.h index a7bd35230..de81d69f2 100644 --- a/Tests/ObjectLibrary/B/b.h +++ b/Tests/ObjectLibrary/B/b.h @@ -1,18 +1,18 @@ #ifdef A_DEF -#error "A_DEF must not be defined" +# error "A_DEF must not be defined" #endif #ifndef B_DEF -#error "B_DEF not defined" +# error "B_DEF not defined" #endif #if defined(_WIN32) && defined(Bexport) -#define EXPORT_B __declspec(dllexport) +# define EXPORT_B __declspec(dllexport) #else -#define EXPORT_B +# define EXPORT_B #endif #if defined(_WIN32) && defined(SHARED_B) -#define IMPORT_B __declspec(dllimport) +# define IMPORT_B __declspec(dllimport) #else -#define IMPORT_B +# define IMPORT_B #endif diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt index 4bffd1221..7897ab99b 100644 --- a/Tests/ObjectLibrary/CMakeLists.txt +++ b/Tests/ObjectLibrary/CMakeLists.txt @@ -62,4 +62,14 @@ add_custom_target(UseABinternalDep COMMAND ${CMAKE_COMMAND} -E touch UseABintern add_custom_command(TARGET UseABinternal POST_BUILD COMMAND ${CMAKE_COMMAND} -P UseABinternalDep.cmake) add_dependencies(UseABinternal UseABinternalDep) +# Test a static library with sources from a different static library +add_library(UseCstaticObjs STATIC $<TARGET_OBJECTS:Cstatic> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>) + +# Test a shared library with sources from a different shared library +add_library(UseCsharedObjs SHARED $<TARGET_OBJECTS:Cshared> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>) + +# Test a shared executable with sources from a different shared library +add_executable(UseABstaticObjs $<TARGET_OBJECTS:UseABstatic>) +target_link_libraries(UseABstaticObjs ABstatic) + add_subdirectory(ExportLanguages) diff --git a/Tests/ObjectLibrary/c.c b/Tests/ObjectLibrary/c.c index 4c37e38b2..2692899cc 100644 --- a/Tests/ObjectLibrary/c.c +++ b/Tests/ObjectLibrary/c.c @@ -1,7 +1,7 @@ #if defined(_WIN32) && defined(Cshared_EXPORTS) -#define EXPORT_C __declspec(dllexport) +# define EXPORT_C __declspec(dllexport) #else -#define EXPORT_C +# define EXPORT_C #endif extern int a1(void); diff --git a/Tests/ObjectLibrary/main.c b/Tests/ObjectLibrary/main.c index b2f1d44bd..cc7568527 100644 --- a/Tests/ObjectLibrary/main.c +++ b/Tests/ObjectLibrary/main.c @@ -1,7 +1,7 @@ #if defined(_WIN32) && defined(SHARED_C) -#define IMPORT_C __declspec(dllimport) +# define IMPORT_C __declspec(dllimport) #else -#define IMPORT_C +# define IMPORT_C #endif extern IMPORT_C int b1(void); extern IMPORT_C int b2(void); diff --git a/Tests/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt index 88468c3c0..823ab0864 100644 --- a/Tests/OutDir/CMakeLists.txt +++ b/Tests/OutDir/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(OutDir C) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) foreach(config ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER "${config}" CONFIG) list(APPEND configs "${CONFIG}") diff --git a/Tests/OutOfSource/CMakeLists.txt b/Tests/OutOfSource/CMakeLists.txt index de1603a55..4687882aa 100644 --- a/Tests/OutOfSource/CMakeLists.txt +++ b/Tests/OutOfSource/CMakeLists.txt @@ -1,4 +1,4 @@ -# a simple test cas +# a simple test case cmake_minimum_required (VERSION 2.6) project (OutOfSource) diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt index 10a2f59d1..76a93d24a 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/OutOfSource/OutOfSourceSubdir/testlib.h b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h index bacf5a109..3e012d252 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/testlib.h +++ b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h @@ -1,11 +1,11 @@ #ifdef _WIN32 -#ifdef testlib_EXPORTS -#define CM_TEST_LIB_EXPORT __declspec(dllexport) +# ifdef testlib_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec(dllexport) +# else +# define CM_TEST_LIB_EXPORT __declspec(dllimport) +# endif #else -#define CM_TEST_LIB_EXPORT __declspec(dllimport) -#endif -#else -#define CM_TEST_LIB_EXPORT +# define CM_TEST_LIB_EXPORT #endif CM_TEST_LIB_EXPORT float TestLib(); diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt index 2fb894ed8..6d8d6cc00 100644 --- a/Tests/PDBDirectoryAndName/CMakeLists.txt +++ b/Tests/PDBDirectoryAndName/CMakeLists.txt @@ -19,7 +19,7 @@ set(my_targets "") add_library(mylibA SHARED mylibA.c) set_target_properties(mylibA PROPERTIES PDB_NAME "mylibA_Special" - PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibA_PDB" + PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibA_PDB/$<CONFIG>" ) list(APPEND my_targets mylibA) @@ -87,7 +87,13 @@ foreach(t ${my_targets}) if(NOT pdb_dir) set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR}) endif() - list(APPEND pdbs ${pdb_dir}/${CMAKE_CFG_INTDIR}/${pdb_name}.pdb) + if (pdb_dir MATCHES "\\$<.*>") + # Skip per-configuration subdirectory if the value contained + # a generator expression. + list(APPEND pdbs ${pdb_dir}/${pdb_name}.pdb) + else() + list(APPEND pdbs ${pdb_dir}/${CMAKE_CFG_INTDIR}/${pdb_name}.pdb) + endif() endforeach() add_custom_target(check_pdbs ALL VERBATIM COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIGURATION> "-Dpdbs=${pdbs}" diff --git a/Tests/PerConfig/pcShared.h b/Tests/PerConfig/pcShared.h index 031cd7965..2ae66cd42 100644 --- a/Tests/PerConfig/pcShared.h +++ b/Tests/PerConfig/pcShared.h @@ -2,13 +2,13 @@ #define pcShared_h #ifdef _WIN32 -#ifdef pcShared_EXPORTS -#define PC_EXPORT __declspec(dllexport) +# ifdef pcShared_EXPORTS +# define PC_EXPORT __declspec(dllexport) +# else +# define PC_EXPORT __declspec(dllimport) +# endif #else -#define PC_EXPORT __declspec(dllimport) -#endif -#else -#define PC_EXPORT +# define PC_EXPORT #endif PC_EXPORT const char* pcShared(void); diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index 9e2b4abd9..8e8fa0759 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -15,6 +15,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static) set(KWSYS_NAMESPACE kwsys) set(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include) set(KWSYS_USE_DynamicLoader 1) +set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) add_subdirectory(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys) # Configure the location of plugins. @@ -28,13 +29,6 @@ include_directories( ${Plugin_SOURCE_DIR}/include ) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/Tests/Plugin/include/example.h b/Tests/Plugin/include/example.h index 87d992e57..cbcb3dcc3 100644 --- a/Tests/Plugin/include/example.h +++ b/Tests/Plugin/include/example.h @@ -2,13 +2,13 @@ #define example_h #if defined(_WIN32) || defined(__CYGWIN__) -#if defined(example_exe_EXPORTS) -#define EXAMPLE_EXPORT __declspec(dllexport) +# if defined(example_exe_EXPORTS) +# define EXAMPLE_EXPORT __declspec(dllexport) +# else +# define EXAMPLE_EXPORT __declspec(dllimport) +# endif #else -#define EXAMPLE_EXPORT __declspec(dllimport) -#endif -#else -#define EXAMPLE_EXPORT +# define EXAMPLE_EXPORT #endif #ifdef __cplusplus diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx index 017fbf607..257a35ca5 100644 --- a/Tests/Plugin/src/example_exe.cxx +++ b/Tests/Plugin/src/example_exe.cxx @@ -17,9 +17,9 @@ extern "C" int example_exe_function() } #ifdef CMAKE_INTDIR -#define CONFIG_DIR "/" CMAKE_INTDIR +# define CONFIG_DIR "/" CMAKE_INTDIR #else -#define CONFIG_DIR "" +# define CONFIG_DIR "" #endif int main() diff --git a/Tests/Plugin/src/example_mod_1.c b/Tests/Plugin/src/example_mod_1.c index a5dd9840d..87b559d2f 100644 --- a/Tests/Plugin/src/example_mod_1.c +++ b/Tests/Plugin/src/example_mod_1.c @@ -3,15 +3,15 @@ #include <stdio.h> #if defined(_WIN32) -#define MODULE_EXPORT __declspec(dllexport) +# define MODULE_EXPORT __declspec(dllexport) #else -#define MODULE_EXPORT +# define MODULE_EXPORT #endif #ifdef __WATCOMC__ -#define MODULE_CCONV __cdecl +# define MODULE_CCONV __cdecl #else -#define MODULE_CCONV +# define MODULE_CCONV #endif MODULE_EXPORT int MODULE_CCONV example_mod_1_function(int n) diff --git a/Tests/PolicyScope/CMakeLists.txt b/Tests/PolicyScope/CMakeLists.txt index 413195a5c..353842bc4 100644 --- a/Tests/PolicyScope/CMakeLists.txt +++ b/Tests/PolicyScope/CMakeLists.txt @@ -52,6 +52,10 @@ if(1) # CMP0002 should be changed when this function is invoked cmake_policy(GET CMP0002 cmp) check(CMP0002 "OLD" "${cmp}") + + # The undocumented PARENT_SCOPE option sees the caller's setting. + cmake_policy(GET CMP0002 cmp PARENT_SCOPE) + check(CMP0002 "NEW" "${cmp}") endfunction() # Unset CMP0002 @@ -61,6 +65,10 @@ if(1) cmake_policy(GET CMP0002 cmp) check(CMP0002 "" "${cmp}") + # The undocumented PARENT_SCOPE option sees the caller's setting. + cmake_policy(GET CMP0002 cmp PARENT_SCOPE) + check(CMP0002 "NEW" "${cmp}") + # Setting the policy should work here and also in the caller. cmake_policy(SET CMP0002 OLD) cmake_policy(GET CMP0002 cmp) diff --git a/Tests/PrecompiledHeader/CMakeLists.txt b/Tests/PrecompiledHeader/CMakeLists.txt index a80453892..58f4863b4 100644 --- a/Tests/PrecompiledHeader/CMakeLists.txt +++ b/Tests/PrecompiledHeader/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.9) project(PrecompiledHeader C) # Make sure the proper compiler is in use. @@ -7,7 +7,8 @@ if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") endif() # Compute a custom name for the precompiled header. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(PCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/PCH/${CMAKE_CFG_INTDIR}") foreach(cfg ${CMAKE_CONFIGURATION_TYPES}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PCH/${cfg}) diff --git a/Tests/PrecompiledHeader/foo1.c b/Tests/PrecompiledHeader/foo1.c index 77172bae7..fef258612 100644 --- a/Tests/PrecompiledHeader/foo1.c +++ b/Tests/PrecompiledHeader/foo1.c @@ -1,5 +1,5 @@ #ifndef foo_h -#error "Precompiled header foo_precompiled.h has not been loaded." +# error "Precompiled header foo_precompiled.h has not been loaded." #endif int main() diff --git a/Tests/PrecompiledHeader/foo2.c b/Tests/PrecompiledHeader/foo2.c index f192e1615..3ed04ed99 100644 --- a/Tests/PrecompiledHeader/foo2.c +++ b/Tests/PrecompiledHeader/foo2.c @@ -1,6 +1,6 @@ #ifndef foo_h -#include "foo.h" -#error "Precompiled header foo_precompiled.h has not been loaded." +# include "foo.h" +# error "Precompiled header foo_precompiled.h has not been loaded." #endif int foo() diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index 8c2cdc9e7..588af0320 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -28,6 +28,11 @@ endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") set(PP_VS 1) endif() +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND + "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND + "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + set(CLANG_GNULIKE_WINDOWS 1) +endif() # Some tests below check the PP_* variables set above. They are meant # to test the case that the build tool is at fault. Other tests below @@ -53,7 +58,7 @@ endif() string(APPEND STRING_EXTRA " ") -if(NOT PP_BORLAND AND NOT PP_WATCOM) +if(NOT PP_BORLAND AND NOT PP_WATCOM AND NOT CLANG_GNULIKE_WINDOWS) # Borland, WMake: multiple spaces # The make tool seems to remove extra whitespace from inside # quoted strings when passing to the compiler. It does not have @@ -70,14 +75,14 @@ if(NOT PP_VS) string(APPEND STRING_EXTRA ",") endif() -if(NOT PP_MINGW) +if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS) # MinGW: & # When inside -D"FOO=\"a & b\"" MinGW make wants -D"FOO=\"a "&" b\"" # but it does not like quoted ampersand elsewhere. string(APPEND STRING_EXTRA "&") endif() -if(NOT PP_MINGW) +if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS) # MinGW: | # When inside -D"FOO=\"a | b\"" MinGW make wants -D"FOO=\"a "|" b\"" # but it does not like quoted pipe elsewhere. @@ -100,7 +105,8 @@ endif() set(EXPR_OP1 "/") if((NOT MSVC OR PP_NMAKE) AND - NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND + NOT CLANG_GNULIKE_WINDOWS) # MSVC cl, Intel icl: % # When the cl compiler is invoked from the command line then % must # be written %% (to distinguish from %ENV% syntax). However cl does diff --git a/Tests/Preprocess/preprocess.c b/Tests/Preprocess/preprocess.c index 1b038b0c5..958c77ebc 100644 --- a/Tests/Preprocess/preprocess.c +++ b/Tests/Preprocess/preprocess.c @@ -10,7 +10,8 @@ int check_defines_C(void) { int result = 1; if (strcmp(FILE_STRING, STRING_VALUE) != 0) { - fprintf(stderr, "FILE_STRING has wrong value in C [%s]\n", FILE_STRING); + fprintf(stderr, "FILE_STRING has wrong value in C [%s] vs [%s]\n", + FILE_STRING, STRING_VALUE); result = 0; } if (strcmp(TARGET_STRING, STRING_VALUE) != 0) { @@ -33,117 +34,117 @@ int check_defines_C(void) } } #ifdef NDEBUG -#ifdef FILE_DEF_DEBUG +# ifdef FILE_DEF_DEBUG { fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n"); result = 0; } -#endif -#ifdef TARGET_DEF_DEBUG +# endif +# ifdef TARGET_DEF_DEBUG { fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n"); result = 0; } -#endif -#ifdef DIRECTORY_DEF_DEBUG +# endif +# ifdef DIRECTORY_DEF_DEBUG { fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n"); result = 0; } -#endif -#ifndef FILE_DEF_RELEASE -#ifndef PREPROCESS_XCODE +# endif +# ifndef FILE_DEF_RELEASE +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n"); result = 0; } -#endif -#endif -#ifndef TARGET_DEF_RELEASE +# endif +# endif +# ifndef TARGET_DEF_RELEASE { fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n"); result = 0; } -#endif -#ifndef DIRECTORY_DEF_RELEASE +# endif +# ifndef DIRECTORY_DEF_RELEASE { fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n"); result = 0; } -#endif +# endif #endif #ifdef PREPROCESS_DEBUG -#ifndef FILE_DEF_DEBUG -#ifndef PREPROCESS_XCODE +# ifndef FILE_DEF_DEBUG +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n"); result = 0; } -#endif -#endif -#ifndef TARGET_DEF_DEBUG +# endif +# endif +# ifndef TARGET_DEF_DEBUG { fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n"); result = 0; } -#endif -#ifndef DIRECTORY_DEF_DEBUG +# endif +# ifndef DIRECTORY_DEF_DEBUG { fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n"); result = 0; } -#endif -#ifdef FILE_DEF_RELEASE +# endif +# ifdef FILE_DEF_RELEASE { fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n"); result = 0; } -#endif -#ifdef TARGET_DEF_RELEASE +# endif +# ifdef TARGET_DEF_RELEASE { fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n"); result = 0; } -#endif -#ifdef DIRECTORY_DEF_RELEASE +# endif +# ifdef DIRECTORY_DEF_RELEASE { fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n"); result = 0; } -#endif +# endif #endif #if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) -#if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG) -#ifndef PREPROCESS_XCODE +# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG) +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n"); result = 0; } -#endif -#endif -#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) +# endif +# endif +# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) { fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n"); result = 0; } -#endif +# endif #endif #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) -#if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE) -#ifndef PREPROCESS_XCODE +# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE) +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n"); result = 0; } -#endif -#endif -#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) +# endif +# endif +# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) { fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n"); result = 0; } -#endif +# endif #endif #ifndef FILE_PATH_DEF { diff --git a/Tests/Preprocess/preprocess.cxx b/Tests/Preprocess/preprocess.cxx index 0fab78525..34a69c6c6 100644 --- a/Tests/Preprocess/preprocess.cxx +++ b/Tests/Preprocess/preprocess.cxx @@ -35,118 +35,118 @@ int check_defines_CXX() } } #ifdef NDEBUG -#ifdef FILE_DEF_DEBUG +# ifdef FILE_DEF_DEBUG { fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n"); result = 0; } -#endif -#ifdef TARGET_DEF_DEBUG +# endif +# ifdef TARGET_DEF_DEBUG { fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n"); result = 0; } -#endif -#ifdef DIRECTORY_DEF_DEBUG +# endif +# ifdef DIRECTORY_DEF_DEBUG { fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in CXX\n"); result = 0; } -#endif -#ifndef FILE_DEF_RELEASE -#ifndef PREPROCESS_XCODE +# endif +# ifndef FILE_DEF_RELEASE +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_RELEASE should be defined in CXX\n"); result = 0; } -#endif -#endif -#ifndef TARGET_DEF_RELEASE +# endif +# endif +# ifndef TARGET_DEF_RELEASE { fprintf(stderr, "TARGET_DEF_RELEASE should be defined in CXX\n"); result = 0; } -#endif -#ifndef DIRECTORY_DEF_RELEASE +# endif +# ifndef DIRECTORY_DEF_RELEASE { fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in CXX\n"); result = 0; } -#endif +# endif #endif #ifdef PREPROCESS_DEBUG -#ifndef FILE_DEF_DEBUG -#ifndef PREPROCESS_XCODE +# ifndef FILE_DEF_DEBUG +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_DEBUG should be defined in CXX\n"); result = 0; } -#endif -#endif -#ifndef TARGET_DEF_DEBUG +# endif +# endif +# ifndef TARGET_DEF_DEBUG { fprintf(stderr, "TARGET_DEF_DEBUG should be defined in CXX\n"); result = 0; } -#endif -#ifndef DIRECTORY_DEF_DEBUG +# endif +# ifndef DIRECTORY_DEF_DEBUG { fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in CXX\n"); result = 0; } -#endif -#ifdef FILE_DEF_RELEASE +# endif +# ifdef FILE_DEF_RELEASE { fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n"); result = 0; } -#endif -#ifdef TARGET_DEF_RELEASE +# endif +# ifdef TARGET_DEF_RELEASE { fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n"); result = 0; } -#endif -#ifdef DIRECTORY_DEF_RELEASE +# endif +# ifdef DIRECTORY_DEF_RELEASE { fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in CXX\n"); result = 0; } -#endif +# endif #endif #if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) -#if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG) -#ifndef PREPROCESS_XCODE +# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG) +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n"); result = 0; } -#endif -#endif -#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) +# endif +# endif +# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) { fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n"); result = 0; } -#endif +# endif #endif #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) -#if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE) -#ifndef PREPROCESS_XCODE +# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE) +# ifndef PREPROCESS_XCODE { fprintf(stderr, "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n"); result = 0; } -#endif -#endif -#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) +# endif +# endif +# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) { fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n"); result = 0; } -#endif +# endif #endif #ifndef FILE_PATH_DEF { diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt index 11fca45b0..a26306122 100644 --- a/Tests/Properties/CMakeLists.txt +++ b/Tests/Properties/CMakeLists.txt @@ -11,7 +11,7 @@ set_source_files_properties(properties.h PROPERTIES TEST1 1) get_source_file_property(RESULT1 properties.h TEST1) # test properties on a headerfile in the source tree -# accessed without an extenion (also yuck) +# accessed without an extension (also yuck) set_source_files_properties(properties2 PROPERTIES TEST2 1) get_source_file_property(RESULT2 properties2 TEST2) diff --git a/Tests/Properties/subdirtest.cxx b/Tests/Properties/subdirtest.cxx index 02d8f3d3f..23f1048ec 100644 --- a/Tests/Properties/subdirtest.cxx +++ b/Tests/Properties/subdirtest.cxx @@ -1,6 +1,6 @@ #ifndef SUBDIR_TEST -#error Expected SUBDIR_TEST +# error Expected SUBDIR_TEST #endif int main(int, char**) diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt index 646ea9f3b..c73a38c0f 100644 --- a/Tests/Qt4Deploy/CMakeLists.txt +++ b/Tests/Qt4Deploy/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(Qt4Deploy) set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install) @@ -10,7 +10,8 @@ add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp) target_link_libraries(testdeploy ${QT_LIBRARIES}) set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") -if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG) # note: installing debug Qt libraries from a Qt installation configured with # -debug-and-release not yet supported (very low priority). install(CODE " @@ -58,7 +59,7 @@ if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE) endif() # custom target to install and test the installation at build time - if(CMAKE_CONFIGURATION_TYPES) + if(_isMultiConfig) set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}") endif() diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index ae0a02bb6..2ca11e40b 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -20,6 +20,16 @@ if (WIN32) endif() endif() +# Qt4 moc does not support utf8 paths in _parameter files generated by +# qt4_wrap_cpp and qt4_generate_moc +# https://bugreports.qt.io/browse/QTBUG-35480 +# Do a simple check if there is are non ASCII character in the build path +string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR}) +if(NON_ASCII_BDIR) + message(WARNING "Build path contains non ASCII characters. Skipping Qt4 test.") + return() +endif() + qt4_generate_moc(main_gen_test.cpp "${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc" TARGET Qt4GenerateMacroTest diff --git a/Tests/Qt4Targets/activeqtexe.cpp b/Tests/Qt4Targets/activeqtexe.cpp index f17b0a639..98176f1de 100644 --- a/Tests/Qt4Targets/activeqtexe.cpp +++ b/Tests/Qt4Targets/activeqtexe.cpp @@ -2,7 +2,7 @@ #include <QApplication> #ifndef QT_QAXSERVER_LIB -#error Expected QT_QAXSERVER_LIB +# error Expected QT_QAXSERVER_LIB #endif #include <QAxFactory> diff --git a/Tests/Qt4Targets/main.cpp b/Tests/Qt4Targets/main.cpp index 07443b0c4..f8eacdcdc 100644 --- a/Tests/Qt4Targets/main.cpp +++ b/Tests/Qt4Targets/main.cpp @@ -5,11 +5,11 @@ #include <QString> #ifndef QT_CORE_LIB -#error Expected QT_CORE_LIB +# error Expected QT_CORE_LIB #endif #ifndef QT_GUI_LIB -#error Expected QT_GUI_LIB +# error Expected QT_GUI_LIB #endif int main(int argc, char** argv) diff --git a/Tests/Qt4Targets/main_gen_test.cpp b/Tests/Qt4Targets/main_gen_test.cpp index 1ea390bcf..6616e844c 100644 --- a/Tests/Qt4Targets/main_gen_test.cpp +++ b/Tests/Qt4Targets/main_gen_test.cpp @@ -3,7 +3,9 @@ #include "myinterface.h" -class MyObject : public QObject, MyInterface +class MyObject + : public QObject + , MyInterface { Q_OBJECT Q_INTERFACES(MyInterface) diff --git a/Tests/Qt4Targets/mywrapobject.h b/Tests/Qt4Targets/mywrapobject.h index 5d4e52aec..231a1fe8b 100644 --- a/Tests/Qt4Targets/mywrapobject.h +++ b/Tests/Qt4Targets/mywrapobject.h @@ -6,7 +6,9 @@ #include "myinterface.h" -class MyWrapObject : public QObject, MyInterface +class MyWrapObject + : public QObject + , MyInterface { Q_OBJECT Q_INTERFACES(MyInterface) diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake index 86a989623..45798ce59 100644 --- a/Tests/RunCMake/Android/RunCMakeTest.cmake +++ b/Tests/RunCMake/Android/RunCMakeTest.cmake @@ -61,8 +61,12 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) list(APPEND _abis_${_version} ${_abis}) endif() endforeach() - set(_abis_ ${_abis_${_latest_gcc}}) set(_abis_clang ${_abis_${_latest_clang}}) + if(_latest_gcc) + set(_abis_ ${_abis_${_latest_gcc}}) + else() + set(_abis_ ${_abis_clang}) + endif() if(_versions MATCHES "clang") set(_versions "clang" ${_versions}) endif() @@ -88,12 +92,14 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) -DCMAKE_ANDROID_ARM_MODE=0 ) run_cmake(ndk-badarm) - set(RunCMake_TEST_OPTIONS - -DCMAKE_SYSTEM_NAME=Android - -DCMAKE_ANDROID_NDK=${ndk} - -DCMAKE_ANDROID_ARM_NEON=0 - ) - run_cmake(ndk-badneon) + if("armeabi" IN_LIST _abis_) + set(RunCMake_TEST_OPTIONS + -DCMAKE_SYSTEM_NAME=Android + -DCMAKE_ANDROID_NDK=${ndk} + -DCMAKE_ANDROID_ARM_NEON=0 + ) + run_cmake(ndk-badneon) + endif() set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=${ndk} @@ -130,10 +136,11 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) set(stl_types none system - gnustl_static - gnustl_shared ) + if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gnu-libstdc++") + list(APPEND stl_types gnustl_static gnustl_shared) + endif() if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gabi++/libs") list(APPEND stl_types gabi++_static gabi++_shared) endif() diff --git a/Tests/RunCMake/Android/android.cxx b/Tests/RunCMake/Android/android.cxx index 2dee8f9bd..a6d8c551d 100644 --- a/Tests/RunCMake/Android/android.cxx +++ b/Tests/RunCMake/Android/android.cxx @@ -1,19 +1,19 @@ #include "android.h" #ifndef STL_NONE -#include <cmath> -#include <cstdio> -#ifndef STL_SYSTEM -#include <exception> -#include <typeinfo> -#ifndef STL_STLPORT -#include <cxxabi.h> -#endif -#ifndef STL_GABI -#include <iostream> -#include <string> -#endif -#endif +# include <cmath> +# include <cstdio> +# ifndef STL_SYSTEM +# include <exception> +# include <typeinfo> +# ifndef STL_STLPORT +# include <cxxabi.h> +# endif +# ifndef STL_GABI +# include <iostream> +# include <string> +# endif +# endif #endif int main() @@ -30,19 +30,19 @@ int main() try { delete (new int); } catch (std::exception const& e) { -#if defined(STL_GABI) +# if defined(STL_GABI) e.what(); typeid(e).name(); -#else +# else std::cerr << e.what() << std::endl; std::cerr << typeid(e).name() << std::endl; -#endif +# endif } -#if defined(STL_GABI) +# if defined(STL_GABI) return 0; -#else +# else std::string s; return static_cast<int>(s.size()); -#endif +# endif #endif } diff --git a/Tests/RunCMake/Android/android.h b/Tests/RunCMake/Android/android.h index a5fd67e58..2c5cd9590 100644 --- a/Tests/RunCMake/Android/android.h +++ b/Tests/RunCMake/Android/android.h @@ -1,103 +1,103 @@ #ifndef __ANDROID__ -#error "__ANDROID__ not defined" +# error "__ANDROID__ not defined" #endif #include <android/api-level.h> #if API_LEVEL != __ANDROID_API__ -#error "API levels do not match" +# error "API levels do not match" #endif #ifdef COMPILER_IS_CLANG -#ifndef __clang__ -#error "COMPILER_IS_CLANG but __clang__ is not defined" -#endif +# ifndef __clang__ +# error "COMPILER_IS_CLANG but __clang__ is not defined" +# endif #else -#ifdef __clang__ -#error "!COMPILER_IS_CLANG but __clang__ is defined" -#endif +# ifdef __clang__ +# error "!COMPILER_IS_CLANG but __clang__ is defined" +# endif #endif #ifdef ARM_MODE -#if ARM_MODE == 1 && defined(__thumb__) -#error "ARM_MODE==1 but __thumb__ is defined" -#elif ARM_MODE == 0 && !defined(__thumb__) -#error "ARM_MODE==0 but __thumb__ is not defined" -#endif +# if ARM_MODE == 1 && defined(__thumb__) +# error "ARM_MODE==1 but __thumb__ is defined" +# elif ARM_MODE == 0 && !defined(__thumb__) +# error "ARM_MODE==0 but __thumb__ is not defined" +# endif #endif #ifdef ARM_NEON -#if ARM_NEON == 0 && defined(__ARM_NEON__) -#error "ARM_NEON==0 but __ARM_NEON__ is defined" -#elif ARM_NEON == 1 && !defined(__ARM_NEON__) -#error "ARM_NEON==1 but __ARM_NEON__ is not defined" -#endif +# if ARM_NEON == 0 && defined(__ARM_NEON__) +# error "ARM_NEON==0 but __ARM_NEON__ is defined" +# elif ARM_NEON == 1 && !defined(__ARM_NEON__) +# error "ARM_NEON==1 but __ARM_NEON__ is not defined" +# endif #endif #ifdef ABI_armeabi -#ifndef __ARM_EABI__ -#error "ABI_armeabi: __ARM_EABI__ not defined" -#endif -#if __ARM_ARCH != 5 -#error "ABI_armeabi: __ARM_ARCH is not 5" -#endif +# ifndef __ARM_EABI__ +# error "ABI_armeabi: __ARM_EABI__ not defined" +# endif +# if __ARM_ARCH != 5 +# error "ABI_armeabi: __ARM_ARCH is not 5" +# endif #endif #ifdef ABI_armeabi_v6 -#ifndef __ARM_EABI__ -#error "ABI_armeabi_v6: __ARM_EABI__ not defined" -#endif -#if __ARM_ARCH != 6 -#error "ABI_armeabi_v6: __ARM_ARCH is not 6" -#endif +# ifndef __ARM_EABI__ +# error "ABI_armeabi_v6: __ARM_EABI__ not defined" +# endif +# if __ARM_ARCH != 6 +# error "ABI_armeabi_v6: __ARM_ARCH is not 6" +# endif #endif #ifdef ABI_armeabi_v7a -#ifndef __ARM_EABI__ -#error "ABI_armeabi_v7a: __ARM_EABI__ not defined" -#endif -#if __ARM_ARCH != 7 -#error "ABI_armeabi_v7a: __ARM_ARCH is not 7" -#endif +# ifndef __ARM_EABI__ +# error "ABI_armeabi_v7a: __ARM_EABI__ not defined" +# endif +# if __ARM_ARCH != 7 +# error "ABI_armeabi_v7a: __ARM_ARCH is not 7" +# endif #endif #ifdef ABI_arm64_v8a -#ifdef __ARM_EABI__ -#error "ABI_arm64_v8a: __ARM_EABI__ defined" -#endif -#ifndef __aarch64__ -#error "ABI_arm64_v8a: __aarch64__ not defined" -#endif +# ifdef __ARM_EABI__ +# error "ABI_arm64_v8a: __ARM_EABI__ defined" +# endif +# ifndef __aarch64__ +# error "ABI_arm64_v8a: __aarch64__ not defined" +# endif #endif #ifdef ABI_mips -#if __mips != 32 -#error "ABI_mips: __mips != 32" -#endif -#ifndef _ABIO32 -#error "ABI_mips: _ABIO32 not defined" -#endif +# if __mips != 32 +# error "ABI_mips: __mips != 32" +# endif +# ifndef _ABIO32 +# error "ABI_mips: _ABIO32 not defined" +# endif #endif #ifdef ABI_mips64 -#if __mips != 64 -#error "ABI_mips64: __mips != 64" -#endif -#ifndef _ABI64 -#error "ABI_mips: _ABI64 not defined" -#endif +# if __mips != 64 +# error "ABI_mips64: __mips != 64" +# endif +# ifndef _ABI64 +# error "ABI_mips: _ABI64 not defined" +# endif #endif #ifdef ABI_x86 -#ifndef __i686__ -#error "ABI_x86: __i686__ not defined" -#endif +# ifndef __i686__ +# error "ABI_x86: __i686__ not defined" +# endif #endif #ifdef ABI_x86_64 -#ifndef __x86_64__ -#error "ABI_x86_64: __x86_64__ not defined" -#endif +# ifndef __x86_64__ +# error "ABI_x86_64: __x86_64__ not defined" +# endif #endif #include <stddef.h> diff --git a/Tests/RunCMake/Android/android_sysinc.c b/Tests/RunCMake/Android/android_sysinc.c index 18d73dbc8..f7cc6f026 100644 --- a/Tests/RunCMake/Android/android_sysinc.c +++ b/Tests/RunCMake/Android/android_sysinc.c @@ -1,7 +1,7 @@ #include <dlfcn.h> #ifndef NOT_SYSTEM_DLFCN_HEADER -#error "sysroot /usr/include appears too early" +# error "sysroot /usr/include appears too early" #endif #include "android.c" diff --git a/Tests/RunCMake/Android/android_sysinc.cxx b/Tests/RunCMake/Android/android_sysinc.cxx index 5c5694b8d..9379f1453 100644 --- a/Tests/RunCMake/Android/android_sysinc.cxx +++ b/Tests/RunCMake/Android/android_sysinc.cxx @@ -1,7 +1,7 @@ #include <dlfcn.h> #ifndef NOT_SYSTEM_DLFCN_HEADER -#error "sysroot /usr/include appears too early" +# error "sysroot /usr/include appears too early" #endif #include "android.cxx" diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index 015f2029e..aaa7c8919 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -8,7 +8,6 @@ endif() foreach(f "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}g++${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" - "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}cpp${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ar${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ld${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" ) @@ -61,10 +60,12 @@ execute_process( if(NOT _res EQUAL 0) message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}") endif() -if(NOT _out STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}") +string(REPLACE "--" "-" _out_check "${_out}") +if(NOT _out_check STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" + AND NOT (_out STREQUAL "arm--linux-android" AND CMAKE_C_ANDROID_TOOLCHAIN_MACHINE STREQUAL "arm-linux-androideabi")) message(SEND_ERROR "'gcc -dumpmachine' produced:\n" " ${_out}\n" - "which is not equal to CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" + "which does not match CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" ) endif() @@ -92,6 +93,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/Android/ndk-badvernum-stderr.txt b/Tests/RunCMake/Android/ndk-badvernum-stderr.txt index 25bbaf92c..adacaf160 100644 --- a/Tests/RunCMake/Android/ndk-badvernum-stderr.txt +++ b/Tests/RunCMake/Android/ndk-badvernum-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\): - Android: No toolchain for ABI 'armeabi' found in the NDK: + Android: No toolchain for ABI 'armeabi(-v7a)?' found in the NDK: .* diff --git a/Tests/RunCMake/AndroidMK/AndroidMK.cmake b/Tests/RunCMake/AndroidMK/AndroidMK.cmake index 2596e8c30..9137f2be6 100644 --- a/Tests/RunCMake/AndroidMK/AndroidMK.cmake +++ b/Tests/RunCMake/AndroidMK/AndroidMK.cmake @@ -4,8 +4,10 @@ add_library(foo foo.cxx) add_library(car foo.cxx) add_library(bar bar.c) add_library(dog foo.cxx) -target_link_libraries(foo car bar dog debug -lm) -export(TARGETS bar dog car foo ANDROID_MK +target_link_libraries(foo PRIVATE car bar dog debug -lm) +add_library(foo2 foo.cxx) +target_link_options(foo2 INTERFACE -lm) +export(TARGETS bar dog car foo foo2 ANDROID_MK ${build_BINARY_DIR}/Android.mk) -install(TARGETS bar dog car foo DESTINATION lib EXPORT myexp) +install(TARGETS bar dog car foo foo2 DESTINATION lib EXPORT myexp) install(EXPORT_ANDROID_MK myexp DESTINATION share/ndk-modules) diff --git a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt index bbf67a51c..a0e5044b1 100644 --- a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt +++ b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt @@ -24,3 +24,11 @@ LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_EXPORT_LDLIBS := -lm LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* +.* +include.*CLEAR_VARS.* +LOCAL_MODULE.*foo2 +LOCAL_SRC_FILES.*.*foo2.* +LOCAL_CPP_FEATURES.*rtti exceptions +LOCAL_EXPORT_LDFLAGS := -lm +LOCAL_HAS_CPP := true +include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt index 3515fb9e9..28b1c210e 100644 --- a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt +++ b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt @@ -26,3 +26,11 @@ LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_EXPORT_LDLIBS := -lm LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* + +include.*CLEAR_VARS.* +LOCAL_MODULE.*foo2 +LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo2.* +LOCAL_CPP_FEATURES.*rtti exceptions +LOCAL_EXPORT_LDFLAGS := -lm +LOCAL_HAS_CPP := true +include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake index f268de721..27a609dcb 100644 --- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -12,7 +12,7 @@ if("${RunCMake_GENERATOR}" MATCHES "Watcom WMake|Borland Makefiles") endif() # we build debug so the say.exe will be found in Debug/say.exe for # Visual Studio generators -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) set(INTDIR "Debug/") endif() # build AutoExport diff --git a/Tests/RunCMake/AutoExportDll/foo.c b/Tests/RunCMake/AutoExportDll/foo.c index 4b1318b9e..d13bc3ede 100644 --- a/Tests/RunCMake/AutoExportDll/foo.c +++ b/Tests/RunCMake/AutoExportDll/foo.c @@ -1,7 +1,7 @@ #ifdef _MSC_VER -#include "windows.h" +# include "windows.h" #else -#define WINAPI +# define WINAPI #endif int WINAPI foo() diff --git a/Tests/RunCMake/AutoExportDll/hello.h b/Tests/RunCMake/AutoExportDll/hello.h index 3749b976f..7192f65af 100644 --- a/Tests/RunCMake/AutoExportDll/hello.h +++ b/Tests/RunCMake/AutoExportDll/hello.h @@ -1,11 +1,11 @@ #ifndef _MSC_VER -#define winexport +# define winexport #else -#ifdef autoexport_EXPORTS -#define winexport -#else -#define winexport __declspec(dllimport) -#endif +# ifdef autoexport_EXPORTS +# define winexport +# else +# define winexport __declspec(dllimport) +# endif #endif class Hello diff --git a/Tests/RunCMake/AutoExportDll/say.cxx b/Tests/RunCMake/AutoExportDll/say.cxx index 51060e8de..c8bfcc7bd 100644 --- a/Tests/RunCMake/AutoExportDll/say.cxx +++ b/Tests/RunCMake/AutoExportDll/say.cxx @@ -1,9 +1,9 @@ #include "hello.h" #include <stdio.h> #ifdef _MSC_VER -#include "windows.h" +# include "windows.h" #else -#define WINAPI +# define WINAPI #endif extern "C" { diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake index ef3301216..87b0de010 100644 --- a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake @@ -11,7 +11,7 @@ endif() ]]) endif() -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/test.manifest\" ) diff --git a/Tests/RunCMake/BuildDepends/C-Exe.cmake b/Tests/RunCMake/BuildDepends/C-Exe.cmake index 5057ca91d..ad5cd4d47 100644 --- a/Tests/RunCMake/BuildDepends/C-Exe.cmake +++ b/Tests/RunCMake/BuildDepends/C-Exe.cmake @@ -2,7 +2,7 @@ enable_language(C) add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c\" ) diff --git a/Tests/RunCMake/BuildDepends/Custom-Always.cmake b/Tests/RunCMake/BuildDepends/Custom-Always.cmake index d412708a1..c7e7fb0bc 100644 --- a/Tests/RunCMake/BuildDepends/Custom-Always.cmake +++ b/Tests/RunCMake/BuildDepends/Custom-Always.cmake @@ -16,7 +16,7 @@ add_custom_command( add_custom_target(drive ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/after-always) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"${CMAKE_CURRENT_BINARY_DIR}/always-updated|${CMAKE_CURRENT_BINARY_DIR}/before-always\" \"${CMAKE_CURRENT_BINARY_DIR}/after-always|${CMAKE_CURRENT_BINARY_DIR}/always-updated\" diff --git a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake index 687c8271f..1e1f22ad0 100644 --- a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake +++ b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake @@ -16,7 +16,7 @@ add_custom_command( add_custom_target(drive ALL DEPENDS use-byproduct) add_dependencies(drive produce) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " if (check_step EQUAL 1) set(check_pairs \"${CMAKE_CURRENT_BINARY_DIR}/use-byproduct|${CMAKE_CURRENT_BINARY_DIR}/gen-byproduct-stamp\" diff --git a/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake b/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake index 0f92e0edb..8b2ae78cf 100644 --- a/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake +++ b/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake @@ -6,7 +6,7 @@ add_custom_command( add_custom_target(generate ALL DEPENDS output.cxx) set_property(TARGET generate PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " set(check_pairs \"${CMAKE_CURRENT_BINARY_DIR}/output.cxx|${CMAKE_CURRENT_BINARY_DIR}/MakeCustomIncludes.h\" ) diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake index add9aeb69..af6ad86ba 100644 --- a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake @@ -3,7 +3,7 @@ get_filename_component(include_dir "${CMAKE_BINARY_DIR}" PATH) include_directories("${include_dir}") add_executable(MakeInProjectOnly MakeInProjectOnly.c) set(CMAKE_DEPENDS_IN_PROJECT_ONLY 1) -file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " if (check_step EQUAL 1) set(check_pairs \"$<TARGET_FILE:MakeInProjectOnly>|${include_dir}/MakeInProjectOnly.h\" diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 9941c70df..14ae2439b 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -9,9 +9,11 @@ endif() function(run_BuildDepends CASE) # Use a single build tree for a few tests without cleaning. - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + if(NOT RunCMake_TEST_BINARY_DIR) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + endif() set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -32,7 +34,8 @@ endfunction() run_BuildDepends(C-Exe) if(NOT RunCMake_GENERATOR STREQUAL "Xcode") - if(RunCMake_GENERATOR MATCHES "Visual Studio 10") + if(RunCMake_GENERATOR MATCHES "Visual Studio 10" OR + RunCMake_GENERATOR_TOOLSET MATCHES "^(v80|v90|v100)$") # VS 10 forgets to re-link when a manifest changes set(run_BuildDepends_skip_step_2 1) endif() @@ -43,6 +46,18 @@ endif() run_BuildDepends(Custom-Symbolic-and-Byproduct) run_BuildDepends(Custom-Always) +# Test header dependencies with a build tree underneath a source tree. +set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource") +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource/build") +file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}/include") +foreach(f CMakeLists.txt BuildUnderSource.cmake BuildUnderSource.c) + configure_file("${RunCMake_SOURCE_DIR}/${f}" "${RunCMake_TEST_SOURCE_DIR}/${f}" COPYONLY) +endforeach() +run_BuildDepends(BuildUnderSource) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_SOURCE_DIR) + if(RunCMake_GENERATOR MATCHES "Make") run_BuildDepends(MakeCustomIncludes) if(NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}") diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt index 05b021746..6a1f1bde4 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt @@ -4,4 +4,4 @@ CMake Error at CMP0026-CONFIG-LOCATION-NEW.cmake:7 \(get_target_property\): expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt index edeb33728..84dec3212 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt @@ -7,4 +7,4 @@ specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt index d44dcb48d..d2209fdc8 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt @@ -8,5 +8,5 @@ CMake Warning \(dev\) at CMP0026-CONFIG-LOCATION-WARN.cmake:5 \(get_target_prope expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt index fec9dfb4d..1490103d5 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt @@ -4,4 +4,4 @@ CMake Error at CMP0026-LOCATION-CONFIG-NEW.cmake:7 \(get_target_property\): expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt index 32ff698f1..1fb4ef679 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt @@ -7,4 +7,4 @@ specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt index cd6f3d095..8b4faf011 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt @@ -8,5 +8,5 @@ CMake Warning \(dev\) at CMP0026-LOCATION-CONFIG-WARN.cmake:5 \(get_target_prope expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt index fa025129f..8c47c2ab3 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt @@ -4,4 +4,4 @@ CMake Error at CMP0026-NEW.cmake:7 \(get_target_property\): expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt index b3f79fc4d..b4282f545 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt @@ -7,4 +7,4 @@ specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt index d122c4a2e..0d39596b4 100644 --- a/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt @@ -8,7 +8,7 @@ CMake Warning \(dev\) at CMP0026-WARN.cmake:5 \(get_target_property\): expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. + CMake Warning \(dev\) at CMP0026-WARN.cmake:8 \(get_target_property\): @@ -21,5 +21,5 @@ CMake Warning \(dev\) at CMP0026-WARN.cmake:8 \(get_target_property\): expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt b/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt index 0996cb6b4..63779219a 100644 --- a/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt +++ b/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt @@ -8,5 +8,5 @@ CMake Warning \(dev\) at LOCATION-and-TARGET_OBJECTS.cmake:[0-9]+ \(get_target_p \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt index 87d198d00..360d98765 100644 --- a/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt +++ b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt @@ -8,5 +8,5 @@ CMake Warning \(dev\) at ObjlibNotDefined.cmake:[0-9]+ \(get_target_property\): expression \$<TARGET_FILE>, as appropriate. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt b/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt index 157a0468a..3525704bb 100644 --- a/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt +++ b/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt @@ -7,4 +7,4 @@ specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake index f4c070d7a..fd56e7566 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 NEW) add_library("lib:colon" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake index e9f640469..83a711909 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 NEW) add_library(all empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake index 9227986e9..2a288cc99 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 NEW) add_library("lib with spaces" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake index 870a28672..f52e4d2d0 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 OLD) add_library(all empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake index 46193a1fa..c9fb6c890 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) cmake_policy(SET CMP0037 OLD) add_library("lib with spaces" empty.cpp) diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake index 445e3b23e..1b1a405e8 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) add_library("lib:colon" empty.cpp) add_executable("exe:colon" empty.cpp) add_custom_target("custom:colon") diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake index e50a64dcf..e01b8e5ec 100644 --- a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake +++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake @@ -1,4 +1,4 @@ - +enable_language(CXX) add_library("lib with spaces" empty.cpp) add_executable("exe with spaces" empty.cpp) add_custom_target("custom with spaces") diff --git a/Tests/RunCMake/CMP0037/CMakeLists.txt b/Tests/RunCMake/CMP0037/CMakeLists.txt index f452db177..12cd3c775 100644 --- a/Tests/RunCMake/CMP0037/CMakeLists.txt +++ b/Tests/RunCMake/CMP0037/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 2.8.4) -project(${RunCMake_TEST} CXX) +project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake index b7d8d7bb4..98274f08b 100644 --- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -9,5 +9,22 @@ if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make")) run_cmake(CMP0037-WARN-colon) endif() +run_cmake(CMP0037-WARN-reserved) run_cmake(CMP0037-OLD-reserved) run_cmake(CMP0037-NEW-reserved) + +run_cmake(NEW-cond) +run_cmake(NEW-cond-test) +run_cmake(NEW-cond-package) +run_cmake(OLD-cond) +run_cmake(OLD-cond-test) +run_cmake(OLD-cond-package) +run_cmake(WARN-cond) +run_cmake(WARN-cond-test) +run_cmake(WARN-cond-package) + +if(RunCMake_GENERATOR MATCHES "Make|Ninja") + run_cmake(NEW-cond-package_source) + run_cmake(OLD-cond-package_source) + run_cmake(WARN-cond-package_source) +endif() diff --git a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt index e3e3ff468..70ed05ba1 100644 --- a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt +++ b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt @@ -1,8 +1,8 @@ CMake Warning \(dev\) at CMP0040-WARN-missing-target.cmake:2 \(add_custom_command\): Policy CMP0040 is not set: The target in the TARGET signature of - add_custom_command\(\) must exist. Run "cmake --help-policy CMP0040" for - policy details. Use the cmake_policy command to set the policy and - suppress this warning. + add_custom_command\(\) must exist and must be defined in the current + directory. Run "cmake --help-policy CMP0040" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + No TARGET 'foobar' has been created in this directory. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt index cc17f3371..e1c44e507 100644 --- a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt @@ -1 +1,12 @@ -^Sources: "empty.cpp"$ +^CMake Deprecation Warning at CMP0051-OLD.cmake:2 \(cmake_policy\): + The OLD behavior for policy CMP0051 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Sources: "empty.cpp"$ diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt index ae2e46848..78c6b6d30 100644 --- a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt @@ -9,7 +9,7 @@ CMake Warning \(dev\) at CMP0051-WARN.cmake:6 \(get_target_property\): needs to be adapted to ignore the generator expression using the string\(GENEX_STRIP\) command. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. Sources: "empty.cpp" @@ -25,7 +25,7 @@ CMake Warning \(dev\) at CMP0051-WARN.cmake:12 \(get_target_property\): needs to be adapted to ignore the generator expression using the string\(GENEX_STRIP\) command. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. Sources: "../empty.cpp"$ diff --git a/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt b/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt index 836b0ffe9..2a0ddbaaf 100644 --- a/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt @@ -1,2 +1,13 @@ -^called +^CMake Deprecation Warning at CMP0053-OLD.cmake:1 \(cmake_policy\): + The OLD behavior for policy CMP0053 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +called --><--$ diff --git a/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt index f5a8fbe6e..0500280cd 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt @@ -1 +1,10 @@ -$^ +^CMake Deprecation Warning at CMP0054-OLD.cmake:1 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt index f5a8fbe6e..60303cd86 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt @@ -1 +1,10 @@ -$^ +^CMake Deprecation Warning at CMP0054-keywords-OLD.cmake:1 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt index f5a8fbe6e..1b354728d 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt @@ -1 +1,10 @@ -$^ +^CMake Deprecation Warning at CMP0054-policy-command-scope.cmake:25 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt index f5a8fbe6e..4eac90eed 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt @@ -1 +1,54 @@ -$^ +^CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:14 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:14 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:27 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:48 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:48 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt index f5a8fbe6e..a2dd62e4a 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt @@ -1 +1,10 @@ -$^ +^CMake Deprecation Warning at CMP0054-policy-nested-if.cmake:23 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt index f5a8fbe6e..718904d39 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt @@ -1 +1,54 @@ -$^ +^CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:16 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:16 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:37 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:58 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:58 \(cmake_policy\): + The OLD behavior for policy CMP0054 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CMP0060/CMP0060-Common.cmake b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake index e0a56e68c..06955eeba 100644 --- a/Tests/RunCMake/CMP0060/CMP0060-Common.cmake +++ b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake @@ -1,6 +1,7 @@ # Always build in a predictable configuration. For multi-config # generators we depend on RunCMakeTest.cmake to do this for us. -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt index f6cc97854..e2c280ee7 100644 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt @@ -12,5 +12,5 @@ will ask the linker to search for these by library name. Call Stack \(most recent call first\): CMP0060-WARN-ON.cmake:[0-9]+ \(include\) - CMakeLists.txt:3 \(include\) + CMakeLists.txt:4 \(include\) This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0060/CMakeLists.txt b/Tests/RunCMake/CMP0060/CMakeLists.txt index db6b701c0..291d34d43 100644 --- a/Tests/RunCMake/CMP0060/CMakeLists.txt +++ b/Tests/RunCMake/CMP0060/CMakeLists.txt @@ -1,3 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.9) +cmake_policy(VERSION 3.2) project(${RunCMake_TEST} C) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt index ddb3cae61..87ac88e62 100644 --- a/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt +++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at CMP0069-NEW-cmake\.cmake:[0-9]+ \(add_executable\): CMake doesn't support IPO for current compiler Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt index 8decfab3c..cb9d19b47 100644 --- a/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt +++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at CMP0069-NEW-compiler\.cmake:[0-9]+ \(add_executable\): Compiler doesn't support IPO Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt index 0e05ee783..1159ec043 100644 --- a/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt +++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt @@ -1,4 +1,6 @@ ^CMake Error at CMP0069-NEW-generator\.cmake:[0-9]+ \(add_executable\): CMake doesn't support IPO for current generator Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/CMP0069/RunCMakeTest.cmake b/Tests/RunCMake/CMP0069/RunCMakeTest.cmake index f44f84002..456e6a656 100644 --- a/Tests/RunCMake/CMP0069/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0069/RunCMakeTest.cmake @@ -5,6 +5,6 @@ run_cmake(CMP0069-NEW-cmake) run_cmake(CMP0069-NEW-compiler) run_cmake(CMP0069-WARN) -if(RunCMake_GENERATOR MATCHES "^Visual Studio ") +if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") run_cmake(CMP0069-NEW-generator) endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 79f487d41..69f816215 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -1,5 +1,8 @@ # See adjacent README.rst for documentation of this test infrastructure. +# Note that the _isMultiConfig variable is set in the parent directory's +# CMakeLists.txt (slightly complex logic to support CMake versions before 3.9) + macro(add_RunCMake_test test) set(TEST_ARGS ${ARGN}) if ("${ARGV1}" STREQUAL "TEST_DIR") @@ -14,7 +17,9 @@ macro(add_RunCMake_test test) endif() add_test(NAME RunCMake.${test} COMMAND ${CMAKE_CMAKE_COMMAND} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} + -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig} -DRunCMake_GENERATOR=${CMAKE_GENERATOR} + -DRunCMake_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE} -DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} @@ -37,7 +42,12 @@ function(add_RunCMake_test_group test types) # much system information so it is easier to set programs and environment # values here unset(${test}_${type}_FOUND_PREREQUIREMENTS) - include("${CMAKE_CURRENT_SOURCE_DIR}/${test}/${type}/Prerequirements.cmake") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test}/${type}/Prerequirements.cmake") + include("${CMAKE_CURRENT_SOURCE_DIR}/${test}/${type}/Prerequirements.cmake") + else() + string(REGEX MATCH "^[^.]*" main_type "${type}") + include("${CMAKE_CURRENT_SOURCE_DIR}/${test}/${main_type}/Prerequirements.cmake") + endif() get_test_prerequirements("${test}_${type}_FOUND_PREREQUIREMENTS" "${TEST_CONFIG_DIR}/${type}_config.cmake") @@ -46,7 +56,9 @@ function(add_RunCMake_test_group test types) add_test(NAME RunCMake.${test}_${type} COMMAND ${CMAKE_CMAKE_COMMAND} -DTEST_TYPE=${type} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} + -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig} -DRunCMake_GENERATOR=${CMAKE_GENERATOR} + -DRunCMake_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE} -DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} @@ -59,6 +71,9 @@ function(add_RunCMake_test_group test types) endforeach() endfunction() +# Some tests use python for extra checks. +find_package(PythonInterp QUIET) + if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 6.1) set(Swift_ARGS -DXCODE_BELOW_6_1=1) endif() @@ -99,6 +114,7 @@ if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) add_RunCMake_test(CMP0068) endif() add_RunCMake_test(CMP0069) +add_RunCMake_test(CMP0081) # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode @@ -107,13 +123,16 @@ if(NOT CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") add_RunCMake_test(CMP0065) endif() if(CMAKE_GENERATOR MATCHES "Make") - add_RunCMake_test(Make) + add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU}) endif() if(CMAKE_GENERATOR STREQUAL "Ninja") set(Ninja_ARGS -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) @@ -131,8 +150,20 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() add_RunCMake_test(AndroidTestUtilities) +set(autogen_with_qt5 FALSE) +if(CMake_TEST_Qt5) + find_package(Qt5Widgets QUIET NO_MODULE) +endif() +if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) + set(autogen_with_qt5 TRUE) +endif () +add_RunCMake_test(Autogen -Dwith_qt5=${autogen_with_qt5}) add_RunCMake_test(BuildDepends) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") + add_RunCMake_test(Byproducts) +endif() +add_RunCMake_test(CMakeRoleGlobalProperty) +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) endif() add_RunCMake_test(CompilerNotFound) @@ -141,21 +172,40 @@ add_RunCMake_test(DisallowedCommands) add_RunCMake_test(ExternalData) add_RunCMake_test(FeatureSummary) add_RunCMake_test(FPHSA) +add_RunCMake_test(FileAPI -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) +add_RunCMake_test(FindBoost) +add_RunCMake_test(FindLua) +add_RunCMake_test(FindOpenGL) +if(CMake_TEST_UseSWIG) + add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython=${CMake_TEST_FindPython}) +endif() if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom") add_RunCMake_test(GenerateExportHeader) endif() add_RunCMake_test(GeneratorExpression) +add_RunCMake_test(GeneratorInstance) add_RunCMake_test(GeneratorPlatform) add_RunCMake_test(GeneratorToolset) +add_RunCMake_test(GetPrerequisites) add_RunCMake_test(GNUInstallDirs -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) +if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") + add_RunCMake_test(MetaCompileFeatures) +endif() +if(MSVC) + add_RunCMake_test(MSVCRuntimeLibrary) + add_RunCMake_test(MSVCWarningFlags) +endif() add_RunCMake_test(ObjectLibrary) +add_RunCMake_test(ParseImplicitIncludeInfo) if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") add_RunCMake_test(RuntimePath) endif() -add_RunCMake_test(Swift) +add_RunCMake_test(ScriptMode) +add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER}) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) add_RunCMake_test(ToolchainFile) @@ -163,9 +213,12 @@ add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) add_RunCMake_test(CompileFeatures) add_RunCMake_test(PolicyScope) +add_RunCMake_test(WriteBasicConfigVersionFile) add_RunCMake_test(WriteCompilerDetectionHeader) +add_RunCMake_test(SourceProperties) if(NOT WIN32) - add_RunCMake_test(PositionIndependentCode) + add_RunCMake_test(PositionIndependentCode -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}) endif() if(NOT CMAKE_GENERATOR MATCHES "Visual Studio") add_RunCMake_test(VisibilityPreset) @@ -175,14 +228,20 @@ if (QT4_FOUND) endif() add_RunCMake_test(CompatibleInterface) add_RunCMake_test(Syntax) +add_RunCMake_test(WorkingDirectory) +add_RunCMake_test(MaxRecursionDepth) add_RunCMake_test(add_custom_command) add_RunCMake_test(add_custom_target) add_RunCMake_test(add_dependencies) +add_RunCMake_test(add_executable) +add_RunCMake_test(add_library) add_RunCMake_test(add_subdirectory) add_RunCMake_test(build_command) +add_executable(exit_code exit_code.c) +set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>) if(NOT CMake_TEST_EXTERNAL_CMAKE) - set(execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>) + list(APPEND execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>) endif() add_RunCMake_test(execute_process) add_RunCMake_test(export) @@ -200,6 +259,7 @@ add_RunCMake_test(ctest_submit) add_RunCMake_test(ctest_test) add_RunCMake_test(ctest_disabled_test) add_RunCMake_test(ctest_skipped_test) +add_RunCMake_test(ctest_update) add_RunCMake_test(ctest_upload) add_RunCMake_test(ctest_fixtures) add_RunCMake_test(file) @@ -208,33 +268,60 @@ add_RunCMake_test(find_library) add_RunCMake_test(find_package) add_RunCMake_test(find_path) add_RunCMake_test(find_program -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(foreach) add_RunCMake_test(get_filename_component) add_RunCMake_test(get_property) add_RunCMake_test(if) add_RunCMake_test(include) add_RunCMake_test(include_directories) +add_RunCMake_test(include_guard) add_RunCMake_test(list) +add_RunCMake_test(math) add_RunCMake_test(message) +add_RunCMake_test(option) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) +add_RunCMake_test(project_injected) add_RunCMake_test(return) add_RunCMake_test(separate_arguments) add_RunCMake_test(set_property) add_RunCMake_test(string) -foreach(var - CMAKE_C_COMPILER_ID - CMAKE_C_COMPILER_VERSION - CMAKE_C_STANDARD_DEFAULT - CMAKE_CXX_COMPILER_ID - CMAKE_CXX_COMPILER_VERSION - CMAKE_CXX_STANDARD_DEFAULT - CMake_TEST_CUDA - ) - if(DEFINED ${var}) - list(APPEND try_compile_ARGS -D${var}=${${var}}) +add_RunCMake_test(test_include_dirs) +add_RunCMake_test(BundleUtilities) + +function(add_RunCMake_test_try_compile) + if(CMAKE_VERSION VERSION_LESS 3.9.20170907 AND "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + # Older CMake versions do not know about MSVC language standards. + # Approximate our logic from MSVC-CXX.cmake. + if ((NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.24215.1 AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR + NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10.25017) + set(CMAKE_CXX_STANDARD_DEFAULT 14) + elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) + set(CMAKE_CXX_STANDARD_DEFAULT "") + else() + unset(CMAKE_CXX_STANDARD_DEFAULT) + endif() endif() -endforeach() -add_RunCMake_test(try_compile) -add_RunCMake_test(try_run) + foreach(var + CMAKE_SYSTEM_NAME + CMAKE_C_COMPILER_ID + CMAKE_C_COMPILER_VERSION + CMAKE_C_STANDARD_DEFAULT + CMAKE_CXX_COMPILER_ID + CMAKE_CXX_COMPILER_VERSION + CMAKE_CXX_STANDARD_DEFAULT + CMake_TEST_CUDA + ) + if(DEFINED ${var}) + list(APPEND try_compile_ARGS -D${var}=${${var}}) + endif() + endforeach() + add_RunCMake_test(try_compile) +endfunction() +add_RunCMake_test_try_compile() + +add_RunCMake_test(try_run -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test(set) add_RunCMake_test(variable_watch) add_RunCMake_test(while) @@ -260,25 +347,37 @@ if(PKG_CONFIG_FOUND) add_RunCMake_test(FindPkgConfig) endif() -find_package(GTK2 QUIET) -if (GTK2_FOUND) +if(CMake_TEST_FindGTK2) add_RunCMake_test(FindGTK2) endif() 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) + add_RunCMake_test(include_external_msproject -DVS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME}) + 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])") - add_RunCMake_test(VS10Project) +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^9]|9[0-9])") + add_RunCMake_test(VS10Project + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + ) + if( vs12 AND wince ) + add_RunCMake_test( VS10ProjectWinCE "-DRunCMake_GENERATOR_PLATFORM=${wince_sdk}") + endif() endif() if(XCODE_VERSION) add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION}) + + # This test can take a very long time due to lots of combinations. + # Use a long default timeout and provide an option to customize it. + if(NOT DEFINED CMake_TEST_XcodeProject_TIMEOUT) + set(CMake_TEST_XcodeProject_TIMEOUT 2000) + endif() + set_property(TEST RunCMake.XcodeProject PROPERTY TIMEOUT ${CMake_TEST_XcodeProject_TIMEOUT}) endif() if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" @@ -288,19 +387,40 @@ endif() add_RunCMake_test(File_Generate) add_RunCMake_test(ExportWithoutLanguage) +add_RunCMake_test(target_link_directories) add_RunCMake_test(target_link_libraries) +add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) +add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) +add_RunCMake_test(target_compile_definitions) add_RunCMake_test(target_compile_features) +add_RunCMake_test(target_compile_options) +add_RunCMake_test(target_include_directories) +add_RunCMake_test(target_sources) add_RunCMake_test(CheckModules) add_RunCMake_test(CheckIPOSupported) add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(CommandLineTar) -add_RunCMake_test(install) +if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)) + set(NO_NAMELINK 1) +else() + set(NO_NAMELINK 0) +endif() + +add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN}) +add_RunCMake_test(CPackCommandLine) add_RunCMake_test(CPackConfig) add_RunCMake_test(CPackInstallProperties) add_RunCMake_test(ExternalProject) -add_RunCMake_test(CTestCommandLine) +add_RunCMake_test(FetchContent) +set(CTestCommandLine_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + list(APPEND CTestCommandLine_ARGS -DTEST_AFFINITY=$<TARGET_FILE:testAffinity>) +endif() +add_executable(print_stdin print_stdin.c) +add_RunCMake_test(CTestCommandLine -DTEST_PRINT_STDIN=$<TARGET_FILE:print_stdin>) +add_RunCMake_test(CacheNewline) # Only run this test on unix platforms that support # symbolic links if(UNIX) @@ -313,18 +433,26 @@ add_RunCMake_test(IfacePaths_INCLUDE_DIRECTORIES TEST_DIR IfacePaths) set(IfacePaths_SOURCES_ARGS -DTEST_PROP=SOURCES) add_RunCMake_test(IfacePaths_SOURCES TEST_DIR IfacePaths) -add_RunCMake_test(COMPILE_LANGUAGE-genex) - # Matlab module related tests -if(CMake_TEST_FindMatlab) - add_RunCMake_test(FindMatlab) +if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "")) + set(FindMatlab_additional_test_options ) + if(CMake_TEST_FindMatlab_MCR OR NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "") + set(FindMatlab_additional_test_options -DIS_MCR=TRUE) + endif() + if(NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "") + set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMCR_ROOT:FILEPATH=${CMake_TEST_FindMatlab_MCR_ROOT_DIR}") + endif() + + add_RunCMake_test(FindMatlab ${FindMatlab_additional_test_options}) endif() add_executable(pseudo_emulator pseudo_emulator.c) add_executable(pseudo_emulator_custom_command pseudo_emulator_custom_command.c) +add_executable(pseudo_emulator_custom_command_arg pseudo_emulator_custom_command_arg.c) add_RunCMake_test(CrosscompilingEmulator -DPSEUDO_EMULATOR=$<TARGET_FILE:pseudo_emulator> - -DPSEUDO_EMULATOR_CUSTOM_COMMAND=$<TARGET_FILE:pseudo_emulator_custom_command>) + -DPSEUDO_EMULATOR_CUSTOM_COMMAND=$<TARGET_FILE:pseudo_emulator_custom_command> + -DPSEUDO_EMULATOR_CUSTOM_COMMAND_ARG=$<TARGET_FILE:pseudo_emulator_custom_command_arg>) if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") if(UNIX AND NOT CYGWIN) execute_process(COMMAND ldd --help @@ -338,13 +466,74 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") add_executable(pseudo_tidy pseudo_tidy.c) add_executable(pseudo_iwyu pseudo_iwyu.c) add_executable(pseudo_cpplint pseudo_cpplint.c) + add_executable(pseudo_cppcheck pseudo_cppcheck.c) add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>) add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>) add_RunCMake_test(Cpplint -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint>) + add_RunCMake_test(Cppcheck -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck>) + add_RunCMake_test(MultiLint + -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy> + -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu> + -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint> + -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck> + ) + if(DEFINED CMake_TEST_CUDA) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + endif() + if(CMAKE_Fortran_COMPILER) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_Fortran=1) + endif() add_RunCMake_test(CompilerLauncher) + add_RunCMake_test(ctest_labels_for_subprojects) endif() -add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ") +set(cpack_tests + DEB.CUSTOM_NAMES + DEB.DEBUGINFO + DEB.DEFAULT_PERMISSIONS + DEB.DEPENDENCIES + DEB.EMPTY_DIR + DEB.VERSION + DEB.EXTRA + DEB.GENERATE_SHLIBS + DEB.GENERATE_SHLIBS_LDCONFIG + DEB.LONG_FILENAMES + DEB.MINIMAL + DEB.PER_COMPONENT_FIELDS + DEB.TIMESTAMPS + DEB.MD5SUMS + DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY + + RPM.CUSTOM_BINARY_SPEC_FILE + RPM.CUSTOM_NAMES + RPM.DEBUGINFO + RPM.DEFAULT_PERMISSIONS + RPM.DEPENDENCIES + RPM.DIST + RPM.EMPTY_DIR + RPM.VERSION + RPM.INSTALL_SCRIPTS + RPM.MAIN_COMPONENT + RPM.MINIMAL + RPM.PARTIALLY_RELOCATABLE_WARNING + RPM.PER_COMPONENT_FIELDS + RPM.SINGLE_DEBUGINFO + RPM.EXTRA_SLASH_IN_PATH + RPM.SOURCE_PACKAGE + RPM.SUGGESTS + RPM.SYMLINKS + RPM.USER_FILELIST + + 7Z + TBZ2 + TGZ + TXZ + TZ + ZIP + STGZ + External + ) +add_RunCMake_test_group(CPack "${cpack_tests}") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used add_RunCMake_test(AutoExportDll) @@ -371,3 +560,8 @@ if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN) endif() set_property(TEST RunCMake.Android PROPERTY TIMEOUT ${CMake_TEST_ANDROID_TIMEOUT}) endif() + +if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|9[0-9])") + add_RunCMake_test(CSharpCustomCommand) + add_RunCMake_test(CSharpReferenceImport) +endif() diff --git a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake index 99d3155dd..948c6ab15 100644 --- a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake +++ b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake @@ -45,13 +45,22 @@ function(toExpectedContentList FILE_NO CONTENT_VAR) unset(prefix_) endif() - if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) - set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + # add install prefix to expected paths + if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX) + set(EXPECTED_FILE_PACKAGING_PREFIX + "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}") + elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX) + # default CPack Archive packaging install prefix + set(EXPECTED_FILE_PACKAGING_PREFIX "/") endif() + set(prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}") + foreach(part_ IN LISTS ${CONTENT_VAR}) + list(APPEND prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}${part_}") + endforeach() unset(filtered_) - foreach(part_ IN LISTS ${CONTENT_VAR}) - string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + foreach(part_ IN LISTS prepared_) + string(REGEX REPLACE "^/" "" part_ "${part_}") if(part_) list(APPEND filtered_ "${prefix_}${part_}") diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index c361af065..1b3dbb228 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -15,3 +15,7 @@ include(tests/${RunCMake_TEST_FILE_PREFIX}/test.cmake) set(CPACK_GENERATOR "${GENERATOR_TYPE}") include(CPack) + +if(COMMAND run_after_include_cpack) + run_after_include_cpack() +endif() diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index f883c69e5..f65cb9df8 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -1,10 +1,15 @@ cmake_policy(SET CMP0057 NEW) -function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE) +function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE package_target) if(TEST_TYPE IN_LIST types) + string(REGEX MATCH "^[^.]*" GENERATOR_TYPE "${TEST_TYPE}") set(RunCMake_TEST_NO_CLEAN TRUE) - set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build") - set(full_test_name_ "${TEST_NAME}") + if(package_target) + set(full_test_name_ "${TEST_NAME}-package-target") + else() + set(full_test_name_ "${TEST_NAME}") + endif() + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${full_test_name_}-build") if(SUBTEST_SUFFIX) set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_BINARY_DIR}-${SUBTEST_SUFFIX}-subtest") @@ -17,8 +22,8 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - if(EXISTS "${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake") - include("${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake") + if(EXISTS "${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-Prerequirements.cmake") + include("${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-Prerequirements.cmake") set(FOUND_PREREQUIREMENTS false) get_test_prerequirements("FOUND_PREREQUIREMENTS" "${config_file}") @@ -31,28 +36,55 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK endif() # execute cmake - set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}" + set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${GENERATOR_TYPE}" "-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}" "-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}" "-DPACKAGING_TYPE=${PACKAGING_TYPE}") + + foreach(o out err) + if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-std${o}.txt") + else() + unset(RunCMake-std${o}-file) + endif() + endforeach() + run_cmake(${full_test_name_}) # execute optional build step if(build) + unset(RunCMake-stdout-file) + unset(RunCMake-stderr-file) run_cmake_command(${full_test_name_}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}") endif() if(source) - set(pack_params_ -G ${TEST_TYPE} --config ./CPackSourceConfig.cmake) + set(pack_params_ -G ${GENERATOR_TYPE} --config ./CPackSourceConfig.cmake) FILE(APPEND ${RunCMake_TEST_BINARY_DIR}/CPackSourceConfig.cmake - "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_} -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME} -DGENERATOR_TYPE:STRING=${TEST_TYPE}\")") + "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_} -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME} -DGENERATOR_TYPE:STRING=${GENERATOR_TYPE}\")") else() unset(pack_params_) endif() + if(package_target) + set(cpack_command_ ${CMAKE_COMMAND} --build "${RunCMake_TEST_BINARY_DIR}" --target package) + else() + set(cpack_command_ ${CMAKE_CPACK_COMMAND} ${pack_params_}) + endif() + # execute cpack + set(SETENV) + if(ENVIRONMENT) + set(SETENV ${CMAKE_COMMAND} -E env "${ENVIRONMENT}") + endif() execute_process( - COMMAND ${CMAKE_CPACK_COMMAND} ${pack_params_} + COMMAND ${SETENV} ${cpack_command_} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" RESULT_VARIABLE "result_" OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt" @@ -60,27 +92,31 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK ) foreach(o out err) - if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) - set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") - elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt) - set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt") - elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) - set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") - elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt) - set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt") - elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/default_expected_std${o}.txt) - set(RunCMake-std${o}-file "${TEST_TYPE}/default_expected_std${o}.txt") + if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-std${o}.txt") + elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-std${o}.txt") + elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/${GENERATOR_TYPE}/default_expected_std${o}.txt) + set(RunCMake-std${o}-file "${GENERATOR_TYPE}/default_expected_std${o}.txt") + else() + unset(RunCMake-std${o}-file) endif() endforeach() # verify result run_cmake_command( - ${TEST_TYPE}/${full_test_name_} + ${GENERATOR_TYPE}/${full_test_name_} "${CMAKE_COMMAND}" -DRunCMake_TEST=${full_test_name_} -DRunCMake_TEST_FILE_PREFIX=${TEST_NAME} -DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX} - -DGENERATOR_TYPE=${TEST_TYPE} + -DGENERATOR_TYPE=${GENERATOR_TYPE} -DPACKAGING_TYPE=${PACKAGING_TYPE} "-Dsrc_dir=${RunCMake_SOURCE_DIR}" "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}" @@ -92,18 +128,24 @@ endfunction() function(run_cpack_test TEST_NAME types build PACKAGING_TYPES) foreach(packaging_type_ IN LISTS PACKAGING_TYPES) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}") + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}" false) + endforeach() +endfunction() + +function(run_cpack_test_package_target TEST_NAME types build PACKAGING_TYPES) + foreach(packaging_type_ IN LISTS PACKAGING_TYPES) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}" true) endforeach() endfunction() function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build PACKAGING_TYPES) foreach(suffix_ IN LISTS SUBTEST_SUFFIXES) foreach(packaging_type_ IN LISTS PACKAGING_TYPES) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}") + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}" false) endforeach() endforeach() endfunction() function(run_cpack_source_test TEST_NAME types) - run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "") + run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "" false) endfunction() diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index ad1b47bdc..9b98ed41f 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -1,7 +1,7 @@ -set(ALL_FILES_GLOB "*.deb") +set(ALL_FILES_GLOB "*.deb" "*.ddeb") function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}" + execute_process(COMMAND ${CMAKE_COMMAND} -E env TZ=Etc/UTC ${DPKG_EXECUTABLE} -c "${FILE}" OUTPUT_VARIABLE package_content_ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -23,7 +23,7 @@ function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_V endif() if(GENERATOR_SPECIFIC_FORMAT) - set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}-${REVISION}_*.deb" PARENT_SCOPE) + set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}_*.deb" PARENT_SCOPE) else() set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.deb" PARENT_SCOPE) endif() @@ -47,7 +47,20 @@ function(getPackageContentList FILE RESULT_VAR) endfunction() function(toExpectedContentList FILE_NO CONTENT_VAR) - # no need to do anything + # add install prefix to expected paths + if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX) + set(EXPECTED_FILE_PACKAGING_PREFIX + "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}") + elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX) + # default CPackDeb packaging install prefix + set(EXPECTED_FILE_PACKAGING_PREFIX "/usr") + endif() + set(prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}") + foreach(part_ IN LISTS ${CONTENT_VAR}) + list(APPEND prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}${part_}") + endforeach() + + set(${CONTENT_VAR} "${prepared_}" PARENT_SCOPE) endfunction() function(getMissingShlibsErrorExtra FILE RESULT_VAR) diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index 7c98f6972..216512505 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -91,6 +91,19 @@ If test will be used for multiple generators but some of them require some generator specific commands then those commands should be added to 'test.cmake' script wrapped with 'if(GENERATOR_TYPE STREQUAL <name_of_the_generator>)'. +NOTE: In some cases (for example when testing CPackComponent.cmake functions) +the test has to run some functions after CPack.cmake is included. In such cases +a function run_after_include_cpack can be declared in test.cmake file and that +function will run after the inclusion of CPack.cmake. + +NOTE: During CMake configure stage developer warnings may be expected. In such +cases an expected output regular expression can be provided by creating +'<test_name>/configure-stdout.txt' and/or '<test_name>/configure-stderr.txt' +file. There are also more specialized versions of the file available: +- configure-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt +- configure-${SUBTEST_SUFFIX}-std${o}.txt +- configure-${PACKAGING_TYPE}-std${o}.txt + build phase (optional and not available for source package tests) ----------------------------------------------------------------- @@ -144,17 +157,23 @@ this step and must contain NOTE: This variable should be used only as last resort as it sets generator specific regular expression. EXPECTED_FILE_CONTENT_<file_number_starting_with_1>_LIST should be - prefered as it requires a list of expected files and directories that + preferred as it requires a list of expected files and directories that is later changed automatically depending on the generator so expected package content can be written only once per test for all generators. -Optional verification phase is generator specific and is optionaly executed. +- EXPECTED_FILE_PACKAGING_PREFIX and + EXPECTED_FILE_<file_number_starting_with_1>_PACKAGING_PREFIX variables can be + set to explicitly specified CPACK_PACKAGING_PREFIX value. By default this + variable does not need to be set as it is implicitly set to package generator + specific prefix. + +Optional verification phase is generator specific and is optionally executed. This phase is executed if '<test_name>/VerifyResult.cmake' script exists. VerifyResult.cmake script also automatically prints out standard output and standard error from CPack execution phase that is compared with '<test_name>/<generator_name>-stdout.txt' regular expression and -and '<test_name>/<generator_name>-stderr.txt' regular expresson respectively. +'<test_name>/<generator_name>-stderr.txt' regular expresson respectively. NOTE: For subtests generator name can also be suffixed with subtest name and/or packaging type (MONOLITHIC, COMPONENT, GROUP) and in such cases the preferences of which file will be used are as follows: @@ -162,6 +181,7 @@ NOTE: For subtests generator name can also be suffixed with subtest name and/or - generator name + packaging type - generator name + subtest name - generator name + - subtest name - default generator File name format: '<generator_name>-<packaging_type>-<subtest_name>-std<type>.txt' where <type> can either be 'out' or 'err'. @@ -204,7 +224,7 @@ To add a new generator we must + FILE that will contain the package file for which the package content should be returned. + RESULT_VAR that will tell the function which variable in parent scope - should contain the result (list of pacakge content) + should contain the result (list of package content) - toExpectedContentList: This function should convert an expected package content list into one that is expected for the generator (e.g. rpm packages have install/relocate diff --git a/Tests/RunCMake/CPack/RPM/Helpers.cmake b/Tests/RunCMake/CPack/RPM/Helpers.cmake index d8012b11b..a29c02065 100644 --- a/Tests/RunCMake/CPack/RPM/Helpers.cmake +++ b/Tests/RunCMake/CPack/RPM/Helpers.cmake @@ -23,6 +23,9 @@ function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_V endif() if(GENERATOR_SPECIFIC_FORMAT) + if(NOT REVISION) + set(REVISION "1") + endif() set(${RESULT_VAR} "${NAME}${COMPONENT}-${VERSION}-${REVISION}.*.rpm" PARENT_SCOPE) else() set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.rpm" PARENT_SCOPE) @@ -44,14 +47,29 @@ function(getPackageContentList FILE RESULT_VAR) endfunction() function(toExpectedContentList FILE_NO CONTENT_VAR) - if(NOT DEFINED TEST_INSTALL_PREFIX_PATHS) - set(TEST_INSTALL_PREFIX_PATHS "/usr") + # add install prefix to expected paths + if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX) + set(EXPECTED_FILE_PACKAGING_PREFIX + "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}") + elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX) + # default CPackRPM packaging install prefix + set(EXPECTED_FILE_PACKAGING_PREFIX "/usr") endif() + set(prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}") + foreach(part_ IN LISTS ${CONTENT_VAR}) + list(APPEND prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}${part_}") + endforeach() + # remove paths that are excluded from auto packaging + if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST + /etc /etc/init.d /usr /usr/bin /usr/include /usr/lib + /usr/libx32 /usr/lib64 /usr/share /usr/share/aclocal /usr/share/doc) + endif() unset(filtered_) - foreach(part_ IN LISTS ${CONTENT_VAR}) + foreach(part_ IN LISTS prepared_) unset(dont_add_) - foreach(for_removal_ IN LISTS TEST_INSTALL_PREFIX_PATHS) + foreach(for_removal_ IN LISTS CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) if(part_ STREQUAL for_removal_) set(dont_add_ TRUE) break() diff --git a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt index 4a0e4e6d0..6c87ca0c0 100644 --- a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt +++ b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt @@ -1 +1 @@ -^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$ +^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM\.[^/]*/CPack/[^-]*(-package-target)?-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$ diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index faf151a13..37df57cd0 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -4,26 +4,35 @@ include(RunCMake) include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") # run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" -run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM" false "MONOLITHIC;COMPONENT") -run_cpack_test(CUSTOM_NAMES "RPM;DEB;TGZ" true "COMPONENT") -run_cpack_test(DEBUGINFO "RPM" true "COMPONENT") -run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT") -run_cpack_test(DIST "RPM" false "MONOLITHIC") -run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true "MONOLITHIC;COMPONENT") -run_cpack_test(EXTRA "DEB" false "COMPONENT") -run_cpack_test(GENERATE_SHLIBS "DEB" true "COMPONENT") -run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") -run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") -run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") -run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT") +run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM.CUSTOM_BINARY_SPEC_FILE" false "MONOLITHIC;COMPONENT") +run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ" true "COMPONENT") +run_cpack_test(DEBUGINFO "RPM.DEBUGINFO;DEB.DEBUGINFO" true "COMPONENT") +run_cpack_test_subtests(DEFAULT_PERMISSIONS "CMAKE_var_set;CPACK_var_set;both_set;invalid_CMAKE_var;invalid_CPACK_var" "RPM.DEFAULT_PERMISSIONS;DEB.DEFAULT_PERMISSIONS" false "MONOLITHIC;COMPONENT") +run_cpack_test(DEPENDENCIES "RPM.DEPENDENCIES;DEB.DEPENDENCIES" true "COMPONENT") +run_cpack_test(DIST "RPM.DIST" false "MONOLITHIC") +run_cpack_test(EMPTY_DIR "RPM.EMPTY_DIR;DEB.EMPTY_DIR;TGZ" true "MONOLITHIC;COMPONENT") +run_cpack_test(VERSION "RPM.VERSION;DEB.VERSION" false "MONOLITHIC;COMPONENT") +run_cpack_test(EXTRA "DEB.EXTRA" false "COMPONENT") +run_cpack_test_subtests(GENERATE_SHLIBS "soversion_not_zero;soversion_zero" "DEB.GENERATE_SHLIBS" true "COMPONENT") +run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB.GENERATE_SHLIBS_LDCONFIG" true "COMPONENT") +run_cpack_test(INSTALL_SCRIPTS "RPM.INSTALL_SCRIPTS" false "COMPONENT") +run_cpack_test(LONG_FILENAMES "DEB.LONG_FILENAMES" false "MONOLITHIC") +run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM.MAIN_COMPONENT" false "COMPONENT") +run_cpack_test(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") +run_cpack_test_package_target(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") -run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") -run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") -run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true "CUSTOM") -run_cpack_test(EXTRA_SLASH_IN_PATH "RPM" true "COMPONENT") -run_cpack_source_test(SOURCE_PACKAGE "RPM") -run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC") -run_cpack_test(SYMLINKS "RPM;TGZ" false "MONOLITHIC;COMPONENT") -run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC") -run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT") +run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM.PARTIALLY_RELOCATABLE_WARNING" false "COMPONENT") +run_cpack_test(PER_COMPONENT_FIELDS "RPM.PER_COMPONENT_FIELDS;DEB.PER_COMPONENT_FIELDS" false "COMPONENT") +run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM.SINGLE_DEBUGINFO" true "CUSTOM") +run_cpack_test(EXTRA_SLASH_IN_PATH "RPM.EXTRA_SLASH_IN_PATH" true "COMPONENT") +run_cpack_source_test(SOURCE_PACKAGE "RPM.SOURCE_PACKAGE") +run_cpack_test(SUGGESTS "RPM.SUGGESTS" false "MONOLITHIC") +run_cpack_test(SYMLINKS "RPM.SYMLINKS;TGZ" false "MONOLITHIC;COMPONENT") +set(ENVIRONMENT "SOURCE_DATE_EPOCH=123456789") +run_cpack_test(TIMESTAMPS "DEB.TIMESTAMPS;TGZ" false "COMPONENT") +unset(ENVIRONMENT) +run_cpack_test(USER_FILELIST "RPM.USER_FILELIST" false "MONOLITHIC") +run_cpack_test(MD5SUMS "DEB.MD5SUMS" false "MONOLITHIC;COMPONENT") +run_cpack_test(CPACK_INSTALL_SCRIPT "ZIP" false "MONOLITHIC") +run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY" false "MONOLITHIC;COMPONENT") +run_cpack_test_subtests(EXTERNAL "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad;stage_and_package" "External" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/STGZ/Helpers.cmake b/Tests/RunCMake/CPack/STGZ/Helpers.cmake index 68b1eabd2..175664551 100644 --- a/Tests/RunCMake/CPack/STGZ/Helpers.cmake +++ b/Tests/RunCMake/CPack/STGZ/Helpers.cmake @@ -47,18 +47,29 @@ function(toExpectedContentList FILE_NO CONTENT_VAR) string(SUBSTRING "${prefix_}" 0 ${pos_} prefix_) endif() - if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) - set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + # add install prefix to expected paths + if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX) + set(EXPECTED_FILE_PACKAGING_PREFIX + "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}") + elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX) + # default CPack Archive packaging install prefix + set(EXPECTED_FILE_PACKAGING_PREFIX "/") endif() - set(filtered_ "${prefix_}") - foreach(part_ IN LISTS ${CONTENT_VAR}) - string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + # remove trailing slash otherwise path concatenation will cause double slashes + string(REGEX REPLACE "/$" "" EXPECTED_FILE_PACKAGING_PREFIX + "${EXPECTED_FILE_PACKAGING_PREFIX}") + + if(EXPECTED_FILE_PACKAGING_PREFIX) + set(prepared_ "${prefix_}") + else() + unset(prepared_) + endif() - if(part_) - list(APPEND filtered_ "${prefix_}/${part_}") - endif() + list(APPEND prepared_ "${prefix_}${EXPECTED_FILE_PACKAGING_PREFIX}") + foreach(part_ IN LISTS ${CONTENT_VAR}) + list(APPEND prepared_ "${prefix_}${EXPECTED_FILE_PACKAGING_PREFIX}${part_}") endforeach() - set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) + set(${CONTENT_VAR} "${prepared_}" PARENT_SCOPE) endfunction() diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 470ebf7a8..345b37fac 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -8,9 +8,7 @@ function(findExpectedFile FILE_NO RESULT_VAR GLOBING_EXPR_VAR) endif() if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_VERSION) set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1") - endif() - if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_REVISION) - set(EXPECTED_FILE_${FILE_NO}_REVISION "1") + set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1" PARENT_SCOPE) endif() getPackageNameGlobexpr("${EXPECTED_FILE_${FILE_NO}_NAME}" @@ -58,8 +56,12 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) set(EXPECTED_FILE_CONTENT_${file_no_} "${EXPECTED_FILE_CONTENT_${file_no_}_LIST}") toExpectedContentList("${file_no_}" "EXPECTED_FILE_CONTENT_${file_no_}") - list(SORT PACKAGE_CONTENT) - list(SORT EXPECTED_FILE_CONTENT_${file_no_}) + if(NOT PACKAGE_CONTENT STREQUAL "") + list(SORT PACKAGE_CONTENT) + endif() + if(NOT EXPECTED_FILE_CONTENT_${file_no_} STREQUAL "") + list(SORT EXPECTED_FILE_CONTENT_${file_no_}) + endif() if(PACKAGE_CONTENT STREQUAL EXPECTED_FILE_CONTENT_${file_no_}) set(expected_content_list TRUE) @@ -90,7 +92,7 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) # check that there were no extra files generated foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB) file(GLOB foundAll_ RELATIVE "${bin_dir}" "${all_files_glob_}") - list(APPEND allFoundFiles_ "${foundAll_}") + list(APPEND allFoundFiles_ ${foundAll_}) endforeach() list(LENGTH foundFiles_ foundFilesCount_) diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake index 694dc00ab..6d895ec2f 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake @@ -1,9 +1,9 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") if(PACKAGING_TYPE STREQUAL "COMPONENT") set(EXPECTED_FILES_COUNT "2") set(EXPECTED_FILE_1_COMPONENT "test") set(EXPECTED_FILE_2_COMPONENT "test2") - set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") + set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt index e6d86d0de..b0502628e 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt @@ -1,2 +1,2 @@ ^CPackRPM: Will use USER specified spec file: (/[^/]*)*/CUSTOM_BINARY_SPEC_FILE/custom\.spec\.in -CPackRPM: Will use GENERATED spec file:.*/Tests/RunCMake/RPM/CPack/CUSTOM_BINARY_SPEC_FILE-build/_CPack_Packages/.*/RPM/SPECS/custom_binary_spec_file-test2\.spec$ +CPackRPM: Will use GENERATED spec file:.*/Tests/RunCMake/RPM\.CUSTOM_BINARY_SPEC_FILE/CPack/CUSTOM_BINARY_SPEC_FILE-build/_CPack_Packages/.*/RPM/SPECS/custom_binary_spec_file-test2\.spec$ diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake index 5cb280cd6..07226df04 100644 --- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake @@ -1,10 +1,10 @@ set(EXPECTED_FILES_COUNT "3") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) set(EXPECTED_FILE_1_COMPONENT "pkg_1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") set(EXPECTED_FILE_2_NAME "second") -set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") -set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_2_LIST "/foo;/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_3_LIST "/foo;/foo/CMakeLists.txt") if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") string(TOLOWER "${GENERATOR_TYPE}" file_extension_) diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake index 3d8de74d4..cf2e8ac6b 100644 --- a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake @@ -3,16 +3,39 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "5") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) -set(EXPECTED_FILE_1_NAME "Debuginfo") +if(GENERATOR_TYPE STREQUAL "RPM") + set(NAME "Debuginfo") + set(DEBUG_SUFFIX "debuginfo") + set(PKG "rpm") + set(DEBUG_PKG "rpm") +elseif(GENERATOR_TYPE STREQUAL "DEB") + set(NAME "debuginfo") + set(DEBUG_SUFFIX "dbgsym") + set(PKG "deb") + set(DEBUG_PKG "ddeb") +endif() + +set(EXPECTED_FILE_1_NAME "${NAME}") set(EXPECTED_FILE_1_COMPONENT "applications") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") -set(EXPECTED_FILE_2 "TestDinfo-pkg*-headers.rpm") -set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") -set(EXPECTED_FILE_3 "TestDinfo-pkg*-libs.rpm") -set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") + +set(EXPECTED_FILE_2 "TestDinfo-pkg*-headers.${PKG}") +set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") + +set(EXPECTED_FILE_3 "TestDinfo-pkg*-libs.${PKG}") +set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so") + +set(EXPECTED_FILE_4 "${NAME}-applications-${DEBUG_SUFFIX}*.${DEBUG_PKG}") +if(GENERATOR_TYPE STREQUAL "RPM") + set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*") +elseif(GENERATOR_TYPE STREQUAL "DEB") + set(EXPECTED_FILE_CONTENT_4 ".*/usr/lib/debug/.build-id/.*\.debug.*") +endif() -set(EXPECTED_FILE_4_NAME "Debuginfo") -set(EXPECTED_FILE_4_COMPONENT "applications-debuginfo") -set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") -set(EXPECTED_FILE_5 "libs-DebugInfoPackage.rpm") -set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*") +if(GENERATOR_TYPE STREQUAL "RPM") + set(EXPECTED_FILE_5 "libs-DebugInfoPackage.rpm") + set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*") +elseif(GENERATOR_TYPE STREQUAL "DEB") + set(EXPECTED_FILE_5 "TestDinfo-pkg-libs-dbgsym.ddeb") + set(EXPECTED_FILE_CONTENT_5 ".*/usr/lib/debug/.build-id/.*\.debug.*") +endif() diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake index f1b6738bd..161a36a85 100644 --- a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake @@ -8,6 +8,10 @@ endif() set(CMAKE_BUILD_TYPE Debug) +# for rpm packages execute flag must be set for shared libs if debuginfo +# packages are generated +set(CPACK_RPM_INSTALL_WITH_EXEC TRUE) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" "int test_lib();\n") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" @@ -25,12 +29,16 @@ install(TARGETS test_lib DESTINATION bas COMPONENT libs) set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON) +set(CPACK_DEBIAN_APPLICATIONS_FILE_NAME "DEB-DEFAULT") +set(CPACK_DEBIAN_APPLICATIONS_DEBUGINFO_PACKAGE ON) # test that components with debuginfo enabled still honor # CPACK_PACKAGE_FILE_NAME setting set(CPACK_RPM_PACKAGE_NAME "Debuginfo") set(CPACK_PACKAGE_FILE_NAME "TestDinfo-pkg") set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON) +set(CPACK_DEBIAN_PACKAGE_NAME "Debuginfo") +set(CPACK_DEBIAN_LIBS_DEBUGINFO_PACKAGE ON) # test debuginfo package rename set(CPACK_RPM_DEBUGINFO_FILE_NAME diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake index 3b280ba73..be7ba07db 100644 --- a/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake @@ -1,14 +1,14 @@ set(EXPECTED_FILES_COUNT "5") set(EXPECTED_FILE_1_COMPONENT "applications") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") set(EXPECTED_FILE_2_COMPONENT "applications_auto") -set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo_auto;/usr/foo_auto/test_prog") +set(EXPECTED_FILE_CONTENT_2_LIST "/foo_auto;/foo_auto/test_prog") set(EXPECTED_FILE_3_COMPONENT "headers") -set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_3_LIST "/bar;/bar/CMakeLists.txt") set(EXPECTED_FILE_4_COMPONENT "libs") -set(EXPECTED_FILE_CONTENT_4_LIST "/usr/bas;/usr/bas/libtest_lib.so") +set(EXPECTED_FILE_CONTENT_4_LIST "/bas;/bas/libtest_lib.so") set(EXPECTED_FILE_5_COMPONENT "libs_auto") -set(EXPECTED_FILE_CONTENT_5_LIST "/usr;/usr/bas_auto;/usr/bas_auto/libtest_lib.so") +set(EXPECTED_FILE_CONTENT_5_LIST "/bas_auto;/bas_auto/libtest_lib.so") if(GENERATOR_TYPE STREQUAL "DEB") set(whitespaces_ "[\t\n\r ]*") diff --git a/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake index 6142eb39a..d1a3a5fb2 100644 --- a/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake @@ -1,2 +1,2 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake index 7375ecc21..1b2eb4877 100644 --- a/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake @@ -5,6 +5,11 @@ execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist} set(whitespaces_ "[\t\n\r ]*") +# since we have no control over dist tag value we should try to escape +# the content for use as a regular expression +string(REPLACE "+" "\\+" DIST_TAG "${DIST_TAG}") +string(REPLACE "." "\\." DIST_TAG "${DIST_TAG}") + getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_") if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}") message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'") diff --git a/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake index 650687ce0..8df683115 100644 --- a/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake @@ -1,6 +1,6 @@ set(EXPECTED_FILES_COUNT "1") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/empty") +set(EXPECTED_FILE_CONTENT_1_LIST "/empty") if(PACKAGING_TYPE STREQUAL "COMPONENT") set(EXPECTED_FILE_1_COMPONENT "test") diff --git a/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake index ded2923e2..407cbe630 100644 --- a/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake @@ -1,8 +1,8 @@ set(EXPECTED_FILES_COUNT "3") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) set(EXPECTED_FILE_1_COMPONENT "foo") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") set(EXPECTED_FILE_2_COMPONENT "bar") -set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") set(EXPECTED_FILE_3_COMPONENT "bas") -set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake index a45b38ddd..3fb05346c 100644 --- a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake @@ -2,6 +2,7 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "5") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_PACKAGING_PREFIX "") set(EXPECTED_FILE_1_COMPONENT "applications") set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") @@ -11,6 +12,6 @@ set(EXPECTED_FILE_3 "extra_slash_in_path*-libs.rpm") set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so") set(EXPECTED_FILE_4_COMPONENT "applications-debuginfo") -set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") +set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*") set(EXPECTED_FILE_5_COMPONENT "libs-debuginfo") -set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*") +set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*") diff --git a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake index 4fd1e810a..7cee1888e 100644 --- a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake +++ b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake @@ -8,6 +8,10 @@ endif() set(CMAKE_BUILD_TYPE Debug) +# for rpm packages execute flag must be set for shared libs if debuginfo +# packages are generated +set(CPACK_RPM_INSTALL_WITH_EXEC TRUE) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" "int test_lib();\n") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake index b1952efd1..8cefeea5f 100644 --- a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake @@ -1,4 +1,9 @@ -set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$") +if(RunCMake_SUBTEST_SUFFIX STREQUAL "soversion_not_zero") + set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$") +else() # soversion_zero + set(shlibs_shlibs "^libtest_lib 0 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$") +endif() + # optional dot at the end of permissions regex is for SELinux enabled systems set(shlibs_shlibs_permissions_regex "-rw-r--r--\.? .*") verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs") diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake index 90351ba43..e0eb67b84 100644 --- a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake @@ -9,6 +9,11 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") -set_target_properties(test_lib PROPERTIES SOVERSION "0.8") + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "soversion_not_zero") + set_target_properties(test_lib PROPERTIES SOVERSION "0.8") +else() # soversion_zero + set_target_properties(test_lib PROPERTIES SOVERSION "0") +endif() install(TARGETS test_lib DESTINATION foo COMPONENT libs) diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake index 44346ab8d..de38df9ef 100644 --- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake @@ -1,5 +1,5 @@ set(EXPECTED_FILES_COUNT "2") set(EXPECTED_FILE_1_COMPONENT "foo") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") set(EXPECTED_FILE_2_COMPONENT "bar") -set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake index 631d95704..4cb8dd0eb 100644 --- a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake @@ -1,3 +1,3 @@ set(EXPECTED_FILES_COUNT "1") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt") diff --git a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake index 6bfb0c19f..629be9ea5 100644 --- a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake @@ -3,9 +3,9 @@ set(EXPECTED_FILES_COUNT "0") if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "invalid") set(EXPECTED_FILES_COUNT "3") set(EXPECTED_FILE_1 "main_component-0.1.1-1.*.rpm") - set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") set(EXPECTED_FILE_2_COMPONENT "headers") - set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") + set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") set(EXPECTED_FILE_3_COMPONENT "libs") - set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt") + set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/CMakeLists.txt") endif() diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake index 6142eb39a..d1a3a5fb2 100644 --- a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake @@ -1,2 +1,2 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake index 6142eb39a..d1a3a5fb2 100644 --- a/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake @@ -1,2 +1,2 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake index eed5b92b0..c375aca9d 100644 --- a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake @@ -2,5 +2,5 @@ set(EXPECTED_FILES_COUNT "0") if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") set(EXPECTED_FILES_COUNT "1") - set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") endif() diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake index e4f9618d3..2bb4d3ff9 100644 --- a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake @@ -1,8 +1,7 @@ if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") - string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION) + string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} CHECKSUM_EXTENSION) file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz") - file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}") - file(STRINGS ${CSUMFILE} CHSUM_VALUE) + file(STRINGS ${PACKAGE}.${CHECKSUM_EXTENSION} CHSUM_VALUE) file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value ) set(expected_value "${expected_value} ${PACKAGE}") diff --git a/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake index ae58c4b0c..137da470e 100644 --- a/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake @@ -1,2 +1,4 @@ set(EXPECTED_FILES_COUNT "1") +# don't set the prefix here as we have absolute paths that should not be prefixed +set(EXPECTED_FILE_PACKAGING_PREFIX "") set(EXPECTED_FILE_CONTENT_1_LIST "/not_relocatable;/not_relocatable/CMakeLists.txt;/opt") diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake index 9bdb176dd..26fa1df92 100644 --- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake @@ -1,8 +1,8 @@ set(EXPECTED_FILES_COUNT "3") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) set(EXPECTED_FILE_1_COMPONENT "pkg_1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") set(EXPECTED_FILE_2_NAME "second") -set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_2_LIST "/foo;/foo/CMakeLists.txt") set(EXPECTED_FILE_3_COMPONENT "pkg_3") -set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_3_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake index 18ef63cd8..b4bdb61b6 100644 --- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake @@ -1,7 +1,7 @@ function(checkPackageInfo_ TYPE FILE REGEX) getPackageInfo("${FILE}" "FILE_INFO_") if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") + message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'; does not match '${REGEX}'") endif() endfunction() @@ -24,3 +24,15 @@ checkPackageInfo_("name" "${FOUND_FILE_3}" ".*${name_}${whitespaces_}:${whitespa checkPackageInfo_("group" "${FOUND_FILE_1}" ".*${group_}${whitespaces_}:${whitespaces_}default") checkPackageInfo_("group" "${FOUND_FILE_2}" ".*${group_}${whitespaces_}:${whitespaces_}second_group") checkPackageInfo_("group" "${FOUND_FILE_3}" ".*${group_}${whitespaces_}:${whitespaces_}default") + +# check package summaries (not available in DEB) +if(GENERATOR_TYPE STREQUAL "RPM") + checkPackageInfo_("summary" "${FOUND_FILE_1}" ".*Summary${whitespaces_}:${whitespaces_}Global summary") + checkPackageInfo_("summary" "${FOUND_FILE_2}" ".*Summary${whitespaces_}:${whitespaces_}Summary for pkg_2") + checkPackageInfo_("summary" "${FOUND_FILE_3}" ".*Summary${whitespaces_}:${whitespaces_}Global summary") +endif() + +# check package description +checkPackageInfo_("description" "${FOUND_FILE_1}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_1") +checkPackageInfo_("description" "${FOUND_FILE_2}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_2") +checkPackageInfo_("description" "${FOUND_FILE_3}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_3") diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake index 8719c0b5e..dc61d0abb 100644 --- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake @@ -11,6 +11,13 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_${group_} "default") set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second") set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_${group_} "second_group") + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_SUMMARY "Global summary") # not used for DEB + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_SUMMARY "Summary for pkg_2") # not used for DEB + + set(CPACK_COMPONENT_PKG_1_DESCRIPTION "Description for pkg_1") + set(CPACK_COMPONENT_PKG_2_DESCRIPTION "Description for pkg_2") + set(CPACK_COMPONENT_PKG_3_DESCRIPTION "Description for pkg_3") endif() install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake index ca866eaa8..936e4ed80 100644 --- a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake @@ -5,26 +5,26 @@ set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") set(EXPECTED_FILES_COUNT "4") set(EXPECTED_FILE_1 "single_debuginfo-0.1.1-1.*.rpm") - set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") + set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm") - set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") + set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm") - set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so") + set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so") set(EXPECTED_FILE_4_COMPONENT "debuginfo") - set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*") + set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*") elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo") set(EXPECTED_FILES_COUNT "2") set(EXPECTED_FILE_1 "single_debuginfo-0*-applications.rpm") - set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") + set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") set(EXPECTED_FILE_2 "single_debuginfo-applications-debuginfo*.rpm") - set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") + set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*") elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_components") set(EXPECTED_FILES_COUNT "2") set(EXPECTED_FILE_1 "single_debuginfo-0*.rpm") - set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") + set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") set(EXPECTED_FILE_2 "single_debuginfo-debuginfo*.rpm") - set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") + set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*") endif() diff --git a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake index 0a3e42635..d78f222a3 100644 --- a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake @@ -1,2 +1,3 @@ set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_PACKAGING_PREFIX "") set(EXPECTED_FILE_CONTENT_1_LIST "source_package-0.1.1.tar.gz;source_package.spec") diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake index 6142eb39a..d1a3a5fb2 100644 --- a/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake @@ -1,2 +1,2 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt index feb296cae..53d71d91f 100644 --- a/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt @@ -1 +1 @@ -^(.*CPackRPM:Warning: SUGGESTS not supported in provided rpmbuild.*)?CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build/_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec$ +^(.*CPackRPM:Warning: SUGGESTS not supported in provided rpmbuild.*)?CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM\.SUGGESTS/CPack/[^-]*-build/_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec$ diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake index 32cc6d1af..61ce752fe 100644 --- a/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake @@ -13,7 +13,7 @@ if(NOT RPMBUILD_CAPS_RESULT) endif() # Only verify that suggests tag is present only if that tag is supported. -# If it is not supported the rpm package was corretly generated by ignoring +# If it is not supported the rpm package was correctly generated by ignoring # that tag and that was already checked by expected files test. if(should_contain_suggests_tag_) execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p "${FOUND_FILE_1}" diff --git a/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake index 05be748c1..e8281a8d3 100644 --- a/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake @@ -1,12 +1,11 @@ set(EXPECTED_FILES_COUNT "1") set(EXPECTED_FILE_CONTENT_1_LIST - "/usr" - "/usr/empty_dir" - "/usr/non_empty_dir" - "/usr/non_empty_dir/CMakeLists.txt" - "/usr/symlink_to_empty_dir" - "/usr/symlink_to_non_empty_dir") + "/empty_dir" + "/non_empty_dir" + "/non_empty_dir/CMakeLists.txt" + "/symlink_to_empty_dir" + "/symlink_to_non_empty_dir") if(PACKAGING_TYPE STREQUAL "COMPONENT") set(EXPECTED_FILE_1_COMPONENT "links") diff --git a/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake index aabe53761..8420986f2 100644 --- a/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake @@ -1,2 +1,2 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/usr/one;/usr/one/foo.txt;/usr/one/two;/usr/one/two/bar.txt;/usr/three;/usr/three/baz.txt;/usr/three/qux.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/one;/one/foo.txt;/one/two;/one/two/bar.txt;/three;/three/baz.txt;/three/qux.txt") diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake index 16d2cf39f..8f2196d5b 100644 --- a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake @@ -4,3 +4,6 @@ run_cmake(Simple) run_cmake(Default) run_cmake(Special) run_cmake(Verbatim) +run_cmake(Version1) +run_cmake(Version2) +run_cmake(Version3) diff --git a/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake index 1a373b928..8fc1218f2 100644 --- a/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake +++ b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake @@ -1,6 +1,6 @@ add_executable(mytest test.cpp) -file(GENERATE OUTPUT runtest_info.cmake CONTENT [[ +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info.cmake CONTENT [[ set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>") ]]) diff --git a/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake index 77fe8ed5d..b23d3c7df 100644 --- a/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake +++ b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake @@ -6,7 +6,7 @@ foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) OUTPUT_NAME_${UPPER_CONFIG} bar_${CONFIG}) endforeach() -file(GENERATE OUTPUT runtest_info_$<CONFIG>.cmake CONTENT [[ +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info_$<CONFIG>.cmake CONTENT [[ set(CPACK_BUILD_CONFIG "$<CONFIG>") set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>") ]]) diff --git a/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake index 2e1d4656c..2001d9f4c 100644 --- a/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake +++ b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake @@ -1,6 +1,6 @@ add_executable(mytest test.cpp) -file(GENERATE OUTPUT runtest_info.cmake CONTENT [[ +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info.cmake CONTENT [[ set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>") ]]) diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake index a6f684224..13922401e 100644 --- a/Tests/RunCMake/CTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake @@ -3,3 +3,5 @@ include(RunCMake) set(RunCMake_TEST_OPTIONS -DNoProject=1) run_cmake(BeforeProject) unset(RunCMake_TEST_OPTIONS) + +run_cmake(NotOn) diff --git a/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt b/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt index 7fe04eb6a..9cfe41ca3 100644 --- a/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt +++ b/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt @@ -1,7 +1,7 @@ 100% tests passed, 0 tests failed out of 4 + +Label Time Summary: -+'bar' = +[0-9.]+ sec \(3 tests\) -+'foo' = +[0-9.]+ sec \(1 test\) ++'bar' = +[0-9.]+ sec\*proc \(3 tests\) ++'foo' = +[0-9.]+ sec\*proc \(1 test\) + Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index e936dab4c..b7f9a37ac 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -102,7 +102,7 @@ function(run_TestLoad name load) add_test(TestLoad1 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\") add_test(TestLoad2 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\") ") - run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -j2 --test-load ${load} --test-timeout 5) + run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -j2 --test-load ${load}) endfunction() # Tests for the --test-load feature of ctest @@ -111,8 +111,8 @@ endfunction() set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 5) # Verify that new tests are not started when the load average exceeds -# our threshold. -run_TestLoad(test-load-fail 2) +# our threshold and that they then run once the load average drops. +run_TestLoad(test-load-wait 3) # Verify that warning message is displayed but tests still start when # an invalid argument is given. @@ -141,3 +141,74 @@ 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() + +function(run_TestStdin) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestStdin) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " + add_test(TestStdin \"${TEST_PRINT_STDIN}\") + ") + run_cmake_command(TestStdin ${CMAKE_CTEST_COMMAND} -V) +endfunction() +run_TestStdin() + +function(show_only_json_check_python v) + if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE) + return() + endif() + set(json_file "${RunCMake_TEST_BINARY_DIR}/ctest.json") + file(WRITE "${json_file}" "${actual_stdout}") + set(actual_stdout "" PARENT_SCOPE) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/show-only_json-v${v}_check.py" "${json_file}" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE output + ) + if(NOT result EQUAL 0) + string(REPLACE "\n" "\n " output " ${output}") + set(RunCMake_TEST_FAILED "Unexpected output:\n${output}" PARENT_SCOPE) + endif() +endfunction() + +function(run_ShowOnly) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ShowOnly) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " + add_test(ShowOnly \"${CMAKE_COMMAND}\" -E echo) + set_tests_properties(ShowOnly PROPERTIES + WILL_FAIL true + REQUIRED_FILES RequiredFileDoesNotExist + _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\" + ) + add_test(ShowOnlyNotAvailable NOT_AVAILABLE) +") + run_cmake_command(show-only_human ${CMAKE_CTEST_COMMAND} --show-only=human) + run_cmake_command(show-only_bad ${CMAKE_CTEST_COMMAND} --show-only=bad) + run_cmake_command(show-only_json-v1 ${CMAKE_CTEST_COMMAND} --show-only=json-v1) +endfunction() +run_ShowOnly() diff --git a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake index e14556944..b7d524ccf 100644 --- a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake @@ -8,6 +8,6 @@ run_cmake(not-supported-by-compiler) run_cmake(save-to-result) run_cmake(cmp0069-is-old) -if(RunCMake_GENERATOR MATCHES "^Visual Studio ") +if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") run_cmake(not-supported-by-generator) endif() diff --git a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake index 5b4e57edc..8a046e14c 100644 --- a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(CMP0075) + run_cmake(CheckStructHasMemberOk) run_cmake(CheckStructHasMemberUnknownLanguage) run_cmake(CheckStructHasMemberMissingLanguage) @@ -14,3 +16,9 @@ run_cmake(CheckTypeSizeUnknownArgument) run_cmake(CheckTypeSizeMixedArgs) run_cmake(CheckTypeSizeOkNoC) + +run_cmake(CheckIncludeFilesOk) +run_cmake(CheckIncludeFilesOkNoC) +run_cmake(CheckIncludeFilesMissingLanguage) +run_cmake(CheckIncludeFilesUnknownArgument) +run_cmake(CheckIncludeFilesUnknownLanguage) diff --git a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt index 5315f5904..2a4ee6451 100644 --- a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt +++ b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt @@ -1,3 +1,3 @@ ^CMake Error: Error processing file: nosuchcachefile.txt -CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt" does not exist. +CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/C-no-file-build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.$ diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt index 6c5ea44b3..b4b170ef2 100644 --- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt +++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt @@ -1 +1 @@ -^{.*}$ +^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":0}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":true,"version":{.*}}$ diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake index d7e652de7..5df5f2fb7 100644 --- a/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake +++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake @@ -1,6 +1,10 @@ -if(NOT IS_SYMLINK ${RunCMake_TEST_BINARY_DIR}/L) - set(RunCMake_TEST_FAILED "Symlink 'L' incorrectly not created!") -endif() -if(EXISTS ${RunCMake_TEST_BINARY_DIR}/L) - set(RunCMake_TEST_FAILED "Symlink 'L' not broken!") +if(${actual_stderr_var} MATCHES "operation not permitted") + unset(msg) +else() + if(NOT IS_SYMLINK ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' incorrectly not created!") + endif() + if(EXISTS ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' not broken!") + endif() endif() diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake index c078ae8fc..d37df0169 100644 --- a/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake +++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake @@ -1,3 +1,7 @@ -if(NOT IS_DIRECTORY ${RunCMake_TEST_BINARY_DIR}/L) - set(RunCMake_TEST_FAILED "Symlink 'L' not replaced correctly!") +if(${actual_stderr_var} MATCHES "operation not permitted") + unset(msg) +else() + if(NOT IS_DIRECTORY ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' not replaced correctly!") + endif() endif() diff --git a/Tests/RunCMake/CommandLine/NoArgs-stdout.txt b/Tests/RunCMake/CommandLine/NoArgs-stdout.txt index 1cd34697b..f1dafc886 100644 --- a/Tests/RunCMake/CommandLine/NoArgs-stdout.txt +++ b/Tests/RunCMake/CommandLine/NoArgs-stdout.txt @@ -2,6 +2,7 @@ cmake \[options\] <path-to-source> cmake \[options\] <path-to-existing-build> + cmake \[options\] -S <path-to-source> -B <path-to-build> Specify a source directory to \(re-\)generate a build system for it in the current working directory. Specify an existing build directory to diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index f94b10ac5..c9d3a4ddd 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -3,31 +3,43 @@ cmake_minimum_required(VERSION 3.1) include(RunCMake) run_cmake_command(NoArgs ${CMAKE_COMMAND}) -run_cmake_command(C-no-arg ${CMAKE_COMMAND} -C) -run_cmake_command(C-no-file ${CMAKE_COMMAND} -C nosuchcachefile.txt) +run_cmake_command(Wizard ${CMAKE_COMMAND} -i) +run_cmake_command(C-no-arg ${CMAKE_COMMAND} -B DummyBuildDir -C) +run_cmake_command(C-no-file ${CMAKE_COMMAND} -B DummyBuildDir -C nosuchcachefile.txt) +run_cmake_command(Cno-file ${CMAKE_COMMAND} -B DummyBuildDir -Cnosuchcachefile.txt) run_cmake_command(cache-no-file ${CMAKE_COMMAND} nosuchsubdir/CMakeCache.txt) run_cmake_command(lists-no-file ${CMAKE_COMMAND} nosuchsubdir/CMakeLists.txt) -run_cmake_command(D-no-arg ${CMAKE_COMMAND} -D) -run_cmake_command(U-no-arg ${CMAKE_COMMAND} -U) +run_cmake_command(D-no-arg ${CMAKE_COMMAND} -B DummyBuildDir -D) +run_cmake_command(D-no-src ${CMAKE_COMMAND} -B DummyBuildDir -D VAR=VALUE) +run_cmake_command(Dno-src ${CMAKE_COMMAND} -B DummyBuildDir -DVAR=VALUE) +run_cmake_command(U-no-arg ${CMAKE_COMMAND} -B DummyBuildDir -U) +run_cmake_command(U-no-src ${CMAKE_COMMAND} -B DummyBuildDir -U VAR) +run_cmake_command(Uno-src ${CMAKE_COMMAND} -B DummyBuildDir -UVAR) run_cmake_command(E-no-arg ${CMAKE_COMMAND} -E) run_cmake_command(E_capabilities ${CMAKE_COMMAND} -E capabilities) run_cmake_command(E_capabilities-arg ${CMAKE_COMMAND} -E capabilities --extra-arg) +run_cmake_command(E_compare_files-different-eol ${CMAKE_COMMAND} -E compare_files ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf) +run_cmake_command(E_compare_files-ignore-eol-same ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf) +run_cmake_command(E_compare_files-ignore-eol-empty ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/empty1 ${RunCMake_SOURCE_DIR}/compare_files/empty2) +run_cmake_command(E_compare_files-ignore-eol-nonexistent ${CMAKE_COMMAND} -E compare_files --ignore-eol nonexistent_a nonexistent_b) run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append) run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename) run_cmake_command(E_server-arg ${CMAKE_COMMAND} -E server --extra-arg) run_cmake_command(E_server-pipe ${CMAKE_COMMAND} -E server --pipe=) + run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate) +run_cmake_command(E_touch-nonexistent-dir ${CMAKE_COMMAND} -E touch "${RunCMake_BINARY_DIR}/touch-nonexistent-dir/foo") run_cmake_command(E_time ${CMAKE_COMMAND} -E time ${CMAKE_COMMAND} -E echo "hello world") run_cmake_command(E_time-no-arg ${CMAKE_COMMAND} -E time) -run_cmake_command(E___run_iwyu-no-iwyu ${CMAKE_COMMAND} -E __run_iwyu -- command-does-not-exist) -run_cmake_command(E___run_iwyu-bad-iwyu ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist -- command-does-not-exist) -run_cmake_command(E___run_iwyu-no--- ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist command-does-not-exist) -run_cmake_command(E___run_iwyu-no-cc ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist --) +run_cmake_command(E___run_co_compile-no-iwyu ${CMAKE_COMMAND} -E __run_co_compile -- command-does-not-exist) +run_cmake_command(E___run_co_compile-bad-iwyu ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist -- command-does-not-exist) +run_cmake_command(E___run_co_compile-no--- ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist command-does-not-exist) +run_cmake_command(E___run_co_compile-no-cc ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist --) -run_cmake_command(G_no-arg ${CMAKE_COMMAND} -G) -run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -G NoSuchGenerator) +run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G) +run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator) run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P) run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake) @@ -42,11 +54,61 @@ run_cmake_command(build-bad-dir run_cmake_command(build-bad-generator ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator) +run_cmake_command(install-no-dir + ${CMAKE_COMMAND} --install) +run_cmake_command(install-bad-dir + ${CMAKE_COMMAND} --install dir-does-not-exist) +run_cmake_command(install-options-to-vars + ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-install-options-to-vars + --strip --prefix /var/test --config sample --component pack) + run_cmake_command(cache-bad-entry ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-entry/) run_cmake_command(cache-empty-entry ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-empty-entry/) +function(run_ExplicitDirs) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_NO_SOURCE_DIR 1) + + set(source_dir ${RunCMake_BINARY_DIR}/ExplicitDirsMissing) + + file(REMOVE_RECURSE "${source_dir}") + file(MAKE_DIRECTORY "${source_dir}") + file(WRITE ${source_dir}/CMakeLists.txt [=[ +cmake_minimum_required(VERSION 3.13) +project(ExplicitDirsMissing LANGUAGES NONE) +]=]) + set(RunCMake_TEST_SOURCE_DIR "${source_dir}") + set(RunCMake_TEST_BINARY_DIR "${source_dir}") + run_cmake_with_options(no-S-B -DFOO=BAR) + + set(source_dir ${RunCMake_SOURCE_DIR}/ExplicitDirs) + set(binary_dir ${RunCMake_BINARY_DIR}/ExplicitDirs-build) + + set(RunCMake_TEST_SOURCE_DIR "${source_dir}") + set(RunCMake_TEST_BINARY_DIR "${binary_dir}") + + file(REMOVE_RECURSE "${binary_dir}") + run_cmake_with_options(S-arg -S ${source_dir} ${binary_dir}) + run_cmake_with_options(S-arg-reverse-order ${binary_dir} -S${source_dir} ) + run_cmake_with_options(S-no-arg -S ) + run_cmake_with_options(S-no-arg2 -S -T) + run_cmake_with_options(S-B -S ${source_dir} -B ${binary_dir}) + + # make sure that -B can explicitly construct build directories + file(REMOVE_RECURSE "${binary_dir}") + run_cmake_with_options(B-arg -B ${binary_dir} ${source_dir}) + file(REMOVE_RECURSE "${binary_dir}") + run_cmake_with_options(B-arg-reverse-order ${source_dir} -B${binary_dir}) + run_cmake_with_options(B-no-arg -B ) + run_cmake_with_options(B-no-arg2 -B -T) + file(REMOVE_RECURSE "${binary_dir}") + run_cmake_with_options(B-S -B${binary_dir} -S${source_dir}) + +endfunction() +run_ExplicitDirs() + function(run_BuildDir) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BuildDir-build) @@ -58,10 +120,128 @@ function(run_BuildDir) run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget) run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir .. - ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget2 --target CustomTarget3) + ${CMAKE_COMMAND} --build BuildDir-build -t CustomTarget2 --target CustomTarget3) + run_cmake_command(BuildDir--build-multiple-targets-jobs ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget CustomTarget2 -j2 --target CustomTarget3) + run_cmake_command(BuildDir--build-multiple-targets-with-clean-first ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --target clean CustomTarget) + run_cmake_command(BuildDir--build-multiple-targets-with-clean-second ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget clean) + run_cmake_command(BuildDir--build-jobs-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 12ab) + run_cmake_command(BuildDir--build-jobs-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 2) + run_cmake_command(BuildDir--build-jobs-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 2 --target CustomTarget) + run_cmake_command(BuildDir--build--parallel-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 12ab) + run_cmake_command(BuildDir--build--parallel-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 2) + run_cmake_command(BuildDir--build--parallel-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 2 --target CustomTarget) + run_cmake_command(BuildDir--build-jobs-no-space-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j12ab) + run_cmake_command(BuildDir--build-jobs-no-space-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j2) + run_cmake_command(BuildDir--build-jobs-no-space-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j2 --target CustomTarget) + run_cmake_command(BuildDir--build--parallel-no-space-bad-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel12ab) + run_cmake_command(BuildDir--build--parallel-no-space-good-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel2) + run_cmake_command(BuildDir--build--parallel-no-space-good-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel2 --target CustomTarget) + run_cmake_command(BuildDir--build-jobs-zero ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 0) + run_cmake_command(BuildDir--build--parallel-zero ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 0) + run_cmake_command(BuildDir--build-jobs-large ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j 4294967293) + run_cmake_command(BuildDir--build--parallel-large ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel 4294967293) + + # No default jobs for Xcode and FreeBSD build command + if(NOT RunCMake_GENERATOR MATCHES "Xcode" AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + run_cmake_command(BuildDir--build-jobs-no-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j) + run_cmake_command(BuildDir--build-jobs-no-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build -j --target CustomTarget) + run_cmake_command(BuildDir--build--parallel-no-number ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel) + run_cmake_command(BuildDir--build--parallel-no-number-trailing--target ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --parallel --target CustomTarget) + endif() endfunction() run_BuildDir() +function(run_EnvironmentGenerator) + set(source_dir ${RunCMake_SOURCE_DIR}/EnvGenerator) + + set(ENV{CMAKE_GENERATOR_INSTANCE} "instance") + set(ENV{CMAKE_GENERATOR_PLATFORM} "platform") + set(ENV{CMAKE_GENERATOR_TOOLSET} "toolset") + run_cmake_command(Envgen-warnings ${CMAKE_COMMAND} -G) + unset(ENV{CMAKE_GENERATOR_INSTANCE}) + unset(ENV{CMAKE_GENERATOR_PLATFORM}) + unset(ENV{CMAKE_GENERATOR_TOOLSET}) + + # Test CMAKE_GENERATOR without actual configuring + run_cmake_command(Envgen-unset ${CMAKE_COMMAND} -G) + set(ENV{CMAKE_GENERATOR} "Ninja") + run_cmake_command(Envgen-ninja ${CMAKE_COMMAND} -G) + set(ENV{CMAKE_GENERATOR} "NoSuchGenerator") + run_cmake_command(Envgen-bad ${CMAKE_COMMAND} -G) + unset(ENV{CMAKE_GENERATOR}) + + if(RunCMake_GENERATOR MATCHES "Visual Studio.*") + set(ENV{CMAKE_GENERATOR} "${RunCMake_GENERATOR}") + run_cmake_command(Envgen ${CMAKE_COMMAND} ${source_dir}) + # Toolset is available since VS 2010. + if(RunCMake_GENERATOR MATCHES "Visual Studio [1-9][0-9]") + set(ENV{CMAKE_GENERATOR_TOOLSET} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-toolset-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + run_cmake_command(Envgen-toolset-invalid ${CMAKE_COMMAND} ${source_dir}) + # Command line -G implies -T"" + run_cmake_command(Envgen-G-implicit-toolset ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir}) + run_cmake_command(Envgen-T-toolset ${CMAKE_COMMAND} -T "fromcli" ${source_dir}) + unset(ENV{CMAKE_GENERATOR_TOOLSET}) + endif() + # Platform can be set only if not in generator name. + if(RunCMake_GENERATOR MATCHES "^Visual Studio [0-9]+ [0-9]+$") + set(ENV{CMAKE_GENERATOR_PLATFORM} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-platform-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") + set(RunCMake-stderr-file "Envgen-platform-invalid-stderr-vs9.txt") + endif() + run_cmake_command(Envgen-platform-invalid ${CMAKE_COMMAND} ${source_dir}) + unset(RunCMake-stderr-file) + # Command line -G implies -A"" + run_cmake_command(Envgen-G-implicit-platform ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir}) + if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") + set(RunCMake-stderr-file "Envgen-A-platform-stderr-vs9.txt") + endif() + run_cmake_command(Envgen-A-platform ${CMAKE_COMMAND} -A "fromcli" ${source_dir}) + unset(RunCMake-stderr-file) + unset(ENV{CMAKE_GENERATOR_PLATFORM}) + endif() + # Instance is available since VS 2017. + if(RunCMake_GENERATOR MATCHES "Visual Studio (15|16).*") + set(ENV{CMAKE_GENERATOR_INSTANCE} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-instance-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + run_cmake_command(Envgen-instance-invalid ${CMAKE_COMMAND} ${source_dir}) + unset(ENV{CMAKE_GENERATOR_INSTANCE}) + endif() + unset(ENV{CMAKE_GENERATOR}) + endif() +endfunction() +run_EnvironmentGenerator() + if(RunCMake_GENERATOR STREQUAL "Ninja") # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build) @@ -78,39 +258,35 @@ 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 - ) - run_cmake_command(E_create_symlink-missing-dir - ${CMAKE_COMMAND} -E create_symlink T missing-dir/L - ) +run_cmake_command(E_create_symlink-no-arg + ${CMAKE_COMMAND} -E create_symlink + ) +run_cmake_command(E_create_symlink-missing-dir + ${CMAKE_COMMAND} -E create_symlink T missing-dir/L + ) - # Use a single build tree for a few tests without cleaning. - set(RunCMake_TEST_BINARY_DIR - ${RunCMake_BINARY_DIR}/E_create_symlink-broken-build) - set(RunCMake_TEST_NO_CLEAN 1) - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - run_cmake_command(E_create_symlink-broken-create - ${CMAKE_COMMAND} -E create_symlink T L - ) - run_cmake_command(E_create_symlink-broken-replace - ${CMAKE_COMMAND} -E create_symlink . L - ) - unset(RunCMake_TEST_BINARY_DIR) - unset(RunCMake_TEST_NO_CLEAN) +# Use a single build tree for a few tests without cleaning. +# These tests are special on Windows since it will only fail if the user +# running the test does not have the priveldge to create symlinks. If this +# happens we clear the msg in the -check.cmake and say that the test passes +set(RunCMake_DEFAULT_stderr "(operation not permitted)?") +set(RunCMake_TEST_BINARY_DIR + ${RunCMake_BINARY_DIR}/E_create_symlink-broken-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +run_cmake_command(E_create_symlink-broken-create + ${CMAKE_COMMAND} -E create_symlink T L + ) +run_cmake_command(E_create_symlink-broken-replace + ${CMAKE_COMMAND} -E create_symlink . L + ) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_DEFAULT_stderr) - run_cmake_command(E_create_symlink-no-replace-dir - ${CMAKE_COMMAND} -E create_symlink T . - ) -endif() +run_cmake_command(E_create_symlink-no-replace-dir + ${CMAKE_COMMAND} -E create_symlink T . + ) set(in ${RunCMake_SOURCE_DIR}/copy_input) set(out ${RunCMake_BINARY_DIR}/copy_output) @@ -158,10 +334,16 @@ file(MAKE_DIRECTORY ${out}) file(WRITE ${outfile} "") run_cmake_command(E_make_directory-three-directories ${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${out}/d2) +run_cmake_command(E_remove_directory-three-directories + ${CMAKE_COMMAND} -E remove_directory ${out}/d1 ${out}/d2 ${out}/d2) run_cmake_command(E_make_directory-directory-with-parent ${CMAKE_COMMAND} -E make_directory ${out}/parent/child) -run_cmake_command(E_make_directory-three-directories-and-file +run_cmake_command(E_remove_directory-directory-with-parent + ${CMAKE_COMMAND} -E remove_directory ${out}/parent) +run_cmake_command(E_make_directory-two-directories-and-file ${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${outfile}) +run_cmake_command(E_remove_directory-two-directories-and-file + ${CMAKE_COMMAND} -E remove_directory ${out}/d1 ${out}/d2 ${outfile}) unset(out) unset(outfile) @@ -172,6 +354,30 @@ run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1) run_cmake_command(E_env-set ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-set.cmake) run_cmake_command(E_env-unset ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -E env --unset=TEST_ENV ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-unset.cmake) +run_cmake_command(E_md5sum-dir ${CMAKE_COMMAND} -E md5sum .) +run_cmake_command(E_sha1sum-dir ${CMAKE_COMMAND} -E sha1sum .) +run_cmake_command(E_sha224sum-dir ${CMAKE_COMMAND} -E sha224sum .) +run_cmake_command(E_sha256sum-dir ${CMAKE_COMMAND} -E sha256sum .) +run_cmake_command(E_sha384sum-dir ${CMAKE_COMMAND} -E sha384sum .) +run_cmake_command(E_sha512sum-dir ${CMAKE_COMMAND} -E sha512sum .) + +run_cmake_command(E_md5sum-no-file ${CMAKE_COMMAND} -E md5sum nonexisting) +run_cmake_command(E_sha1sum-no-file ${CMAKE_COMMAND} -E sha1sum nonexisting) +run_cmake_command(E_sha224sum-no-file ${CMAKE_COMMAND} -E sha224sum nonexisting) +run_cmake_command(E_sha256sum-no-file ${CMAKE_COMMAND} -E sha256sum nonexisting) +run_cmake_command(E_sha384sum-no-file ${CMAKE_COMMAND} -E sha384sum nonexisting) +run_cmake_command(E_sha512sum-no-file ${CMAKE_COMMAND} -E sha512sum nonexisting) + +file(WRITE "${RunCMake_BINARY_DIR}/dummy" "dummy") +run_cmake_command(E_md5sum ${CMAKE_COMMAND} -E md5sum ../dummy) +run_cmake_command(E_md5sum-mixed ${CMAKE_COMMAND} -E md5sum . ../dummy nonexisting) +run_cmake_command(E_sha1sum ${CMAKE_COMMAND} -E sha1sum ../dummy) +run_cmake_command(E_sha224sum ${CMAKE_COMMAND} -E sha224sum ../dummy) +run_cmake_command(E_sha256sum ${CMAKE_COMMAND} -E sha256sum ../dummy) +run_cmake_command(E_sha384sum ${CMAKE_COMMAND} -E sha384sum ../dummy) +run_cmake_command(E_sha512sum ${CMAKE_COMMAND} -E sha512sum ../dummy) +file(REMOVE "${RunCMake_BINARY_DIR}/dummy") + set(RunCMake_DEFAULT_stderr ".") run_cmake_command(E_sleep-no-args ${CMAKE_COMMAND} -E sleep) unset(RunCMake_DEFAULT_stderr) @@ -254,9 +460,9 @@ set(RunCMake_TEST_OPTIONS -Wdev -Wno-dev) run_cmake(Wno-dev) unset(RunCMake_TEST_OPTIONS) -run_cmake_command(W_bad-arg1 ${CMAKE_COMMAND} -W) -run_cmake_command(W_bad-arg2 ${CMAKE_COMMAND} -Wno-) -run_cmake_command(W_bad-arg3 ${CMAKE_COMMAND} -Werror=) +run_cmake_command(W_bad-arg1 ${CMAKE_COMMAND} -B DummyBuildDir -W) +run_cmake_command(W_bad-arg2 ${CMAKE_COMMAND} -B DummyBuildDir -Wno-) +run_cmake_command(W_bad-arg3 ${CMAKE_COMMAND} -B DummyBuildDir -Werror=) set(RunCMake_TEST_OPTIONS --debug-output) run_cmake(debug-output) @@ -270,6 +476,14 @@ 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 -Wno-deprecated --warn-uninitialized) +run_cmake(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) @@ -313,4 +527,8 @@ function(reject_fifo) endfunction() if(CMAKE_HOST_UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "CYGWIN") reject_fifo() + run_cmake_command(closed_stdin sh -c "\"${CMAKE_COMMAND}\" --version <&-") + run_cmake_command(closed_stdout sh -c "\"${CMAKE_COMMAND}\" --version >&-") + run_cmake_command(closed_stderr sh -c "\"${CMAKE_COMMAND}\" --version 2>&-") + run_cmake_command(closed_stdall sh -c "\"${CMAKE_COMMAND}\" --version <&- >&- 2>&-") endif() diff --git a/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt index e9be1dcb3..30385f88e 100644 --- a/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt +++ b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt @@ -1,4 +1,4 @@ ^CMake Deprecation Warning at Wdeprecated.cmake:1 \(message\): Some deprecated warning Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CommandLine/Wdev-stderr.txt b/Tests/RunCMake/CommandLine/Wdev-stderr.txt index 88cfb3a30..172fb8155 100644 --- a/Tests/RunCMake/CommandLine/Wdev-stderr.txt +++ b/Tests/RunCMake/CommandLine/Wdev-stderr.txt @@ -1,11 +1,11 @@ ^CMake Warning \(dev\) at Wdev.cmake:1 \(message\): Some author warning Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning \(dev\) at Wdev.cmake:6 \(include\): include\(\) given empty file name \(ignored\). Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt b/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt index 6acdc7362..d681836b2 100644 --- a/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt +++ b/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt @@ -1,4 +1,4 @@ ^CMake Deprecation Error at Werror_deprecated.cmake:1 \(message\): Some deprecated warning Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt b/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt index 590ec96d3..35890fc99 100644 --- a/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt +++ b/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt @@ -1,11 +1,11 @@ ^CMake Error \(dev\) at Werror_dev.cmake:4 \(include\): include\(\) given empty file name \(ignored\). Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This error is for project developers. Use -Wno-error=dev to suppress it. CMake Error \(dev\) at Werror_dev.cmake:7 \(message\): Some author warning Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This error is for project developers. Use -Wno-error=dev to suppress it.$ diff --git a/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt b/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt index 0ed169861..45897062d 100644 --- a/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt +++ b/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt @@ -1,4 +1,4 @@ ^CMake Deprecation Warning at Wno-error_deprecated.cmake:2 \(message\): Some deprecated warning Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt b/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt index dd22d5568..ee28d7f02 100644 --- a/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt +++ b/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt @@ -1,11 +1,11 @@ ^CMake Warning \(dev\) at Wno-error_dev.cmake:2 \(message\): Some author warning Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning \(dev\) at Wno-error_dev.cmake:6 \(include\): include\(\) given empty file name \(ignored\). Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake index 12635dbfb..a64af9524 100644 --- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake @@ -4,25 +4,33 @@ function(external_command_test NAME) run_cmake_command(${NAME} ${CMAKE_COMMAND} -E ${ARGN}) endfunction() -external_command_test(bad-opt1 tar cvf bad.tar --bad) -external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .) -external_command_test(bad-from1 tar cvf bad.tar --files-from=bad) -external_command_test(bad-from2 tar cvf bad.tar --files-from=.) -external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt) -external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt) -external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt) -external_command_test(end-opt1 tar cvf bad.tar -- --bad) -external_command_test(end-opt2 tar cvf bad.tar --) -external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC") -external_command_test(bad-format tar cvf bad.tar "--format=bad-format") -external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip") -external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip") +external_command_test(without-files tar cvf bad.tar) +external_command_test(bad-opt1 tar cvf bad.tar --bad) +external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .) +external_command_test(bad-from1 tar cvf bad.tar --files-from=bad) +external_command_test(bad-from2 tar cvf bad.tar --files-from=.) +external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt) +external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt) +external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt) +external_command_test(bad-file tar cf bad.tar badfile.txt ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(bad-without-action tar f bad.tar ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(bad-wrong-flag tar cvfq bad.tar ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(end-opt1 tar cvf bad.tar -- --bad) +external_command_test(end-opt2 tar cvf bad.tar --) +external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(bad-format tar cvf bad.tar "--format=bad-format" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) +external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt) run_cmake(7zip) run_cmake(gnutar) run_cmake(gnutar-gz) run_cmake(pax) run_cmake(pax-xz) +run_cmake(pax-zstd) run_cmake(paxr) run_cmake(paxr-bz2) run_cmake(zip) + +# Extracting only selected files or directories +run_cmake(zip-filtered) diff --git a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt index 1417d4d32..fb0702a1a 100644 --- a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt @@ -1,2 +1,2 @@ -^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.* +^CMake Error: Unable to read from file 'does-not-exist':.* CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt index 1417d4d32..fb0702a1a 100644 --- a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt @@ -1,2 +1,2 @@ -^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.* +^CMake Error: Unable to read from file 'does-not-exist':.* CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt index 1fddf6d2d..1342dc8d0 100644 --- a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt @@ -1,2 +1,2 @@ -^CMake Error: archive_read_disk_entry_from_file '--bad':.* +^CMake Error: Unable to read from file '--bad':.* CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake index 5f2674a8f..53ee96186 100644 --- a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake +++ b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake @@ -1,9 +1,9 @@ set(OUTPUT_NAME "test.tar.gz") -set(COMPRESSION_FLAGS cvzf) +set(COMPRESSION_FLAGS -cvzf) set(COMPRESSION_OPTIONS --format=gnutar) -set(DECOMPRESSION_FLAGS xvzf) +set(DECOMPRESSION_FLAGS -xvzf) include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) diff --git a/Tests/RunCMake/CommandLineTar/pax.cmake b/Tests/RunCMake/CommandLineTar/pax.cmake index 60ed2385c..77f74d135 100644 --- a/Tests/RunCMake/CommandLineTar/pax.cmake +++ b/Tests/RunCMake/CommandLineTar/pax.cmake @@ -1,9 +1,9 @@ set(OUTPUT_NAME "test.tar") -set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_FLAGS -cvf) set(COMPRESSION_OPTIONS --format=pax) -set(DECOMPRESSION_FLAGS xvf) +set(DECOMPRESSION_FLAGS -xvf) include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) diff --git a/Tests/RunCMake/CommandLineTar/roundtrip.cmake b/Tests/RunCMake/CommandLineTar/roundtrip.cmake index dc1c88528..fa63d1240 100644 --- a/Tests/RunCMake/CommandLineTar/roundtrip.cmake +++ b/Tests/RunCMake/CommandLineTar/roundtrip.cmake @@ -47,7 +47,11 @@ file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR}) file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR}) run_tar(${CMAKE_CURRENT_BINARY_DIR} ${COMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${COMPRESSION_OPTIONS} ${COMPRESS_DIR}) -run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS}) +run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS} -- ${DECOMPRESSION_PATHNAMES}) + +if(CUSTOM_CHECK_FILES) + set(CHECK_FILES ${CUSTOM_CHECK_FILES}) +endif() foreach(file ${CHECK_FILES}) set(input ${FULL_COMPRESS_DIR}/${file}) @@ -69,6 +73,14 @@ foreach(file ${CHECK_FILES}) endif() endforeach() +foreach(file ${NOT_EXISTING_FILES_CHECK}) + set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) + + if(EXISTS ${output}) + message(SEND_ERROR "File ${output} exists but it shouldn't") + endif() +endforeach() + function(check_magic EXPECTED) file(READ ${FULL_OUTPUT_NAME} ACTUAL ${ARGN} diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index 5884d5c4d..bb8da037a 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -15,9 +15,17 @@ function(run_compiler_launcher lang) run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() -run_compiler_launcher(C) -run_compiler_launcher(CXX) -if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") - run_compiler_launcher(C-launch) - run_compiler_launcher(CXX-launch) +set(langs C CXX) +if(CMake_TEST_CUDA) + list(APPEND langs CUDA) endif() +if(CMake_TEST_Fortran) + list(APPEND langs Fortran) +endif() + +foreach(lang ${langs}) + run_compiler_launcher(${lang}) + if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_compiler_launcher(${lang}-launch) + endif() +endforeach() diff --git a/Tests/RunCMake/Cpplint/C-error-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-Build-result.txt index d197c913c..573541ac9 100644 --- a/Tests/RunCMake/Cpplint/C-error-Build-result.txt +++ b/Tests/RunCMake/Cpplint/C-error-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt index d197c913c..573541ac9 100644 --- a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt +++ b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt index d197c913c..573541ac9 100644 --- a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt +++ b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt index d197c913c..573541ac9 100644 --- a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt +++ b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake index c4db11bde..9fcc5bcd7 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake @@ -26,12 +26,14 @@ add_custom_command(OUTPUT output2 # DoesNotUseEmulator: The command will fail if emulator is prepended add_custom_command(OUTPUT output3 + COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected COMMAND $<TARGET_FILE:generated_exe_emulator_unexpected> COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3 DEPENDS generated_exe_emulator_unexpected) # DoesNotUseEmulator: The command will fail if emulator is prepended add_custom_command(OUTPUT outputImp + COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected_imported COMMAND generated_exe_emulator_unexpected_imported COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp ) @@ -39,6 +41,7 @@ add_custom_command(OUTPUT outputImp # UsesEmulator: The command only succeeds if the emulator is prepended # to the command. add_custom_command(OUTPUT output4 + COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_expected COMMAND generated_exe_emulator_expected COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4 DEPENDS generated_exe_emulator_expected) diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake index 1aeb510f0..2fdefc4ce 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake @@ -26,3 +26,9 @@ get_property(emulator TARGET target_without_emulator if(NOT "${emulator}" STREQUAL "") message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set to null") endif() + +add_executable(target_with_empty_emulator simple_src_exiterror.cxx) +set_property(TARGET target_with_empty_emulator PROPERTY CROSSCOMPILING_EMULATOR "") + +enable_testing() +add_test(NAME test_target_with_empty_emulator COMMAND target_with_empty_emulator) diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake index 71aaad19b..97b7b5a31 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake @@ -11,13 +11,18 @@ function(CustomCommandGenerator_run_and_build case) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS - "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(${case}) run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .) endfunction() +set(RunCMake_TEST_OPTIONS +"-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}") CustomCommandGenerator_run_and_build(AddCustomCommand) CustomCommandGenerator_run_and_build(AddCustomTarget) + +set(RunCMake_TEST_OPTIONS +"-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND_ARG}\;custom_argument") +CustomCommandGenerator_run_and_build(AddCustomCommandWithArg) +CustomCommandGenerator_run_and_build(AddCustomTargetWithArg) diff --git a/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt b/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt index c3708a9c8..5388c46de 100644 --- a/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt @@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): The transform name must be a valid C identifier. Call Stack \(most recent call first\): - BadAlgoMap1.cmake:[0-9]+ \(ExternalData_Add_Target\) - CMakeLists.txt:3 \(include\) + BadAlgoMap1\.cmake:[0-9]+ \(ExternalData_Add_Target\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt b/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt index 1f10644dc..a48e41455 100644 --- a/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt @@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): The transform name must be a valid C identifier. Call Stack \(most recent call first\): - BadAlgoMap2.cmake:[0-9]+ \(ExternalData_Add_Target\) - CMakeLists.txt:3 \(include\) + BadAlgoMap2\.cmake:[0-9]+ \(ExternalData_Add_Target\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt index f68f0be6b..1f9f6b51b 100644 --- a/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt @@ -4,5 +4,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): BAD Call Stack \(most recent call first\): .* - BadHashAlgo1.cmake:3 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + BadHashAlgo1\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadOption1-stderr.txt b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt index b63d098c0..fece87703 100644 --- a/Tests/RunCMake/ExternalData/BadOption1-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt @@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Call Stack \(most recent call first\): .* - BadOption1.cmake:2 \(ExternalData_Add_Test\) - CMakeLists.txt:3 \(include\) + BadOption1\.cmake:[0-9]+ \(ExternalData_Add_Test\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadOption2-stderr.txt b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt index d114c8aa9..865552aca 100644 --- a/Tests/RunCMake/ExternalData/BadOption2-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt @@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Call Stack \(most recent call first\): .* - BadOption2.cmake:2 \(ExternalData_Add_Test\) - CMakeLists.txt:3 \(include\) + BadOption2\.cmake:[0-9]+ \(ExternalData_Add_Test\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt index aedc33015..9d04693ca 100644 --- a/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt @@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Recurse option "RECURSE:" allowed only with directories. Call Stack \(most recent call first\): .* - BadRecurse1.cmake:2 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + BadRecurse1\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt index 3f809ca69..135b42477 100644 --- a/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt @@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Recurse option "RECURSE:" allowed only with directories. Call Stack \(most recent call first\): .* - BadRecurse2.cmake:2 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + BadRecurse2\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt index 37740e0f7..df9bb0e17 100644 --- a/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt @@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Call Stack \(most recent call first\): .* - BadRecurse3.cmake:2 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + BadRecurse3\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt index 3099be579..5b3495985 100644 --- a/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt @@ -15,5 +15,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Call Stack \(most recent call first\): .* - BadSeries1.cmake:3 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + BadSeries1\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt index 3a02c25e9..82b2311d2 100644 --- a/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt @@ -12,5 +12,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): \(x\)\(y\)\$ Call Stack \(most recent call first\): .* - BadSeries2.cmake:3 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + BadSeries2\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt index 594cb6f6a..13e75c5c5 100644 --- a/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt +++ b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt @@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Series option ":" not allowed with associated files. Call Stack \(most recent call first\): .* - BadSeries3.cmake:2 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + BadSeries3\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory1-stderr.txt b/Tests/RunCMake/ExternalData/Directory1-stderr.txt index 2bc3c601d..833683285 100644 --- a/Tests/RunCMake/ExternalData/Directory1-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory1-stderr.txt @@ -10,5 +10,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): that is directory instead of a file! Call Stack \(most recent call first\): .* - Directory1.cmake:3 \(ExternalData_Add_Test\) - CMakeLists.txt:3 \(include\) + Directory1\.cmake:[0-9]+ \(ExternalData_Add_Test\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory2-stderr.txt b/Tests/RunCMake/ExternalData/Directory2-stderr.txt index 92c9a2ff5..ad6d814ec 100644 --- a/Tests/RunCMake/ExternalData/Directory2-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory2-stderr.txt @@ -6,5 +6,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): must list associated files. Call Stack \(most recent call first\): .* - Directory2.cmake:3 \(ExternalData_Add_Test\) - CMakeLists.txt:3 \(include\) + Directory2\.cmake:[0-9]+ \(ExternalData_Add_Test\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory3-stderr.txt b/Tests/RunCMake/ExternalData/Directory3-stderr.txt index ceed2a04d..5538c38a8 100644 --- a/Tests/RunCMake/ExternalData/Directory3-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory3-stderr.txt @@ -10,6 +10,6 @@ CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): that does not exist as a file \(with or without an extension\)! Call Stack \(most recent call first\): .* - Directory3.cmake:3 \(ExternalData_Add_Test\) - CMakeLists.txt:3 \(include\) + Directory3\.cmake:[0-9]+ \(ExternalData_Add_Test\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalData/Directory4-stderr.txt b/Tests/RunCMake/ExternalData/Directory4-stderr.txt index dcb8522f8..ef8847685 100644 --- a/Tests/RunCMake/ExternalData/Directory4-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory4-stderr.txt @@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Series option ":" not allowed with directories. Call Stack \(most recent call first\): .* - Directory4.cmake:3 \(ExternalData_Add_Test\) - CMakeLists.txt:3 \(include\) + Directory4\.cmake:[0-9]+ \(ExternalData_Add_Test\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory5-stderr.txt b/Tests/RunCMake/ExternalData/Directory5-stderr.txt index 8e54aecd2..3fcde414d 100644 --- a/Tests/RunCMake/ExternalData/Directory5-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory5-stderr.txt @@ -10,5 +10,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): that does not exist as a directory! Call Stack \(most recent call first\): .* - Directory5.cmake:3 \(ExternalData_Add_Test\) - CMakeLists.txt:3 \(include\) + Directory5\.cmake:[0-9]+ \(ExternalData_Add_Test\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/MissingData-stderr.txt b/Tests/RunCMake/ExternalData/MissingData-stderr.txt index 39ed2f15f..b10997681 100644 --- a/Tests/RunCMake/ExternalData/MissingData-stderr.txt +++ b/Tests/RunCMake/ExternalData/MissingData-stderr.txt @@ -10,6 +10,6 @@ CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): that does not exist as a file \(with or without an extension\)! Call Stack \(most recent call first\): .* - MissingData.cmake:4 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + MissingData\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt index 315af5e49..426d86ccd 100644 --- a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt +++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt @@ -10,6 +10,6 @@ CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): that does not exist as a file \(with or without an extension\)! Call Stack \(most recent call first\): .* - MissingDataWithAssociated.cmake:4 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + MissingDataWithAssociated\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt index 496ad8ae4..33cef07b4 100644 --- a/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt +++ b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt @@ -2,5 +2,5 @@ CMake Warning at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): ExternalData_LINK_CONTENT cannot be used in-source Call Stack \(most recent call first\): .* - NoLinkInSource.cmake:8 \(ExternalData_Expand_Arguments\) - CMakeLists.txt:3 \(include\) + NoLinkInSource\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt index ccbaf5af3..45dfb94cb 100644 --- a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt +++ b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt @@ -1,5 +1,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Neither ExternalData_URL_TEMPLATES nor ExternalData_OBJECT_STORES is set! Call Stack \(most recent call first\): - NoURLTemplates.cmake:2 \(ExternalData_Add_Target\) - CMakeLists.txt:3 \(include\) + NoURLTemplates\.cmake:[0-9]+ \(ExternalData_Add_Target\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake index cb48be7e0..c5018563c 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake @@ -24,3 +24,21 @@ if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) set(RunCMake_TEST_FAILED "Expected forced TEST_LIST argument") return() endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache") + return() +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected forced TEST_OPTIONAL argument") + return() +endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL_LAST \"TEST_OPTIONAL_LAST-NOTFOUND\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL_LAST argument in cache") + return() +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected forced TEST_OPTIONAL_LAST argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake index 1f76fd03e..4f7e02006 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) @@ -7,4 +8,6 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" CMAKE_CACHE_ARGS "-DFOO:STRING=$<1:BAR>$<0:BAD>" - "-DTEST_LIST:STRING=A;B;C") + "-DTEST_LIST:STRING=A;B;C" + "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND" + "-DTEST_OPTIONAL_LAST:FILEPATH=TEST_OPTIONAL_LAST-NOTFOUND") diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake index c84932d60..059f6d327 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake @@ -24,3 +24,21 @@ if("${CMAKE_MATCH_0}" MATCHES FORCE) set(RunCMake_TEST_FAILED "Expected not forced TEST_LIST argument") return() endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache") + return() +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected not forced TEST_OPTIONAL argument") + return() +endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL_LAST \"TEST_OPTIONAL_LAST-NOTFOUND\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL_LAST argument in cache") + return() +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected not forced TEST_OPTIONAL_LAST argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake index 1b619c8c0..61334183c 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) @@ -7,4 +8,6 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" CMAKE_CACHE_DEFAULT_ARGS "-DFOO:STRING=$<1:BAR>$<0:BAD>" - "-DTEST_LIST:STRING=A;B;C") + "-DTEST_LIST:STRING=A;B;C" + "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND" + "-DTEST_OPTIONAL_LAST:FILEPATH=TEST_OPTIONAL_LAST-NOTFOUND") diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake index 192776ba7..2fb0705a5 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt index 12a76c5d4..2fc7d291b 100644 --- a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt +++ b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt @@ -6,12 +6,12 @@ is not an existing non-empty directory. Please specify one of: \* SOURCE_DIR with an existing non-empty directory + \* DOWNLOAD_COMMAND \* URL \* GIT_REPOSITORY + \* SVN_REPOSITORY \* HG_REPOSITORY \* CVS_REPOSITORY and CVS_MODULE - \* SVN_REVISION - \* DOWNLOAD_COMMAND Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\) NoOptions.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 47d612969..caaf0d2fd 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(IncludeScope-Add) +run_cmake(IncludeScope-Add_Step) run_cmake(NoOptions) run_cmake(SourceEmpty) run_cmake(SourceMissing) @@ -12,3 +14,41 @@ run_cmake(Add_StepDependencies_iface) run_cmake(Add_StepDependencies_iface_step) run_cmake(Add_StepDependencies_no_target) run_cmake(UsesTerminal) + +# Run both cmake and build steps. We always do a clean before the +# build to ensure that the download step re-runs each time. +function(__ep_test_with_build testName) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${testName}) + run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean) + run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .) +endfunction() + +__ep_test_with_build(MultiCommand) + +# Output is not predictable enough to be able to verify it reliably +# when using the various different Visual Studio generators +if(NOT RunCMake_GENERATOR MATCHES "Visual Studio") + __ep_test_with_build(LogOutputOnFailure) + __ep_test_with_build(LogOutputOnFailureMerged) +endif() + +# We can't test the substitution when using the old MSYS due to +# make/sh mangling the paths (substitution is performed correctly, +# but the mangling means we can't reliably test the output). +# There is no such issue when using the newer MSYS though. Therefore, +# we need to bypass the substitution test if using old MSYS. +# See merge request 1537 for discussion. +set(doSubstitutionTest YES) +if(RunCMake_GENERATOR STREQUAL "MSYS Makefiles") + execute_process(COMMAND uname OUTPUT_VARIABLE uname) + if(uname MATCHES "^MINGW32_NT") + set(doSubstitutionTest NO) + endif() +endif() +if(doSubstitutionTest) + __ep_test_with_build(Substitutions) +endif() diff --git a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt index 58a343ccf..07c6e8798 100644 --- a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt +++ b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt @@ -6,12 +6,12 @@ is not an existing non-empty directory. Please specify one of: \* SOURCE_DIR with an existing non-empty directory + \* DOWNLOAD_COMMAND \* URL \* GIT_REPOSITORY + \* SVN_REPOSITORY \* HG_REPOSITORY \* CVS_REPOSITORY and CVS_MODULE - \* SVN_REVISION - \* DOWNLOAD_COMMAND Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\) SourceEmpty.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt index e62f7cf5a..373f6e3aa 100644 --- a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt +++ b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt @@ -6,12 +6,12 @@ is not an existing non-empty directory. Please specify one of: \* SOURCE_DIR with an existing non-empty directory + \* DOWNLOAD_COMMAND \* URL \* GIT_REPOSITORY + \* SVN_REPOSITORY \* HG_REPOSITORY \* CVS_REPOSITORY and CVS_MODULE - \* SVN_REVISION - \* DOWNLOAD_COMMAND Call Stack \(most recent call first\): .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\) SourceMissing.cmake:[0-9]+ \(ExternalProject_Add\) diff --git a/Tests/RunCMake/ExternalProject/UsesTerminal.cmake b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake index cd874039d..d3494fd4e 100644 --- a/Tests/RunCMake/ExternalProject/UsesTerminal.cmake +++ b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index e9b2a7a70..dd73cd487 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -4,7 +4,18 @@ run_cmake(BadFoundVar) # The pseudo module will "find" a package with the given version. Check if the # version selection code in FPHSA works correctly. -set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=1.2.3.4.5") + +# Find a package with version 0. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0") +run_cmake(any_version_find_0) + +# Find a package with more customary version number, without requesting a specific version and in +# the presence of a cache variable VERSION. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudoNoVersionVar_VERSION=1.2.3.4_SHOULD_BE_IGNORED" "-DVERSION=BAD_VERSION") +run_cmake(any_version_VERSION_cache_variable) + +# Find a package with a more customary version number, without requesting a specific version. +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=1.2.3.4") run_cmake(any_version) # test EXACT mode with every subcomponent diff --git a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake b/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake index e2b081d48..bead2af6f 100644 --- a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake +++ b/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake @@ -1,12 +1,6 @@ - enable_language(CXX C) -add_library(empty empty.cpp empty.c) -target_compile_options(empty - PRIVATE LANG_IS_$<COMPILE_LANGUAGE> -) - file(GENERATE - OUTPUT opts-$<COMPILE_LANGUAGE>.txt - CONTENT "$<TARGET_PROPERTY:empty,COMPILE_OPTIONS>\n" + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opts-$<COMPILE_LANGUAGE>.txt + CONTENT "LANG_IS_$<COMPILE_LANGUAGE>\n" ) diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt index b08ef5a15..4c2e35fcc 100644 --- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt @@ -3,6 +3,7 @@ CMake Error at OutputNameMatchesObjects.cmake:[0-9]+ \(file\): \$<TARGET_OBJECTS:foo> - Objects of target "foo" referenced but is not an OBJECT library. + Objects of target "foo" referenced but is not an allowed library types + \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\). Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake index daa7c49ca..84825feea 100644 --- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake +++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake @@ -1,11 +1,8 @@ enable_language(CXX) file(GENERATE - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<BOOL:$<TARGET_OBJECTS:foo>>somefile.cpp" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>/somefile.cpp" CONTENT "static const char content[] = \"$<TARGET_OBJECTS:foo>\";\n" ) -add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/input.txt" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" "${CMAKE_CURRENT_BINARY_DIR}") - -add_executable(foo empty.cpp "${CMAKE_CURRENT_BINARY_DIR}/1somefile.cpp" "${CMAKE_CURRENT_BINARY_DIR}/input.txt") +add_library(foo INTERFACE ) diff --git a/Tests/RunCMake/File_Generate/ReRunCMake.cmake b/Tests/RunCMake/File_Generate/ReRunCMake.cmake index 109d60e6f..541d86df2 100644 --- a/Tests/RunCMake/File_Generate/ReRunCMake.cmake +++ b/Tests/RunCMake/File_Generate/ReRunCMake.cmake @@ -1,5 +1,5 @@ file(GENERATE - OUTPUT output_file.txt + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_file.txt" INPUT "${CMAKE_CURRENT_BINARY_DIR}/input_file.txt" ) diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index 82e903d82..94aaca84a 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -1,7 +1,11 @@ include(RunCMake) +run_cmake(CMP0070-NEW) +run_cmake(CMP0070-OLD) +run_cmake(CMP0070-WARN) + run_cmake(CommandConflict) -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) run_cmake(OutputConflict) endif() run_cmake(EmptyCondition1) @@ -17,15 +21,13 @@ if (NOT file_contents MATCHES "generated.cpp.rule") message(SEND_ERROR "Rule file not in target sources! ${file_contents}") endif() -if (NOT RunCMake_GENERATOR MATCHES "Visual Studio") - run_cmake(COMPILE_LANGUAGE-genex) - foreach(l CXX C) - file(READ "${RunCMake_BINARY_DIR}/COMPILE_LANGUAGE-genex-build/opts-${l}.txt" l_defs) - if (NOT l_defs STREQUAL "LANG_IS_${l}\n") - message(FATAL_ERROR "File content does not match: ${l_defs}") - endif() - endforeach() -endif() +run_cmake(COMPILE_LANGUAGE-genex) +foreach(l CXX C) + file(READ "${RunCMake_BINARY_DIR}/COMPILE_LANGUAGE-genex-build/opts-${l}.txt" l_defs) + if (NOT l_defs STREQUAL "LANG_IS_${l}\n") + message(FATAL_ERROR "File content does not match: ${l_defs}") + endif() +endforeach() set(timeformat "%Y%j%H%M%S") diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake index d1d832a11..bb36a4c48 100644 --- a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake +++ b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake @@ -1,5 +1,5 @@ file(GENERATE - OUTPUT output_file.txt + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output_file.txt CONTENT "123" ) diff --git a/Tests/RunCMake/FindMatlab/MatlabTest1.cmake b/Tests/RunCMake/FindMatlab/MatlabTest1.cmake index 1cbc1c202..b4cc7415b 100644 --- a/Tests/RunCMake/FindMatlab/MatlabTest1.cmake +++ b/Tests/RunCMake/FindMatlab/MatlabTest1.cmake @@ -3,6 +3,9 @@ cmake_minimum_required (VERSION 2.8.12) enable_testing() project(test_should_fail) +if(NOT "${matlab_root}" STREQUAL "") + set(Matlab_ROOT_DIR ${matlab_root}) +endif() find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY) matlab_add_mex( diff --git a/Tests/RunCMake/FindMatlab/MatlabTest2.cmake b/Tests/RunCMake/FindMatlab/MatlabTest2.cmake index d5b0e6db1..4295d3c73 100644 --- a/Tests/RunCMake/FindMatlab/MatlabTest2.cmake +++ b/Tests/RunCMake/FindMatlab/MatlabTest2.cmake @@ -6,4 +6,8 @@ if(NOT DEFINED matlab_required) set(matlab_required REQUIRED) endif() +if(NOT DEFINED Matlab_ROOT_DIR AND NOT "${matlab_root}" STREQUAL "") + set(Matlab_ROOT_DIR ${matlab_root}) +endif() + find_package(Matlab ${matlab_required} COMPONENTS MX_LIBRARY) diff --git a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake index f0eb6b4bb..deebf89d9 100644 --- a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake @@ -1,5 +1,13 @@ include(RunCMake) + + +if(NOT "${MCR_ROOT}" STREQUAL "") + if(NOT EXISTS "${MCR_ROOT}") + message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}") + endif() + set(RunCMake_TEST_OPTIONS "-Dmatlab_root=${MCR_ROOT}") +endif() run_cmake(MatlabTest1) if(RunCMake_GENERATOR MATCHES "Make" AND UNIX) @@ -11,6 +19,9 @@ if(RunCMake_GENERATOR MATCHES "Make" AND UNIX) message(STATUS "RerunFindMatlab: first configuration to extract real Matlab_ROOT_DIR") set(RunCMake_TEST_OPTIONS "-Dmatlab_required=REQUIRED") + if(NOT "${MCR_ROOT}" STREQUAL "") + set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS} "-Dmatlab_root=${MCR_ROOT}") + endif() run_cmake(MatlabTest2) message(STATUS "RerunFindMatlab: flushing the variables") diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index 00cbb7b38..e82b05fd8 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -1,10 +1,12 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(FindPkgConfig_IMPORTED_TARGET C) find_package(PkgConfig REQUIRED) pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses) +message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}") + if (NCURSES_FOUND) set(tgt PkgConfig::NCURSES) if (NOT TARGET ${tgt}) @@ -24,3 +26,107 @@ if (NCURSES_FOUND) else () message(STATUS "skipping test; ncurses not found") endif () + + +# Setup for the remaining package tests below +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH) +set(fakePkgDir ${CMAKE_CURRENT_BINARY_DIR}/pc-fakepackage) +foreach(i 1 2) + set(pname cmakeinternalfakepackage${i}) + file(WRITE ${fakePkgDir}/lib/lib${pname}.a "") + file(WRITE ${fakePkgDir}/lib/${pname}.lib "") + file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc +"Name: CMakeInternalFakePackage${i} +Description: Dummy package (${i}) for FindPkgConfig IMPORTED_TARGET test +Version: 1.2.3 +Libs: -l${pname} +") +endforeach() + +# Always find the .pc file in the calls further below so that we can test that +# the import target find_library() calls handle the NO...PATH options correctly +set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig) + +# Confirm correct behavior of NO_CMAKE_PATH, ensuring we only find the library +# for the imported target if we have both set CMAKE_PREFIX_PATH and have not +# given the NO_CMAKE_PATH option +unset(CMAKE_PREFIX_PATH) +unset(ENV{CMAKE_PREFIX_PATH}) +pkg_check_modules(FakePackage1 QUIET IMPORTED_TARGET cmakeinternalfakepackage1) +if (TARGET PkgConfig::FakePackage1) + message(FATAL_ERROR "Have import target for fake package 1 with no path prefix") +endif() + +set(CMAKE_PREFIX_PATH ${fakePkgDir}) +pkg_check_modules(FakePackage1 QUIET IMPORTED_TARGET NO_CMAKE_PATH cmakeinternalfakepackage1) +if (TARGET PkgConfig::FakePackage1) + message(FATAL_ERROR "Have import target for fake package 1 with ignored cmake path") +endif() + +pkg_check_modules(FakePackage1 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage1) +if (NOT TARGET PkgConfig::FakePackage1) + message(FATAL_ERROR "No import target for fake package 1 with prefix path") +endif() + +# find targets in subdir and check their visibility +add_subdirectory(target_subdir) +if (TARGET PkgConfig::FakePackage1_dir) + message(FATAL_ERROR "imported target PkgConfig::FakePackage1_dir is visible outside it's directory") +endif() + +if (NOT TARGET PkgConfig::FakePackage1_global) + message(FATAL_ERROR "imported target PkgConfig::FakePackage1_global is not visible outside it's directory") +endif() + +# And now do the same for the NO_CMAKE_ENVIRONMENT_PATH - ENV{CMAKE_PREFIX_PATH} +# combination +unset(CMAKE_PREFIX_PATH) +unset(ENV{CMAKE_PREFIX_PATH}) +pkg_check_modules(FakePackage2 QUIET IMPORTED_TARGET cmakeinternalfakepackage2) +if (TARGET PkgConfig::FakePackage2) + message(FATAL_ERROR "Have import target for fake package 2 with no path prefix") +endif() + +set(ENV{CMAKE_PREFIX_PATH} ${fakePkgDir}) +pkg_check_modules(FakePackage2 QUIET IMPORTED_TARGET NO_CMAKE_ENVIRONMENT_PATH cmakeinternalfakepackage2) +if (TARGET PkgConfig::FakePackage2) + message(FATAL_ERROR "Have import target for fake package 2 with ignored cmake path") +endif() + +pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2) +if (NOT TARGET PkgConfig::FakePackage2) + message(FATAL_ERROR "No import target for fake package 2 with prefix path") +endif() + +# check that the full library path is also returned +if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") + message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}") +endif() + +# the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run +unset(FakePackage2_LINK_LIBRARIES) +pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2) +if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") + message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}") +endif() + +set(pname fakelinkoptionspackage) +file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc +"Name: FakeLinkOptionsPackage +Description: Dummy package for FindPkgConfig IMPORTED_TARGET INTERFACE_LINK_OPTIONS test +Version: 1.2.3 +Libs: -e dummy_main +") + +set(expected_link_options -e dummy_main) +pkg_check_modules(FakeLinkOptionsPackage REQUIRED QUIET IMPORTED_TARGET fakelinkoptionspackage) +if (NOT TARGET PkgConfig::FakeLinkOptionsPackage) + message(FATAL_ERROR "No import target for fake link options package") +endif() +get_target_property(link_options PkgConfig::FakeLinkOptionsPackage INTERFACE_LINK_OPTIONS) +if (NOT link_options STREQUAL expected_link_options) + message(FATAL_ERROR + "Additional link options not present in INTERFACE_LINK_OPTIONS property" + "expected: \"${expected_link_options}\", but got \"${link_options}\"" + ) +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake index 1defde840..d1d538512 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake @@ -29,7 +29,7 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") endif() else() - # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS propertie + # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS) get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS) get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index e12b52fe4..414d9b68f 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -14,6 +14,9 @@ endif() find_package(PkgConfig) if (PKG_CONFIG_FOUND) run_cmake(FindPkgConfig_GET_VARIABLE) + run_cmake(FindPkgConfig_GET_VARIABLE_PREFIX_PATH) + run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH) run_cmake(FindPkgConfig_cache_variables) run_cmake(FindPkgConfig_IMPORTED_TARGET) + run_cmake(FindPkgConfig_VERSION_OPERATORS) endif () diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat index b03837030..486977cbb 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -1,27 +1,27 @@ -@ECHO OFF - -:LOOP - -IF "%1"=="" ( - EXIT /B 255 -) - -IF "%1"=="--version" ( - ECHO 0.0-cmake-dummy - EXIT /B 0 -) - -IF "%1"=="--exists" ( - SHIFT - ECHO Expected: %* - ECHO Found: %PKG_CONFIG_PATH% - IF NOT "%*"=="%PKG_CONFIG_PATH%" ( - EXIT /B 1 - ) ELSE ( - EXIT /B 0 - ) -) -SHIFT -IF NOT "%~1"=="" GOTO LOOP - -EXIT /B 255 +@ECHO OFF
+
+:LOOP
+
+IF "%1"=="" (
+ EXIT /B 255
+)
+
+IF "%1"=="--version" (
+ ECHO 0.0-cmake-dummy
+ EXIT /B 0
+)
+
+IF "%1"=="--exists" (
+ SHIFT
+ ECHO Expected: %*
+ ECHO Found: %PKG_CONFIG_PATH%
+ IF NOT "%*"=="%PKG_CONFIG_PATH%" (
+ EXIT /B 1
+ ) ELSE (
+ EXIT /B 0
+ )
+)
+SHIFT
+IF NOT "%~1"=="" GOTO LOOP
+
+EXIT /B 255
diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake index 3d62a8af3..84012aa36 100644 --- a/Tests/RunCMake/Framework/FrameworkLayout.cmake +++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake @@ -11,8 +11,11 @@ add_library(Framework ${FRAMEWORK_TYPE} flatresource.txt deepresource.txt some.txt) +if("${CMAKE_FRAMEWORK}" STREQUAL "") + set_target_properties(Framework PROPERTIES + FRAMEWORK TRUE) +endif() set_target_properties(Framework PROPERTIES - FRAMEWORK TRUE PUBLIC_HEADER foo.h RESOURCE "res.txt") set_source_files_properties(flatresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources) @@ -22,4 +25,4 @@ set_source_files_properties(some.txt PROPERTIES MACOSX_PACKAGE_LOCATION somedir) add_custom_command(TARGET Framework POST_BUILD COMMAND /usr/bin/file $<TARGET_FILE:Framework>) -file(GENERATE OUTPUT FrameworkName.cmake CONTENT "set(framework-dir \"$<TARGET_BUNDLE_DIR:Framework>\")\n") +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkName.cmake CONTENT "set(framework-dir \"$<TARGET_BUNDLE_DIR:Framework>\")\n") diff --git a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt index 532cfedcc..4b5f761af 100644 --- a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt +++ b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt @@ -1,2 +1,2 @@ -.*/Framework:( Mach-O universal binary with [^ -]*)? current ar archive random library.* +/Framework: (Mach-O universal binary with [^ +]*)?current ar archive random library diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index 4fc83f801..c7e1319c1 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(InstallBeforeFramework) + function(framework_layout_test Name Toolchain Type) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkLayout-build) set(RunCMake_TEST_NO_CLEAN 1) @@ -18,11 +20,14 @@ framework_layout_test(iOSFrameworkLayout-build ios STATIC) framework_layout_test(OSXFrameworkLayout-build osx SHARED) framework_layout_test(OSXFrameworkLayout-build osx STATIC) -function(framework_type_test Toolchain Type) +function(framework_type_test Toolchain Type UseProperty) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkType-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake") list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}") + if(NOT ${UseProperty}) + list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FRAMEWORK=YES") + endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -31,7 +36,12 @@ function(framework_type_test Toolchain Type) run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .) endfunction() -framework_type_test(ios SHARED) -framework_type_test(ios STATIC) -framework_type_test(osx SHARED) -framework_type_test(osx STATIC) +framework_type_test(ios SHARED NO) +framework_type_test(ios STATIC NO) +framework_type_test(osx SHARED NO) +framework_type_test(osx STATIC NO) + +framework_type_test(ios SHARED YES) +framework_type_test(ios STATIC YES) +framework_type_test(osx SHARED YES) +framework_type_test(osx STATIC YES) diff --git a/Tests/RunCMake/Framework/ios.cmake b/Tests/RunCMake/Framework/ios.cmake index 209a50d39..446e9146a 100644 --- a/Tests/RunCMake/Framework/ios.cmake +++ b/Tests/RunCMake/Framework/ios.cmake @@ -20,6 +20,16 @@ execute_process( OUTPUT_VARIABLE IOS_SDK_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND ${XCRUN_EXECUTABLE} --sdk iphoneos --show-sdk-version + OUTPUT_VARIABLE IOS_SDK_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(IOS_SDK_VERSION VERSION_GREATER_EQUAL 11.0) + set(IOS_ARCH arm64) +else() + set(IOS_ARCH armv7) +endif() + set(CMAKE_OSX_SYSROOT ${IOS_SDK_PATH} CACHE PATH "Sysroot used for iOS support") -set(CMAKE_OSX_ARCHITECTURES "armv7" CACHE STRING "Architectures to build for") +set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE STRING "Architectures to build for") set(CMAKE_FIND_ROOT_PATH ${IOS_SDK_PATH} CACHE PATH "Find search path root") diff --git a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake index b544ba640..d671ee0ab 100644 --- a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake +++ b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake @@ -1,7 +1,11 @@ include(RunCMake) -if(SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$") - set(EXPECT_BSD 1) +if(SYSTEM_NAME STREQUAL "FreeBSD") + set(variant "-FreeBSD") +elseif(SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$") + set(variant "-BSD") +else() + set(variant "") endif() foreach(case @@ -10,8 +14,6 @@ foreach(case Usr UsrLocal ) - if(EXPECT_BSD) - set(RunCMake-stderr-file ${case}-BSD-stderr.txt) - endif() + set(RunCMake-stderr-file ${case}${variant}-stderr.txt) run_cmake(${case}) endforeach() diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index e0677a7a3..ae9a84c43 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -45,13 +45,6 @@ include(GenerateExportHeader) set(CMAKE_CXX_STANDARD 98) -# Those versions of the HP compiler that need a flag to get proper C++98 -# template support also need a flag to use the newer C++ library. -if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND - CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98") - string(APPEND CMAKE_CXX_FLAGS " -AA") -endif () - # Clang/C2 in C++98 mode cannot properly handle some of MSVC headers if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") @@ -60,7 +53,16 @@ endif() add_subdirectory(lib_shared_and_static) -add_compiler_export_flags() +if(CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY) + # With GNU 7 on AIX, passing -fvisibility=hidden when driving the + # linker for a shared library drops the so init/destruct symbols. + # Just use the modern approach instead of testing the macro. + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +else() + add_compiler_export_flags() +endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}) @@ -83,6 +85,7 @@ macro_add_test_library(libshared) macro_add_test_library(libstatic) add_subdirectory(nodeprecated) +add_subdirectory(includeguard) if(NOT BORLAND) add_subdirectory(c_identifier) endif() diff --git a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake index 9423ef5dd..18c334080 100644 --- a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake @@ -4,7 +4,7 @@ function(run_GEH) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GEH-build) set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -12,6 +12,8 @@ function(run_GEH) run_cmake(GEH) run_cmake_command(GEH-build ${CMAKE_COMMAND} --build . --config Debug) run_cmake_command(GEH-run ${RunCMake_TEST_BINARY_DIR}/GenerateExportHeader) + run_cmake_command(GEH-incguard-macro-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_macro) + run_cmake_command(GEH-incguard-custom-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_custom) file(STRINGS "${RunCMake_TEST_BINARY_DIR}/failure_test_targets" failure_test_targets) diff --git a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp index 9ac838183..752b49e71 100644 --- a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp +++ b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp @@ -1,7 +1,7 @@ #include "libshared_and_static.h" #ifndef MY_CUSTOM_CONTENT_ADDED -#error "MY_CUSTOM_CONTENT_ADDED not defined!" +# error "MY_CUSTOM_CONTENT_ADDED not defined!" #endif int libshared_and_static::Class::method() const diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt index c4a761c74..9516a5aa2 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt +++ b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt @@ -1,7 +1,5 @@ include(GenerateExportHeader) -add_compiler_export_flags() - set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(libshared SHARED libshared.cpp) diff --git a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt index 0fd136cee..56e833524 100644 --- a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt +++ b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt @@ -2,8 +2,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) include(GenerateExportHeader) -add_compiler_export_flags() - # Show that the export header has no effect on a static library. add_library(libstatic STATIC libstatic.cpp) diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h index e8af0a5c1..0b1dcba5b 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h index 598bd71be..5e3ac9f3f 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h index cc20e09b0..dac4fda65 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h index 4aaa84863..b6e2a4a88 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h index 053ad1869..11f8042e3 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h index 4aaa84863..b6e2a4a88 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h index 808ff0131..1481acd87 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h index 4aaa84863..b6e2a4a88 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h index cc20e09b0..dac4fda65 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h index 4aaa84863..b6e2a4a88 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h index 4e675af6c..3ba2d2eac 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h index 4d5ed4ecd..3c7e093ab 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h index 84340e305..bf9163ebe 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h index 598bd71be..5e3ac9f3f 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt index 0e48ba423..86d3e0472 100644 --- a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt @@ -50,4 +50,6 @@ CMake Error at BadAND.cmake:1 \(add_custom_target\): Parameters to \$<AND> must resolve to either '0' or '1'. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt index 964ea4d4e..42dd0ce50 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt @@ -32,4 +32,6 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): Expression syntax not recognized. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt index e5e628c30..627327c12 100644 --- a/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt @@ -49,4 +49,6 @@ CMake Error at BadNOT.cmake:1 \(add_custom_target\): \$<NOT> parameter must resolve to exactly one '0' or '1' value. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt index eb263286e..56e6af00f 100644 --- a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt @@ -50,4 +50,6 @@ CMake Error at BadOR.cmake:1 \(add_custom_target\): Parameters to \$<OR> must resolve to either '0' or '1'. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt index 8d3c4ccd6..a08e7b236 100644 --- a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt @@ -15,3 +15,12 @@ CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\): "Relative/Path" is not an absolute path. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) ++ +CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<SHELL_PATH:;> + + "" is not an absolute path. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake index 5eff7bccb..0e7c342e4 100644 --- a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake @@ -1,4 +1,5 @@ add_custom_target(check ALL COMMAND check $<SHELL_PATH:> $<SHELL_PATH:Relative/Path> + "$<SHELL_PATH:;>" VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt index dd0d931be..2f04c78f0 100644 --- a/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt @@ -35,4 +35,6 @@ CMake Error at BadStrEqual.cmake:1 \(add_custom_target\): \$<STREQUAL> expression requires 2 comma separated parameters, but got 3 instead. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt index 969393acc..98eed1f0a 100644 --- a/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt @@ -5,4 +5,6 @@ CMake Error at BadTargetName.cmake:1 \(add_custom_target\): \$<TARGET_NAME> expression requires literal input. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists.txt:3 \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt index 533d38cef..a597d79b6 100644 --- a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): +CMake Error at BadTargetTypeObject.cmake:2 \(add_custom_target\): Error evaluating generator expression: \$<TARGET_FILE:objlib> @@ -7,7 +7,7 @@ CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): +CMake Error at BadTargetTypeObject.cmake:2 \(add_custom_target\): Error evaluating generator expression: \$<TARGET_SONAME_FILE:objlib> @@ -16,7 +16,7 @@ CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): +CMake Error at BadTargetTypeObject.cmake:2 \(add_custom_target\): Error evaluating generator expression: \$<TARGET_LINKER_FILE:objlib> diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake index c47ee2bec..60e2c0dbc 100644 --- a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake @@ -1,5 +1,4 @@ -enable_language(C) -add_library(objlib OBJECT empty.c) +add_library(objlib OBJECT) add_custom_target(check ALL COMMAND echo $<TARGET_FILE:objlib> $<TARGET_SONAME_FILE:objlib> diff --git a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake index d5b85c936..dfa23e09e 100644 --- a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake +++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake @@ -1,5 +1,5 @@ -project(CMP0044-WARN) +enable_language(C) string(TOLOWER ${CMAKE_C_COMPILER_ID} lc_test) if (lc_test STREQUAL CMAKE_C_COMPILER_ID) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt index 789b4d09a..c8f773a0a 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt @@ -1,10 +1,10 @@ -CMake Error at COMPILE_LANGUAGE-add_custom_command.cmake:6 \(add_custom_command\): +CMake Error at COMPILE_LANGUAGE-add_custom_command.cmake:2 \(add_custom_command\): Error evaluating generator expression: \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake index f4ba26153..c3f051ab4 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake @@ -1,8 +1,4 @@ - -enable_language(C) - -add_library(empty empty.c) - -add_custom_command(TARGET empty PRE_BUILD +add_custom_target(drive) +add_custom_command(TARGET drive PRE_BUILD COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANGUAGE> ) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt index 400fbc035..7025838b1 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt @@ -1,10 +1,10 @@ -CMake Error at COMPILE_LANGUAGE-add_custom_target.cmake:4 \(add_custom_target\): +CMake Error at COMPILE_LANGUAGE-add_custom_target.cmake:1 \(add_custom_target\): Error evaluating generator expression: \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake index 4102623f8..b826772e2 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake @@ -1,6 +1,3 @@ - -enable_language(C) - -add_custom_target(empty +add_custom_target(drive COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANGUAGE> ) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt index e45bb020e..8d05e59a0 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt @@ -1,10 +1,10 @@ -CMake Error at COMPILE_LANGUAGE-add_executable.cmake:4 \(add_executable\): +CMake Error at COMPILE_LANGUAGE-add_executable.cmake:1 \(add_executable\): Error evaluating generator expression: \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake index 5c2ff351c..ff965a9e7 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake @@ -1,4 +1 @@ - -enable_language(C) - add_executable(empty empty.$<COMPILE_LANGUAGE>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt index c9ee6fe2a..2ac9b76ac 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt @@ -1,10 +1,10 @@ -CMake Error at COMPILE_LANGUAGE-add_library.cmake:4 \(add_library\): +CMake Error at COMPILE_LANGUAGE-add_library.cmake:1 \(add_library\): Error evaluating generator expression: \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake index dd9f82403..dd1b5a2d7 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake @@ -1,4 +1 @@ - -enable_language(C) - add_library(empty empty.$<COMPILE_LANGUAGE>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt index 9955f5d91..fd8a731f1 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt @@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-add_test.cmake:5 \(add_test\): \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt index eca700f4d..bef7f63b9 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt @@ -3,6 +3,6 @@ CMake Error: \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt index 2d324e2ac..8e7f88125 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt @@ -1,10 +1,10 @@ -CMake Error at COMPILE_LANGUAGE-target_sources.cmake:5 \(target_sources\): +CMake Error at COMPILE_LANGUAGE-target_sources.cmake:2 \(target_sources\): Error evaluating generator expression: \$<COMPILE_LANGUAGE> - \$<COMPILE_LANGUAGE:...> may only be used to specify include directories - compile definitions, compile options and to evaluate components of the + \$<COMPILE_LANGUAGE:...> may only be used to specify include directories, + compile definitions, compile options, and to evaluate components of the file\(GENERATE\) command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake index 0c78acd74..a4a5abb5e 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake @@ -1,5 +1,2 @@ - -enable_language(C) - -add_library(empty empty.c) +add_library(empty) target_sources(empty PRIVATE empty.$<COMPILE_LANGUAGE>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake index cec12a3fb..00dd29070 100644 --- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake @@ -1,4 +1,4 @@ enable_language(C) add_executable(empty empty.c) -target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wall>) +target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:$<TARGET_EXISTS:too,many,parameters>>) diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt index dd7a18304..0c21aa682 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at NonValidTarget-CXX_COMPILER_ID.cmake:4 \(add_custom_command\): +CMake Error at NonValidTarget-CXX_COMPILER_ID.cmake:1 \(add_custom_command\): Error evaluating generator expression: \$<CXX_COMPILER_ID> diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake index 7dd38da4a..a9fb0925f 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake @@ -1,8 +1,4 @@ - -enable_language(CXX) - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<CXX_COMPILER_ID>.cpp" ) - -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt index d4a064af1..fae1bd225 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at NonValidTarget-CXX_COMPILER_VERSION.cmake:4 \(add_custom_command\): +CMake Error at NonValidTarget-CXX_COMPILER_VERSION.cmake:1 \(add_custom_command\): Error evaluating generator expression: \$<CXX_COMPILER_VERSION> diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake index 1afb2b56f..41610c422 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake @@ -1,8 +1,4 @@ - -enable_language(CXX) - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<CXX_COMPILER_VERSION>.cpp" ) - -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt index b8e53ed91..337b2996e 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at NonValidTarget-C_COMPILER_ID.cmake:4 \(add_custom_command\): +CMake Error at NonValidTarget-C_COMPILER_ID.cmake:1 \(add_custom_command\): Error evaluating generator expression: \$<C_COMPILER_ID> diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake index 2d92ee39e..1b02431e1 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake @@ -1,8 +1,4 @@ - -enable_language(CXX) - -add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp" - COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_ID>.cpp" +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_ID>.c" ) - -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c") diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt index 551efe963..d8548b515 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at NonValidTarget-C_COMPILER_VERSION.cmake:4 \(add_custom_command\): +CMake Error at NonValidTarget-C_COMPILER_VERSION.cmake:1 \(add_custom_command\): Error evaluating generator expression: \$<C_COMPILER_VERSION> diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake index 9b8a53150..bc1ffe059 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake @@ -1,8 +1,4 @@ - -enable_language(CXX) - -add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp" - COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_VERSION>.cpp" +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_VERSION>.c" ) - -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c") diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt index 0e87538c6..4babf4375 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at NonValidTarget-TARGET_POLICY.cmake:4 \(add_custom_command\): +CMake Error at NonValidTarget-TARGET_POLICY.cmake:1 \(add_custom_command\): Error evaluating generator expression: \$<TARGET_POLICY:CMP0004> diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake index 10b37b5a4..55d8a9981 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake @@ -1,8 +1,4 @@ - -enable_language(CXX) - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_POLICY:CMP0004>.cpp" ) - -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt index 08ad3c2d8..c4149470a 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at NonValidTarget-TARGET_PROPERTY.cmake:4 \(add_custom_command\): +CMake Error at NonValidTarget-TARGET_PROPERTY.cmake:1 \(add_custom_command\): Error evaluating generator expression: \$<TARGET_PROPERTY:NotAProperty> diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake index 64abc5f90..9e246b278 100644 --- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake +++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake @@ -1,8 +1,4 @@ - -enable_language(CXX) - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_PROPERTY:NotAProperty>.cpp" ) - -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") +add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp") diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt index bf592e75c..013c4f25b 100644 --- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt @@ -1,4 +1,10 @@ CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): - Target 'empty1' OUTPUT_NAME depends on itself. + Target 'empty2' OUTPUT_NAME depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty2' OUTPUT_NAME depends on itself. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake index 5cb80509e..006b0daad 100644 --- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake +++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake @@ -1,3 +1,6 @@ enable_language(C) add_executable(empty1 empty.c) set_property(TARGET empty1 PROPERTY OUTPUT_NAME $<TARGET_FILE_NAME:empty1>) + +add_executable(empty2 empty.c) +set_property(TARGET empty2 PROPERTY OUTPUT_NAME $<TARGET_FILE_BASE_NAME:empty2>) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 2486259da..68a017251 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -15,8 +15,10 @@ run_cmake(BadSHELL_PATH) run_cmake(CMP0044-WARN) run_cmake(NonValidTarget-C_COMPILER_ID) run_cmake(NonValidTarget-CXX_COMPILER_ID) +run_cmake(NonValidTarget-Fortran_COMPILER_ID) run_cmake(NonValidTarget-C_COMPILER_VERSION) run_cmake(NonValidTarget-CXX_COMPILER_VERSION) +run_cmake(NonValidTarget-Fortran_COMPILER_VERSION) run_cmake(NonValidTarget-TARGET_BUNDLE_DIR) run_cmake(NonValidTarget-TARGET_BUNDLE_CONTENT_DIR) run_cmake(NonValidTarget-TARGET_PROPERTY) @@ -29,18 +31,79 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(COMPILE_LANG_AND_ID-add_custom_target) +run_cmake(COMPILE_LANG_AND_ID-add_custom_command) +run_cmake(COMPILE_LANG_AND_ID-install) +run_cmake(COMPILE_LANG_AND_ID-target_sources) +run_cmake(COMPILE_LANG_AND_ID-add_executable) +run_cmake(COMPILE_LANG_AND_ID-add_library) +run_cmake(COMPILE_LANG_AND_ID-add_test) +run_cmake(COMPILE_LANG_AND_ID-unknown-lang) run_cmake(TARGET_FILE-recursion) run_cmake(OUTPUT_NAME-recursion) +run_cmake(TARGET_FILE_PREFIX) +run_cmake(TARGET_FILE_PREFIX-imported-target) +run_cmake(TARGET_FILE_PREFIX-non-valid-target) +run_cmake(TARGET_LINKER_FILE_PREFIX-non-valid-target) +run_cmake(TARGET_FILE_SUFFIX) +run_cmake(TARGET_FILE_SUFFIX-imported-target) +run_cmake(TARGET_FILE_SUFFIX-non-valid-target) +run_cmake(TARGET_LINKER_FILE_SUFFIX-non-valid-target) +run_cmake_with_options(TARGET_FILE_BASE_NAME -DCMAKE_BUILD_TYPE:STRING=Debug) +run_cmake_with_options(TARGET_FILE_BASE_NAME-imported-target -DCMAKE_BUILD_TYPE:STRING=Debug) +run_cmake(TARGET_FILE_BASE_NAME-non-valid-target) +run_cmake(TARGET_LINKER_FILE_BASE_NAME-non-valid-target) +run_cmake(TARGET_PROPERTY-INCLUDE_DIRECTORIES) run_cmake(TARGET_PROPERTY-LOCATION) run_cmake(TARGET_PROPERTY-SOURCES) run_cmake(LINK_ONLY-not-linking) +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(TARGET_GENEX_EVAL-no-arg) +run_cmake(TARGET_GENEX_EVAL-no-target) +run_cmake(TARGET_GENEX_EVAL-non-valid-target) +run_cmake(TARGET_GENEX_EVAL-recursion1) +run_cmake(TARGET_GENEX_EVAL-recursion2) +run_cmake(TARGET_GENEX_EVAL) +run_cmake(GENEX_EVAL-recursion1) +run_cmake(GENEX_EVAL-recursion2) +run_cmake(GENEX_EVAL) +run_cmake(REMOVE_DUPLICATES-empty) +run_cmake(REMOVE_DUPLICATES-1) +run_cmake(REMOVE_DUPLICATES-2) +run_cmake(REMOVE_DUPLICATES-3) +run_cmake(REMOVE_DUPLICATES-4) +run_cmake(FILTER-empty) +run_cmake(FILTER-InvalidOperator) +run_cmake(FILTER-Exclude) +run_cmake(FILTER-Include) run_cmake(ImportedTarget-TARGET_BUNDLE_DIR) run_cmake(ImportedTarget-TARGET_BUNDLE_CONTENT_DIR) run_cmake(ImportedTarget-TARGET_PDB_FILE) +run_cmake(ImportedTarget-TARGET_PDB_FILE_BASE_NAME) if(LINKER_SUPPORTS_PDB) run_cmake(NonValidTarget-TARGET_PDB_FILE) run_cmake(ValidTarget-TARGET_PDB_FILE) + run_cmake(NonValidTarget-TARGET_PDB_FILE_BASE_NAME) + run_cmake(ValidTarget-TARGET_PDB_FILE_BASE_NAME) else() run_cmake(NonValidCompiler-TARGET_PDB_FILE) + run_cmake(NonValidCompiler-TARGET_PDB_FILE_BASE_NAME) endif() + +set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=OLD) +run_cmake(CMP0085-OLD) +unset(RunCMake_TEST_OPTIONS) + +run_cmake(CMP0085-WARN) + +set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=NEW) +run_cmake(CMP0085-NEW) +unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake index f1452b54d..c1a0f5bc4 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake @@ -1,8 +1,5 @@ file(READ ${RunCMake_TEST_BINARY_DIR}/foo.txt foo_sources) -# VS generators inject CMakeLists.txt as a source. Remove it. -string(REGEX REPLACE ";[^;]*CMakeLists.txt$" "" foo_sources "${foo_sources}") - set(foo_expected "empty.c;empty2.c;empty3.c") if(NOT foo_sources STREQUAL foo_expected) set(RunCMake_TEST_FAILED "foo SOURCES was:\n [[${foo_sources}]]\nbut expected:\n [[${foo_expected}]]") diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake index 89993ee09..dee7ead54 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake @@ -1,5 +1,5 @@ +cmake_policy(SET CMP0070 NEW) enable_language(C) add_library(foo empty.c empty2.c) target_sources(foo PRIVATE empty3.c) -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.txt - CONTENT "$<TARGET_PROPERTY:foo,SOURCES>") +file(GENERATE OUTPUT foo.txt CONTENT "$<TARGET_PROPERTY:foo,SOURCES>") diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake index 38e47f91f..a66394b42 100644 --- a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake +++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake @@ -3,7 +3,8 @@ enable_language(C) add_library(empty SHARED empty.c) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG) set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>) endif() diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake index 27250cba7..27ede066e 100644 --- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake @@ -3,7 +3,7 @@ include(RunCMake) set(RunCMake_GENERATOR_PLATFORM "") run_cmake(NoPlatform) -if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[01245])( 20[0-9][0-9])?$") +if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[012456])( 20[0-9][0-9])?$") set(RunCMake_GENERATOR_PLATFORM "x64") run_cmake(x64Platform) else() @@ -17,7 +17,7 @@ set(RunCMake_TEST_OPTIONS -A "Extra Platform") run_cmake(TwoPlatforms) unset(RunCMake_TEST_OPTIONS) -if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[01245])( 20[0-9][0-9])?$") +if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[012456])( 20[0-9][0-9])?$") set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestPlatform-toolchain.cmake) run_cmake(TestPlatformToolchain) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake b/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake index 763478cc5..d8138b8b2 100644 --- a/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake +++ b/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake @@ -1 +1,2 @@ +message("CMAKE_VS_PLATFORM_NAME_DEFAULT is \"${CMAKE_VS_PLATFORM_NAME_DEFAULT}\"") set(CMAKE_GENERATOR_PLATFORM "Test Platform") diff --git a/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt b/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt index b9bb3b231..686779013 100644 --- a/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt +++ b/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt @@ -1,3 +1,4 @@ +CMAKE_VS_PLATFORM_NAME_DEFAULT is "[^"]+" CMake Error at TestPlatformToolchain.cmake:[0-9]+ \(message\): CMAKE_GENERATOR_PLATFORM is "Test Platform" as expected. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt index 164d3aa79..7067423f4 100644 --- a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt @@ -5,6 +5,6 @@ CMake Error at CMakeLists.txt:[0-9]+ \(project\): given toolset specification - Test Toolset,host=x64,host=x64 + Test Toolset,host=x64,host=x86 that contains duplicate field key 'host'\.$ diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index f89100e84..ef8fd2540 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -3,7 +3,7 @@ include(RunCMake) set(RunCMake_GENERATOR_TOOLSET "") run_cmake(NoToolset) -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]") +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolset) set(RunCMake_GENERATOR_TOOLSET "Test Toolset,cuda=Test Cuda") @@ -12,19 +12,33 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]") run_cmake(TestToolsetCudaOnly) set(RunCMake_GENERATOR_TOOLSET "cuda=Test Cuda") run_cmake(TestToolsetCudaOnly) - if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[245]") + if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[2456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") run_cmake(TestToolsetHostArchBoth) set(RunCMake_GENERATOR_TOOLSET ",host=x64") - run_cmake(TestToolsetHostArchOnly) + run_cmake(TestToolsetHostArchOnly_x64) set(RunCMake_GENERATOR_TOOLSET "host=x64") - run_cmake(TestToolsetHostArchOnly) + run_cmake(TestToolsetHostArchOnly_x64) + set(RunCMake_GENERATOR_TOOLSET "host=x86") + run_cmake(TestToolsetHostArchOnly_x86) set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolsetHostArchNone) set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x65") run_cmake(BadToolsetHostArch) - set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x64") + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x86") run_cmake(BadToolsetHostArchTwice) + if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[56]") + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Test Toolset Version") + run_cmake(TestToolsetVersionBoth) + set(RunCMake_GENERATOR_TOOLSET ",version=Test Toolset Version") + run_cmake(TestToolsetVersionOnly) + set(RunCMake_GENERATOR_TOOLSET "version=Test Toolset Version") + run_cmake(TestToolsetVersionOnly) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Bad Toolset Version") + run_cmake(BadToolsetVersion) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Test Toolset Version,version=Test Toolset Version") + run_cmake(BadToolsetVersionTwice) + endif() else() set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") run_cmake(BadToolsetHostArch) @@ -47,7 +61,7 @@ set(RunCMake_TEST_OPTIONS -T "Extra Toolset") run_cmake(TwoToolsets) unset(RunCMake_TEST_OPTIONS) -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]|Xcode") +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]|Xcode") set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestToolset-toolchain.cmake) run_cmake(TestToolsetToolchain) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt index 576b40cc0..e5e6c8da9 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt @@ -1,2 +1,2 @@ -- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset' --- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='.*' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake index 26926f9db..085bb6b17 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -1,2 +1,15 @@ message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") + +if(CMAKE_GENERATOR MATCHES "Visual Studio 1[6]") + cmake_host_system_information(RESULT is_64_bit QUERY IS_64BIT) + if(is_64_bit) + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'x64' as expected.") + endif() + endif() +else() + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.") + endif() +endif() diff --git a/Tests/RunCMake/Languages/RunCMakeTest.cmake b/Tests/RunCMake/Languages/RunCMakeTest.cmake index 732baae41..2a534b338 100644 --- a/Tests/RunCMake/Languages/RunCMakeTest.cmake +++ b/Tests/RunCMake/Languages/RunCMakeTest.cmake @@ -6,3 +6,5 @@ run_cmake(link-libraries-TARGET_FILE-genex) run_cmake(link-libraries-TARGET_FILE-genex-ok) run_cmake(DetermineFail) + +run_cmake(ExternalCUDA) diff --git a/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake b/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake index 0d2949211..d3a8afb21 100644 --- a/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake +++ b/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake @@ -1,3 +1,30 @@ include(RunCMake) run_cmake(LINK_SEARCH_STATIC) + + +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + # Intel compiler does not reject bad flags or objects! + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(STATIC_LIBRARY_OPTIONS) + + run_cmake_target(STATIC_LIBRARY_OPTIONS basic StaticLinkOptions) + run_cmake_target(STATIC_LIBRARY_OPTIONS genex StaticLinkOptions_genex --config Release) + run_cmake_target(STATIC_LIBRARY_OPTIONS shared SharedLinkOptions) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index 869d11e5d..82db6b742 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -16,4 +16,22 @@ run_TargetMessages(OFF) run_TargetMessages(VAR-ON -DCMAKE_TARGET_MESSAGES=ON) run_TargetMessages(VAR-OFF -DCMAKE_TARGET_MESSAGES=OFF) +function(run_VerboseBuild) + run_cmake(VerboseBuild) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VerboseBuild-build) + if(RunCMake_GENERATOR STREQUAL "Watcom WMake") + # wmake does not actually show the verbose output. + set(RunCMake-stdout-file VerboseBuild-build-watcom-stdout.txt) + endif() + run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first) + unset(RunCMake-stdout-file) + if(MAKE_IS_GNU) + set(RunCMake-stdout-file VerboseBuild-nowork-gnu-stdout.txt) + endif() + run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose) +endfunction() +run_VerboseBuild() + run_cmake(CustomCommandDepfile-ERROR) +run_cmake(IncludeRegexSubdir) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index b3720fb7a..808a872aa 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -21,6 +21,24 @@ function(run_NinjaToolMissing) endfunction() run_NinjaToolMissing() +function(run_NoWorkToDo) + run_cmake(NoWorkToDo) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoWorkToDo-build) + run_cmake_command(NoWorkToDo-build ${CMAKE_COMMAND} --build .) + run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain) +endfunction() +run_NoWorkToDo() + +function(run_VerboseBuild) + run_cmake(VerboseBuild) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VerboseBuild-build) + run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first) + run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose) +endfunction() +run_VerboseBuild() + function(run_CMP0058 case) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build) @@ -39,6 +57,14 @@ run_CMP0058(NEW-no) run_CMP0058(NEW-by) run_cmake(CustomCommandDepfile) +run_cmake(CustomCommandJobPool) +run_cmake(JobPoolUsesTerminal) + +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) @@ -190,15 +216,16 @@ function(run_sub_cmake test ninja_output_path_prefix) set(cmd_prefix "") set(cmd_suffix "") endif() + set(fs_delay 3) # We assume the system as 1 sec timestamp resolution. file(WRITE "${top_build_ninja}" "\ subninja ${escaped_ninja_output_path_prefix}/build.ninja default ${escaped_ninja_output_path_prefix}/all -# Sleep for 1 second before to regenerate to make sure the timestamp of +# Sleep for long enough before regenerating to make sure the timestamp of # the top build.ninja will be strictly greater than the timestamp of the -# sub/build.ninja file. We assume the system as 1 sec timestamp resolution. +# sub/build.ninja file. rule RERUN - command = ${cmd_prefix}\"${escaped_CMAKE_COMMAND}\" -E sleep 1 && \"${escaped_CMAKE_COMMAND}\" -E touch \"${escaped_top_build_ninja}\"${cmd_suffix} + command = ${cmd_prefix}\"${escaped_CMAKE_COMMAND}\" -E sleep ${fs_delay} && \"${escaped_CMAKE_COMMAND}\" -E touch \"${escaped_top_build_ninja}\"${cmd_suffix} description = Testing regeneration generator = 1 @@ -224,7 +251,7 @@ build build.ninja: RERUN ${escaped_build_ninja_dep} || ${escaped_ninja_output_pa # Test regeneration rules run in order. set(main_cmakelists "${RunCMake_SOURCE_DIR}/CMakeLists.txt") - sleep(1) # Assume the system as 1 sec timestamp resolution. + sleep(${fs_delay}) touch("${main_cmakelists}") touch("${build_ninja_dep}") run_ninja("${top_build_dir}") @@ -263,3 +290,17 @@ foreach(ninja_output_path_prefix "sub space" "sub") run_sub_cmake(SubDirPrefix "${ninja_output_path_prefix}") run_sub_cmake(CustomCommandWorkingDirectory "${ninja_output_path_prefix}") endforeach(ninja_output_path_prefix) + +function (run_PreventTargetAliasesDupBuildRule) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PreventTargetAliasesDupBuildRule-build) + run_cmake(PreventTargetAliasesDupBuildRule) + run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err) +endfunction () +run_PreventTargetAliasesDupBuildRule() + +function (run_PreventConfigureFileDupBuildRule) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PreventConfigureFileDupBuildRule-build) + run_cmake(PreventConfigureFileDupBuildRule) + run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err) +endfunction() +run_PreventConfigureFileDupBuildRule() diff --git a/Tests/RunCMake/Ninja/greeting.c b/Tests/RunCMake/Ninja/greeting.c index ba3e55beb..1124d14c0 100644 --- a/Tests/RunCMake/Ninja/greeting.c +++ b/Tests/RunCMake/Ninja/greeting.c @@ -6,4 +6,5 @@ __declspec(dllexport) void greeting(void) { printf("Hello world!\n"); + fflush(stdout); } diff --git a/Tests/RunCMake/Ninja/greeting2.c b/Tests/RunCMake/Ninja/greeting2.c index c6ed87daa..cc8409c11 100644 --- a/Tests/RunCMake/Ninja/greeting2.c +++ b/Tests/RunCMake/Ninja/greeting2.c @@ -3,4 +3,5 @@ void greeting2(void) { printf("Hello world 2!\n"); + fflush(stdout); } diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt index 838b3d8c4..4dbd86144 100644 --- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt @@ -3,6 +3,7 @@ CMake Error at BadSourceExpression3.cmake:2 \(add_library\): \$<TARGET_OBJECTS:NotObjLib> - Objects of target "NotObjLib" referenced but is not an OBJECT library. + Objects of target "NotObjLib" referenced but is not an allowed library + types \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\). Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake index c3d9a622d..4e07ea6fa 100644 --- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake @@ -1,2 +1,2 @@ -add_library(NotObjLib STATIC a.c) +add_library(NotObjLib INTERFACE) add_library(A STATIC a.c $<TARGET_OBJECTS:NotObjLib>) diff --git a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt index a17c8cd13..d1b0d2c3e 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/InstallNotSupported-stderr.txt b/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt index 35a0e4fdf..a7004c14e 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/OwnSources-stderr.txt b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt index 40d650e21..208f3c9e6 100644 --- a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt @@ -2,4 +2,6 @@ The SOURCES of "A" use a generator expression that depends on the SOURCES themselves. Call Stack \(most recent call first\): - CMakeLists.txt:[0-9]+ \(include\)$ + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index b8eed73bb..5ec401873 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -6,17 +6,51 @@ 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 () + +if(NOT (RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")) + run_object_lib_build(CheckTargetObjects) +endif() + +run_object_lib_build(LinkObjLHSShared) +run_object_lib_build(LinkObjLHSStatic) +run_object_lib_build(LinkObjRHSShared) +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_object_lib_build(TransitiveDependencies) + run_cmake(MissingSource) run_cmake(ObjWithObj) run_cmake(OwnSources) @@ -24,6 +58,7 @@ run_cmake(PostBuild) run_cmake(PreBuild) run_cmake(PreLink) + function(run_Dependencies) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Dependencies-build) set(RunCMake_TEST_NO_CLEAN 1) diff --git a/Tests/RunCMake/ObjectLibrary/a.c b/Tests/RunCMake/ObjectLibrary/a.c index 16363033d..8e490f374 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 6751907b6..220ce0302 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/PolicyScope/dir1/CMakeLists.txt b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt index 16bcb3689..66ff016f9 100644 --- a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt +++ b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt @@ -2,4 +2,4 @@ add_library(foo STATIC foo.cpp) string(TOLOWER ${CMAKE_CXX_COMPILER_ID} compiler_id) -target_compile_definitions(foo PRIVATE Foo=$<CXX_COMPILER_ID:${compiler_id}>) +target_compile_definitions(foo PRIVATE Foo=$<CXX_COMPILER_ID:invalid,${compiler_id}>) diff --git a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake index 6a67e3cad..6efa0d402 100644 --- a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake +++ b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake @@ -7,3 +7,67 @@ run_cmake(Conflict4) run_cmake(Conflict5) run_cmake(Conflict6) run_cmake(Debug) +run_cmake(Genex1) +run_cmake(Genex2) + +set(RunCMake_TEST_OPTIONS "-DPIE_SUPPORTED=${RunCMake_BINARY_DIR}/PIESupported.cmake") +run_cmake(CheckPIESupported) +include ("${RunCMake_BINARY_DIR}/PIESupported.cmake" OPTIONAL) + +if (PIE_SUPPORTED OR NO_PIE_SUPPORTED) + if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|(Free|Net|Open)BSD)$") + # try to locate readelf needed for validation + find_program (READELF NAMES readelf) + endif() + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + # try to locate otool needed for validation + find_program (OTOOL NAMES otool) + endif() + + if ((READELF OR OTOOL) AND + (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")) + macro(run_cmake_target test subtest) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_CONFIG Release) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --config Release --target ${subtest} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + endmacro() + + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_SOURCE_DIR}") + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(PIE) + if (PIE_SUPPORTED) + run_cmake_target(PIE pie_on) + endif() + if (NO_PIE_SUPPORTED) + run_cmake_target(PIE pie_off) + endif() + + run_cmake(CMP0083) + run_cmake_target(CMP0083 cmp0083_ref) + + # retrieve default mode + include("${RunCMake_SOURCE_DIR}/PIE_validator.cmake") + include("${RunCMake_BINARY_DIR}/CMP0083-build/Release/CMP0083_config.cmake") + check_executable("${cmp0083_ref}" cmp0083_ref_mode) + + if ((cmp0083_ref_mode STREQUAL "PIE" AND NO_PIE_SUPPORTED) + OR (cmp0083_ref_mode STREQUAL "NO_PIE" AND PIE_SUPPORTED)) + run_cmake_target(CMP0083 cmp0083_new) + endif() + run_cmake_target(CMP0083 cmp0083_old) + + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) + endif() +endif() diff --git a/Tests/RunCMake/README.rst b/Tests/RunCMake/README.rst index 4aae4aed5..d8b43feef 100644 --- a/Tests/RunCMake/README.rst +++ b/Tests/RunCMake/README.rst @@ -47,11 +47,11 @@ but do not actually build anything. To add a test: containing expected test results: ``<SubTest>-result.txt`` - Process result expected if not "0" + Regex matching expected process result, if not ``0`` ``<SubTest>-stdout.txt`` Regex matching expected stdout content ``<SubTest>-stderr.txt`` - Regex matching expected stderr content, if not "^$" + Regex matching expected stderr content, if not ``^$`` ``<SubTest>-check.cmake`` Custom result check. @@ -65,3 +65,14 @@ but do not actually build anything. To add a test: Top of test binary tree and an failure must store a message in ``RunCMake_TEST_FAILED``. + +To speed up local testing, you can choose to run only a subset of +``run_cmake()`` tests in a ``RunCMakeTest.cmake`` script by using the +``RunCMake_TEST_FILTER`` environment variable. If this variable is set, +it is treated as a regular expression, and any tests whose names don't +match the regular expression are not run. For example:: + + $ RunCMake_TEST_FILTER="^example" ctest -R '^RunCMake\.Example$' + +This will only run subtests in ``RunCMake.Example`` that start with +``example``. diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 26312c45c..c743a02a3 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -9,6 +9,10 @@ foreach(arg endforeach() function(run_cmake test) + if(DEFINED ENV{RunCMake_TEST_FILTER} AND NOT test MATCHES "$ENV{RunCMake_TEST_FILTER}") + return() + endif() + set(top_src "${RunCMake_SOURCE_DIR}") set(top_bin "${RunCMake_BINARY_DIR}") if(EXISTS ${top_src}/${test}-result.txt) @@ -45,15 +49,17 @@ function(run_cmake test) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") endif() file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + if(RunCMake-prep-file AND EXISTS ${top_src}/${RunCMake-prep-file}) + include(${top_src}/${RunCMake-prep-file}) + else() + include(${top_src}/${test}-prep.cmake OPTIONAL) + endif() if(NOT DEFINED RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS "") endif() 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() @@ -68,22 +74,45 @@ function(run_cmake test) else() set(maybe_timeout "") endif() + if(RunCMake-stdin-file AND EXISTS ${top_src}/${RunCMake-stdin-file}) + set(maybe_input_file INPUT_FILE ${top_src}/${RunCMake-stdin-file}) + elseif(EXISTS ${top_src}/${test}-stdin.txt) + set(maybe_input_file INPUT_FILE ${top_src}/${test}-stdin.txt) + else() + set(maybe_input_file "") + endif() if(RunCMake_TEST_COMMAND) + if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + endif() execute_process( COMMAND ${RunCMake_TEST_COMMAND} - WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" + WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}" OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE ${actual_stderr_var} RESULT_VARIABLE actual_result ENCODING UTF8 ${maybe_timeout} + ${maybe_input_file} ) else() + if(RunCMake_GENERATOR_INSTANCE) + set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}") + else() + set(_D_CMAKE_GENERATOR_INSTANCE "") + endif() + if(NOT RunCMake_TEST_NO_SOURCE_DIR) + set(maybe_source_dir "${RunCMake_TEST_SOURCE_DIR}") + else() + set(maybe_source_dir "") + endif() execute_process( - COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" + COMMAND ${CMAKE_COMMAND} + ${maybe_source_dir} -G "${RunCMake_GENERATOR}" -A "${RunCMake_GENERATOR_PLATFORM}" -T "${RunCMake_GENERATOR_TOOLSET}" + ${_D_CMAKE_GENERATOR_INSTANCE} -DRunCMake_TEST=${test} --no-warn-unused-cli ${RunCMake_TEST_OPTIONS} @@ -93,15 +122,31 @@ function(run_cmake test) RESULT_VARIABLE actual_result ENCODING UTF8 ${maybe_timeout} + ${maybe_input_file} ) endif() set(msg "") if(NOT "${actual_result}" MATCHES "${expect_result}") string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n") endif() + string(CONCAT ignore_line_regex + "(^|\n)((==[0-9]+==" + "|BullseyeCoverage" + "|[a-z]+\\([0-9]+\\) malloc:" + "|clang[^:]*: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled:" + "|Error kstat returned" + "|Hit xcodebuild bug" + "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" + "|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" + ")[^\n]*\n)+" + ) foreach(o out err) string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}") - string(REGEX REPLACE "(^|\n)((==[0-9]+==|BullseyeCoverage|[a-z]+\\([0-9]+\\) malloc:|Error kstat returned|Hit xcodebuild bug|[^\n]*is a member of multiple groups|[^\n]*from Time Machine by path|[^\n]*Bullseye Testing Technology)[^\n]*\n)+" "\\1" actual_std${o} "${actual_std${o}}") + string(REGEX REPLACE "${ignore_line_regex}" "\\1" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") set(expect_${o} "") if(DEFINED expect_std${o}) @@ -146,5 +191,10 @@ function(run_cmake_command test) run_cmake(${test}) endfunction() +function(run_cmake_with_options test) + set(RunCMake_TEST_OPTIONS "${ARGN}") + run_cmake(${test}) +endfunction() + # Protect RunCMake tests from calling environment. unset(ENV{MAKEFLAGS}) diff --git a/Tests/RunCMake/RunCTest.cmake b/Tests/RunCMake/RunCTest.cmake index 89e16ee69..98fdf20ac 100644 --- a/Tests/RunCMake/RunCTest.cmake +++ b/Tests/RunCMake/RunCTest.cmake @@ -3,8 +3,12 @@ include(RunCMake) function(run_ctest CASE_NAME) configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake @ONLY) - configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in - ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY) + if(EXISTS "${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in") + configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in + ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY) + else() + file(REMOVE ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake) + endif() configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in ${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY) run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND} diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake index a9a7f05c7..6f1baa1d9 100644 --- a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake +++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake @@ -5,7 +5,7 @@ function(run_SymlinkImplicit) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SymlinkImplicit-build) set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -16,3 +16,17 @@ function(run_SymlinkImplicit) ${CMAKE_COMMAND} -Ddir=${RunCMake_TEST_BINARY_DIR} -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake) endfunction() run_SymlinkImplicit() + +function(run_Relative) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Relative-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(Relative) + run_cmake_command(Relative-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() +run_Relative() diff --git a/Tests/RunCMake/RuntimePath/main.c b/Tests/RunCMake/RuntimePath/main.c index 8488f4e58..181cd0973 100644 --- a/Tests/RunCMake/RuntimePath/main.c +++ b/Tests/RunCMake/RuntimePath/main.c @@ -1,4 +1,6 @@ +extern int libA(void); + int main(void) { - return 0; + return libA(); } diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index 4864295dc..481704554 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -4,6 +4,10 @@ if(RunCMake_GENERATOR STREQUAL Xcode) if(XCODE_BELOW_6_1) run_cmake(XcodeTooOld) endif() +elseif(RunCMake_GENERATOR STREQUAL Ninja) + if(CMAKE_Swift_COMPILER) + run_cmake(Win32ExecutableDisallowed) + endif() else() run_cmake(NotSupported) endif() diff --git a/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt index acfa30a25..0dde1bc5e 100644 --- a/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt +++ b/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt @@ -1 +1,12 @@ -^-->wrong<--$ +^CMake Deprecation Warning at CMP0053-At-OLD.cmake:1 \(cmake_policy\): + The OLD behavior for policy CMP0053 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +-->wrong<--$ diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake index d1fbb16aa..8d74dc163 100644 --- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake +++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake @@ -55,6 +55,8 @@ run_cmake(BracketNoSpace5) run_cmake(Escape1) run_cmake(Escape2) run_cmake(EscapeCharsAllowed) +run_cmake(NullAfterBackslash) +run_cmake(NullTerminatedArgument) include("${RunCMake_SOURCE_DIR}/EscapeCharsDisallowed.cmake") run_cmake(ParenNoSpace0) run_cmake(ParenNoSpace1) @@ -109,6 +111,11 @@ run_cmake(CMP0053-NameWithNewlineQuoted) run_cmake(CMP0053-NameWithCarriageReturnQuoted) run_cmake(CMP0053-NameWithEscapedSpacesQuoted) run_cmake(CMP0053-NameWithEscapedTabsQuoted) +run_cmake(CMP0053-Dollar-OLD) +run_cmake(CMP0053-Dollar-NEW) + +# Variable special types +run_cmake(QueryCache) # Function and macro tests. run_cmake(FunctionUnmatched) diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt index 3f5224487..f3ee8951b 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt +++ b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at UnterminatedCall1.cmake:2: +CMake Error at UnterminatedCall1.cmake:1: Parse error. Function missing ending "\)". End of file reached. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1.cmake b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake index 1166109c9..e1d211877 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall1.cmake +++ b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake @@ -1 +1,4 @@ message( + + +message("Additional message") diff --git a/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt index 18656f713..04216c32f 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt +++ b/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at UnterminatedCall2.cmake:4: +CMake Error at UnterminatedCall2.cmake:3: Parse error. Function missing ending "\)". End of file reached. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/UnterminatedCall2.cmake b/Tests/RunCMake/Syntax/UnterminatedCall2.cmake index 26e9e6223..8d4088dcb 100644 --- a/Tests/RunCMake/Syntax/UnterminatedCall2.cmake +++ b/Tests/RunCMake/Syntax/UnterminatedCall2.cmake @@ -1,3 +1,6 @@ set(var "\ ") message( + + +message("Additional message") diff --git a/Tests/RunCMake/TargetObjects/NoTarget.cmake b/Tests/RunCMake/TargetObjects/NoTarget.cmake index 5d7e33e79..268577d50 100644 --- a/Tests/RunCMake/TargetObjects/NoTarget.cmake +++ b/Tests/RunCMake/TargetObjects/NoTarget.cmake @@ -1,7 +1,7 @@ add_library(iface INTERFACE) target_sources(iface INTERFACE $<TARGET_OBJECTS:NoTarget>) -file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:NoTarget>) -file(GENERATE OUTPUT test_output2 CONTENT $<TARGET_PROPERTY:iface,INTERFACE_SOURCES>) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:NoTarget>) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output2 CONTENT $<TARGET_PROPERTY:iface,INTERFACE_SOURCES>) install(FILES $<TARGET_OBJECTS:NoTarget> DESTINATION objects) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt index a66794ce8..77c4afd08 100644 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt @@ -1,8 +1,9 @@ -CMake Error at NotObjlibTarget.cmake:3 \(file\): +CMake Error at NotObjlibTarget.cmake:[0-9]+ \(file\): Error evaluating generator expression: - \$<TARGET_OBJECTS:StaticLib> + \$<TARGET_OBJECTS:IFaceLib> - Objects of target "StaticLib" referenced but is not an OBJECT library. + Objects of target "IFaceLib" referenced but is not an allowed library types + \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\). Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake index 8e5fdd047..9fec369a7 100644 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake @@ -1,3 +1,3 @@ -add_library(StaticLib empty.cpp) +add_library(IFaceLib INTERFACE ) -file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:StaticLib>) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:IFaceLib>) diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 5f6be877b..0bcf88678 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -12,6 +12,7 @@ \* CMP0021 \* CMP0022 \* CMP0027 + \* CMP0037 \* CMP0038 \* CMP0041 \* CMP0042 @@ -22,6 +23,10 @@ \* CMP0065 \* CMP0068 \* CMP0069 + \* CMP0073 + \* CMP0076 + \* CMP0081 + \* CMP0083 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt index 3adf73ea0..d40b16baa 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt @@ -5,4 +5,6 @@ CMake Error at BadNonTarget.cmake:7 \(include_directories\): Target "NonExistent" not found. Call Stack \(most recent call first\): - CMakeLists.txt:8 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt index 7e002f547..8bff68e08 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt @@ -7,4 +7,4 @@ CMake Error at LinkImplementationCycle1.cmake:5 \(target_link_libraries\): target property which is transitive over the link libraries, creating a recursion. Call Stack \(most recent call first\): - CMakeLists.txt:8 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt index 2f72de6ec..044b77cc6 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt @@ -7,4 +7,4 @@ CMake Error at LinkImplementationCycle2.cmake:5 \(target_link_libraries\): target property which is transitive over the link libraries, creating a recursion. Call Stack \(most recent call first\): - CMakeLists.txt:8 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake index 645a57d5f..4294e9fd7 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake @@ -1,20 +1,8 @@ include(RunCMake) -run_cmake(BadSelfReference1) -run_cmake(BadSelfReference2) -run_cmake(BadSelfReference3) -run_cmake(BadSelfReference4) -run_cmake(BadSelfReference5) -run_cmake(BadSelfReference6) +run_cmake(BadSelfReference) run_cmake(BadNonTarget) -run_cmake(BadInvalidName1) -run_cmake(BadInvalidName2) -run_cmake(BadInvalidName3) -run_cmake(BadInvalidName4) -run_cmake(BadInvalidName5) -run_cmake(BadInvalidName6) -run_cmake(BadInvalidName7) -run_cmake(BadInvalidName8) +run_cmake(BadInvalidName) run_cmake(LinkImplementationCycle1) run_cmake(LinkImplementationCycle2) run_cmake(LinkImplementationCycle3) diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt index 1de5dd72e..c6b75fceb 100644 --- a/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt +++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt @@ -6,9 +6,7 @@ CMake Error in CMakeLists.txt: .*/Tests/RunCMake/TargetSources/empty_1.cpp .*/Tests/RunCMake/TargetSources/empty_2.cpp - .*/Tests/RunCMake/TargetSources/CMakeLists.txt Config "Release": .*/Tests/RunCMake/TargetSources/empty_1.cpp - .*/Tests/RunCMake/TargetSources/CMakeLists.txt diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt index 11bc96cf9..a40f46315 100644 --- a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt +++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt @@ -4,7 +4,7 @@ CMake Debug Log at OriginDebug.cmake:13 \(add_library\): \* .*Tests/RunCMake/TargetSources/empty_2.cpp Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) .* CMake Debug Log at OriginDebug.cmake:16 \(set_property\): Used sources for target OriginDebug: @@ -12,7 +12,7 @@ CMake Debug Log at OriginDebug.cmake:16 \(set_property\): \* .*Tests/RunCMake/TargetSources/empty_3.cpp Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) .* CMake Debug Log at OriginDebug.cmake:20 \(target_sources\): Used sources for target OriginDebug: @@ -20,7 +20,7 @@ CMake Debug Log at OriginDebug.cmake:20 \(target_sources\): \* .*Tests/RunCMake/TargetSources/empty_4.cpp Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) .* CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\): Used sources for target OriginDebug: @@ -28,4 +28,4 @@ CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\): \* .*Tests/RunCMake/TargetSources/empty_1.cpp Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake index 8bb6149d9..0d3e9a456 100644 --- a/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake +++ b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake @@ -1,6 +1,10 @@ +cmake_policy(SET CMP0076 NEW) add_library(iface INTERFACE) target_sources(iface INTERFACE empty_1.cpp) +get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES) +message(STATUS "iface: ${iface_sources}") + add_executable(main main.cpp) target_link_libraries(main iface) diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index bb55a6ebd..bee8c4e38 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -2,11 +2,15 @@ include(RunCMake) if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") run_cmake(ConfigNotAllowed) - run_cmake(OriginDebugIDE) -else() - run_cmake(OriginDebug) endif() +run_cmake(OriginDebug) run_cmake(CMP0026-LOCATION) +run_cmake(CMP0076-OLD) +run_cmake(CMP0076-WARN) run_cmake(RelativePathInInterface) +run_cmake(RelativePathInSubdirGenEx) +run_cmake(RelativePathInSubdirInterface) +run_cmake(RelativePathInSubdirPrivate) +run_cmake(RelativePathInSubdirInclude) run_cmake(ExportBuild) diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake index 8a202008f..7eb4485d0 100644 --- a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake +++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake @@ -9,3 +9,11 @@ run_cmake_toolchain(CallEnableLanguage) run_cmake_toolchain(CallProject) run_cmake_toolchain(FlagsInit) run_cmake_toolchain(LinkFlagsInit) + +function(run_IncludeDirectories) + run_cmake_toolchain(IncludeDirectories) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncludeDirectories-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(IncludeDirectories-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() +run_IncludeDirectories() diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 3af877f4f..27b81b7cd 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,6 +1,32 @@ include(RunCMake) +cmake_policy(SET CMP0054 NEW) + +run_cmake(VsCSharpCompilerOpts) +run_cmake(ExplicitCMakeLists) +run_cmake(RuntimeLibrary) +run_cmake(SourceGroupCMakeLists) + run_cmake(VsConfigurationType) run_cmake(VsTargetsFileReferences) run_cmake(VsCustomProps) run_cmake(VsDebuggerWorkingDir) +run_cmake(VsDebuggerCommand) +run_cmake(VsDebuggerCommandArguments) +run_cmake(VsDebuggerEnvironment) run_cmake(VsCSharpCustomTags) +run_cmake(VsCSharpReferenceProps) +run_cmake(VsCSharpWithoutSources) +run_cmake(VsCSharpDeployFiles) +run_cmake(VSCSharpDefines) +run_cmake(VsSdkDirectories) +run_cmake(VsGlobals) +run_cmake(VsProjectImport) +run_cmake(VsPackageReferences) + +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) + run_cmake(VsJustMyCode) +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20) + run_cmake(VsSpectreMitigation) +endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake index 70ea19326..9eb4619f4 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake @@ -4,20 +4,31 @@ if(NOT EXISTS "${csProjectFile}") return() endif() -set(tagFound FALSE) +# test VS_CSHARP_* for the following extensions +set(fileExtensions + "cs" + "png" + "jpg" + "xml" + "settings") +# set(tagName "MyCustomTag") set(tagValue "MyCustomValue") file(STRINGS "${csProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<${tagName}>${tagValue}</${tagName}>") - message(STATUS "foo.csproj has tag ${tagName} with value ${tagValue} defined") - set(tagFound TRUE) + +foreach(e ${fileExtensions}) + string(TOUPPER ${e} eUC) + set(tagFound FALSE) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<${tagName}${eUC}>${tagValue}${eUC}</${tagName}${eUC}>") + message(STATUS "foo.csproj has tag ${tagName}${eUC} with value ${tagValue}${eUC} defined") + set(tagFound TRUE) + endif() + endforeach() + if(NOT tagFound) + set(RunCMake_TEST_FAILED "Source file tag ${tagName}${eUC} with value ${tagValue}${eUC} not found.") + return() endif() endforeach() - -if(NOT tagFound) - set(RunCMake_TEST_FAILED "Source file tag ${tagName} with value ${tagValue} not found.") - return() -endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake index c51e9c370..96be54b06 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake @@ -1,11 +1,26 @@ enable_language(CSharp) -add_library(foo foo.cs) -set(props_file "${CMAKE_CURRENT_SOURCE_DIR}/my.props") +# test VS_CSHARP_* for the following extensions +set(fileExtensions + "cs" + "png" + "jpg" + "xml" + "settings") +# set(tagName "MyCustomTag") set(tagValue "MyCustomValue") -set_source_files_properties(foo.cs - PROPERTIES - VS_CSHARP_${tagName} "${tagValue}") +set(fileNames) +foreach(e ${fileExtensions}) + set(currentFile "${CMAKE_CURRENT_BINARY_DIR}/foo.${e}") + list(APPEND fileNames ${currentFile}) + file(TOUCH "${currentFile}") + string(TOUPPER ${e} eUC) + set_source_files_properties("${currentFile}" + PROPERTIES + VS_CSHARP_${tagName}${eUC} "${tagValue}${eUC}") +endforeach() + +add_library(foo ${fileNames}) diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake index 637c68c60..9d3f2a850 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake @@ -1,22 +1,24 @@ -set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") -if(NOT EXISTS "${vcProjectFile}") - set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") - return() -endif() +foreach(target foo bar) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() + endif() -set(debuggerWorkDirSet FALSE) + set(debuggerWorkDirSet FALSE) -file(STRINGS "${vcProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$") - if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory") - message(STATUS "foo.vcxproj has debugger working dir set") - set(debuggerWorkDirSet TRUE) + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo") + message(STATUS "${target}.vcxproj has debugger working dir set") + set(debuggerWorkDirSet TRUE) + endif() endif() + endforeach() + + if(NOT debuggerWorkDirSet) + set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.") + return() endif() endforeach() - -if(NOT debuggerWorkDirSet) - set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.") - return() -endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake index a277c6575..69ed85c62 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake @@ -1,5 +1,6 @@ enable_language(CXX) add_library(foo foo.cpp) +add_custom_target(bar) -set_target_properties(foo PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory") +set_target_properties(foo bar PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt index ca8c33f36..a63591fff 100644 --- a/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt +++ b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt @@ -1 +1 @@ -CMake Error: Target visibility_preset uses unsupported value \"hiden\" for CXX_VISIBILITY_PRESET +CMake Error: Target visibility_preset uses unsupported value \"hiden\" for CXX_VISIBILITY_PRESET. The supported values are: default, hidden, protected, and internal. diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt index 044574404..f4449929f 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/PerConfigPerSourceFlags-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt index 650064920..c3e9e318a 100644 --- a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt @@ -5,4 +5,6 @@ specified for source: - .*/Tests/RunCMake/XcodeProject/main.c$ + .*/Tests/RunCMake/XcodeProject/main.c ++ +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 5f4bdc30d..191f56dd7 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -1,9 +1,12 @@ include(RunCMake) +run_cmake(ExplicitCMakeLists) + run_cmake(XcodeFileType) run_cmake(XcodeAttributeLocation) run_cmake(XcodeAttributeGenex) run_cmake(XcodeAttributeGenexError) +run_cmake(XcodeGenerateTopLevelProjectOnly) run_cmake(XcodeObjectNeedsEscape) run_cmake(XcodeObjectNeedsQuote) run_cmake(XcodeOptimizationFlags) @@ -14,13 +17,52 @@ if (NOT XCODE_VERSION VERSION_LESS 6) endif() run_cmake(PerConfigPerSourceFlags) +run_cmake(PerConfigPerSourceOptions) +run_cmake(PerConfigPerSourceDefinitions) +run_cmake(PerConfigPerSourceIncludeDirs) + +function(XcodeSchemaGeneration) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeSchemaGeneration) + run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build) +endfunction() + +if(NOT XCODE_VERSION VERSION_LESS 7) + XcodeSchemaGeneration() + run_cmake(XcodeSchemaProperty) +endif() + +function(XcodeDependOnZeroCheck) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeDependOnZeroCheck-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeDependOnZeroCheck) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target parentdirlib) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target subdirlib) +endfunction() + +XcodeDependOnZeroCheck() + +# Isolate device tests from host architecture selection. +unset(ENV{CMAKE_OSX_ARCHITECTURES}) # Use a single build tree for a few tests without cleaning. if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeInstallIOS-build) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install") + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -35,7 +77,7 @@ if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_IOS=OFF" + "-DCMAKE_SYSTEM_NAME=Darwin" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -52,7 +94,7 @@ if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_IOS=ON" + "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -71,7 +113,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesWatchOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_WATCHOS=ON" + "-DCMAKE_SYSTEM_NAME=watchOS" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -90,7 +132,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesTvOS-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DTEST_TVOS=ON" + "-DCMAKE_SYSTEM_NAME=tvOS" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -116,8 +158,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "-DCMAKE_IOS_INSTALL_COMBINED=YES") + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -134,8 +177,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedPrune-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "-DCMAKE_IOS_INSTALL_COMBINED=YES") + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -152,8 +196,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedSingleArch-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS - "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install" - "-DCMAKE_IOS_INSTALL_COMBINED=YES") + "-DCMAKE_SYSTEM_NAME=iOS" + "-DCMAKE_IOS_INSTALL_COMBINED=YES" + "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -170,6 +215,7 @@ endif() if(NOT XCODE_VERSION VERSION_LESS 5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeMultiplatform-build) set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "${IOS_DEPLOYMENT_TARGET}") file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -188,18 +234,41 @@ if(NOT XCODE_VERSION VERSION_LESS 5) unset(RunCMake_TEST_OPTIONS) endif() -function(XcodeSchemaGeneration) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON") +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + function(deployment_target_test SystemName SDK) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DeploymentTarget-${SDK}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}") + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(DeploymentTarget) + run_cmake_command(DeploymentTarget-${SDK} ${CMAKE_COMMAND} --build .) + endfunction() + + deployment_target_test(Darwin macosx) + deployment_target_test(iOS iphoneos) + deployment_target_test(iOS iphonesimulator) + deployment_target_test(tvOS appletvos) + deployment_target_test(tvOS appletvsimulator) + deployment_target_test(watchOS watchos) + deployment_target_test(watchOS watchsimulator) +endif() - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + function(xctest_lookup_test SystemName SDK) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XCTestLookup-${SDK}-build) + set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}") - run_cmake(XcodeSchemaGeneration) - run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build) -endfunction() + run_cmake(XCTestLookup) + endfunction() -if(NOT XCODE_VERSION VERSION_LESS 7) - XcodeSchemaGeneration() + xctest_lookup_test(Darwin macosx) + xctest_lookup_test(iOS iphoneos) + xctest_lookup_test(iOS iphonesimulator) + xctest_lookup_test(tvOS appletvos) + xctest_lookup_test(tvOS appletvsimulator) endif() + +# Please add macOS-only tests above before the device-specific tests. diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake index 0b854d80a..ef772ea65 100644 --- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake @@ -3,24 +3,12 @@ cmake_minimum_required(VERSION 3.3) enable_language(C) -if(TEST_IOS) - set(CMAKE_OSX_SYSROOT iphoneos) - set(CMAKE_OSX_ARCHITECTURES "armv7") +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -endif(TEST_IOS) - -if(TEST_WATCHOS) - set(CMAKE_OSX_SYSROOT watchos) - set(CMAKE_OSX_ARCHITECTURES "armv7k") - set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") - set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") - set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") endif() -if(TEST_TVOS) - set(CMAKE_OSX_SYSROOT appletvos) - set(CMAKE_OSX_ARCHITECTURES "arm64") +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") @@ -38,7 +26,7 @@ add_dependencies(AppBundleTest AppBundle) # with custom extension -if (NOT TEST_IOS AND NOT TEST_WATCHOS AND NOT TEST_TVOS) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_executable(AppBundleExt MACOSX_BUNDLE main.m) set_target_properties(AppBundleExt PROPERTIES BUNDLE_EXTENSION "foo") install(TARGETS AppBundleExt BUNDLE DESTINATION FooExtension) @@ -52,7 +40,7 @@ endif() # Shared Framework (not supported for iOS on Xcode < 6) -if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS" OR NOT XCODE_VERSION VERSION_LESS 6) add_library(SharedFramework SHARED main.c) set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE) diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake index fc830b19e..f6c00b165 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake @@ -2,7 +2,14 @@ cmake_minimum_required(VERSION 3.3) project(IOSInstallCombined CXX) -set(CMAKE_OSX_SYSROOT iphoneos) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() + +if(NOT IOS) + message(FATAL_ERROR "IOS variable is not set") +endif() + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake index b47d3a597..ec11dbbd4 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake @@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(XcodeIOSInstallCombinedPrune CXX) -set(CMAKE_OSX_SYSROOT iphoneos) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake index 4b5e7ce36..58e96b4f3 100644 --- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake @@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 3.3) project(XcodeIOSInstallCombinedSingleArch CXX) -set(CMAKE_OSX_SYSROOT iphoneos) +if(XCODE_VERSION VERSION_GREATER_EQUAL 9) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10) +endif() + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf") diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake index a79741069..ab31387cd 100644 --- a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake @@ -2,11 +2,8 @@ cmake_minimum_required(VERSION 2.8.5) project(XcodeInstallIOS) -set(CMAKE_OSX_SYSROOT iphoneos) set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -set(CMAKE_OSX_ARCHITECTURES "armv7;i386") - add_library(foo STATIC foo.cpp) install(TARGETS foo ARCHIVE DESTINATION lib) diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 397c63d0a..0387dbb60 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -10,3 +10,14 @@ run_cmake(SourceByproducts) run_cmake(SourceUsesTerminal) run_cmake(TargetImported) run_cmake(TargetNotInDir) + +if(${RunCMake_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") + run_cmake(RemoveEmptyCommands) +endif() + +run_cmake(AssigningMultipleTargets) +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AssigningMultipleTargets-build) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(AssigningMultipleTargets-build ${CMAKE_COMMAND} --build .) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake index 6c4e91bca..2caed0328 100644 --- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(CommandExpandsEmpty) run_cmake(NoArguments) run_cmake(BadTargetName) run_cmake(ByproductsNoCommand) diff --git a/Tests/RunCMake/add_subdirectory/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMakeLists.txt index 18dfd2686..47d249cce 100644 --- a/Tests/RunCMake/add_subdirectory/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/CMakeLists.txt @@ -1,3 +1,10 @@ cmake_minimum_required(VERSION 3.2) + +# Have to set policy here due to policy scope +if(DEFINED CMP0082_VALUE) + cmake_policy(SET CMP0082 "${CMP0082_VALUE}") +endif() +set(CMAKE_POLICY_WARNING_CMP0082 ON) + project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt index 369a956e6..013058111 100644 --- a/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt +++ b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt @@ -2,4 +2,4 @@ add_subdirectory given source "DoesNotExist" which is not an existing directory. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake index f68600511..ff676a6ba 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake @@ -4,3 +4,11 @@ add_subdirectory(ExcludeFromAll EXCLUDE_FROM_ALL) add_executable(main main.cpp) target_link_libraries(main PRIVATE foo) + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(main_exe \"$<TARGET_FILE:main>\") +set(foo_lib \"$<TARGET_FILE:foo>\") +set(bar_lib \"$<TARGET_FILE:bar>\") +set(zot_lib \"$<TARGET_FILE:zot>\") +set(subinc_lib \"$<TARGET_FILE:subinc>\") +") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt index b1df6b04f..790da542f 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -1,4 +1,11 @@ -add_library(bar STATIC bar.cpp) +project(ExcludeFromAllSub NONE) + +add_library(bar STATIC EXCLUDE_FROM_ALL bar.cpp) + +add_library(zot STATIC zot.cpp) add_library(foo STATIC foo.cpp) target_include_directories(foo PUBLIC .) + +add_library(subinc STATIC subinc.cpp) +set_target_properties(subinc PROPERTIES EXCLUDE_FROM_ALL OFF) diff --git a/Tests/RunCMake/add_subdirectory/Missing-stderr.txt b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt index aba06755a..dd831406e 100644 --- a/Tests/RunCMake/add_subdirectory/Missing-stderr.txt +++ b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt @@ -5,4 +5,4 @@ does not contain a CMakeLists.txt file. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index 88b928308..951e03c8f 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -4,14 +4,57 @@ run_cmake(DoesNotExist) run_cmake(Missing) run_cmake(Function) -set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build) -set(RunCMake_TEST_NO_CLEAN 1) +macro(run_cmake_install case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS ${ARGN}) -file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") -file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${case}) + run_cmake_command(${case}-install ${CMAKE_COMMAND} -P cmake_install.cmake) + run_cmake_command(${case}-install-component ${CMAKE_COMMAND} -DCOMPONENT=Unspecified -P cmake_install.cmake) -run_cmake(ExcludeFromAll) -run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endmacro() -unset(RunCMake_TEST_BINARY_DIR) +run_cmake_install(CMP0082-WARN) +run_cmake_install(CMP0082-WARN-Nested) +run_cmake_install(CMP0082-WARN-NestedSub) +run_cmake_install(CMP0082-WARN-None) +run_cmake_install(CMP0082-WARN-NoTopInstall) +run_cmake_install(CMP0082-OLD -DCMP0082_VALUE=OLD) +run_cmake_install(CMP0082-NEW -DCMP0082_VALUE=NEW) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build) +if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) +endif() +run_cmake(ExcludeFromAll) +set(RunCMake_TEST_NO_CLEAN 1) +set(RunCMake-check-file ExcludeFromAll/check.cmake) +run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build . --config Debug) +if(RunCMake_GENERATOR STREQUAL "Ninja") + if(WIN32) + set(slash [[\]]) + else() + set(slash [[/]]) + endif() + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build . --target "ExcludeFromAll${slash}all") +elseif(RunCMake_GENERATOR MATCHES "Make") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll) + run_cmake_command(ExcludeFromAll-build-sub "${RunCMake_MAKE_PROGRAM}") +elseif(RunCMake_GENERATOR MATCHES "^Visual Studio [1-9][0-9]") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build ExcludeFromAll --config Debug) +elseif(RunCMake_GENERATOR STREQUAL "Xcode") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll) + run_cmake_command(ExcludeFromAll-build-sub xcodebuild -configuration Debug) +endif() +unset(RunCMake-check-file) unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_TEST_OPTIONS) +unset(RunCMake_TEST_BINARY_DIR) diff --git a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake index 9a5eaaf1c..dded248ed 100644 --- a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake +++ b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake @@ -6,6 +6,7 @@ run_cmake(exclude-from-all) run_cmake(imported) run_cmake(invalid-name) run_cmake(invalid-target) +run_cmake(imported-global-target) run_cmake(imported-target) run_cmake(alias-target) run_cmake(set_property) diff --git a/Tests/RunCMake/alias_targets/imported-target-stderr.txt b/Tests/RunCMake/alias_targets/imported-target-stderr.txt index bbff29a80..465de0362 100644 --- a/Tests/RunCMake/alias_targets/imported-target-stderr.txt +++ b/Tests/RunCMake/alias_targets/imported-target-stderr.txt @@ -1,5 +1,15 @@ -CMake Error at imported-target.cmake:6 \(add_library\): - add_library cannot create ALIAS target "alias" because target "foo" is - IMPORTED. +^CMake Error at imported-target.cmake:[0-9]+ \(add_executable\): + add_executable cannot create ALIAS target \"alias-test-exe\" because target + \"test-exe\" is imported but not globally visible. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists.txt:[0-9]+ \(include\) ++ +'alias-test-exe' does not exist![?] +* +CMake Error at imported-target.cmake:[0-9]+ \(add_library\): + add_library cannot create ALIAS target "alias-test-lib" because target + "test-lib" is imported but not globally visible. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +'alias-test-lib' does not exist![?]$ diff --git a/Tests/RunCMake/alias_targets/imported-target.cmake b/Tests/RunCMake/alias_targets/imported-target.cmake index 7259ab091..bb682fecd 100644 --- a/Tests/RunCMake/alias_targets/imported-target.cmake +++ b/Tests/RunCMake/alias_targets/imported-target.cmake @@ -1,6 +1,46 @@ enable_language(CXX) -add_library(foo SHARED IMPORTED) -add_library(alias ALIAS foo) +add_executable(test-exe IMPORTED) +add_executable(alias-test-exe ALIAS test-exe) + +if(TARGET alias-test-exe) + get_target_property(aliased-target alias-test-exe ALIASED_TARGET) + if("${aliased-target}" STREQUAL "test-exe") + get_target_property(aliased-name alias-test-exe NAME) + if("${aliased-name}" STREQUAL "test-exe") + message("'alias-test-exe' is an alias for '${aliased-target}'" + " and its name-property contains '${aliased-name}'.") + else() + message("'alias-test-exe' is an alias for '${aliased-target}'" + " but its name-property contains '${aliased-name}'!?") + endif() + else() + message("'alias-test-exe' is something but not a real target!?") + endif() +else() + message("'alias-test-exe' does not exist!?") +endif() + + +add_library(test-lib SHARED IMPORTED) +add_library(alias-test-lib ALIAS test-lib) + +if(TARGET alias-test-lib) + get_target_property(aliased-target alias-test-lib ALIASED_TARGET) + if("${aliased-target}" STREQUAL "test-lib") + get_target_property(aliased-name alias-test-lib NAME) + if("${aliased-name}" STREQUAL "test-lib") + message("'alias-test-lib' is an alias for '${aliased-target}'" + " and its name-property contains '${aliased-name}'.") + else() + message("'alias-test-lib' is an alias for '${aliased-target}'" + " but its name-property contains '${aliased-name}'!?") + endif() + else() + message("'alias-test-lib' is something but not a real target!?") + endif() +else() + message("'alias-test-lib' does not exist!?") +endif() diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt b/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt index 28e0e7235..1938da37f 100644 --- a/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt +++ b/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt @@ -1,4 +1,15 @@ -^[^ +^CMake Deprecation Warning at CMP0061-OLD-make.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0061 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +[^ ]+ --build \. --config "Release" -- -i [^ ]+ --build \. --config "Release" --target "MyTarget" -- -i diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt b/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt index 1dde84379..85bbdf175 100644 --- a/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt +++ b/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt @@ -1,4 +1,15 @@ -^[^ +^CMake Deprecation Warning at CMP0061-OLD-other.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0061 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +[^ ]+ --build \. --config "Release" [^ ]+ --build \. --config "Release" --target "MyTarget" diff --git a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake index e4c65e3b6..1030211e7 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_parse_arguments/RunCMakeTest.cmake b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake index 1e15b3b2c..505840d7a 100644 --- a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake @@ -11,3 +11,4 @@ run_cmake(BadArgvN2) run_cmake(BadArgvN3) run_cmake(BadArgvN4) run_cmake(CornerCasesArgvN) +run_cmake(KeyWordsMissingValues) diff --git a/Tests/RunCMake/configure_file/DirInput-stderr.txt b/Tests/RunCMake/configure_file/DirInput-stderr.txt index 2e0cd144c..165ad80eb 100644 --- a/Tests/RunCMake/configure_file/DirInput-stderr.txt +++ b/Tests/RunCMake/configure_file/DirInput-stderr.txt @@ -1,7 +1,7 @@ CMake Error at DirInput.cmake:[0-9]+ \(configure_file\): configure_file input location - .*/Tests/RunCMake/configure_file/. + .*/Tests/RunCMake/configure_file is a directory but a file was expected. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt b/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt index 2e59d99ec..cc9085fee 100644 --- a/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt +++ b/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt @@ -1,7 +1,6 @@ Run dashboard with model Experimental Source directory: .*/Tests/RunCMake/ctest_build/BuildQuiet Build directory: .*/Tests/RunCMake/ctest_build/BuildQuiet-build - Reading ctest configuration file: .*/Tests/RunCMake/ctest_build/BuildQuiet/CTestConfig.cmake Site: test-site Build name: test-build-name Use Experimental tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt b/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt index 015644d81..98f5a4cd4 100644 --- a/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt +++ b/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt @@ -1,7 +1,6 @@ Run dashboard with model Experimental Source directory: .*/Tests/RunCMake/ctest_configure/ConfigureQuiet Build directory: .*/Tests/RunCMake/ctest_configure/ConfigureQuiet-build - Reading ctest configuration file: .*/Tests/RunCMake/ctest_configure/ConfigureQuiet/CTestConfig.cmake Site: test-site Build name: test-build-name Use Experimental tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in b/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in index 5cb0b4ef6..6b11cffac 100644 --- a/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in +++ b/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in @@ -27,7 +27,11 @@ passTest(two) # 6 passTest(cleanupBar) # 7 passTest(three) # 8 failTest(setupFails) # 9 -passTest(wontRun) # 10 + +# Special case, test executable always missing to verify fixture dependencies +# are checked before existence of test executable to be run +add_test(NAME wontRun COMMAND iDoNotExist) # 10 + passTest(cyclicSetup) # 11 passTest(cyclicCleanup) # 12 passTest(cleanupUnused) # 13 diff --git a/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in b/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in index 6d4a718d0..53bdd20c8 100644 --- a/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in +++ b/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in @@ -1,9 +1,6 @@ -set (CTEST_PROJECT_NAME "CTestTestMemcheck@CASE_NAME@") set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) @CTEST_EXTRA_CONFIG@ diff --git a/Tests/RunCMake/ctest_skipped_test/skip.bat b/Tests/RunCMake/ctest_skipped_test/skip.bat index 80e1290df..580f46018 100755 --- a/Tests/RunCMake/ctest_skipped_test/skip.bat +++ b/Tests/RunCMake/ctest_skipped_test/skip.bat @@ -1 +1 @@ -EXIT 125 +EXIT 125
diff --git a/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt b/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt index 7e94b8a12..f4a0ba37a 100644 --- a/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt +++ b/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt @@ -1,7 +1,6 @@ Run dashboard with model Experimental Source directory: .*/Tests/RunCMake/ctest_start/ConfigInBuild Build directory: .*/Tests/RunCMake/ctest_start/ConfigInBuild-build - Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/ConfigInBuild-build/CTestConfig.cmake Site: test-site Build name: test-build-name Use Experimental tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt b/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt index c3903726a..5f98b4e31 100644 --- a/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt +++ b/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt @@ -1,7 +1,6 @@ Run dashboard with model Experimental Source directory: .*/Tests/RunCMake/ctest_start/ConfigInSource Build directory: .*/Tests/RunCMake/ctest_start/ConfigInSource-build - Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/ConfigInSource/CTestConfig.cmake Site: test-site Build name: test-build-name Use Experimental tag: [0-9-]+ diff --git a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake index d630a7904..905ad0003 100644 --- a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake @@ -7,17 +7,47 @@ function(run_ctest_start CASE_NAME) run_ctest(${CASE_NAME}) endfunction() -run_ctest_start(StartQuiet Experimental QUIET) +function(check_tag_contents EXPECTED) + set(_tag_file "${RunCMake_BINARY_DIR}/${CASE_NAME}-build/Testing/TAG") + if(EXISTS "${_tag_file}") + file(READ "${_tag_file}" _tag_contents) + if(NOT _tag_contents MATCHES "${EXPECTED}") + set(RunCMake_TEST_FAILED "Testing/TAG file does not match expected value.\nActual TAG file:\n${_tag_contents}\nExpected TAG file:\n${EXPECTED}\n" PARENT_SCOPE) + endif() + else() + set(RunCMake_TEST_FAILED "Testing/TAG file does not exist." PARENT_SCOPE) + endif() +endfunction() +run_ctest_start(StartQuiet Experimental QUIET) run_ctest_start(ConfigInSource Experimental) +run_ctest_start(FunctionScope Experimental QUIET) +run_ctest_start(WriteModelToTagExperimental Experimental QUIET) +run_ctest_start(WriteModelToTagContinuous Continuous QUIET) +run_ctest_start(WriteModelToTagNightly Nightly QUIET) +run_ctest_start(WriteModelToTagNoMatchingTrack Continuous TRACK SomeWeirdTrackName QUIET) +run_ctest_start(AppendSameModel Continuous APPEND) +run_ctest_start(AppendDifferentModel Experimental APPEND) +run_ctest_start(AppendNoModel APPEND) +run_ctest_start(AppendDifferentTrack TRACK ExperimentalDifferent APPEND) +run_ctest_start(NoAppendDifferentTrack Experimental TRACK ExperimentalDifferent) +run_ctest_start(AppendNoMatchingTrack Continuous APPEND) +run_ctest_start(AppendOldContinuous Continuous APPEND) +run_ctest_start(AppendOldNoModel APPEND) +run_ctest_start(NoModel QUIET) +run_ctest_start(MissingTrackArg Experimental TRACK) +run_ctest_start(MissingTrackArgAppend Experimental TRACK APPEND) +run_ctest_start(MissingTrackArgQuiet Experimental TRACK QUIET) +run_ctest_start(TooManyArgs Experimental + ${RunCMake_BINARY_DIR}/TooManyArgs-build + ${RunCMake_BINARY_DIR}/TooManyArgs-build + ${RunCMake_BINARY_DIR}/TooManyArgs-build) function(run_ConfigInBuild) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ConfigInBuild-build) set(RunCMake_TEST_NO_CLEAN 1) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in - ${RunCMake_BINARY_DIR}/ConfigInBuild-build/CTestConfig.cmake @ONLY) run_ctest_start(ConfigInBuild Experimental) endfunction() run_ConfigInBuild() diff --git a/Tests/RunCMake/ctest_start/test.cmake.in b/Tests/RunCMake/ctest_start/test.cmake.in index 21e3fad2d..8cd3cff5a 100644 --- a/Tests/RunCMake/ctest_start/test.cmake.in +++ b/Tests/RunCMake/ctest_start/test.cmake.in @@ -8,6 +8,26 @@ set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") + +function(setup_tests) + ctest_start(${ctest_start_args}) +endfunction() + +if("@CASE_NAME@" MATCHES "^(No)?Append") + if("@CASE_NAME@" MATCHES "^AppendNoMatchingTrack$") + file(WRITE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "19551112-2204\nSomeWeirdTrackName\n") + else() + file(WRITE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "19551112-2204\nContinuousTrack\n") + endif() + if(NOT "@CASE_NAME@" MATCHES "^AppendOld") + file(APPEND "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "Continuous\n") + endif() +endif() set(ctest_start_args "@CASE_CTEST_START_ARGS@") -ctest_start(${ctest_start_args}) +if("@CASE_NAME@" STREQUAL "FunctionScope") + setup_tests() +else() + ctest_start(${ctest_start_args}) +endif() diff --git a/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt b/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt index 4825d7a8e..a8f10b558 100644 --- a/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt +++ b/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt @@ -1,3 +1 @@ - *Error when uploading file: .*/Configure.xml *Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*) - *Problems when submitting via HTTP diff --git a/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in b/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in index 378a85a0c..140e4be35 100644 --- a/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in +++ b/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in @@ -1,4 +1,3 @@ -set(CTEST_PROJECT_NAME "CTestSubmit@CASE_NAME@") # Intentionally leave out other upload-related CTestConfig.cmake settings # so that any ctest_submit calls fail with an error message. diff --git a/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt index c7f35c5ff..c9111b0cf 100644 --- a/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt +++ b/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt @@ -1,3 +1,2 @@ -Submit files \(using http\) - Using HTTP submit method - Drop site:http:// +Submit files + SubmitURL: http://-no-site- diff --git a/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt index 19f82347b..2c67eb9db 100644 --- a/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt +++ b/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt @@ -1,3 +1,2 @@ -Submit files \(using https\) - Using HTTP submit method - Drop site:https:// +Submit files + SubmitURL: https://-no-site- diff --git a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake index b5d90d28c..78856b410 100644 --- a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake @@ -5,28 +5,36 @@ set(CASE_DROP_METHOD "http") set(CASE_DROP_SITE "-no-site-") set(CASE_CTEST_SUBMIT_ARGS "") -#----------------------------------------------------------------------------- -# Test bad argument combinations. function(run_ctest_submit CASE_NAME) set(CASE_CTEST_SUBMIT_ARGS "${ARGN}") run_ctest(${CASE_NAME}) endfunction() +function(run_ctest_submit_debug CASE_NAME) + set(CASE_CTEST_SUBMIT_ARGS "${ARGN}") + run_ctest(${CASE_NAME} "--debug") +endfunction() + +#----------------------------------------------------------------------------- +# Test bad argument combinations. run_ctest_submit(BadArg bad-arg) run_ctest_submit(BadPARTS PARTS bad-part) run_ctest_submit(BadFILES FILES bad-file) run_ctest_submit(RepeatRETURN_VALUE RETURN_VALUE res RETURN_VALUE res) run_ctest_submit(PARTSCDashUpload PARTS Configure CDASH_UPLOAD) run_ctest_submit(PARTSCDashUploadType PARTS Configure CDASH_UPLOAD_TYPE) +run_ctest_submit(PARTSDone PARTS Done) run_ctest_submit(CDashUploadPARTS CDASH_UPLOAD bad-upload PARTS) run_ctest_submit(CDashUploadFILES CDASH_UPLOAD bad-upload FILES) run_ctest_submit(CDashUploadNone CDASH_UPLOAD) run_ctest_submit(CDashUploadMissingFile CDASH_UPLOAD bad-upload) run_ctest_submit(CDashUploadRetry CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo RETRY_COUNT 2 RETRY_DELAY 1 INTERNAL_TEST_CHECKSUM) run_ctest_submit(CDashSubmitQuiet QUIET) -run_ctest_submit(CDashSubmitHeaders HTTPHEADER "Authorization: Bearer asdf") -run_ctest_submit(CDashUploadHeaders CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo HTTPHEADER "Authorization: Bearer asdf") +run_ctest_submit_debug(CDashSubmitVerbose BUILD_ID my_build_id) +run_ctest_submit_debug(FILESNoBuildId FILES ${CMAKE_CURRENT_LIST_FILE}) +run_ctest_submit_debug(CDashSubmitHeaders HTTPHEADER "Authorization: Bearer asdf") +run_ctest_submit_debug(CDashUploadHeaders CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo HTTPHEADER "Authorization: Bearer asdf") function(run_ctest_CDashUploadFTP) set(CASE_DROP_METHOD ftp) @@ -41,9 +49,5 @@ function(run_ctest_submit_FailDrop CASE_DROP_METHOD) run_ctest(FailDrop-${CASE_DROP_METHOD}) endfunction() -run_ctest_submit_FailDrop(cp) -run_ctest_submit_FailDrop(ftp) run_ctest_submit_FailDrop(http) run_ctest_submit_FailDrop(https) -run_ctest_submit_FailDrop(scp) -run_ctest_submit_FailDrop(xmlrpc) diff --git a/Tests/RunCMake/ctest_submit/test.cmake.in b/Tests/RunCMake/ctest_submit/test.cmake.in index ba826f1b3..35cd16a98 100644 --- a/Tests/RunCMake/ctest_submit/test.cmake.in +++ b/Tests/RunCMake/ctest_submit/test.cmake.in @@ -9,6 +9,7 @@ set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set_property(GLOBAL PROPERTY SubProject "mysubproj") ctest_start(Experimental) ctest_configure() diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 1b3172676..6877e6a87 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -21,8 +21,8 @@ set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 5) run_ctest_test(TestLoadPass TEST_LOAD 6) # Verify that new tests are not started when the load average exceeds -# our threshold. -run_ctest_test(TestLoadFail TEST_LOAD 2) +# our threshold and that they then run once the load average drops. +run_ctest_test(TestLoadWait TEST_LOAD 2) # Verify that when an invalid "TEST_LOAD" value is given, a warning # message is displayed and the value is ignored. @@ -34,9 +34,9 @@ set(CASE_CTEST_TEST_LOAD 7) run_ctest_test(CTestTestLoadPass) # Verify that new tests are not started when the load average exceeds -# our threshold. +# our threshold and that they then run once the load average drops. set(CASE_CTEST_TEST_LOAD 4) -run_ctest_test(CTestTestLoadFail) +run_ctest_test(CTestTestLoadWait) # Verify that when an invalid "CTEST_TEST_LOAD" value is given, # a warning message is displayed and the value is ignored. diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index 62e18c601..b203aabfd 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -10,4 +10,17 @@ run_cmake_command(MergeOutputVars ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/Mer run_cmake(EncodingMissing) if(TEST_ENCODING_EXE) run_cmake_command(EncodingUTF8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake) + run_cmake_command(EncodingUTF-8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF-8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake) endif() + +if(EXIT_CODE_EXE) + run_cmake_command(ExitValues ${CMAKE_COMMAND} -DEXIT_CODE_EXE=${EXIT_CODE_EXE} -P ${RunCMake_SOURCE_DIR}/ExitValues.cmake) +endif() + +run_cmake_command(EchoCommand ${CMAKE_COMMAND} -DCHECK_GLOBAL=TRUE + -P ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) +run_cmake_command(EchoCommand2 ${CMAKE_COMMAND} -P + ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) +run_cmake_command(EchoCommand3 ${CMAKE_COMMAND} + -DCHECK_ERROR_OUTPUT_LOCATION=TRUE -P + ${RunCMake_SOURCE_DIR}/EchoCommand.cmake) diff --git a/Tests/RunCMake/export/AppendExport-stderr.txt b/Tests/RunCMake/export/AppendExport-stderr.txt index d71620e5f..d12124c9a 100644 --- a/Tests/RunCMake/export/AppendExport-stderr.txt +++ b/Tests/RunCMake/export/AppendExport-stderr.txt @@ -1,4 +1,4 @@ CMake Error at AppendExport.cmake:[0-9]+ \(export\): - export EXPORT signature does not recognise the APPEND option. + export Unknown argument: "APPEND". Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/OldIface-stderr.txt b/Tests/RunCMake/export/OldIface-stderr.txt index 818c2cb20..3cc10331e 100644 --- a/Tests/RunCMake/export/OldIface-stderr.txt +++ b/Tests/RunCMake/export/OldIface-stderr.txt @@ -1,5 +1,4 @@ CMake Error at OldIface.cmake:[0-9]+ \(export\): - export EXPORT signature does not recognise the - EXPORT_LINK_INTERFACE_LIBRARIES option. + export Unknown argument: "EXPORT_LINK_INTERFACE_LIBRARIES". Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 6d0b7ca7c..97a0ca6d8 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -1,7 +1,12 @@ include(RunCMake) run_cmake(CustomTarget) +run_cmake(Empty) run_cmake(TargetNotFound) run_cmake(AppendExport) run_cmake(OldIface) run_cmake(NoExportSet) +run_cmake(ForbiddenToExportInterfaceProperties) +run_cmake(ForbiddenToExportImportedProperties) +run_cmake(ForbiddenToExportPropertyWithGenExp) +run_cmake(ExportPropertiesUndefined) diff --git a/Tests/RunCMake/file/FileOpenFailRead-stderr.txt b/Tests/RunCMake/file/FileOpenFailRead-stderr.txt index 23d4337f4..9f8cee26a 100644 --- a/Tests/RunCMake/file/FileOpenFailRead-stderr.txt +++ b/Tests/RunCMake/file/FileOpenFailRead-stderr.txt @@ -3,4 +3,4 @@ CMake Error at FileOpenFailRead.cmake:[0-9]+ \(file\): .*/Tests/RunCMake/file/does_not_exist/file.txt Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt index 557b817bb..bb7e4d2cc 100644 --- a/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt +++ b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt @@ -2,31 +2,31 @@ CMake Error at INSTALL-MESSAGE-bad.cmake:1 \(file\): file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are mutually exclusive. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at INSTALL-MESSAGE-bad.cmake:2 \(file\): file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are mutually exclusive. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at INSTALL-MESSAGE-bad.cmake:3 \(file\): file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are mutually exclusive. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at INSTALL-MESSAGE-bad.cmake:4 \(file\): file option MESSAGE_ALWAYS may not appear after PATTERN or REGEX. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at INSTALL-MESSAGE-bad.cmake:5 \(file\): file option MESSAGE_LAZY may not appear after PATTERN or REGEX. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) + CMake Error at INSTALL-MESSAGE-bad.cmake:6 \(file\): file option MESSAGE_NEVER may not appear after PATTERN or REGEX. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 26051b4d7..5db4b3bce 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -1,11 +1,20 @@ include(RunCMake) +run_cmake(CREATE_LINK) +run_cmake(CREATE_LINK-COPY_ON_ERROR) +run_cmake(CREATE_LINK-noarg) +run_cmake(CREATE_LINK-noexist) run_cmake(DOWNLOAD-hash-mismatch) 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) run_cmake(UPLOAD-pass-not-set) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-FILES_FROM_DIR) @@ -30,13 +39,97 @@ 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) +run_cmake(SIZE) +run_cmake(SIZE-error-does-not-exist) + +run_cmake(REMOVE-empty) + +# tests are valid both for GLOB and GLOB_RECURSE +run_cmake(GLOB-sort-dedup) run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean) -# 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-FOLLOW_SYMLINKS) 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(CREATE_LINK-SYMBOLIC) + run_cmake(CREATE_LINK-SYMBOLIC-noexist) run_cmake(GLOB_RECURSE-cyclic-recursion) run_cmake(INSTALL-SYMLINK) + run_cmake(READ_SYMLINK) + run_cmake(READ_SYMLINK-noexist) + run_cmake(READ_SYMLINK-notsymlink) + run_cmake(INSTALL-FOLLOW_SYMLINK_CHAIN) +endif() + +if(RunCMake_GENERATOR STREQUAL "Ninja") + # 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/find_package/PackageRoot.cmake b/Tests/RunCMake/find_package/PackageRoot.cmake index 4c4f4c233..aa12e9b5f 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 ba06c09ce..1ef32cbba 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 2795cd48f..017834cd3 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 d548da027..066523ec6 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) @@ -21,3 +23,9 @@ run_cmake(PolicyPop) run_cmake(SetFoundFALSE) run_cmake(WrongVersion) run_cmake(WrongVersionConfig) +run_cmake(CMP0084-OLD) +run_cmake(CMP0084-WARN) +run_cmake(CMP0084-NEW) +if(UNIX) + run_cmake(SetFoundResolved) +endif() diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake index bf0fa8951..3afbedc90 100644 --- a/Tests/RunCMake/find_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(EmptyOldStyle) if(WIN32 OR CYGWIN) run_cmake(PrefixInPATH) endif() diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 89307c1ae..6903f057b 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(EnvAndHints) run_cmake(DirsPerName) run_cmake(NamesPerDir) +run_cmake(RelAndAbsPath) if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$") run_cmake(WindowsCom) diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 7dfb55d79..54b858f92 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -11,8 +11,10 @@ set(expect_DIRECTORY "/path/to") set(expect_NAME "filename.ext.in") set(expect_EXT ".ext.in") set(expect_NAME_WE "filename") +set(expect_LAST_EXT ".in") +set(expect_NAME_WLE "filename.ext") set(expect_PATH "/path/to") -foreach(c DIRECTORY NAME EXT NAME_WE PATH) +foreach(c DIRECTORY NAME EXT NAME_WE LAST_EXT NAME_WLE PATH) get_filename_component(actual_${c} "${filename}" ${c}) check("${c}" "${actual_${c}}" "${expect_${c}}") list(APPEND non_cache_vars actual_${c}) @@ -80,6 +82,17 @@ get_filename_component(test_program_name "/ arg1 arg2" PROGRAM check("PROGRAM with args output: name" "${test_program_name}" "/") check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2") +get_filename_component(test_program_name " " PROGRAM) +check("PROGRAM with just a space" "${test_program_name}" "") + +get_filename_component(test_program_name "${CMAKE_CURRENT_LIST_FILE}" PROGRAM) +check("PROGRAM specified explicitly without quoting" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}") + +get_filename_component(test_program_name "\"${CMAKE_CURRENT_LIST_FILE}\" arg1 arg2" PROGRAM + PROGRAM_ARGS test_program_args) +check("PROGRAM specified explicitly with arguments: name" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}") +check("PROGRAM specified explicitly with arguments: args" "${test_program_args}" " arg1 arg2") + list(APPEND non_cache_vars test_program_name) list(APPEND non_cache_vars test_program_args) diff --git a/Tests/RunCMake/get_property/BadArgument-stderr.txt b/Tests/RunCMake/get_property/BadArgument-stderr.txt index 37c44775c..ce5a20923 100644 --- a/Tests/RunCMake/get_property/BadArgument-stderr.txt +++ b/Tests/RunCMake/get_property/BadArgument-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at BadArgument.cmake:1 \(get_property\): get_property given invalid argument "FOO". Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/BadDirectory-stderr.txt b/Tests/RunCMake/get_property/BadDirectory-stderr.txt index 98464f8dc..6afec038a 100644 --- a/Tests/RunCMake/get_property/BadDirectory-stderr.txt +++ b/Tests/RunCMake/get_property/BadDirectory-stderr.txt @@ -3,4 +3,4 @@ found. This could be because the directory argument was invalid or, it is valid but has not been processed yet. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/BadScope-stderr.txt b/Tests/RunCMake/get_property/BadScope-stderr.txt index 4cc32c87b..3084bb7fd 100644 --- a/Tests/RunCMake/get_property/BadScope-stderr.txt +++ b/Tests/RunCMake/get_property/BadScope-stderr.txt @@ -2,4 +2,4 @@ get_property given invalid scope FOO. Valid scopes are GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/BadTarget-stderr.txt b/Tests/RunCMake/get_property/BadTarget-stderr.txt index 45a0df6c9..e85711721 100644 --- a/Tests/RunCMake/get_property/BadTarget-stderr.txt +++ b/Tests/RunCMake/get_property/BadTarget-stderr.txt @@ -2,4 +2,4 @@ get_property could not find TARGET FOO. Perhaps it has not yet been created. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/BadTest-stderr.txt b/Tests/RunCMake/get_property/BadTest-stderr.txt index 819c0704a..aec9e9e9c 100644 --- a/Tests/RunCMake/get_property/BadTest-stderr.txt +++ b/Tests/RunCMake/get_property/BadTest-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at BadTest.cmake:1 \(get_property\): get_property given TEST name that does not exist: FOO Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/GlobalName-stderr.txt b/Tests/RunCMake/get_property/GlobalName-stderr.txt index a7d4971c2..4ddceb257 100644 --- a/Tests/RunCMake/get_property/GlobalName-stderr.txt +++ b/Tests/RunCMake/get_property/GlobalName-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at GlobalName.cmake:1 \(get_property\): get_property given name for GLOBAL scope. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/MissingArgument-stderr.txt b/Tests/RunCMake/get_property/MissingArgument-stderr.txt index 87227127a..00d3311af 100644 --- a/Tests/RunCMake/get_property/MissingArgument-stderr.txt +++ b/Tests/RunCMake/get_property/MissingArgument-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at MissingArgument.cmake:1 \(get_property\): get_property called with incorrect number of arguments Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/NoCache-stderr.txt b/Tests/RunCMake/get_property/NoCache-stderr.txt index defafb62d..7348cffdb 100644 --- a/Tests/RunCMake/get_property/NoCache-stderr.txt +++ b/Tests/RunCMake/get_property/NoCache-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at NoCache.cmake:1 \(get_property\): get_property not given name for CACHE scope. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/NoProperty-stderr.txt b/Tests/RunCMake/get_property/NoProperty-stderr.txt index 0ef147fdb..79b8c8702 100644 --- a/Tests/RunCMake/get_property/NoProperty-stderr.txt +++ b/Tests/RunCMake/get_property/NoProperty-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at NoProperty.cmake:1 \(get_property\): get_property not given a PROPERTY <name> argument. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/NoSource-stderr.txt b/Tests/RunCMake/get_property/NoSource-stderr.txt index 59fd0add7..cefff4167 100644 --- a/Tests/RunCMake/get_property/NoSource-stderr.txt +++ b/Tests/RunCMake/get_property/NoSource-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at NoSource.cmake:1 \(get_property\): get_property not given name for SOURCE scope. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/NoTarget-stderr.txt b/Tests/RunCMake/get_property/NoTarget-stderr.txt index a0e1a9440..fb1c8f4e8 100644 --- a/Tests/RunCMake/get_property/NoTarget-stderr.txt +++ b/Tests/RunCMake/get_property/NoTarget-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at NoTarget.cmake:1 \(get_property\): get_property not given name for TARGET scope. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/NoTest-stderr.txt b/Tests/RunCMake/get_property/NoTest-stderr.txt index c90a0ffc2..93c3e9821 100644 --- a/Tests/RunCMake/get_property/NoTest-stderr.txt +++ b/Tests/RunCMake/get_property/NoTest-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at NoTest.cmake:1 \(get_property\): get_property not given name for TEST scope. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/RunCMakeTest.cmake b/Tests/RunCMake/get_property/RunCMakeTest.cmake index 017990fa9..06a0c673c 100644 --- a/Tests/RunCMake/get_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/get_property/RunCMakeTest.cmake @@ -23,6 +23,10 @@ run_cmake(NoSource) run_cmake(NoProperty) run_cmake(NoCache) +# Since we are testing the GENERATOR_IS_MULTI_CONFIG property itself, +# don't rely on RunCMake_GENERATOR_IS_MULTI_CONFIG being set correctly +# and instead explicitly check for a match against those generators we +# expect to be multi-config if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") run_cmake(IsMultiConfig) else() diff --git a/Tests/RunCMake/get_property/VariableName-stderr.txt b/Tests/RunCMake/get_property/VariableName-stderr.txt index e9f382759..250d920b4 100644 --- a/Tests/RunCMake/get_property/VariableName-stderr.txt +++ b/Tests/RunCMake/get_property/VariableName-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at VariableName.cmake:1 \(get_property\): get_property given name for VARIABLE scope. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/get_property/directory_properties-stderr.txt b/Tests/RunCMake/get_property/directory_properties-stderr.txt index 6d5bcdb0d..89f5618ee 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 4e68738d8..9b978fd50 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 7318b9777..95106adca 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/get_property/source_properties-stderr.txt b/Tests/RunCMake/get_property/source_properties-stderr.txt index 0a46f96a0..00a9b8287 100644 --- a/Tests/RunCMake/get_property/source_properties-stderr.txt +++ b/Tests/RunCMake/get_property/source_properties-stderr.txt @@ -3,4 +3,10 @@ get_property: --><-- get_source_file_property: -->value<-- get_property: -->value<-- get_source_file_property: -->NOTFOUND<-- -get_property: --><--$ +get_property: --><-- +get_source_file_property: -->value<-- +get_property: -->value<-- +get_source_file_property: -->NOTFOUND<-- +get_property: --><-- +get_source_file_property: -->value<-- +get_property: -->value<--$ diff --git a/Tests/RunCMake/get_property/source_properties.cmake b/Tests/RunCMake/get_property/source_properties.cmake index 263ffe123..12d2d0797 100644 --- a/Tests/RunCMake/get_property/source_properties.cmake +++ b/Tests/RunCMake/get_property/source_properties.cmake @@ -13,3 +13,13 @@ set_source_files_properties(file.c PROPERTIES empty "" custom value) check_source_file_property(file.c empty) check_source_file_property(file.c custom) check_source_file_property(file.c noexist) + +# Test strange legacy behavior in which the order in which source files are +# first accessed affects how properties are applied without an extension. +# See also issue #15208. +get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.c PROPERTY LANGUAGE) +get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.h PROPERTY LANGUAGE) +set_property(SOURCE file2 PROPERTY custom value) # set property without extension +check_source_file_property(file2 custom) # should have property +check_source_file_property(file2.h custom) # should not have property +check_source_file_property(file2.c custom) # should have property diff --git a/Tests/RunCMake/get_property/target_properties-stderr.txt b/Tests/RunCMake/get_property/target_properties-stderr.txt index 6b3c6ca1b..df7a2f12c 100644 --- a/Tests/RunCMake/get_property/target_properties-stderr.txt +++ b/Tests/RunCMake/get_property/target_properties-stderr.txt @@ -7,4 +7,10 @@ get_property: --><-- get_target_property: -->(.*)/Tests/RunCMake/get_property<-- get_property: -->(.*)/Tests/RunCMake/get_property<-- get_target_property: -->(.*)/Tests/RunCMake/get_property/target_properties-build<-- -get_property: -->(.*)/Tests/RunCMake/get_property/target_properties-build<--$ +get_property: -->(.*)/Tests/RunCMake/get_property/target_properties-build<-- +get_target_property: -->FALSE<-- +get_property: -->FALSE<-- +get_target_property: -->FALSE<-- +get_property: -->FALSE<-- +get_target_property: -->TRUE<-- +get_property: -->TRUE<--$ diff --git a/Tests/RunCMake/get_property/target_properties.cmake b/Tests/RunCMake/get_property/target_properties.cmake index 9ff833a67..321d5b5b8 100644 --- a/Tests/RunCMake/get_property/target_properties.cmake +++ b/Tests/RunCMake/get_property/target_properties.cmake @@ -16,3 +16,10 @@ check_target_property(tgt custom) check_target_property(tgt noexist) check_target_property(tgt SOURCE_DIR) check_target_property(tgt BINARY_DIR) + +add_library(imported_local_tgt SHARED IMPORTED) +add_library(imported_global_tgt SHARED IMPORTED GLOBAL) + +check_target_property(tgt IMPORTED_GLOBAL) +check_target_property(imported_local_tgt IMPORTED_GLOBAL) +check_target_property(imported_global_tgt IMPORTED_GLOBAL) diff --git a/Tests/RunCMake/include_external_msproject/check_utils.cmake b/Tests/RunCMake/include_external_msproject/check_utils.cmake index e9e9cac72..0a2ba63f5 100644 --- a/Tests/RunCMake/include_external_msproject/check_utils.cmake +++ b/Tests/RunCMake/include_external_msproject/check_utils.cmake @@ -100,6 +100,8 @@ function(check_project test name guid type platform imported_release_config_name set(platform "${RunCMake_GENERATOR_PLATFORM}") elseif("${RunCMake_GENERATOR}" MATCHES "Win64") set(platform "x64") + elseif(VS_PLATFORM_NAME) + set(platform "${VS_PLATFORM_NAME}") else() set(platform "Win32") endif() diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt index 166ba6f04..c8074e96f 100644 --- a/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt @@ -1,4 +1,4 @@ CMake Error at DIRECTORY-PATTERN-MESSAGE_NEVER.cmake:[0-9]+ \(install\): install DIRECTORY does not allow "MESSAGE_NEVER" after PATTERN or REGEX. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 1a60f0c27..c637db151 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -21,6 +21,10 @@ function(run_install_test case) # Check explicit component. set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-exc) run_cmake_command(${case}-exc ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=exc -P cmake_install.cmake) + set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-lib) + run_cmake_command(${case}-lib ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=lib -P cmake_install.cmake) + set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-dev) + run_cmake_command(${case}-dev ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=dev -P cmake_install.cmake) endif() endfunction() @@ -59,11 +63,84 @@ run_cmake(EXPORT-OldIFace) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) +run_cmake(CMP0087-OLD) +run_cmake(CMP0087-NEW) +run_cmake(CMP0087-WARN) +run_cmake(TARGETS-ImportedGlobal) +run_cmake(TARGETS-NAMELINK_COMPONENT-bad-all) +run_cmake(TARGETS-NAMELINK_COMPONENT-bad-exc) +run_cmake(FILES-DESTINATION-TYPE) +run_cmake(DIRECTORY-DESTINATION-TYPE) + +if(APPLE) + run_cmake(TARGETS-Apple-Defaults) +endif() if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") run_install_test(FILES-TARGET_OBJECTS) endif() +run_install_test(TARGETS-InstallFromSubDir) +run_install_test(TARGETS-OPTIONAL) +run_install_test(FILES-OPTIONAL) +run_install_test(DIRECTORY-OPTIONAL) +run_install_test(TARGETS-Defaults) + +set(RunCMake_TEST_OPTIONS + "-DCMAKE_INSTALL_BINDIR:PATH=mybin" + "-DCMAKE_INSTALL_LIBDIR:PATH=mylib" + "-DCMAKE_INSTALL_INCLUDEDIR:PATH=myinclude" + ) +run_install_test(TARGETS-Defaults-Cache) +unset(RunCMake_TEST_OPTIONS) + +run_install_test(FILES-TYPE) +run_install_test(DIRECTORY-TYPE) + +set(RunCMake_TEST_OPTIONS + "-DCMAKE_INSTALL_BINDIR:PATH=mybin" + "-DCMAKE_INSTALL_SBINDIR:PATH=mysbin" + "-DCMAKE_INSTALL_LIBEXECDIR:PATH=mylibexec" + "-DCMAKE_INSTALL_LIBDIR:PATH=mylib" + "-DCMAKE_INSTALL_INCLUDEDIR:PATH=myinclude" + "-DCMAKE_INSTALL_SYSCONFDIR:PATH=myetc" + "-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=mycom" + "-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=myvar" + "-DCMAKE_INSTALL_RUNSTATEDIR:PATH=myrun" + "-DCMAKE_INSTALL_DATADIR:PATH=myshare" + "-DCMAKE_INSTALL_INFODIR:PATH=myinfo" + "-DCMAKE_INSTALL_LOCALEDIR:PATH=mylocale" + "-DCMAKE_INSTALL_MANDIR:PATH=myman" + "-DCMAKE_INSTALL_DOCDIR:PATH=mydoc" + ) +run_install_test(FILES-TYPE-Cache) +run_install_test(DIRECTORY-TYPE-Cache) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS + "-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=myvar" + "-DCMAKE_INSTALL_DATAROOTDIR:PATH=myshare" + ) +run_install_test(FILES-TYPE-CacheDependent) +run_install_test(DIRECTORY-TYPE-CacheDependent) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE:STRING=Debug") +run_install_test(TARGETS-OUTPUT_NAME) +unset(RunCMake_TEST_OPTIONS) + +run_install_test(Deprecated) +run_install_test(PRE_POST_INSTALL_SCRIPT) +run_install_test(SCRIPT) +run_install_test(TARGETS-CONFIGURATIONS) +run_install_test(DIRECTORY-PATTERN) +run_install_test(TARGETS-Parts) +run_install_test(FILES-PERMISSIONS) +run_install_test(TARGETS-RPATH) +run_install_test(InstallRequiredSystemLibraries) + set(run_install_test_components 1) run_install_test(FILES-EXCLUDE_FROM_ALL) run_install_test(TARGETS-EXCLUDE_FROM_ALL) +run_install_test(TARGETS-NAMELINK_COMPONENT) +run_install_test(SCRIPT-COMPONENT) diff --git a/Tests/RunCMake/install/obj1.c b/Tests/RunCMake/install/obj1.c index 2411aab79..70007df8a 100644 --- a/Tests/RunCMake/install/obj1.c +++ b/Tests/RunCMake/install/obj1.c @@ -1,4 +1,7 @@ -int obj1(void) +#ifdef _WIN32 +__declspec(dllexport) +#endif + int obj1(void) { return 0; } diff --git a/Tests/RunCMake/interface_library/global-interface-stderr.txt b/Tests/RunCMake/interface_library/global-interface-stderr.txt index 24edd0f89..23b45d926 100644 --- a/Tests/RunCMake/interface_library/global-interface-stderr.txt +++ b/Tests/RunCMake/interface_library/global-interface-stderr.txt @@ -3,7 +3,7 @@ CMake Error at global-interface.cmake:2 \(add_library\): GLOBAL - Tried extensions \.c \.C \.c\+\+ \.cc \.cpp \.cxx \.m \.M \.mm \.h \.hh \.h\+\+ \.hm \.hpp - \.hxx \.in \.txx + Tried extensions( \.[A-Za-z+]+| + )* Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/target_commands-stderr.txt b/Tests/RunCMake/interface_library/target_commands-stderr.txt index be11b7754..9362a752d 100644 --- a/Tests/RunCMake/interface_library/target_commands-stderr.txt +++ b/Tests/RunCMake/interface_library/target_commands-stderr.txt @@ -23,25 +23,25 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Error at target_commands.cmake:9 \(target_include_directories\): - target_include_directories may only be set INTERFACE properties on - INTERFACE targets + target_include_directories may only set INTERFACE properties on INTERFACE + targets Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Error at target_commands.cmake:10 \(target_include_directories\): - target_include_directories may only be set INTERFACE properties on - INTERFACE targets + target_include_directories may only set INTERFACE properties on INTERFACE + targets Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Error at target_commands.cmake:12 \(target_compile_definitions\): - target_compile_definitions may only be set INTERFACE properties on - INTERFACE targets + target_compile_definitions may only set INTERFACE properties on INTERFACE + targets Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Error at target_commands.cmake:13 \(target_compile_definitions\): - target_compile_definitions may only be set INTERFACE properties on - INTERFACE targets + target_compile_definitions may only set INTERFACE properties on INTERFACE + targets Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake index 98ef05c0f..0db637531 100644 --- a/Tests/RunCMake/interface_library/whitelist.cmake +++ b/Tests/RunCMake/interface_library/whitelist.cmake @@ -4,3 +4,22 @@ add_library(iface INTERFACE) set_property(TARGET iface PROPERTY OUTPUT_NAME output) set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append) get_target_property(outname iface OUTPUT_NAME) + +# Properties starting with `_` are allowed. +set_property(TARGET iface PROPERTY "_custom_property" output) +set_property(TARGET iface APPEND PROPERTY "_custom_property" append) +get_target_property(outname iface "_custom_property") + +# Properties starting with a lowercase letter are allowed. +set_property(TARGET iface PROPERTY "custom_property" output) +set_property(TARGET iface APPEND PROPERTY "custom_property" append) +get_target_property(outname iface "custom_property") + +# PUBLIC_HEADER / PRIVATE_HEADER properties are allowed +set_property(TARGET iface PROPERTY PUBLIC_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PUBLIC_HEADER bar.h) +get_target_property(outname iface PUBLIC_HEADER) + +set_property(TARGET iface PROPERTY PRIVATE_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PRIVATE_HEADER bar.h) +get_target_property(outname iface PRIVATE_HEADER) diff --git a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt index b24a0ed0b..9368e880b 100644 --- a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt +++ b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt @@ -1,4 +1,4 @@ CMake Error at EmptyRemoveAt0.cmake:2 \(list\): - list REMOVE_AT given empty list + list index: mylist, 0 out of range \(0, 0\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/FILTER-NotList.cmake b/Tests/RunCMake/list/FILTER-NotList.cmake index 1e15635b9..bf09ec74f 100644 --- a/Tests/RunCMake/list/FILTER-NotList.cmake +++ b/Tests/RunCMake/list/FILTER-NotList.cmake @@ -1,2 +1,6 @@ unset(nosuchlist) list(FILTER nosuchlist EXCLUDE REGEX "^FILTER_THIS_.+") +if (DEFINED nosuchlist) + message(FATAL_ERROR + "list(FILTER) created our list") +endif () diff --git a/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt b/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt index 6e15c0b43..9b9c5e0af 100644 --- a/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt +++ b/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at INSERT-InvalidIndex.cmake:2 \(list\): - list index: 3 out of range \(-3, 2\) + list index: 4 out of range \(-3, 3\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/INSERT-InvalidIndex.cmake b/Tests/RunCMake/list/INSERT-InvalidIndex.cmake index 4103d974b..12ac114cb 100644 --- a/Tests/RunCMake/list/INSERT-InvalidIndex.cmake +++ b/Tests/RunCMake/list/INSERT-InvalidIndex.cmake @@ -1,2 +1,2 @@ set(mylist alpha bravo charlie) -list(INSERT mylist 3 delta) +list(INSERT mylist 4 delta) diff --git a/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt b/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt index d6e8d85f5..563d865ea 100644 --- a/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt +++ b/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at REMOVE_AT-NotList.cmake:2 \(list\): - list sub-command REMOVE_AT requires list to be present. + list index: nosuchlist, 0 out of range \(0, 0\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/REMOVE_AT-NotList.cmake b/Tests/RunCMake/list/REMOVE_AT-NotList.cmake index 5266c7fe9..090df4933 100644 --- a/Tests/RunCMake/list/REMOVE_AT-NotList.cmake +++ b/Tests/RunCMake/list/REMOVE_AT-NotList.cmake @@ -1,2 +1,6 @@ unset(nosuchlist) list(REMOVE_AT nosuchlist 0) +if (DEFINED nosuchlist) + message(FATAL_ERROR + "list(REMOVE_AT) created our list") +endif () diff --git a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake b/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake index 218f2272c..b9f399943 100644 --- a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake +++ b/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake @@ -1,2 +1,6 @@ unset(nosuchlist) list(REMOVE_DUPLICATES nosuchlist) +if (DEFINED nosuchlist) + message(FATAL_ERROR + "list(REMOVE_DUPLICATES) created our list") +endif () diff --git a/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake b/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake index 079e7fbce..0c66837c5 100644 --- a/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake +++ b/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake @@ -1,2 +1,6 @@ unset(nosuchlist) list(REMOVE_ITEM nosuchlist alpha) +if (DEFINED nosuchlist) + message(FATAL_ERROR + "list(REMOVE_ITEM) created our list") +endif () diff --git a/Tests/RunCMake/list/REVERSE-NotList.cmake b/Tests/RunCMake/list/REVERSE-NotList.cmake index 977e2ccac..71383294c 100644 --- a/Tests/RunCMake/list/REVERSE-NotList.cmake +++ b/Tests/RunCMake/list/REVERSE-NotList.cmake @@ -1,2 +1,6 @@ unset(nosuchlist) list(REVERSE nosuchlist) +if (DEFINED nosuchlist) + message(FATAL_ERROR + "list(REVERSE) created our list") +endif () diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index b002ab388..b4a91bc62 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -13,12 +13,18 @@ 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(REMOVE_AT-EmptyList) + +run_cmake(REMOVE_DUPLICATES-PreserveOrder) run_cmake(FILTER-NotList) run_cmake(REMOVE_AT-NotList) @@ -31,3 +37,78 @@ 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) + +run_cmake(TRANSFORM-NoAction) +run_cmake(TRANSFORM-InvalidAction) +# 'action' oriented tests +run_cmake(TRANSFORM-TOUPPER-TooManyArguments) +run_cmake(TRANSFORM-TOLOWER-TooManyArguments) +run_cmake(TRANSFORM-STRIP-TooManyArguments) +run_cmake(TRANSFORM-GENEX_STRIP-TooManyArguments) +run_cmake(TRANSFORM-APPEND-NoArguments) +run_cmake(TRANSFORM-APPEND-TooManyArguments) +run_cmake(TRANSFORM-PREPEND-NoArguments) +run_cmake(TRANSFORM-PREPEND-TooManyArguments) +run_cmake(TRANSFORM-REPLACE-NoArguments) +run_cmake(TRANSFORM-REPLACE-NoEnoughArguments) +run_cmake(TRANSFORM-REPLACE-TooManyArguments) +run_cmake(TRANSFORM-REPLACE-InvalidRegex) +run_cmake(TRANSFORM-REPLACE-InvalidReplace1) +run_cmake(TRANSFORM-REPLACE-InvalidReplace2) +# 'selector' oriented tests +run_cmake(TRANSFORM-Selector-REGEX-NoArguments) +run_cmake(TRANSFORM-Selector-REGEX-TooManyArguments) +run_cmake(TRANSFORM-Selector-REGEX-InvalidRegex) +run_cmake(TRANSFORM-Selector-AT-NoArguments) +run_cmake(TRANSFORM-Selector-AT-BadArgument) +run_cmake(TRANSFORM-Selector-AT-InvalidIndex) +run_cmake(TRANSFORM-Selector-FOR-NoArguments) +run_cmake(TRANSFORM-Selector-FOR-NoEnoughArguments) +run_cmake(TRANSFORM-Selector-FOR-TooManyArguments) +run_cmake(TRANSFORM-Selector-FOR-BadArgument) +run_cmake(TRANSFORM-Selector-FOR-InvalidIndex) +# 'output' oriented tests +run_cmake(TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments) +run_cmake(TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments) +# Successful tests +run_cmake(TRANSFORM-TOUPPER) +run_cmake(TRANSFORM-TOLOWER) +run_cmake(TRANSFORM-STRIP) +run_cmake(TRANSFORM-GENEX_STRIP) +run_cmake(TRANSFORM-APPEND) +run_cmake(TRANSFORM-PREPEND) +run_cmake(TRANSFORM-REPLACE) + +# argument tests +run_cmake(SORT-WrongOption) +run_cmake(SORT-BadCaseOption) +run_cmake(SORT-BadCompareOption) +run_cmake(SORT-BadOrderOption) +run_cmake(SORT-DuplicateOrderOption) +run_cmake(SORT-DuplicateCompareOption) +run_cmake(SORT-DuplicateCaseOption) +run_cmake(SORT-NoCaseOption) + +# Successful tests +run_cmake(SORT) + +# argument tests +run_cmake(PREPEND-NoArgs) +# Successful tests +run_cmake(PREPEND) + +# argument tests +run_cmake(POP_BACK-NoArgs) +run_cmake(POP_FRONT-NoArgs) +# Successful tests +run_cmake(POP_BACK) +run_cmake(POP_FRONT) diff --git a/Tests/RunCMake/list/SORT-NotList.cmake b/Tests/RunCMake/list/SORT-NotList.cmake index 8f48e1043..6314f1493 100644 --- a/Tests/RunCMake/list/SORT-NotList.cmake +++ b/Tests/RunCMake/list/SORT-NotList.cmake @@ -1,2 +1,6 @@ unset(nosuchlist) list(SORT nosuchlist) +if (DEFINED nosuchlist) + message(FATAL_ERROR + "list(SORT) created our list") +endif () diff --git a/Tests/RunCMake/message/RunCMakeTest.cmake b/Tests/RunCMake/message/RunCMakeTest.cmake index 2346c8675..cecfc7fe5 100644 --- a/Tests/RunCMake/message/RunCMakeTest.cmake +++ b/Tests/RunCMake/message/RunCMakeTest.cmake @@ -7,6 +7,48 @@ run_cmake(nomessage-internal-warning) run_cmake(warnmessage) # message command sets fatal occurred flag, so check each type of error -# seperately +# separately run_cmake(errormessage_deprecated) run_cmake(errormessage_dev) + +run_cmake_command( + message-loglevel-invalid + ${CMAKE_COMMAND} --loglevel=blah -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) + +# Checking various combinations of `message(...)` and log levels `WARNING` to `TRACE` +# - no CLI option -> `WARNING` to `STATUS` output +run_cmake_command( + message-loglevel-default + ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - Only `WARNING` output +run_cmake_command( + message-loglevel-warning + ${CMAKE_COMMAND} --loglevel=warning -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - Only `WARNING` and `NOTICE` output +run_cmake_command( + message-loglevel-notice + ${CMAKE_COMMAND} --loglevel=notice -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `STATUS` output +run_cmake_command( + message-loglevel-status + ${CMAKE_COMMAND} --loglevel=status -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `VERBOSE` output +run_cmake_command( + message-loglevel-verbose + ${CMAKE_COMMAND} --loglevel=verbose -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `DEBUG` output +run_cmake_command( + message-loglevel-debug + ${CMAKE_COMMAND} --loglevel=debug -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) +# - `WARNING` to `TRACE` output +run_cmake_command( + message-loglevel-trace + ${CMAKE_COMMAND} --loglevel=trace -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake + ) diff --git a/Tests/RunCMake/project/ProjectDescription2-stderr.txt b/Tests/RunCMake/project/ProjectDescription2-stderr.txt index 558e2dfbb..c65a99731 100644 --- a/Tests/RunCMake/project/ProjectDescription2-stderr.txt +++ b/Tests/RunCMake/project/ProjectDescription2-stderr.txt @@ -1 +1 @@ - DESCRITPION may be specified at most once. + DESCRIPTION may be specified at most once. diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index 3d13e2ef4..3a8ad4bbf 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -7,8 +7,15 @@ 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(ProjectTwice) 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 52433bcc0..576ac6934 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/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake index b8e8cf1f9..b3bd0a480 100644 --- a/Tests/RunCMake/set/RunCMakeTest.cmake +++ b/Tests/RunCMake/set/RunCMakeTest.cmake @@ -3,3 +3,5 @@ include(RunCMake) run_cmake(ParentScope) run_cmake(ParentPulling) run_cmake(ParentPullingRecursive) +run_cmake(UnknownCacheType) +run_cmake(ExtraEnvValue) diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 1ddaceeab..8d4614c5d 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -3,8 +3,12 @@ include(RunCMake) run_cmake(COMPILE_DEFINITIONS) run_cmake(COMPILE_FEATURES) run_cmake(COMPILE_OPTIONS) +run_cmake(IMPORTED_GLOBAL) run_cmake(INCLUDE_DIRECTORIES) +run_cmake(LINK_OPTIONS) +run_cmake(LINK_DIRECTORIES) run_cmake(LINK_LIBRARIES) run_cmake(SOURCES) run_cmake(TYPE) run_cmake(USER_PROP) +run_cmake(USER_PROP_INHERITED) diff --git a/Tests/RunCMake/string/AppendNoArgs-stderr.txt b/Tests/RunCMake/string/AppendNoArgs-stderr.txt index 75ad427fd..9b7e9facd 100644 --- a/Tests/RunCMake/string/AppendNoArgs-stderr.txt +++ b/Tests/RunCMake/string/AppendNoArgs-stderr.txt @@ -1,4 +1,4 @@ CMake Error at AppendNoArgs.cmake:1 \(string\): string sub-command APPEND requires at least one argument. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/ConcatNoArgs-stderr.txt b/Tests/RunCMake/string/ConcatNoArgs-stderr.txt index efea5f1d8..22b608dd7 100644 --- a/Tests/RunCMake/string/ConcatNoArgs-stderr.txt +++ b/Tests/RunCMake/string/ConcatNoArgs-stderr.txt @@ -1,4 +1,4 @@ CMake Error at ConcatNoArgs.cmake:1 \(string\): string sub-command CONCAT requires at least one argument. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index 38a77b0d1..c432b4ed5 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -3,9 +3,16 @@ include(RunCMake) run_cmake(Append) run_cmake(AppendNoArgs) +run_cmake(Prepend) +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) @@ -20,8 +27,13 @@ run_cmake(UuidMissingTypeValue) run_cmake(UuidBadType) run_cmake(RegexClear) +run_cmake(RegexMultiMatchClear) run_cmake(UTF-16BE) run_cmake(UTF-16LE) run_cmake(UTF-32BE) run_cmake(UTF-32LE) + +run_cmake(Repeat) +run_cmake(RepeatNoArgs) +run_cmake(RepeatNegativeCount) diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt index 653974c62..cd4dcb37e 100644 --- a/Tests/RunCMake/string/Timestamp-stderr.txt +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -1 +1 @@ -RESULT=2005-08-07 23:19:49 Sun Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789 +RESULT=2005-08-07 23:19:49 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789 diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake index d24203942..cba258d12 100644 --- a/Tests/RunCMake/string/Timestamp.cmake +++ b/Tests/RunCMake/string/Timestamp.cmake @@ -1,3 +1,3 @@ set(ENV{SOURCE_DATE_EPOCH} "1123456789") -string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %a %b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC) +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %A=%a %B=%b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC) message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/string/UuidBadNamespace-stderr.txt b/Tests/RunCMake/string/UuidBadNamespace-stderr.txt index cb12903e1..340189b9f 100644 --- a/Tests/RunCMake/string/UuidBadNamespace-stderr.txt +++ b/Tests/RunCMake/string/UuidBadNamespace-stderr.txt @@ -1,4 +1,4 @@ CMake Error at UuidBadNamespace.cmake:3 \(string\): string UUID sub-command, malformed NAMESPACE UUID. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/UuidBadType-stderr.txt b/Tests/RunCMake/string/UuidBadType-stderr.txt index 1993c044a..2734d86a6 100644 --- a/Tests/RunCMake/string/UuidBadType-stderr.txt +++ b/Tests/RunCMake/string/UuidBadType-stderr.txt @@ -1,4 +1,4 @@ CMake Error at UuidBadType.cmake:3 \(string\): string UUID sub-command, unknown TYPE 'FOO'. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt b/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt index 0b7cde463..79819a97d 100644 --- a/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt +++ b/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt @@ -1,4 +1,4 @@ CMake Error at UuidMissingNameValue.cmake:3 \(string\): string UUID sub-command, NAME requires a value. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt b/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt index dfcfe42b2..1ffc53fe0 100644 --- a/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt +++ b/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt @@ -1,4 +1,4 @@ CMake Error at UuidMissingNamespace.cmake:3 \(string\): string UUID sub-command, malformed NAMESPACE UUID. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt b/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt index 86585ad40..2a73d3f0c 100644 --- a/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt +++ b/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt @@ -1,4 +1,4 @@ CMake Error at UuidMissingNamespaceValue.cmake:3 \(string\): string UUID sub-command, NAMESPACE requires a value. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt b/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt index 70252f8cd..44bd479cd 100644 --- a/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt +++ b/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt @@ -1,4 +1,4 @@ CMake Error at UuidMissingTypeValue.cmake:3 \(string\): string UUID sub-command, TYPE requires a value. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake index 1f67f11a0..f8b08094b 100644 --- a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake @@ -12,3 +12,4 @@ run_cmake(no_matching_cxx_feature) run_cmake(not_a_c_feature) run_cmake(no_matching_c_feature) run_cmake(cxx_not_enabled) +run_cmake(empty_keyword_args) diff --git a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt index 5ebe170c3..1658f58df 100644 --- a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt +++ b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt @@ -1,4 +1,4 @@ CMake Error at alias_target.cmake:[0-9]+ \(target_compile_features\): target_compile_features can not be used on an ALIAS target. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt index 4f707c7b9..5b4761c60 100644 --- a/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt +++ b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at cxx_not_enabled.cmake:[0-9]+ \(target_compile_features\): target_compile_features cannot use features from non-enabled language CXX Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt index 7a07427a0..f2a1aba9c 100644 --- a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt +++ b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt @@ -1,4 +1,5 @@ -CMake Error at imported_target.cmake:[0-9]+ \(target_compile_features\): - Cannot specify compile features for imported target "main". +^CMake Error at imported_target.cmake:[0-9]+ \(target_compile_features\): + target_compile_features may only set INTERFACE properties on INTERFACE + targets Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_compile_features/imported_target.cmake b/Tests/RunCMake/target_compile_features/imported_target.cmake index e886ce922..e410ace2a 100644 --- a/Tests/RunCMake/target_compile_features/imported_target.cmake +++ b/Tests/RunCMake/target_compile_features/imported_target.cmake @@ -1,4 +1,10 @@ enable_language(CXX) -add_library(main INTERFACE IMPORTED) -target_compile_features(main INTERFACE cxx_delegating_constructors) +add_library(lib1-interface INTERFACE IMPORTED) +target_compile_features(lib1-interface INTERFACE cxx_delegating_constructors) + +add_library(lib2-interface INTERFACE IMPORTED) +target_compile_features(lib2-interface PUBLIC cxx_delegating_constructors) + +add_library(lib-shared SHARED IMPORTED) +target_compile_features(lib-shared INTERFACE cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt index 9917be77a..ee57b5484 100644 --- a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt +++ b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt @@ -1,4 +1,4 @@ CMake Error at invalid_args.cmake:[0-9]+ \(target_compile_features\): target_compile_features called with invalid arguments Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt index 37089983a..d6564f4c0 100644 --- a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt +++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt @@ -1,5 +1,5 @@ CMake Error at invalid_args_on_interface.cmake:[0-9]+ \(target_compile_features\): - target_compile_features may only be set INTERFACE properties on INTERFACE + target_compile_features may only set INTERFACE properties on INTERFACE targets Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt index 1875d1209..07ddd6a55 100644 --- a/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt +++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt @@ -5,4 +5,4 @@ CMake Error at no_matching_c_feature.cmake:[0-9]+ \((target_compile_features|mes version 4.8.1. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt index 90d41c957..9392f4b25 100644 --- a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt +++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt @@ -5,4 +5,4 @@ CMake Error at no_matching_cxx_feature.cmake:[0-9]+ \((target_compile_features|m version *[.0-9]+\. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_target-stderr.txt b/Tests/RunCMake/target_compile_features/no_target-stderr.txt index 65974b4d6..7b62c947e 100644 --- a/Tests/RunCMake/target_compile_features/no_target-stderr.txt +++ b/Tests/RunCMake/target_compile_features/no_target-stderr.txt @@ -2,4 +2,4 @@ CMake Error at no_target.cmake:[0-9]+ \(target_compile_features\): Cannot specify compile features for target "main" which is not built by this project. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt index 493c5826c..8a4055d07 100644 --- a/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt +++ b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt @@ -2,4 +2,4 @@ CMake Error at not_a_c_feature.cmake:[0-9]+ \(target_compile_features\): target_compile_features specified unknown feature "c_not_a_feature" for target "main". Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt index 3dbf0e654..bd7f2c6b4 100644 --- a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt +++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt @@ -2,4 +2,4 @@ CMake Error at not_a_cxx_feature.cmake:[0-9]+ \(target_compile_features\): target_compile_features specified unknown feature "cxx_not_a_feature" for target "main". Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt index c0c2efac4..34f1ce222 100644 --- a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt +++ b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt @@ -1,4 +1,4 @@ CMake Error at not_enough_args.cmake:[0-9]+ \(target_compile_features\): target_compile_features called with incorrect number of arguments Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt index ff03310d1..0c01377fa 100644 --- a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt +++ b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt @@ -1,4 +1,4 @@ CMake Error at utility_target.cmake:[0-9]+ \(target_compile_features\): target_compile_features called with non-compilable target type Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt index 8e3f3153b..12c00fb01 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt @@ -8,4 +8,4 @@ CMake Error at CMP0023-NEW-2.cmake:11 \(target_link_libraries\): \* CMP0023-NEW-2.cmake:10 \(target_link_libraries\) Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt index 2ef229034..117c80614 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt @@ -8,4 +8,4 @@ CMake Error at CMP0023-NEW.cmake:11 \(target_link_libraries\): \* CMP0023-NEW.cmake:10 \(target_link_libraries\) Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt index 514786154..7e49d525e 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt @@ -13,4 +13,4 @@ CMake Warning \(dev\) at CMP0023-WARN-2.cmake:9 \(target_link_libraries\): \* CMP0023-WARN-2.cmake:8 \(target_link_libraries\) Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt index a7474fac9..df1288e35 100644 --- a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt @@ -13,4 +13,4 @@ CMake Warning \(dev\) at CMP0023-WARN.cmake:9 \(target_link_libraries\): \* CMP0023-WARN.cmake:8 \(target_link_libraries\) Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMakeLists.txt index 12cd3c775..8f85fbf54 100644 --- a/Tests/RunCMake/target_link_libraries/CMakeLists.txt +++ b/Tests/RunCMake/target_link_libraries/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 2.8.4) project(${RunCMake_TEST} NONE) -include(${RunCMake_TEST}.cmake) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt index a0c66dbe2..5b0caf757 100644 --- a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt @@ -1,5 +1,5 @@ CMake Error at MixedSignature.cmake:6 \(target_link_libraries\): - The PUBLIC or PRIVATE option must appear as the second argument, just after - the target name. + The INTERFACE, PUBLIC or PRIVATE option must appear as the second argument, + just after the target name. Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 1466fbf61..0152d4c67 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -4,9 +4,19 @@ run_cmake(CMP0023-WARN) run_cmake(CMP0023-NEW) run_cmake(CMP0023-WARN-2) run_cmake(CMP0023-NEW-2) +run_cmake(CMP0079-iface-WARN) +run_cmake(CMP0079-iface-OLD) +run_cmake(CMP0079-iface-NEW) +run_cmake(CMP0079-link-WARN) +run_cmake(CMP0079-link-OLD) +run_cmake(CMP0079-link-NEW) +run_cmake(CMP0079-link-NEW-bogus) +run_cmake(ImportedTarget) +run_cmake(ImportedTargetFailure) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) -run_cmake(SubDirTarget) run_cmake(SharedDepNotTarget) run_cmake(StaticPrivateDepNotExported) run_cmake(StaticPrivateDepNotTarget) +run_cmake(UNKNOWN-IMPORTED-GLOBAL) +run_cmake(empty_keyword_args) diff --git a/Tests/RunCMake/try_compile/CMP0056-stderr.txt b/Tests/RunCMake/try_compile/CMP0056-stderr.txt index 5c1f0e4cf..de442059d 100644 --- a/Tests/RunCMake/try_compile/CMP0056-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0056-stderr.txt @@ -10,4 +10,15 @@ CMake Warning \(dev\) at CMP0056.cmake:[0-9]+ \(try_compile\): caller link flags \(e.g. CMAKE_EXE_LINKER_FLAGS\) in the test project. Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it.$ +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Deprecation Warning at CMP0056.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0056 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/CMP0066-stderr.txt b/Tests/RunCMake/try_compile/CMP0066-stderr.txt index b14e2900e..0b92dcfc7 100644 --- a/Tests/RunCMake/try_compile/CMP0066-stderr.txt +++ b/Tests/RunCMake/try_compile/CMP0066-stderr.txt @@ -12,4 +12,15 @@ CMake Warning \(dev\) at CMP0066.cmake:[0-9]+ \(try_compile\): test project. Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it.$ +This warning is for project developers. Use -Wno-dev to suppress it. +* +CMake Deprecation Warning at CMP0066.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0066 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/CStandardGNU.c b/Tests/RunCMake/try_compile/CStandardGNU.c index ac26c15e9..f7ddff4d3 100644 --- a/Tests/RunCMake/try_compile/CStandardGNU.c +++ b/Tests/RunCMake/try_compile/CStandardGNU.c @@ -1,8 +1,8 @@ #if __STDC_VERSION__ != 199901L -#error "Not GNU C 99 mode!" +# error "Not GNU C 99 mode!" #endif #ifndef __STRICT_ANSI__ -#error "Not GNU C strict ANSI!" +# error "Not GNU C strict ANSI!" #endif int main(void) { diff --git a/Tests/RunCMake/try_compile/CxxStandardGNU.cxx b/Tests/RunCMake/try_compile/CxxStandardGNU.cxx index 7990a78dd..ef65e2656 100644 --- a/Tests/RunCMake/try_compile/CxxStandardGNU.cxx +++ b/Tests/RunCMake/try_compile/CxxStandardGNU.cxx @@ -1,9 +1,9 @@ #if __cplusplus != 201103L && \ !(__cplusplus < 201103L && defined(__GXX_EXPERIMENTAL_CXX0X__)) -#error "Not GNU C++ 11 mode!" +# error "Not GNU C++ 11 mode!" #endif #ifndef __STRICT_ANSI__ -#error "Not GNU C++ strict ANSI!" +# error "Not GNU C++ strict ANSI!" #endif int main() { diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 6a1bc64c0..77fb7a0f3 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -25,6 +25,13 @@ run_cmake(TargetTypeExe) run_cmake(TargetTypeInvalid) run_cmake(TargetTypeStatic) +if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$" AND + CMAKE_C_COMPILER_ID MATCHES "^(MSVC|GNU|Clang|AppleClang)$") + set (RunCMake_TEST_OPTIONS -DRunCMake_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) + run_cmake(LinkOptions) + unset (RunCMake_TEST_OPTIONS) +endif() + if(CMAKE_C_STANDARD_DEFAULT) run_cmake(CStandard) elseif(DEFINED CMAKE_C_STANDARD_DEFAULT) diff --git a/Tests/RunCMake/try_compile/src.c b/Tests/RunCMake/try_compile/src.c index 5e513825c..beed9b14d 100644 --- a/Tests/RunCMake/try_compile/src.c +++ b/Tests/RunCMake/try_compile/src.c @@ -3,5 +3,5 @@ int main(void) return 0; } #ifdef PP_ERROR -#error PP_ERROR is defined +# error PP_ERROR is defined #endif diff --git a/Tests/RunCMake/try_run/RunCMakeTest.cmake b/Tests/RunCMake/try_run/RunCMakeTest.cmake index 1ec9a55aa..368956295 100644 --- a/Tests/RunCMake/try_run/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_run/RunCMakeTest.cmake @@ -1,3 +1,10 @@ include(RunCMake) run_cmake(BadLinkLibraries) + +if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$" AND + CMAKE_C_COMPILER_ID MATCHES "^(MSVC|GNU|Clang|AppleClang)$") + set (RunCMake_TEST_OPTIONS -DRunCMake_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) + run_cmake(LinkOptions) + unset (RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake index 9becb4cd7..3883999c6 100644 --- a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake +++ b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake @@ -3,3 +3,5 @@ include(RunCMake) 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 e7eaa8d72..8321edb1d 100644 --- a/Tests/Server/CMakeLists.txt +++ b/Tests/Server/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.4) project(Server CXX) -find_package(PythonInterp REQUIRED) +find_package(Python REQUIRED) -macro(do_test bsname file) - execute_process(COMMAND ${PYTHON_EXECUTABLE} +macro(do_test bsname file type) + execute_process(COMMAND ${Python_EXECUTABLE} -B # no .pyc files - "${CMAKE_SOURCE_DIR}/server-test.py" + "${CMAKE_SOURCE_DIR}/${type}-test.py" "${CMAKE_COMMAND}" "${CMAKE_SOURCE_DIR}/${file}" "${CMAKE_SOURCE_DIR}" @@ -16,12 +16,13 @@ macro(do_test bsname file) ) if (NOT test_result EQUAL 0) - message(SEND_ERROR "TEST FAILED") + message(SEND_ERROR "TEST FAILED: ${test_result}") endif() endmacro() -do_test("test_handshake" "tc_handshake.json") -do_test("test_globalSettings" "tc_globalSettings.json") -do_test("test_buildsystem1" "tc_buildsystem1.json") +do_test("test_cache" "tc_cache.json" "server") +do_test("test_handshake" "tc_handshake.json" "server") +do_test("test_globalSettings" "tc_globalSettings.json" "server") +do_test("test_buildsystem1" "tc_buildsystem1.json" "server") add_executable(Server empty.cpp) diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py index 78450d5bf..546ae4cc5 100644 --- a/Tests/Server/cmakelib.py +++ b/Tests/Server/cmakelib.py @@ -1,5 +1,5 @@ from __future__ import print_function -import sys, subprocess, json +import sys, subprocess, json, os, select, shutil, time, socket termwidth = 150 @@ -38,11 +38,50 @@ def col_print(title, array): for index in range(numRows): print(indent + pad.join(item.ljust(maxitemwidth) for item in array[index::numRows])) +filterPacket = lambda x: x + +STDIN = 0 +PIPE = 1 + +communicationMethods = [STDIN] + +if hasattr(socket, 'AF_UNIX'): + communicationMethods.append(PIPE) + +def defaultExitWithError(proc): + data = "" + try: + while select.select([proc.outPipe], [], [], 3.)[0]: + data = data + proc.outPipe.read(1) + if len(data): + print("Rest of raw buffer from server:") + printServer(data) + except: + pass + proc.outPipe.close() + proc.inPipe.close() + proc.kill() + sys.exit(1) + +exitWithError = lambda proc: defaultExitWithError(proc) + +serverTag = "SERVER" + +def printServer(*args): + print(serverTag + ">", *args) + print() + sys.stdout.flush() + +def printClient(*args): + print("CLIENT>", *args) + print() + sys.stdout.flush() + def waitForRawMessage(cmakeCommand): stdoutdata = "" payload = "" while not cmakeCommand.poll(): - stdoutdataLine = cmakeCommand.stdout.readline() + stdoutdataLine = cmakeCommand.outPipe.readline() if stdoutdataLine: stdoutdata += stdoutdataLine.decode('utf-8') else: @@ -50,12 +89,24 @@ def waitForRawMessage(cmakeCommand): begin = stdoutdata.find('[== "CMake Server" ==[\n') end = stdoutdata.find(']== "CMake Server" ==]') - if (begin != -1 and end != -1): + if begin != -1 and end != -1: begin += len('[== "CMake Server" ==[\n') payload = stdoutdata[begin:end] - if print_communication: - print("\nSERVER>", json.loads(payload), "\n") - return json.loads(payload) + jsonPayload = json.loads(payload) + filteredPayload = filterPacket(jsonPayload) + if print_communication and filteredPayload: + printServer(filteredPayload) + if filteredPayload is not None or jsonPayload is None: + return jsonPayload + stdoutdata = stdoutdata[(end+len(']== "CMake Server" ==]')):] + +# Python2 has no problem writing the output of encodes directly, +# but Python3 returns only 'int's for encode and so must be turned +# into bytes. We use the existence of 'to_bytes' on an int to +# determine which behavior is appropriate. It might be more clear +# to do this in the code which uses the flag, but introducing +# this lookup cost at every byte sent isn't ideal. +has_to_bytes = "to_bytes" in dir(10) def writeRawData(cmakeCommand, content): writeRawData.counter += 1 @@ -71,36 +122,96 @@ def writeRawData(cmakeCommand, content): payload = payload.replace('\n', '\r\n') if print_communication: - print("\nCLIENT>", content, "(Use \\r\\n:", rn, ")\n") - cmakeCommand.stdin.write(payload.encode('utf-8')) - cmakeCommand.stdin.flush() + printClient(content, "(Use \\r\\n:", rn, ")") + + # To stress test how cmake deals with fragmentation in the + # communication channel, we send only one byte at a time. + # Certain communication methods / platforms might still buffer + # it all into one message since its so close together, but in + # general this will catch places where we assume full buffers + # come in all at once. + encoded_payload = payload.encode('utf-8') + + # Python version 3+ can't write ints directly; but 'to_bytes' + # for int was only added in python 3.2. If this is a 3+ version + # of python without that conversion function; just write the whole + # thing out at once. + if sys.version_info[0] > 2 and not has_to_bytes: + cmakeCommand.write(encoded_payload) + else: + for c in encoded_payload: + if has_to_bytes: + c = c.to_bytes(1, byteorder='big') + cmakeCommand.write(c) + writeRawData.counter = 0 def writePayload(cmakeCommand, obj): writeRawData(cmakeCommand, json.dumps(obj)) -def initProc(cmakeCommand): - cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server", "--experimental", "--debug"], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE) +def getPipeName(): + return "/tmp/server-test-socket" + +def attachPipe(cmakeCommand, pipeName): + time.sleep(1) + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.connect(pipeName) + global serverTag + serverTag = "SERVER(PIPE)" + cmakeCommand.outPipe = sock.makefile() + cmakeCommand.inPipe = sock + cmakeCommand.write = cmakeCommand.inPipe.sendall + +def writeAndFlush(pipe, val): + pipe.write(val) + pipe.flush() + +def initServerProc(cmakeCommand, comm): + if comm == PIPE: + pipeName = getPipeName() + cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server", "--experimental", "--pipe=" + pipeName]) + attachPipe(cmakeCommand, pipeName) + else: + cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server", "--experimental", "--debug"], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE) + cmakeCommand.outPipe = cmakeCommand.stdout + cmakeCommand.inPipe = cmakeCommand.stdin + cmakeCommand.write = lambda val: writeAndFlush(cmakeCommand.inPipe, val) packet = waitForRawMessage(cmakeCommand) if packet == None: print("Not in server mode") - sys.exit(1) + sys.exit(2) if packet['type'] != 'hello': print("No hello message") - sys.exit(1) + sys.exit(3) return cmakeCommand +def exitProc(cmakeCommand): + # Tell the server to exit. + cmakeCommand.stdin.close() + cmakeCommand.stdout.close() + + # Wait for the server to exit. + # If this version of python supports it, terminate the server after a timeout. + try: + cmakeCommand.wait(timeout=5) + except TypeError: + cmakeCommand.wait() + except: + cmakeCommand.terminate() + raise + def waitForMessage(cmakeCommand, expected): data = ordered(expected) packet = ordered(waitForRawMessage(cmakeCommand)) if packet != data: - sys.exit(-1) + print ("Received unexpected message; test failed") + exitWithError(cmakeCommand) return packet def waitForReply(cmakeCommand, originalType, cookie, skipProgress): @@ -109,25 +220,27 @@ def waitForReply(cmakeCommand, originalType, cookie, skipProgress): packet = waitForRawMessage(cmakeCommand) t = packet['type'] if packet['cookie'] != cookie or packet['inReplyTo'] != originalType: - sys.exit(1) + print("cookie or inReplyTo mismatch") + sys.exit(4) if t == 'message' or t == 'progress': if skipProgress: continue if t == 'reply': break - sys.exit(1) + print("Unrecognized message", packet) + sys.exit(5) return packet def waitForError(cmakeCommand, originalType, cookie, message): packet = waitForRawMessage(cmakeCommand) if packet['cookie'] != cookie or packet['type'] != 'error' or packet['inReplyTo'] != originalType or packet['errorMessage'] != message: - sys.exit(1) + sys.exit(6) def waitForProgress(cmakeCommand, originalType, cookie, current, message): packet = waitForRawMessage(cmakeCommand) if packet['cookie'] != cookie or packet['type'] != 'progress' or packet['inReplyTo'] != originalType or packet['progressCurrent'] != current or packet['progressMessage'] != message: - sys.exit(1) + sys.exit(7) def handshake(cmakeCommand, major, minor, source, build, generator, extraGenerator): version = { 'major': major } @@ -152,9 +265,9 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): versionString = version['string'] vs = str(version['major']) + '.' + str(version['minor']) + '.' + str(version['patch']) if (versionString != vs and not versionString.startswith(vs + '-')): - sys.exit(1) + sys.exit(8) if (versionString != cmakeVersion): - sys.exit(1) + sys.exit(9) # validate generators: generatorObjects = capabilities['generators'] @@ -163,6 +276,10 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): index = cmakeoutput.index('\nGenerators\n\n') cmakeGenerators = [] for line in cmakeoutput[index + 12:].splitlines(): + if not line: + continue + if line[0] == '*': # default generator marker + line = ' ' + line[1:] if not line.startswith(' '): continue if line.startswith(' '): @@ -175,7 +292,7 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): tmp = line.strip() if tmp.endswith(" [arch]"): tmp = tmp[0:len(tmp) - 7] - if (len(tmp) > 0) and (" - " not in tmp) and (tmp != 'KDevelop3'): + if (len(tmp) > 0) and (" - " not in tmp): cmakeGenerators.append(tmp) generators = [] @@ -187,13 +304,77 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): for gen in cmakeGenerators: if (not gen in generators): - sys.exit(1) + sys.exit(10) gen = packet['generator'] if (gen != '' and not (gen in generators)): - sys.exit(1) + sys.exit(11) for i in data: print("Validating", i) if (packet[i] != data[i]): + sys.exit(12) + +def validateCache(cmakeCommand, data): + packet = waitForReply(cmakeCommand, 'cache', '', False) + + cache = packet['cache'] + + if (data['isEmpty']): + if (cache != []): + print('Expected empty cache, but got data.\n') sys.exit(1) + return; + + if (cache == []): + print('Expected cache contents, but got none.\n') + sys.exit(1) + + hadHomeDir = False + for value in cache: + if (value['key'] == 'CMAKE_HOME_DIRECTORY'): + hadHomeDir = True + + if (not hadHomeDir): + print('No CMAKE_HOME_DIRECTORY found in cache.') + sys.exit(1) + +def handleBasicMessage(proc, obj, debug): + if 'sendRaw' in obj: + data = obj['sendRaw'] + if debug: print("Sending raw:", data) + writeRawData(proc, data) + return True + elif 'send' in obj: + data = obj['send'] + if debug: print("Sending:", json.dumps(data)) + writePayload(proc, data) + return True + elif 'recv' in obj: + data = obj['recv'] + if debug: print("Waiting for:", json.dumps(data)) + waitForMessage(proc, data) + return True + elif 'message' in obj: + print("MESSAGE:", obj["message"]) + sys.stdout.flush() + return True + return False + +def shutdownProc(proc): + # Tell the server to exit. + proc.inPipe.close() + proc.outPipe.close() + + # Wait for the server to exit. + # If this version of python supports it, terminate the server after a timeout. + try: + proc.wait(timeout=5) + except TypeError: + proc.wait() + except: + proc.terminate() + raise + + print('cmake-server exited: %d' % proc.returncode) + sys.exit(proc.returncode) diff --git a/Tests/Server/server-test.py b/Tests/Server/server-test.py index 62d9008b2..701c6e945 100644 --- a/Tests/Server/server-test.py +++ b/Tests/Server/server-test.py @@ -9,7 +9,7 @@ sourceDir = sys.argv[3] buildDir = sys.argv[4] + "/" + os.path.splitext(os.path.basename(testFile))[0] cmakeGenerator = sys.argv[5] -print("Test:", testFile, +print("Server Test:", testFile, "\n-- SourceDir:", sourceDir, "\n-- BuildDir:", buildDir, "\n-- Generator:", cmakeGenerator) @@ -17,104 +17,89 @@ print("Test:", testFile, if os.path.exists(buildDir): shutil.rmtree(buildDir) -proc = cmakelib.initProc(cmakeCommand) +cmakelib.filterBase = sourceDir with open(testFile) as f: testData = json.loads(f.read()) -for obj in testData: - if 'sendRaw' in obj: - data = obj['sendRaw'] - if debug: print("Sending raw:", data) - cmakelib.writeRawData(proc, data) - elif 'send' in obj: - data = obj['send'] - if debug: print("Sending:", json.dumps(data)) - cmakelib.writePayload(proc, data) - elif 'recv' in obj: - data = obj['recv'] - if debug: print("Waiting for:", json.dumps(data)) - cmakelib.waitForMessage(proc, data) - elif 'reply' in obj: - data = obj['reply'] - if debug: print("Waiting for reply:", json.dumps(data)) - originalType = "" - cookie = "" - skipProgress = False; - if 'cookie' in data: cookie = data['cookie'] - if 'type' in data: originalType = data['type'] - if 'skipProgress' in data: skipProgress = data['skipProgress'] - cmakelib.waitForReply(proc, originalType, cookie, skipProgress) - elif 'error' in obj: - data = obj['error'] - if debug: print("Waiting for error:", json.dumps(data)) - originalType = "" - cookie = "" - message = "" - if 'cookie' in data: cookie = data['cookie'] - if 'type' in data: originalType = data['type'] - if 'message' in data: message = data['message'] - cmakelib.waitForError(proc, originalType, cookie, message) - elif 'progress' in obj: - data = obj['progress'] - if debug: print("Waiting for progress:", json.dumps(data)) - originalType = '' - cookie = "" - current = 0 - message = "" - if 'cookie' in data: cookie = data['cookie'] - if 'type' in data: originalType = data['type'] - if 'current' in data: current = data['current'] - if 'message' in data: message = data['message'] - cmakelib.waitForProgress(proc, originalType, cookie, current, message) - elif 'handshake' in obj: - data = obj['handshake'] - if debug: print("Doing handshake:", json.dumps(data)) - major = -1 - minor = -1 - generator = cmakeGenerator - extraGenerator = '' - sourceDirectory = sourceDir - buildDirectory = buildDir - if 'major' in data: major = data['major'] - if 'minor' in data: minor = data['minor'] - if 'buildDirectory' in data: buildDirectory = data['buildDirectory'] - if 'sourceDirectory' in data: sourceDirectory = data['sourceDirectory'] - if 'generator' in data: generator = data['generator'] - if 'extraGenerator' in data: extraGenerator = data['extraGenerator'] - if not os.path.isabs(buildDirectory): - buildDirectory = buildDir + "/" + buildDirectory - if not os.path.isabs(sourceDirectory): - sourceDirectory = sourceDir + "/" + sourceDirectory - cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory, - generator, extraGenerator) - elif 'validateGlobalSettings' in obj: - data = obj['validateGlobalSettings'] - if not 'buildDirectory' in data: data['buildDirectory'] = buildDir - if not 'sourceDirectory' in data: data['sourceDirectory'] = sourceDir - if not 'generator' in data: data['generator'] = cmakeGenerator - if not 'extraGenerator' in data: data['extraGenerator'] = '' - cmakelib.validateGlobalSettings(proc, cmakeCommand, data) - elif 'message' in obj: - print("MESSAGE:", obj["message"]) - else: - print("Unknown command:", json.dumps(obj)) - sys.exit(2) +for communicationMethod in cmakelib.communicationMethods: + proc = cmakelib.initServerProc(cmakeCommand, communicationMethod) + if proc is None: + continue - print("Completed") - -# Tell the server to exit. -proc.stdin.close() -proc.stdout.close() + for obj in testData: + if cmakelib.handleBasicMessage(proc, obj, debug): + pass + elif 'reply' in obj: + data = obj['reply'] + if debug: print("Waiting for reply:", json.dumps(data)) + originalType = "" + cookie = "" + skipProgress = False; + if 'cookie' in data: cookie = data['cookie'] + if 'type' in data: originalType = data['type'] + if 'skipProgress' in data: skipProgress = data['skipProgress'] + cmakelib.waitForReply(proc, originalType, cookie, skipProgress) + elif 'error' in obj: + data = obj['error'] + if debug: print("Waiting for error:", json.dumps(data)) + originalType = "" + cookie = "" + message = "" + if 'cookie' in data: cookie = data['cookie'] + if 'type' in data: originalType = data['type'] + if 'message' in data: message = data['message'] + cmakelib.waitForError(proc, originalType, cookie, message) + elif 'progress' in obj: + data = obj['progress'] + if debug: print("Waiting for progress:", json.dumps(data)) + originalType = '' + cookie = "" + current = 0 + message = "" + if 'cookie' in data: cookie = data['cookie'] + if 'type' in data: originalType = data['type'] + if 'current' in data: current = data['current'] + if 'message' in data: message = data['message'] + cmakelib.waitForProgress(proc, originalType, cookie, current, message) + elif 'handshake' in obj: + data = obj['handshake'] + if debug: print("Doing handshake:", json.dumps(data)) + major = -1 + minor = -1 + generator = cmakeGenerator + extraGenerator = '' + sourceDirectory = sourceDir + buildDirectory = buildDir + if 'major' in data: major = data['major'] + if 'minor' in data: minor = data['minor'] + if 'buildDirectory' in data: buildDirectory = data['buildDirectory'] + if 'sourceDirectory' in data: sourceDirectory = data['sourceDirectory'] + if 'generator' in data: generator = data['generator'] + if 'extraGenerator' in data: extraGenerator = data['extraGenerator'] -# Wait for the server to exit. -# If this version of python supports it, terminate the server after a timeout. -try: - proc.wait(timeout=5) -except TypeError: - proc.wait() -except: - proc.terminate() - raise - -sys.exit(0) + if not os.path.isabs(buildDirectory): + buildDirectory = buildDir + "/" + buildDirectory + if sourceDirectory != '' and not os.path.isabs(sourceDirectory): + sourceDirectory = sourceDir + "/" + sourceDirectory + cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory, + generator, extraGenerator) + elif 'validateGlobalSettings' in obj: + data = obj['validateGlobalSettings'] + if not 'buildDirectory' in data: data['buildDirectory'] = buildDir + if not 'sourceDirectory' in data: data['sourceDirectory'] = sourceDir + if not 'generator' in data: data['generator'] = cmakeGenerator + if not 'extraGenerator' in data: data['extraGenerator'] = '' + cmakelib.validateGlobalSettings(proc, cmakeCommand, data) + elif 'validateCache' in obj: + data = obj['validateCache'] + if not 'isEmpty' in data: data['isEmpty'] = false + cmakelib.validateCache(proc, data) + elif 'reconnect' in obj: + cmakelib.exitProc(proc) + proc = cmakelib.initServerProc(cmakeCommand, communicationMethod) + else: + print("Unknown command:", json.dumps(obj)) + sys.exit(2) + cmakelib.shutdownProc(proc) + print("Completed") diff --git a/Tests/Server/tc_handshake.json b/Tests/Server/tc_handshake.json index 975bb3d32..4bb7fa7ac 100644 --- a/Tests/Server/tc_handshake.json +++ b/Tests/Server/tc_handshake.json @@ -11,6 +11,10 @@ { "send": {"test": "sometext","cookie":"monster"} }, { "recv": {"cookie":"monster","errorMessage":"No type given in request.","inReplyTo":"","type":"error"} }, +{ "message": "Testing commands before handshake" }, +{ "send": {"type": "cache","cookie":"monster"} }, +{ "recv": {"cookie":"monster","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"cache","type":"error"} }, + { "message": "Testing handshake" }, { "send": {"type": "sometype","cookie":"monster2"} }, { "recv": {"cookie":"monster2","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"sometype","type":"error"} }, diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt index 4e4a030ce..a5740bba9 100644 --- a/Tests/SourceGroups/CMakeLists.txt +++ b/Tests/SourceGroups/CMakeLists.txt @@ -39,9 +39,23 @@ set(tree_files_without_prefix ${root}/sub1/tree_bar.c set(tree_files_with_prefix ${root}/tree_prefix_foo.c tree_prefix_bar.c) +set(tree_files_with_empty_prefix ${root}/tree_empty_prefix_foo.c + tree_empty_prefix_bar.c) + +set(tree_files_which_are_actually_directories ${root} + ${root}/ + ${root}/sub1 + ${root}/sub1/) + source_group(TREE ${root} FILES ${tree_files_without_prefix}) -source_group(TREE ${root} PREFIX tree_root/subgroup FILES ${tree_files_with_prefix}) +# Should not crash and not add any files - just silently ignore the directories +source_group(TREE ${root} FILES ${tree_files_which_are_actually_directories}) + +source_group(FILES ${tree_files_with_prefix} PREFIX tree_root/subgroup TREE ${root}) + +source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root}) add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c - ${tree_files_with_prefix} ${tree_files_without_prefix} README.txt) + ${tree_files_with_prefix} ${tree_files_without_prefix} + ${tree_files_with_empty_prefix} README.txt) diff --git a/Tests/SourceGroups/main.c b/Tests/SourceGroups/main.c index 4d84cf20e..87225f546 100644 --- a/Tests/SourceGroups/main.c +++ b/Tests/SourceGroups/main.c @@ -7,6 +7,8 @@ extern int barbar(void); extern int baz(void); extern int tree_prefix_foo(void); extern int tree_prefix_bar(void); +extern int tree_empty_prefix_foo(void); +extern int tree_empty_prefix_bar(void); extern int tree_bar(void); extern int tree_foobar(void); extern int tree_baz(void); @@ -17,8 +19,9 @@ int main() foobar(), barbar(), baz()); printf("tree_prefix_foo: %d tree_prefix_bar: %d tree_bar: %d tree_foobar: " - "%d tree_baz: %d\n", + "%d tree_baz: %d tree_empty_prefix_foo: %d " + "tree_empty_prefix_bar: %d\n", tree_prefix_foo(), tree_prefix_bar(), tree_bar(), tree_foobar(), - tree_baz()); + tree_baz(), tree_empty_prefix_foo(), tree_empty_prefix_bar()); return 0; } diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt index 49ff7fee7..8d2519ea3 100644 --- a/Tests/StagingPrefix/CMakeLists.txt +++ b/Tests/StagingPrefix/CMakeLists.txt @@ -1,15 +1,16 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.9) project(StagingPrefix) # Wipe out the install tree add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/CleanupProject - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ConsumerBuild - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ProducerBuild - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/stage - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/prefix - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ignored + COMMAND ${CMAKE_COMMAND} -E remove_directory + ${CMAKE_BINARY_DIR}/ConsumerBuild + ${CMAKE_BINARY_DIR}/ProducerBuild + ${CMAKE_BINARY_DIR}/stage + ${CMAKE_BINARY_DIR}/prefix + ${CMAKE_BINARY_DIR}/ignored ) add_custom_target(CleanupTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/CleanupProject) set_property( @@ -17,7 +18,8 @@ set_property( PROPERTY SYMBOLIC 1 ) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/SubDir/Executable/test.cxx b/Tests/SubDir/Executable/test.cxx index 06aed018b..01d928085 100644 --- a/Tests/SubDir/Executable/test.cxx +++ b/Tests/SubDir/Executable/test.cxx @@ -1,19 +1,19 @@ #include <stdio.h> #include <stdlib.h> #ifdef _WIN32 -#include <io.h> +# include <io.h> #else -#include <unistd.h> +# include <unistd.h> #endif // return true if the file exists int FileExists(const char* filename) { #ifdef _MSC_VER -#define access _access +# define access _access #endif #ifndef F_OK -#define F_OK 0 +# define F_OK 0 #endif if (access(filename, F_OK) != 0) { return false; diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt index 40c265e5f..0d45db85c 100644 --- a/Tests/SubDirSpaces/CMakeLists.txt +++ b/Tests/SubDirSpaces/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6) project(SUBDIR) # Some systems do not seem to support rpath with spaces. -if(CMAKE_SYSTEM_NAME MATCHES "IRIX|QNX") +if(CMAKE_SYSTEM_NAME MATCHES "QNX") set(CMAKE_SKIP_BUILD_RPATH 1) endif() diff --git a/Tests/SubDirSpaces/Executable Sources/test.cxx b/Tests/SubDirSpaces/Executable Sources/test.cxx index 06aed018b..01d928085 100644 --- a/Tests/SubDirSpaces/Executable Sources/test.cxx +++ b/Tests/SubDirSpaces/Executable Sources/test.cxx @@ -1,19 +1,19 @@ #include <stdio.h> #include <stdlib.h> #ifdef _WIN32 -#include <io.h> +# include <io.h> #else -#include <unistd.h> +# include <unistd.h> #endif // return true if the file exists int FileExists(const char* filename) { #ifdef _MSC_VER -#define access _access +# define access _access #endif #ifndef F_OK -#define F_OK 0 +# define F_OK 0 #endif if (access(filename, F_OK) != 0) { return false; diff --git a/Tests/SubDirSpaces/Executable/test.cxx b/Tests/SubDirSpaces/Executable/test.cxx index 06aed018b..01d928085 100644 --- a/Tests/SubDirSpaces/Executable/test.cxx +++ b/Tests/SubDirSpaces/Executable/test.cxx @@ -1,19 +1,19 @@ #include <stdio.h> #include <stdlib.h> #ifdef _WIN32 -#include <io.h> +# include <io.h> #else -#include <unistd.h> +# include <unistd.h> #endif // return true if the file exists int FileExists(const char* filename) { #ifdef _MSC_VER -#define access _access +# define access _access #endif #ifndef F_OK -#define F_OK 0 +# define F_OK 0 #endif if (access(filename, F_OK) != 0) { return false; diff --git a/Tests/SwiftMix/CMain.c b/Tests/SwiftMix/CMain.c index 8877da430..519058efe 100644 --- a/Tests/SwiftMix/CMain.c +++ b/Tests/SwiftMix/CMain.c @@ -1,5 +1,5 @@ -extern int ObjCMain(int argc, char const* const argv[]); -int main(int argc, char* argv[]) +extern int ObjCMain(void); +int main(void) { - return ObjCMain(argc, argv); + return ObjCMain(); } diff --git a/Tests/SwiftMix/CMakeLists.txt b/Tests/SwiftMix/CMakeLists.txt index 5e50470f6..6d8e48bd0 100644 --- a/Tests/SwiftMix/CMakeLists.txt +++ b/Tests/SwiftMix/CMakeLists.txt @@ -3,3 +3,4 @@ project(SwiftMix C Swift) add_executable(SwiftMix CMain.c ObjCMain.m SwiftMain.swift ObjC-Swift.h) set_property(TARGET SwiftMix PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "ObjC-Swift.h") +target_compile_options(SwiftMix PRIVATE "$<$<COMPILE_LANGUAGE:C>:-Werror=objc-method-access>") diff --git a/Tests/SwiftMix/ObjCMain.m b/Tests/SwiftMix/ObjCMain.m index 20f0bf1ee..afc924380 100644 --- a/Tests/SwiftMix/ObjCMain.m +++ b/Tests/SwiftMix/ObjCMain.m @@ -1,4 +1,4 @@ #import "SwiftMix-Swift.h" -int ObjCMain(int argc, char const* const argv[]) { +int ObjCMain(void) { return [SwiftMainClass SwiftMain]; } diff --git a/Tests/SwiftMix/SwiftMain.swift b/Tests/SwiftMix/SwiftMain.swift index a4a0a62b4..d9c8cd756 100644 --- a/Tests/SwiftMix/SwiftMain.swift +++ b/Tests/SwiftMix/SwiftMain.swift @@ -1,7 +1,7 @@ import Foundation @objc class SwiftMainClass : NSObject { - class func SwiftMain() -> Int32 { + @objc class func SwiftMain() -> Int32 { dump("Hello World!"); return 0; } diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt index cf4463ccf..f4cbac212 100644 --- a/Tests/SwiftOnly/CMakeLists.txt +++ b/Tests/SwiftOnly/CMakeLists.txt @@ -1,8 +1,13 @@ cmake_minimum_required(VERSION 3.3) project(SwiftOnly Swift) -if(NOT XCODE_VERSION VERSION_LESS 8.0) +if(NOT XCODE_VERSION VERSION_LESS 10.2) + set(CMAKE_Swift_LANGUAGE_VERSION 5.0) +elseif(NOT XCODE_VERSION VERSION_LESS 8.0) set(CMAKE_Swift_LANGUAGE_VERSION 3.0) endif() add_executable(SwiftOnly main.swift) + +# Dummy to make sure generation works with such targets. +add_library(SwiftIface INTERFACE) diff --git a/Tests/TestsWorkingDirectory/main.c b/Tests/TestsWorkingDirectory/main.c index 11dd4ff7c..8755c0ef3 100644 --- a/Tests/TestsWorkingDirectory/main.c +++ b/Tests/TestsWorkingDirectory/main.c @@ -3,16 +3,17 @@ #include <stdlib.h> #include <string.h> -#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || \ - defined(__BORLANDC__) || defined(__MINGW32__)) +#if defined(_WIN32) && \ + (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || \ + defined(__MINGW32__)) -#include <direct.h> -#include <io.h> +# include <direct.h> +# include <io.h> -#if defined(__WATCOMC__) -#include <direct.h> -#define _getcwd getcwd -#endif +# if defined(__WATCOMC__) +# include <direct.h> +# define _getcwd getcwd +# endif static const char* Getcwd(char* buf, unsigned int len) { @@ -35,9 +36,9 @@ static const char* Getcwd(char* buf, unsigned int len) } #else -#include <fcntl.h> -#include <sys/types.h> -#include <unistd.h> +# include <fcntl.h> +# include <sys/types.h> +# include <unistd.h> static const char* Getcwd(char* buf, unsigned int len) { diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 2f8e4fb3c..54e96a208 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -165,6 +165,35 @@ try_compile(TEST_INNER OUTPUT_VARIABLE output) TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") +try_compile(COMPILE_DEFINITIONS_LIST_EXPANDED + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/check_a_b.c + OUTPUT_VARIABLE output + COMPILE_DEFINITIONS "-DDEF_A;-DDEF_B" + ) +if(COMPILE_DEFINITIONS_LIST_EXPANDED) + message(STATUS "COMPILE_DEFINITIONS list expanded correctly") +else() + string(REPLACE "\n" "\n " output " ${output}") + message(SEND_ERROR "COMPILE_DEFINITIONS list did not expand correctly\n${output}") +endif() + +try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE output + COMPILE_DEFINITIONS "bad#source.c" + ) +if(SHOULD_FAIL_DUE_TO_BAD_SOURCE AND NOT CMAKE_GENERATOR MATCHES "Watcom WMake|NMake Makefiles") + string(REPLACE "\n" "\n " output " ${output}") + message(SEND_ERROR "try_compile with bad#source.c did not fail:\n${output}") +elseif(NOT output MATCHES [[(bad#source\.c|bad\\)]]) + string(REPLACE "\n" "\n " output " ${output}") + message(SEND_ERROR "try_compile with bad#source.c failed without mentioning bad source:\n${output}") +else() + message(STATUS "try_compile with bad#source.c correctly failed") +endif() + add_executable(TryCompile pass.c) ###################################### @@ -242,7 +271,7 @@ include(CheckCXXSourceCompiles) include(CheckCSourceRuns) include(CheckCXXSourceRuns) -CHECK_C_SOURCE_COMPILES("I dont build" C_BUILD_SHOULD_FAIL) +CHECK_C_SOURCE_COMPILES("I don't build" C_BUILD_SHOULD_FAIL) CHECK_C_SOURCE_COMPILES("int main() {return 0;}" C_BUILD_SHOULD_WORK) CHECK_C_SOURCE_RUNS("int main() {return 1;}" C_RUN_SHOULD_FAIL) CHECK_C_SOURCE_RUNS("int main() {return 0;}" C_RUN_SHOULD_WORK) @@ -252,7 +281,7 @@ TEST_ASSERT(C_BUILD_SHOULD_WORK "CHECK_C_SOURCE_COMPILES() failed") TEST_FAIL(C_RUN_SHOULD_FAIL "CHECK_C_SOURCE_RUNS() succeeded, but should have failed") TEST_ASSERT(C_RUN_SHOULD_WORK "CHECK_C_SOURCE_RUNS() failed") -CHECK_CXX_SOURCE_COMPILES("I dont build" CXX_BUILD_SHOULD_FAIL) +CHECK_CXX_SOURCE_COMPILES("I don't build" CXX_BUILD_SHOULD_FAIL) CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" CXX_BUILD_SHOULD_WORK) CHECK_CXX_SOURCE_RUNS("int main() {return 2;}" CXX_RUN_SHOULD_FAIL) CHECK_CXX_SOURCE_RUNS("int main() {return 0;}" CXX_RUN_SHOULD_WORK) diff --git a/Tests/TryCompile/testdef.c b/Tests/TryCompile/testdef.c index b05f070d0..72301dd4e 100644 --- a/Tests/TryCompile/testdef.c +++ b/Tests/TryCompile/testdef.c @@ -1,5 +1,5 @@ #ifndef TESTDEF -#error "TESTDEF should be defined!" +# error "TESTDEF should be defined!" #endif int main(void) { diff --git a/Tests/Tutorial/Step1/CMakeLists.txt b/Tests/Tutorial/Step1/CMakeLists.txt index e461d3c8b..141f0c27a 100644 --- a/Tests/Tutorial/Step1/CMakeLists.txt +++ b/Tests/Tutorial/Step1/CMakeLists.txt @@ -1,20 +1,3 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) - -# configure a header file to pass some of the CMake settings -# to the source code -configure_file ( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) - -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories("${PROJECT_BINARY_DIR}") - -# add the executable add_executable(Tutorial tutorial.cxx) diff --git a/Tests/Tutorial/Step1/tutorial.cxx b/Tests/Tutorial/Step1/tutorial.cxx index 7a13376cb..f8dd0c6c8 100644 --- a/Tests/Tutorial/Step1/tutorial.cxx +++ b/Tests/Tutorial/Step1/tutorial.cxx @@ -1,19 +1,20 @@ // A simple program that computes the square root of a number -#include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <cmath> +#include <cstdlib> +#include <iostream> +#include <string> int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } + double inputValue = atof(argv[1]); + double outputValue = sqrt(inputValue); - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step2/CMakeLists.txt b/Tests/Tutorial/Step2/CMakeLists.txt index cf1d30ee2..48afaa327 100644 --- a/Tests/Tutorial/Step2/CMakeLists.txt +++ b/Tests/Tutorial/Step2/CMakeLists.txt @@ -1,31 +1,25 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) -# should we use our own math functions -option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) +# add the executable +add_executable(Tutorial tutorial.cxx) + # add the binary tree to the search path for include files # so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - -# add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () - -# add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) diff --git a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx index 2710f9220..7d9379e43 100644 --- a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx @@ -1,5 +1,5 @@ #include "MathFunctions.h" -#include <stdio.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -8,19 +8,16 @@ double mysqrt(double x) return 0; } - double result; - double delta; - result = x; + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } return result; } diff --git a/Tests/Tutorial/Step2/TutorialConfig.h.in b/Tests/Tutorial/Step2/TutorialConfig.h.in index 25a06020a..5395a0671 100644 --- a/Tests/Tutorial/Step2/TutorialConfig.h.in +++ b/Tests/Tutorial/Step2/TutorialConfig.h.in @@ -1,5 +1,4 @@ // the configured options and settings for Tutorial #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ -#cmakedefine USE_MYMATH diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx index 2fae364d4..75b7d67b0 100644 --- a/Tests/Tutorial/Step2/tutorial.cxx +++ b/Tests/Tutorial/Step2/tutorial.cxx @@ -1,33 +1,23 @@ // A simple program that computes the square root of a number -#include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <cmath> +#include <iostream> +#include <string> -#ifdef USE_MYMATH -#include "MathFunctions.h" -#endif +#include "TutorialConfig.h" int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; - - if (inputValue >= 0) { -#ifdef USE_MYMATH - outputValue = mysqrt(inputValue); -#else - outputValue = sqrt(inputValue); -#endif - } + double inputValue = std::stod(argv[1]); - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + double outputValue = sqrt(inputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step3/CMakeLists.txt b/Tests/Tutorial/Step3/CMakeLists.txt index 762302bc5..f904ea748 100644 --- a/Tests/Tutorial/Step3/CMakeLists.txt +++ b/Tests/Tutorial/Step3/CMakeLists.txt @@ -1,68 +1,38 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) + list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions") +endif(USE_MYMATH) # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) - -# add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) - - -# enable testing -enable_testing () - -# does the application run -add_test (TutorialRuns Tutorial 25) +add_executable(Tutorial tutorial.cxx) -# does it sqrt of 25 -add_test (TutorialComp25 Tutorial 25) -set_tests_properties (TutorialComp25 - PROPERTIES PASS_REGULAR_EXPRESSION "25 is 5" - ) - -# does it handle negative numbers -add_test (TutorialNegative Tutorial -25) -set_tests_properties (TutorialNegative - PROPERTIES PASS_REGULAR_EXPRESSION "-25 is 0" - ) - -# does it handle small numbers -add_test (TutorialSmall Tutorial 0.0001) -set_tests_properties (TutorialSmall - PROPERTIES PASS_REGULAR_EXPRESSION "0.0001 is 0.01" - ) +target_link_libraries(Tutorial ${EXTRA_LIBS}) -# does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" - ) +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ${EXTRA_INCLUDES} + ) diff --git a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt index f386036c3..8b443a659 100644 --- a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt @@ -1,4 +1 @@ add_library(MathFunctions mysqrt.cxx) - -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx index 2710f9220..7d9379e43 100644 --- a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx @@ -1,5 +1,5 @@ #include "MathFunctions.h" -#include <stdio.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -8,19 +8,16 @@ double mysqrt(double x) return 0; } - double result; - double delta; - result = x; + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } return result; } diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx index 2fae364d4..1d5742d2d 100644 --- a/Tests/Tutorial/Step3/tutorial.cxx +++ b/Tests/Tutorial/Step3/tutorial.cxx @@ -1,33 +1,32 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH -#include "MathFunctions.h" +# include "MathFunctions.h" #endif int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step4/CMakeLists.txt b/Tests/Tutorial/Step4/CMakeLists.txt index 6994aa1ce..34eab5558 100644 --- a/Tests/Tutorial/Step4/CMakeLists.txt +++ b/Tests/Tutorial/Step4/CMakeLists.txt @@ -1,68 +1,36 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) - -# does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif(USE_MYMATH) # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) - -# add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) - -# enable testing -enable_testing () +add_executable(Tutorial tutorial.cxx) -# does the application run -add_test (TutorialRuns Tutorial 25) - -# does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" - ) - -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} - PROPERTIES PASS_REGULAR_EXPRESSION ${result} - ) -endmacro () - -# do a bunch of result based tests -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) diff --git a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt index f386036c3..0515852a0 100644 --- a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt @@ -1,4 +1,7 @@ add_library(MathFunctions mysqrt.cxx) -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + ) diff --git a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx index 6ca264f76..7d9379e43 100644 --- a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx @@ -1,8 +1,5 @@ #include "MathFunctions.h" -#include "TutorialConfig.h" -#include <stdio.h> - -#include <math.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -11,26 +8,16 @@ double mysqrt(double x) return 0; } - double result; - -// if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - result = exp(log(x) * 0.5); - fprintf(stdout, "Computing sqrt of %g to be %g using log\n", x, result); -#else - double delta; - result = x; + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif return result; } diff --git a/Tests/Tutorial/Step4/TutorialConfig.h.in b/Tests/Tutorial/Step4/TutorialConfig.h.in index a0912656a..25a06020a 100644 --- a/Tests/Tutorial/Step4/TutorialConfig.h.in +++ b/Tests/Tutorial/Step4/TutorialConfig.h.in @@ -3,7 +3,3 @@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH -// does the platform provide exp and log functions? -#cmakedefine HAVE_LOG -#cmakedefine HAVE_EXP - diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Tests/Tutorial/Step4/tutorial.cxx index 2fae364d4..1d5742d2d 100644 --- a/Tests/Tutorial/Step4/tutorial.cxx +++ b/Tests/Tutorial/Step4/tutorial.cxx @@ -1,33 +1,32 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH -#include "MathFunctions.h" +# include "MathFunctions.h" #endif int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step5/CMakeLists.txt b/Tests/Tutorial/Step5/CMakeLists.txt index e40b676b4..63e541056 100644 --- a/Tests/Tutorial/Step5/CMakeLists.txt +++ b/Tests/Tutorial/Step5/CMakeLists.txt @@ -1,72 +1,70 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) - -# does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif() # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) # add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) # enable testing -enable_testing () +enable_testing() # does the application run -add_test (TutorialRuns Tutorial 25) +add_test(NAME Runs COMMAND Tutorial 25) # does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" ) -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} PROPERTIES PASS_REGULAR_EXPRESSION ${result} ) -endmacro () +endfunction(do_test) # do a bunch of result based tests -do_test (4 "4 is 2") -do_test (9 "9 is 3") -do_test (5 "5 is 2.236") -do_test (7 "7 is 2.645") -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") - +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt index 453a46332..11cf4127b 100644 --- a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt @@ -1,17 +1,10 @@ -# first we add the executable that generates the table -# add the binary tree directory to the search path for include files -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +add_library(MathFunctions mysqrt.cxx) -add_executable(MakeTable MakeTable.cxx ) -# add the command to generate the source code -add_custom_command ( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h - COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h - DEPENDS MakeTable - ) +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + ) -# add the main library -add_library(MathFunctions mysqrt.cxx ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) - -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx index cebd50fcc..ee585568c 100644 --- a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx +++ b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx @@ -1,32 +1,25 @@ // A simple program that builds a sqrt table -#include <math.h> -#include <stdio.h> +#include <cmath> +#include <fstream> +#include <iostream> int main(int argc, char* argv[]) { - int i; - double result; - // make sure we have enough arguments if (argc < 2) { return 1; } - // open the output file - FILE* fout = fopen(argv[1], "w"); - if (!fout) { - return 1; + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); } - - // create a source file with a table of square roots - fprintf(fout, "double sqrtTable[] = {\n"); - for (i = 0; i < 10; ++i) { - result = sqrt(static_cast<double>(i)); - fprintf(fout, "%g,\n", result); - } - - // close the table with a zero - fprintf(fout, "0};\n"); - fclose(fout); - return 0; + return fileOpen ? 0 : 1; // return 0 if wrote the file } diff --git a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx index 458ed63a1..7d9379e43 100644 --- a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx @@ -1,11 +1,5 @@ #include "MathFunctions.h" -#include "TutorialConfig.h" -#include <stdio.h> - -// include the generated table -#include "Table.h" - -#include <math.h> +#include <iostream> // a hack square root calculation using simple operations double mysqrt(double x) @@ -14,27 +8,16 @@ double mysqrt(double x) return 0; } - double result; - - // if we have both log and exp then use them - double delta; - - // use the table to help find an initial value - result = x; - if (x >= 1 && x < 10) { - result = sqrtTable[static_cast<int>(x)]; - } + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } - return result; } diff --git a/Tests/Tutorial/Step5/TutorialConfig.h.in b/Tests/Tutorial/Step5/TutorialConfig.h.in index a0912656a..25a06020a 100644 --- a/Tests/Tutorial/Step5/TutorialConfig.h.in +++ b/Tests/Tutorial/Step5/TutorialConfig.h.in @@ -3,7 +3,3 @@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH -// does the platform provide exp and log functions? -#cmakedefine HAVE_LOG -#cmakedefine HAVE_EXP - diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Tests/Tutorial/Step5/tutorial.cxx index 2fae364d4..1d5742d2d 100644 --- a/Tests/Tutorial/Step5/tutorial.cxx +++ b/Tests/Tutorial/Step5/tutorial.cxx @@ -1,33 +1,32 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH -#include "MathFunctions.h" +# include "MathFunctions.h" #endif int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step6/CMakeLists.txt b/Tests/Tutorial/Step6/CMakeLists.txt index 0fb7cac5f..503a31290 100644 --- a/Tests/Tutorial/Step6/CMakeLists.txt +++ b/Tests/Tutorial/Step6/CMakeLists.txt @@ -1,78 +1,76 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) # does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif() # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) # add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) # enable testing -enable_testing () +enable_testing() # does the application run -add_test (TutorialRuns Tutorial 25) +add_test(NAME Runs COMMAND Tutorial 25) # does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" ) -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} PROPERTIES PASS_REGULAR_EXPRESSION ${result} ) -endmacro () +endfunction(do_test) # do a bunch of result based tests -do_test (4 "4 is 2") -do_test (9 "9 is 3") -do_test (5 "5 is 2.236") -do_test (7 "7 is 2.645") -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") - -# build a CPack driven installer package -include (InstallRequiredSystemLibraries) -set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") -set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") -set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") -include (CPack) +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt index 70a35f662..2946075f1 100644 --- a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt @@ -1,24 +1,14 @@ -# first we add the executable that generates the table -add_executable(MakeTable MakeTable.cxx) - -# add the command to generate the source code -add_custom_command ( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h - DEPENDS MakeTable - COMMAND MakeTable - ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h - ) - -set_source_files_properties ( - mysqrt.cxx PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h - ) +add_library(MathFunctions mysqrt.cxx) -# add the binary tree directory to the search path for include files -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the +# TutorialConfig.h include is an implementation detail -# add the main library -add_library(MathFunctions mysqrt.cxx) +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${Tutorial_BINARY_DIR} + ) -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx index cebd50fcc..ee585568c 100644 --- a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx +++ b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx @@ -1,32 +1,25 @@ // A simple program that builds a sqrt table -#include <math.h> -#include <stdio.h> +#include <cmath> +#include <fstream> +#include <iostream> int main(int argc, char* argv[]) { - int i; - double result; - // make sure we have enough arguments if (argc < 2) { return 1; } - // open the output file - FILE* fout = fopen(argv[1], "w"); - if (!fout) { - return 1; + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); } - - // create a source file with a table of square roots - fprintf(fout, "double sqrtTable[] = {\n"); - for (i = 0; i < 10; ++i) { - result = sqrt(static_cast<double>(i)); - fprintf(fout, "%g,\n", result); - } - - // close the table with a zero - fprintf(fout, "0};\n"); - fclose(fout); - return 0; + return fileOpen ? 0 : 1; // return 0 if wrote the file } diff --git a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx index 458ed63a1..b9ad20a84 100644 --- a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx @@ -1,11 +1,8 @@ #include "MathFunctions.h" #include "TutorialConfig.h" -#include <stdio.h> +#include <iostream> -// include the generated table -#include "Table.h" - -#include <math.h> +#include <cmath> // a hack square root calculation using simple operations double mysqrt(double x) @@ -14,27 +11,23 @@ double mysqrt(double x) return 0; } - double result; - // if we have both log and exp then use them - double delta; - - // use the table to help find an initial value - result = x; - if (x >= 1 && x < 10) { - result = sqrtTable[static_cast<int>(x)]; - } +#if defined(HAVE_LOG) && defined(HAVE_EXP) + double result = exp(log(x) * 0.5); + std::cout << "Computing sqrt of " << x << " to be " << result << " using log" + << std::endl; +#else + double result = x; // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } - +#endif return result; } diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx index 2fae364d4..1d5742d2d 100644 --- a/Tests/Tutorial/Step6/tutorial.cxx +++ b/Tests/Tutorial/Step6/tutorial.cxx @@ -1,33 +1,32 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH -#include "MathFunctions.h" +# include "MathFunctions.h" #endif int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Tutorial/Step7/CMakeLists.txt b/Tests/Tutorial/Step7/CMakeLists.txt index d9a92fbef..f2d3839b7 100644 --- a/Tests/Tutorial/Step7/CMakeLists.txt +++ b/Tests/Tutorial/Step7/CMakeLists.txt @@ -1,82 +1,76 @@ -cmake_minimum_required (VERSION 2.6) -project (Tutorial) +cmake_minimum_required(VERSION 3.3) +project(Tutorial) -# The version number. -set (Tutorial_VERSION_MAJOR 1) -set (Tutorial_VERSION_MINOR 0) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# the version number. +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) # does this system provide the log and exp functions? -include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -check_function_exists (log HAVE_LOG) -check_function_exists (exp HAVE_EXP) +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass some of the CMake settings # to the source code -configure_file ( +configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) -# add the binary tree to the search path for include files -# so that we will find TutorialConfig.h -include_directories ("${PROJECT_BINARY_DIR}") - # add the MathFunctions library? -if (USE_MYMATH) - include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") - add_subdirectory (MathFunctions) - set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) -endif () +if(USE_MYMATH) + add_subdirectory(MathFunctions) + list(APPEND EXTRA_LIBS MathFunctions) +endif(USE_MYMATH) # add the executable -add_executable (Tutorial tutorial.cxx) -target_link_libraries (Tutorial ${EXTRA_LIBS}) +add_executable(Tutorial tutorial.cxx) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +target_include_directories(Tutorial PUBLIC + "${PROJECT_BINARY_DIR}" + ) # add the install targets -install (TARGETS Tutorial DESTINATION bin) -install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include) +install(TARGETS Tutorial DESTINATION bin) +install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include + ) # enable testing -enable_testing () +enable_testing() # does the application run -add_test (TutorialRuns Tutorial 25) +add_test(NAME Runs COMMAND Tutorial 25) # does the usage message work? -add_test (TutorialUsage Tutorial) -set_tests_properties (TutorialUsage - PROPERTIES - PASS_REGULAR_EXPRESSION "Usage:.*number" +add_test(NAME Usage COMMAND Tutorial) +set_tests_properties(Usage + PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number" ) -#define a macro to simplify adding tests -macro (do_test arg result) - add_test (TutorialComp${arg} Tutorial ${arg}) - set_tests_properties (TutorialComp${arg} +# define a function to simplify adding tests +function(do_test target arg result) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + set_tests_properties(Comp${arg} PROPERTIES PASS_REGULAR_EXPRESSION ${result} ) -endmacro () +endfunction(do_test) # do a bunch of result based tests -do_test (4 "4 is 2") -do_test (9 "9 is 3") -do_test (5 "5 is 2.236") -do_test (7 "7 is 2.645") -do_test (25 "25 is 5") -do_test (-25 "-25 is 0") -do_test (0.0001 "0.0001 is 0.01") - -# build a CPack driven installer package -include (InstallRequiredSystemLibraries) -set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") -set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") -set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") -set (CPACK_PACKAGE_CONTACT "foo@bar.org") -include (CPack) - -# enable dashboard scripting -include (CTest) +do_test(Tutorial 4 "4 is 2") +do_test(Tutorial 9 "9 is 3") +do_test(Tutorial 5 "5 is 2.236") +do_test(Tutorial 7 "7 is 2.645") +do_test(Tutorial 25 "25 is 5") +do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Tests/Tutorial/Step7/License.txt b/Tests/Tutorial/Step7/License.txt index 673d72453..c62d00b9e 100644 --- a/Tests/Tutorial/Step7/License.txt +++ b/Tests/Tutorial/Step7/License.txt @@ -1,2 +1,2 @@ This is the open source License.txt file introduced in -CMake/Tests/Tutorial/Step6... +CMake/Tutorial/Step7... diff --git a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt index 70a35f662..dc3eb9822 100644 --- a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt @@ -2,23 +2,28 @@ add_executable(MakeTable MakeTable.cxx) # add the command to generate the source code -add_custom_command ( +add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h DEPENDS MakeTable - COMMAND MakeTable - ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) -set_source_files_properties ( - mysqrt.cxx PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h - ) - -# add the binary tree directory to the search path for include files -include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) - # add the main library -add_library(MathFunctions mysqrt.cxx) +add_library(MathFunctions + mysqrt.cxx + ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +# state that anybody linking to us needs to include the current source dir +# to find MathFunctions.h, while we don't. +# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the +# TutorialConfig.h include is an implementation detail +# state that we depend on our binary dir to find Table.h +target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${Tutorial_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) -install (TARGETS MathFunctions DESTINATION bin) -install (FILES MathFunctions.h DESTINATION include) +install(TARGETS MathFunctions DESTINATION lib) +install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx index cebd50fcc..ee585568c 100644 --- a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx +++ b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx @@ -1,32 +1,25 @@ // A simple program that builds a sqrt table -#include <math.h> -#include <stdio.h> +#include <cmath> +#include <fstream> +#include <iostream> int main(int argc, char* argv[]) { - int i; - double result; - // make sure we have enough arguments if (argc < 2) { return 1; } - // open the output file - FILE* fout = fopen(argv[1], "w"); - if (!fout) { - return 1; + std::ofstream fout(argv[1], std::ios_base::out); + const bool fileOpen = fout.is_open(); + if (fileOpen) { + fout << "double sqrtTable[] = {" << std::endl; + for (int i = 0; i < 10; ++i) { + fout << sqrt(static_cast<double>(i)) << "," << std::endl; + } + // close the table with a zero + fout << "0};" << std::endl; + fout.close(); } - - // create a source file with a table of square roots - fprintf(fout, "double sqrtTable[] = {\n"); - for (i = 0; i < 10; ++i) { - result = sqrt(static_cast<double>(i)); - fprintf(fout, "%g,\n", result); - } - - // close the table with a zero - fprintf(fout, "0};\n"); - fclose(fout); - return 0; + return fileOpen ? 0 : 1; // return 0 if wrote the file } diff --git a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx index 458ed63a1..5272f56f2 100644 --- a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx +++ b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx @@ -1,11 +1,11 @@ #include "MathFunctions.h" #include "TutorialConfig.h" -#include <stdio.h> +#include <iostream> // include the generated table #include "Table.h" -#include <math.h> +#include <cmath> // a hack square root calculation using simple operations double mysqrt(double x) @@ -14,26 +14,20 @@ double mysqrt(double x) return 0; } - double result; - - // if we have both log and exp then use them - double delta; - // use the table to help find an initial value - result = x; + double result = x; if (x >= 1 && x < 10) { result = sqrtTable[static_cast<int>(x)]; } // do ten iterations - int i; - for (i = 0; i < 10; ++i) { + for (int i = 0; i < 10; ++i) { if (result <= 0) { result = 0.1; } - delta = x - (result * result); + double delta = x - (result * result); result = result + 0.5 * delta / result; - fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result); + std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } return result; diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx index 2fae364d4..1d5742d2d 100644 --- a/Tests/Tutorial/Step7/tutorial.cxx +++ b/Tests/Tutorial/Step7/tutorial.cxx @@ -1,33 +1,32 @@ // A simple program that computes the square root of a number +#include <cmath> +#include <iostream> +#include <string> + #include "TutorialConfig.h" -#include <math.h> -#include <stdio.h> -#include <stdlib.h> #ifdef USE_MYMATH -#include "MathFunctions.h" +# include "MathFunctions.h" #endif int main(int argc, char* argv[]) { if (argc < 2) { - fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR, - Tutorial_VERSION_MINOR); - fprintf(stdout, "Usage: %s number\n", argv[0]); + std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "." + << Tutorial_VERSION_MAJOR << std::endl; + std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; } - double inputValue = atof(argv[1]); - double outputValue = 0; + double inputValue = std::stod(argv[1]); - if (inputValue >= 0) { #ifdef USE_MYMATH - outputValue = mysqrt(inputValue); + double outputValue = mysqrt(inputValue); #else - outputValue = sqrt(inputValue); + double outputValue = sqrt(inputValue); #endif - } - fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue); + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; return 0; } diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt index 07aa68e7a..a40367bbe 100644 --- a/Tests/Unset/CMakeLists.txt +++ b/Tests/Unset/CMakeLists.txt @@ -21,17 +21,26 @@ set(x 43) if(NOT x EQUAL 43) message(FATAL_ERROR "x!=43") endif() +if(DEFINED CACHE{x}) + message(FATAL_ERROR "x shouldn't be found in the cache") +endif() + set(x) if(DEFINED x) message(FATAL_ERROR "x should be undefined now!") endif() + # Cache variable set(BAR "test" CACHE STRING "documentation") if(NOT DEFINED BAR) message(FATAL_ERROR "BAR not defined") endif() +if(NOT DEFINED CACHE{BAR}) + message(FATAL_ERROR "BAR could not be found by CACHE{BAR}") +endif() + # Test interaction of cache entries with variables. set(BAR "test-var") if(NOT "$CACHE{BAR}" STREQUAL "test") diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt index 7465243bd..8ca725249 100644 --- a/Tests/VSExternalInclude/CMakeLists.txt +++ b/Tests/VSExternalInclude/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.6) project(VSExternalInclude) -if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01245]") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012456]") set(PROJECT_EXT vcxproj) else() set(PROJECT_EXT vcproj) @@ -55,7 +55,7 @@ add_dependencies(VSExternalInclude lib2) # and the sln file can no longer be the only source # of that depend. So, for VS 10 make the executable # depend on lib1 and lib2 -if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01245]") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012456]") add_dependencies(VSExternalInclude lib1) endif() diff --git a/Tests/VSGNUFortran/CMakeLists.txt b/Tests/VSGNUFortran/CMakeLists.txt index 229c3156c..993d0d65f 100644 --- a/Tests/VSGNUFortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(VSGNUFortran) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") @@ -9,7 +9,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") # because gmake build of fortran will not be in a config # directory, and for easier testing we want the exe and .dll # to be in the same directory. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) foreach(config ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER "${config}" config) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} diff --git a/Tests/VSGNUFortran/runtest.cmake.in b/Tests/VSGNUFortran/runtest.cmake.in index 987207bc4..fc05715d3 100644 --- a/Tests/VSGNUFortran/runtest.cmake.in +++ b/Tests/VSGNUFortran/runtest.cmake.in @@ -14,7 +14,7 @@ file(TO_NATIVE_PATH "${MINGW_PATH}" MINGW_PATH) string(REPLACE "\\" "\\\\" MINGW_PATH "${MINGW_PATH}") message("${MINGW_PATH}") set(test_exe "@VSGNUFortran_BINARY_DIR@/bin/c_using_fortran.exe") -set(ENV{PATH} "${MINGW_PATH}";$ENV{PATH}) +set(ENV{PATH} "${MINGW_PATH};$ENV{PATH}") message("run ${test_exe}") execute_process(COMMAND "${test_exe}" RESULT_VARIABLE res) diff --git a/Tests/VSNASM/CMakeLists.txt b/Tests/VSNASM/CMakeLists.txt index c2e29df25..821d0227e 100644 --- a/Tests/VSNASM/CMakeLists.txt +++ b/Tests/VSNASM/CMakeLists.txt @@ -1,10 +1,20 @@ cmake_minimum_required(VERSION 2.8.12) project(VSNASM C ASM_NASM) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) add_definitions(-DTESTx64) string(APPEND CMAKE_ASM_NASM_FLAGS " -DTEST2x64") else() add_definitions(-DTESTi386) endif() + +# Test quoting for definitions with spaces. +add_definitions("-DEAX_COMMA_SPACE_ZERO=eax, 0") + +# Test quoting for file names with spaces. The file is generated because CMake +# itself cannot have files with spaces. +file(READ bar.asm BAR_ASM_CONTENTS) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm" "${BAR_ASM_CONTENTS}") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -add_executable(VSNASM main.c foo.asm) +add_executable(VSNASM main.c foo.asm "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm") diff --git a/Tests/VSNASM/include/foo-proc.asm b/Tests/VSNASM/include/foo-proc.asm index 450a7919b..eb5bb2b06 100644 --- a/Tests/VSNASM/include/foo-proc.asm +++ b/Tests/VSNASM/include/foo-proc.asm @@ -3,5 +3,5 @@ foo: %else _foo: %endif - mov eax, 0 + mov EAX_COMMA_SPACE_ZERO ret diff --git a/Tests/VSNASM/main.c b/Tests/VSNASM/main.c index 18ddb7826..b1401b698 100644 --- a/Tests/VSNASM/main.c +++ b/Tests/VSNASM/main.c @@ -1,5 +1,6 @@ extern int foo(void); +extern int bar(void); int main(void) { - return foo(); + return foo() + bar(); } diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt index 718e62441..fb47c7e13 100644 --- a/Tests/VSResource/CMakeLists.txt +++ b/Tests/VSResource/CMakeLists.txt @@ -56,3 +56,10 @@ endif() set_property(TARGET VSResource PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val") + +if(CMAKE_GENERATOR MATCHES "Ninja|Visual Studio") + cmake_policy(PUSH) + cmake_policy(SET CMP0037 OLD) + add_library("My ResourceLib" lib.cpp lib.rc) + cmake_policy(POP) +endif() diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index 2b0c47806..efc77601d 100644 --- a/Tests/VSWinStorePhone/CMakeLists.txt +++ b/Tests/VSWinStorePhone/CMakeLists.txt @@ -8,6 +8,8 @@ elseif(MSVC_VERSION GREATER 1600) set(COMPILER_VERSION "11") endif() +add_subdirectory(WinRT) + set (APP_MANIFEST_NAME Package.appxmanifest) if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsPhone") set(PLATFORM WP) @@ -116,12 +118,14 @@ set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) -set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"") +set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED") +set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h") set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) -set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"") +set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED") +set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h") source_group("Source Files" FILES ${SOURCE_FILES}) @@ -137,11 +141,14 @@ if("${SHORT_VERSION}" STREQUAL "10.0") message(STATUS "Targeting Windows 10. Setting Extensions to version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") set_property(TARGET ${EXE_NAME} PROPERTY VS_DESKTOP_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") set_property(TARGET ${EXE_NAME} PROPERTY VS_MOBILE_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") - set_property(TARGET ${EXE_NAME} PROPERTY VS_IOT_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") + + # The last IOT reference is on 10.0.17134.0, so only add it if supported + if("${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" VERSION_LESS "10.0.17135.0") + set_property(TARGET ${EXE_NAME} PROPERTY VS_IOT_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") + endif() # Add a reference to an SDK set_property(TARGET ${EXE_NAME} PROPERTY VS_SDK_REFERENCES "Microsoft.UniversalCRT.Debug, Version=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") endif() - -target_link_libraries(${EXE_NAME} d3d11) +target_link_libraries(${EXE_NAME} d3d11 JusticeLeagueWinRT) diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png Binary files differindex 7d95d4e08..c715e1bc7 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png Binary files differindex e26771cb3..65f91ac0f 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png Binary files differindex 1eb0d9d52..460c0222d 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png Binary files differindex 28810b7c0..c2374581a 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png Binary files differindex c951e031b..834256580 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png Binary files differindex dcb672712..508c8a809 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png Binary files differindex e0c59ac01..fcdbaf4ac 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png Binary files differindex e93b89d60..06425c4b1 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png Binary files differindex 550b1b5e8..4cef0eb30 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png Binary files differindex 686e6b53f..253503f04 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png Binary files differindex d4b5ede1b..2ef050fb3 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png +++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png diff --git a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp index 1c969cd2f..3ba35fa43 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp +++ b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp @@ -6,11 +6,15 @@ using namespace DirectX; using namespace Microsoft::WRL; using namespace Windows::Foundation; using namespace Windows::UI::Core; +using namespace JusticeLeagueWinRT; CubeRenderer::CubeRenderer() : m_loadingComplete(false) , m_indexCount(0) { + // Create a new WinRT object to validate that we can link properly + Batman ^ hero = ref new Batman(); + hero->savePeople(); } void CubeRenderer::CreateDeviceResources() diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp index 8f3452c06..0662fbe64 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp +++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp @@ -101,12 +101,12 @@ void Direct3DBase::CreateWindowSizeDependentResources() #if WINVER > 0x0602 m_orientation = DisplayInformation::GetForCurrentView()->CurrentOrientation; #else -#if PHONE +# if PHONE // WP8 doesn't support rotations so always make it landscape m_orientation = DisplayOrientations::Landscape; -#else +# else m_orientation = DisplayProperties::CurrentOrientation; -#endif +# endif #endif bool swapDimensions = m_orientation == DisplayOrientations::Portrait || m_orientation == DisplayOrientations::PortraitFlipped; diff --git a/Tests/VSXaml/Assets/Logo.scale-100.png b/Tests/VSXaml/Assets/Logo.scale-100.png Binary files differindex e26771cb3..65f91ac0f 100644 --- a/Tests/VSXaml/Assets/Logo.scale-100.png +++ b/Tests/VSXaml/Assets/Logo.scale-100.png diff --git a/Tests/VSXaml/Assets/SmallLogo.scale-100.png b/Tests/VSXaml/Assets/SmallLogo.scale-100.png Binary files differindex 1eb0d9d52..460c0222d 100644 --- a/Tests/VSXaml/Assets/SmallLogo.scale-100.png +++ b/Tests/VSXaml/Assets/SmallLogo.scale-100.png diff --git a/Tests/VSXaml/Assets/SplashScreen.scale-100.png b/Tests/VSXaml/Assets/SplashScreen.scale-100.png Binary files differindex c951e031b..834256580 100644 --- a/Tests/VSXaml/Assets/SplashScreen.scale-100.png +++ b/Tests/VSXaml/Assets/SplashScreen.scale-100.png diff --git a/Tests/VSXaml/Assets/StoreLogo.scale-100.png b/Tests/VSXaml/Assets/StoreLogo.scale-100.png Binary files differindex dcb672712..508c8a809 100644 --- a/Tests/VSXaml/Assets/StoreLogo.scale-100.png +++ b/Tests/VSXaml/Assets/StoreLogo.scale-100.png diff --git a/Tests/WarnUnusedCliUnused/CMakeLists.txt b/Tests/WarnUnusedCliUnused/CMakeLists.txt index 7ed69bf3c..a149f043f 100644 --- a/Tests/WarnUnusedCliUnused/CMakeLists.txt +++ b/Tests/WarnUnusedCliUnused/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.14) project(WarnUnusedCliUnused) -set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/CMakeCache.txt" -) +# Remove UNUSED_CLI_VARIABLE from the cache to trigger the +# CMake warning message on re-builds as well. +unset(UNUSED_CLI_VARIABLE CACHE) add_library(dummy empty.cpp) diff --git a/Tests/Wrapping/fakefluid.cxx b/Tests/Wrapping/fakefluid.cxx index a118bbd43..f5fb3fb25 100644 --- a/Tests/Wrapping/fakefluid.cxx +++ b/Tests/Wrapping/fakefluid.cxx @@ -6,9 +6,10 @@ int main(int ac, char** av) if (strcmp(av[i], "-o") == 0 || strcmp(av[i], "-h") == 0) { fprintf(stdout, "fakefluid is creating file \"%s\"\n", av[i + 1]); FILE* file = fopen(av[i + 1], "w"); - fprintf(file, "// Solaris needs non-empty content so ensure\n" - "// we have at least one symbol\n" - "int Solaris_requires_a_symbol_here = 0;\n"); + fprintf(file, + "// Solaris needs non-empty content so ensure\n" + "// we have at least one symbol\n" + "int Solaris_requires_a_symbol_here = 0;\n"); fclose(file); } } diff --git a/Tests/Wrapping/qtwrappingmain.cxx b/Tests/Wrapping/qtwrappingmain.cxx index 37234d900..d4951eef2 100644 --- a/Tests/Wrapping/qtwrappingmain.cxx +++ b/Tests/Wrapping/qtwrappingmain.cxx @@ -2,8 +2,8 @@ #include <qapplication.h> #ifndef _WIN32 -#include <stdio.h> -#include <stdlib.h> +# include <stdio.h> +# include <stdlib.h> #endif int main(int argc, char* argv[]) diff --git a/Tests/X11/HelloWorldX11.cxx b/Tests/X11/HelloWorldX11.cxx index 0863f7bb7..e59248b49 100644 --- a/Tests/X11/HelloWorldX11.cxx +++ b/Tests/X11/HelloWorldX11.cxx @@ -11,15 +11,15 @@ */ #ifndef MAIN_H -#define MAIN_H 1 +# define MAIN_H 1 -#include <iostream> -#include <stdlib.h> +# include <iostream> +# include <stdlib.h> /* include the X library headers */ -#include <X11/Xlib.h> -#include <X11/Xos.h> -#include <X11/Xutil.h> +# include <X11/Xlib.h> +# include <X11/Xos.h> +# include <X11/Xutil.h> class Main { diff --git a/Tests/X11/X11.c b/Tests/X11/X11.c index b802ed8b9..3a6f9f0b3 100644 --- a/Tests/X11/X11.c +++ b/Tests/X11/X11.c @@ -1,8 +1,8 @@ #include "stdio.h" #ifdef CMAKE_HAS_X -#include <X11/Xlib.h> -#include <X11/Xutil.h> +# include <X11/Xlib.h> +# include <X11/Xutil.h> int main() { diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt index d40c40e2a..d0b07ea1c 100644 --- a/Tests/XCTest/CMakeLists.txt +++ b/Tests/XCTest/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(XCTest) +project(XCTest C) enable_testing() find_package(XCTest REQUIRED) diff --git a/Tests/bootstrap.bat.in b/Tests/bootstrap.bat.in index aeb24b1ca..85e79ef00 100644 --- a/Tests/bootstrap.bat.in +++ b/Tests/bootstrap.bat.in @@ -1,2 +1,2 @@ -@echo off -sh "@CMake_SOURCE_DIR@/bootstrap" %* +@echo off
+sh "@CMake_SOURCE_DIR@/bootstrap" %*
|