diff options
Diffstat (limited to 'Tests')
49 files changed, 253 insertions, 38 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6428235..cc2931b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3477,6 +3477,8 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH --build-two-config ${build_generator_args} --build-project IncludeDirectories + --build-options + -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES} --test-command IncludeDirectories) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories") diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index f517e64..785f41d 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -85,6 +85,9 @@ set(result ken bill andy brad) list(SORT result) TEST("SORT result" "andy;bill;brad;ken") +list(SORT result COMPARE NATURAL) +TEST("SORT result COMPARE NATURAL" "andy;bill;brad;ken") + set(result andy bill brad ken) list(REVERSE result) TEST("REVERSE result" "ken;brad;bill;andy") @@ -104,6 +107,26 @@ TEST("REVERSE empty result" "") list(SORT result) TEST("SORT empty result" "") +list(SORT result COMPARE NATURAL) +TEST("SORT result COMPARE NATURAL" "") + +set(result 1.1 10.0 11.0 12.0 12.1 2.0 2.1 3.0 3.1 3.2 8.0 9.0) + +list(SORT result COMPARE NATURAL) +TEST("SORT result COMPARE NATURAL" "1.1;2.0;2.1;3.0;3.1;3.2;8.0;9.0;10.0;11.0;12.0;12.1") + +list(SORT result) +TEST("SORT result" "1.1;10.0;11.0;12.0;12.1;2.0;2.1;3.0;3.1;3.2;8.0;9.0") + +list(SORT result COMPARE NATURAL ORDER DESCENDING) +TEST("SORT result COMPARE NATURAL ORDER DESCENDING" "12.1;12.0;11.0;10.0;9.0;8.0;3.2;3.1;3.0;2.1;2.0;1.1") + +set(result b-1.1 a-10.0 c-2.0 d 1 00 0) + +list(SORT result COMPARE NATURAL) +TEST("SORT result COMPARE NATURAL" "00;0;1;a-10.0;b-1.1;c-2.0;d") + + # these trigger top-level condition foreach(cmd IN ITEMS Append Find Get Insert Length Reverse Remove_At Remove_Duplicates Remove_Item Sort) set(${cmd}-No-Arguments-RESULT 1) diff --git a/Tests/CPackNSISGenerator/CMakeLists.txt b/Tests/CPackNSISGenerator/CMakeLists.txt index b8b2ed6..8ed4d59 100644 --- a/Tests/CPackNSISGenerator/CMakeLists.txt +++ b/Tests/CPackNSISGenerator/CMakeLists.txt @@ -16,5 +16,6 @@ set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}\\\\install.ico") set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}\\\\uninstall.ico") set(CPACK_GENERATOR "NSIS") set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) +set(CPACK_NSIS_MANIFEST_DPI_AWARE ON) include(CPack) diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake index 01b37c5..bfbcf9c 100644 --- a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake @@ -44,3 +44,11 @@ message(STATUS "Found the bitmap at index ${output_index}") if("${output_index}" EQUAL "-1") message(FATAL_ERROR "MUI_HEADERIMAGE_BITMAP not found in the project") endif() + +file(STRINGS "${project_file}" line REGEX "^ManifestDPIAware true") +string(FIND "${line}" "true" output_index) +if("${output_index}" EQUAL "-1") + message(FATAL_ERROR "ManifestDPIAware true not found in the project") +else() + message(STATUS "Found DPI-aware") +endif() diff --git a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt index 1941c49..f4ad83a 100644 --- a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt +++ b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.7) project(CXXStandardSetTwice CXX CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") - set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(CXXStandardSetTwice main.cu) target_compile_features(CXXStandardSetTwice PUBLIC cxx_std_11) diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt index 08d1e16..265bd85 100644 --- a/Tests/Cuda/Complex/CMakeLists.txt +++ b/Tests/Cuda/Complex/CMakeLists.txt @@ -15,7 +15,7 @@ project (Complex CXX CUDA) #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") +set(CMAKE_CUDA_ARCHITECTURES 30) set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD_REQUIRED TRUE) diff --git a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt index b03e51e..e40ffa6 100644 --- a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt @@ -1,10 +1,9 @@ cmake_minimum_required(VERSION 3.7) project(MixedStandardLevels1 CXX CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") - set(CMAKE_CXX_STANDARD 14) set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels1 main.cu lib.cpp) diff --git a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt index 12dd328..7af8081 100644 --- a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.7) project(MixedStandardLevels2 CXX CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") - set(CMAKE_CXX_STANDARD 17) #this can decay +set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels2 main.cu lib.cpp) target_compile_features(MixedStandardLevels2 PUBLIC cuda_std_11) diff --git a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt index 2b611be..2c42003 100644 --- a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.7) project(MixedStandardLevels3 CXX CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels3 main.cu lib.cpp) target_compile_features(MixedStandardLevels3 PUBLIC cuda_std_03 cxx_std_14) diff --git a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt index faf6869..230230d 100644 --- a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.7) project(MixedStandardLevels4 CXX CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") - set(CMAKE_CUDA_STANDARD 03) +set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels4 main.cu lib.cpp) target_compile_features(MixedStandardLevels4 PUBLIC cxx_std_14) diff --git a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt index 7209f60..5f5ee06 100644 --- a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.7) project(MixedStandardLevels5 CXX CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") - set(CMAKE_CXX_STANDARD 98) +set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(MixedStandardLevels5 main.cu lib.cpp) diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt index cb47b09..fe28c3e 100644 --- a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt +++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.13) project(ProperDeviceLibraries CXX CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35") set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_ARCHITECTURES 35) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads) diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt index 69aa3f9..049cbce 100644 --- a/Tests/Cuda/WithC/CMakeLists.txt +++ b/Tests/Cuda/WithC/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.7) project(WithC CUDA C) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +set(CMAKE_CUDA_ARCHITECTURES 30) add_executable(CudaWithC main.c cuda.cu) diff --git a/Tests/CudaOnly/Architecture/CMakeLists.txt b/Tests/CudaOnly/Architecture/CMakeLists.txt new file mode 100644 index 0000000..7270b56 --- /dev/null +++ b/Tests/CudaOnly/Architecture/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.17) +project(Architecture CUDA) + +set(CMAKE_CUDA_ARCHITECTURES 52) +add_executable(Architecture main.cu) diff --git a/Tests/CudaOnly/Architecture/main.cu b/Tests/CudaOnly/Architecture/main.cu new file mode 100644 index 0000000..8c817d5 --- /dev/null +++ b/Tests/CudaOnly/Architecture/main.cu @@ -0,0 +1,9 @@ +#ifdef __CUDA_ARCH__ +# if __CUDA_ARCH__ != 520 +# error "Passed architecture 52, but got something else." +# endif +#endif + +int main() +{ +} diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index cc1ee1a..d74e810 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -1,5 +1,7 @@ +ADD_TEST_MACRO(CudaOnly.Architecture Architecture) ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) +ADD_TEST_MACRO(CudaOnly.CompileFlags CudaOnlyCompileFlags) ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt index 5e6f7ab..e10a348 100644 --- a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt +++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt @@ -5,9 +5,9 @@ project (CircularLinkLine CUDA) # Verify that we de-duplicate the device link line # Verify that a de-duplicated link line still works with circular static libraries -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_ARCHITECTURES 30) add_library(CUDACircularDeviceLinking1 STATIC file1.cu) add_library(CUDACircularDeviceLinking2 STATIC file2.cu) diff --git a/Tests/CudaOnly/CompileFlags/CMakeLists.txt b/Tests/CudaOnly/CompileFlags/CMakeLists.txt new file mode 100644 index 0000000..cbce7d6 --- /dev/null +++ b/Tests/CudaOnly/CompileFlags/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.17) +cmake_policy(SET CMP0104 OLD) +project(CompileFlags CUDA) + +# Clear defaults. +set(CMAKE_CUDA_ARCHITECTURES) + +add_executable(CudaOnlyCompileFlags main.cu) + +# Try passing CUDA architecture flags explicitly. +if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + target_compile_options(CudaOnlyCompileFlags PRIVATE + -gencode arch=compute_50,code=compute_50 + --compiler-options=-DHOST_DEFINE + ) +endif() diff --git a/Tests/CudaOnly/CompileFlags/main.cu b/Tests/CudaOnly/CompileFlags/main.cu new file mode 100644 index 0000000..573d230 --- /dev/null +++ b/Tests/CudaOnly/CompileFlags/main.cu @@ -0,0 +1,16 @@ +#ifdef __CUDA_ARCH__ +# if __CUDA_ARCH__ != 500 +# error "Passed architecture 50, but got something else." +# endif +#endif + +// Check HOST_DEFINE only for nvcc +#ifndef __CUDA__ +# ifndef HOST_DEFINE +# error "HOST_DEFINE not defined!" +# endif +#endif + +int main() +{ +} diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt index 6e3697f..1265660 100644 --- a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt @@ -24,9 +24,9 @@ endif() # Don't resolve the device symbols in the static library # Don't resolve the device symbols in the executable library # Verify that we can't use those device symbols from anything -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) +set(CMAKE_CUDA_ARCHITECTURES 30 50) set(CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS OFF) add_library(CUDANoDeviceResolve SHARED file1.cu) diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index 57aa0b9..bd94ec8 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -21,7 +21,7 @@ endif() # confirming that the first static library is on the device link line # 3. Verify that we can't use those device symbols from anything that links # to the static library -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[sm_30] -gencode arch=compute_50,code=\\\"compute_50\\\"") +set(CMAKE_CUDA_ARCHITECTURES 30 50) add_library(CUDAResolveDeviceDepsA STATIC file1.cu) add_library(CUDAResolveDeviceDepsB STATIC file2.cu) diff --git a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt index 8b58fec..0da5739 100644 --- a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt +++ b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt @@ -15,9 +15,8 @@ else() endif() endif() -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]") - set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_ARCHITECTURES 30) set(CMAKE_CUDA_RUNTIME_LIBRARY static) if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index c1bd64a..586be81 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -9,9 +9,7 @@ project (SeparateCompilation 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,sm_30,sm_35\\\"") -string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]") - +set(CMAKE_CUDA_ARCHITECTURES 30 35 50 52) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu) target_compile_features(CUDASeparateLibA PRIVATE cuda_std_11) diff --git a/Tests/CudaOnly/Standard98/CMakeLists.txt b/Tests/CudaOnly/Standard98/CMakeLists.txt index ef9a685..3ba0360 100644 --- a/Tests/CudaOnly/Standard98/CMakeLists.txt +++ b/Tests/CudaOnly/Standard98/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.7) project(CudaOnlyStandard98 CUDA) -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") +set(CMAKE_CUDA_ARCHITECTURES 30) # Support setting CUDA Standard to 98 which internally gets transformed to # CUDA03 diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index ba9bf04..add8131 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -3,17 +3,7 @@ cmake_minimum_required(VERSION 3.7) project (WithDefs CUDA) #verify that we can pass explicit cuda arch flags -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") -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() - list(APPEND debug_compile_flags -Xcompiler=-Werror) -endif() +set(CMAKE_CUDA_ARCHITECTURES 30) set(release_compile_defs DEFREL) #Goal for this example: @@ -29,7 +19,6 @@ target_compile_options(CudaOnlyWithDefs -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE> -DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> --compiler-options=-DHOST_DEFINE - $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>> ) target_compile_definitions(CudaOnlyWithDefs diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index fa3309f..eb08676 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -65,6 +65,39 @@ else() PROPERTIES COMPILE_FLAGS "-ITarProp") endif() +# Test escaping of special characters in include directory paths. +set(special_chars "~@%&{}()!'") +if(NOT CMAKE_GENERATOR STREQUAL "Watcom WMake") + # Watcom seems to have no way to encode these characters. + string(APPEND special_chars "#=[]") +endif() +if(NOT (MINGW AND CMAKE_GENERATOR MATCHES "(Unix|MSYS) Makefiles")) + # FIXME: Dependencies work but command-line generation does not handle '$'. + string(APPEND special_chars "$") +endif() +if(NOT CMAKE_GENERATOR MATCHES "(Borland|NMake) Makefiles") + # NMake and Borland seem to have no way to encode a single '^'. + string(APPEND special_chars "^") +endif() +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 9 2008|Watcom WMake") + # The vcproj format separates values with ','. + string(APPEND special_chars ",") +endif() +if(NOT WIN32 AND NOT CYGWIN) + string(APPEND special_chars "*?<>") +endif() +set(special_dir "${CMAKE_CURRENT_BINARY_DIR}/special-${special_chars}-include") +file(WRITE "${special_dir}/SpecialDir.h" "#define SPECIAL_DIR_H\n") +target_include_directories(IncludeDirectories PRIVATE "${special_dir}") +target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_DIR) + +if(MAKE_SUPPORTS_SPACES) + set(special_space_dir "${CMAKE_CURRENT_BINARY_DIR}/special-space ${special_chars}-include") + file(WRITE "${special_space_dir}/SpecialSpaceDir.h" "#define SPECIAL_SPACE_DIR_H\n") + target_include_directories(IncludeDirectories PRIVATE "${special_space_dir}") + target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_SPACE_DIR) +endif() + add_library(ordertest ordertest.cpp) target_include_directories(ordertest SYSTEM PUBLIC SystemIncludeDirectories/systemlib) target_include_directories(ordertest PUBLIC SystemIncludeDirectories/userlib) diff --git a/Tests/IncludeDirectories/main.cpp b/Tests/IncludeDirectories/main.cpp index a59d27c..6dc88e2 100644 --- a/Tests/IncludeDirectories/main.cpp +++ b/Tests/IncludeDirectories/main.cpp @@ -3,6 +3,20 @@ #include "SrcProp.h" #include "TarProp.h" +#ifdef INCLUDE_SPECIAL_DIR +# include "SpecialDir.h" +# ifndef SPECIAL_DIR_H +# error "SPECIAL_DIR_H not defined" +# endif +#endif + +#ifdef INCLUDE_SPECIAL_SPACE_DIR +# include "SpecialSpaceDir.h" +# ifndef SPECIAL_SPACE_DIR_H +# error "SPECIAL_SPACE_DIR_H not defined" +# endif +#endif + int main(int argc, char** argv) { return 0; diff --git a/Tests/RunCMake/CMP0104/CMP0104-Common.cmake b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake new file mode 100644 index 0000000..b3568f1 --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake @@ -0,0 +1,2 @@ +enable_language(CUDA) +add_library(cuda main.cu) diff --git a/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake b/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake new file mode 100644 index 0000000..732ab77 --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0104 NEW) +include(CMP0104-Common.cmake) + +if(NOT CMAKE_CUDA_ARCHITECTURES) + message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES is empty with CMP0104 enabled.") +endif() diff --git a/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake b/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake new file mode 100644 index 0000000..415eecc --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake @@ -0,0 +1,12 @@ +cmake_policy(SET CMP0104 OLD) +include(CMP0104-Common.cmake) + +if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + if(CMAKE_CUDA_ARCHITECTURES) + message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES isn't empty for NVIDIA with CMP0104 OLD.") + endif() +else(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Unknown") + if(NOT CMAKE_CUDA_ARCHITECTURES) + message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES isn't non-empty for non-NVIDIA with CMP0104 OLD.") + endif() +endif() diff --git a/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt b/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt new file mode 100644 index 0000000..2c9b7d7 --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt @@ -0,0 +1,8 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC, + empty CUDA_ARCHITECTURES not allowed. Run "cmake --help-policy CMP0104" + for policy details. Use the cmake_policy command to set the policy and + suppress this warning. + + CUDA_ARCHITECTURES is empty for target "cuda". +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake new file mode 100644 index 0000000..841d0a8 --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake @@ -0,0 +1 @@ +include(CMP0104-Common.cmake) diff --git a/Tests/RunCMake/CMP0104/CMakeLists.txt b/Tests/RunCMake/CMP0104/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0104/RunCMakeTest.cmake b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake new file mode 100644 index 0000000..bc8e1b1 --- /dev/null +++ b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0104-OLD) +run_cmake(CMP0104-NEW) +run_cmake(CMP0104-WARN) diff --git a/Tests/RunCMake/CMP0104/main.cu b/Tests/RunCMake/CMP0104/main.cu new file mode 100644 index 0000000..5047a34 --- /dev/null +++ b/Tests/RunCMake/CMP0104/main.cu @@ -0,0 +1,3 @@ +int main() +{ +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 2a4af3e..34e1fbc 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -116,6 +116,9 @@ endif() add_RunCMake_test(CMP0069) add_RunCMake_test(CMP0081) add_RunCMake_test(CMP0102) +if(CMake_TEST_CUDA) + add_RunCMake_test(CMP0104) +endif() # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake index 6f7fc86..ca25b2a 100644 --- a/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake +++ b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake @@ -1,3 +1,4 @@ +cmake_policy(SET CMP0104 NEW) enable_language(CUDA) set(CMAKE_VERBOSE_MAKEFILE TRUE) add_executable(main main.cu) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt new file mode 100644 index 0000000..eeecb6a --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt @@ -0,0 +1,10 @@ +Test project .* + Start 20: skip_test.test1 +1/1 Test #20: skip_test.test1 \.+\*\*\*Skipped +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 1 + +Total Test time \(real\) = +[0-9.]+ sec + +The following tests did not run: +.*20 - skip_test\.test1 \(Skipped\) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake index 4bc6b9d..fca292a 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake @@ -49,3 +49,9 @@ gtest_discover_tests( DISCOVERY_TIMEOUT 20 PROPERTIES TIMEOUT 2 ) + +add_executable(skip_test skip_test.cpp) + +gtest_discover_tests( + skip_test +) diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index 6b9d458..efd22be 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -60,6 +60,20 @@ function(run_GoogleTest DISCOVERY_MODE) -R property_timeout\\.case_with_discovery --no-label-summary ) + + run_cmake_command(GoogleTest-build + ${CMAKE_COMMAND} + --build . + --config Debug + --target skip_test + ) + + run_cmake_command(GoogleTest-skip-test + ${CMAKE_CTEST_COMMAND} + -C Debug + -R skip_test + --no-label-summary + ) endfunction() function(run_GoogleTestXML DISCOVERY_MODE) diff --git a/Tests/RunCMake/GoogleTest/skip_test.cpp b/Tests/RunCMake/GoogleTest/skip_test.cpp new file mode 100644 index 0000000..2bc9fe1 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/skip_test.cpp @@ -0,0 +1,18 @@ +#include <iostream> +#include <string> + +int main(int argc, char** argv) +{ + // Note: GoogleTest.cmake doesn't actually depend on Google Test as such; + // it only requires that we produces output in the expected format when + // invoked with --gtest_list_tests. Thus, we fake that here. This allows us + // to test the module without actually needing Google Test. + if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") { + std::cout << "skip_test." << std::endl; + std::cout << " test1" << std::endl; + return 0; + } + + std::cout << "[ SKIPPED ] skip_test.test1" << std::endl; + return 0; +} diff --git a/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake index 2e9b1cb..00d8a1b 100644 --- a/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake @@ -1,3 +1,4 @@ +cmake_policy(SET CMP0104 NEW) enable_language(CUDA) file(TOUCH ${CMAKE_BINARY_DIR}/empty.cmake) diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 9a1e027..7ffd522 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -29,6 +29,7 @@ \* CMP0083 \* CMP0095 \* CMP0099 + \* CMP0104 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/exit_code.c b/Tests/RunCMake/exit_code.c index 3eba019..9fa8eca 100644 --- a/Tests/RunCMake/exit_code.c +++ b/Tests/RunCMake/exit_code.c @@ -21,7 +21,8 @@ int main(int argc, const char* argv[]) } if (strcmp(str, substring_success) == 0) { return EXIT_SUCCESS; - } else if (strcmp(str, substring_failure) == 0) { + } + if (strcmp(str, substring_failure) == 0) { return EXIT_FAILURE; } fprintf(stderr, "Failed to find string '%s' in '%s'\n", substring_success, diff --git a/Tests/RunCMake/find_program/ExeNoRead-stdout.txt b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt new file mode 100644 index 0000000..35a83f2 --- /dev/null +++ b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt @@ -0,0 +1 @@ +-- ExeNoRead_EXECUTABLE='.*/Tests/RunCMake/find_program/ExeNoRead-build/ExeNoRead' diff --git a/Tests/RunCMake/find_program/ExeNoRead.cmake b/Tests/RunCMake/find_program/ExeNoRead.cmake new file mode 100644 index 0000000..7e22dc5 --- /dev/null +++ b/Tests/RunCMake/find_program/ExeNoRead.cmake @@ -0,0 +1,4 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead" "#!/bin/sh\n") +execute_process(COMMAND chmod -r+x "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead") +find_program(ExeNoRead_EXECUTABLE NAMES ExeNoRead NO_DEFAULT_PATH PATHS "${CMAKE_CURRENT_BINARY_DIR}") +message(STATUS "ExeNoRead_EXECUTABLE='${ExeNoRead_EXECUTABLE}'") diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 0ff9a97..95ffd84 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -10,3 +10,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$") run_cmake(WindowsCom) run_cmake(WindowsExe) endif() + +if(UNIX) + run_cmake(ExeNoRead) +endif() diff --git a/Tests/RunCMake/pseudo_cppcheck.c b/Tests/RunCMake/pseudo_cppcheck.c index 5b1531b..e80620c 100644 --- a/Tests/RunCMake/pseudo_cppcheck.c +++ b/Tests/RunCMake/pseudo_cppcheck.c @@ -11,7 +11,8 @@ int main(int argc, char* argv[]) fprintf(stdout, "stdout from bad command line arg '-bad'\n"); fprintf(stderr, "stderr from bad command line arg '-bad'\n"); return 1; - } else if (strcmp(argv[i], "-error") == 0) { + } + if (strcmp(argv[i], "-error") == 0) { // The real cppcheck allows to set the exitcode with --error-exitcode result = 5; } diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 9ec9b70..df921d8 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -187,7 +187,7 @@ try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE 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\\)]]) +elseif(NOT output MATCHES [[(bad#source\.c|bad\.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() |