diff options
Diffstat (limited to 'Tests')
60 files changed, 334 insertions, 32 deletions
diff --git a/Tests/ISPC/CMakeLists.txt b/Tests/ISPC/CMakeLists.txt index 2c3651d..c993275 100644 --- a/Tests/ISPC/CMakeLists.txt +++ b/Tests/ISPC/CMakeLists.txt @@ -7,6 +7,7 @@ macro (add_ispc_test_macro name) endmacro () add_ispc_test_macro(ISPC.ChainedStaticLibraries ISPCChainedStaticLibraries) +add_ispc_test_macro(ISPC.CustomHeaderSuffix ISPCCustomHeaderSuffix) add_ispc_test_macro(ISPC.Defines ISPCDefines) add_ispc_test_macro(ISPC.DynamicLibrary ISPCDynamicLibrary) add_ispc_test_macro(ISPC.ObjectGenex ISPCObjectGenex) diff --git a/Tests/ISPC/ChainedStaticLibraries/extra.cxx b/Tests/ISPC/ChainedStaticLibraries/extra.cxx index 88ef3a7..9f50df4 100644 --- a/Tests/ISPC/ChainedStaticLibraries/extra.cxx +++ b/Tests/ISPC/ChainedStaticLibraries/extra.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "extra.ispc.h" +#include "extra_ispc.h" int extra() { diff --git a/Tests/ISPC/ChainedStaticLibraries/main.cxx b/Tests/ISPC/ChainedStaticLibraries/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/ChainedStaticLibraries/main.cxx +++ b/Tests/ISPC/ChainedStaticLibraries/main.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt new file mode 100644 index 0000000..d20f88e --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/CMakeLists.txt @@ -0,0 +1,23 @@ + +cmake_minimum_required(VERSION 3.18) +project(ISPCCustomHeaderSuffix CXX ISPC) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ISPC_FLAGS "--arch=x86") +endif() + +set(CMAKE_ISPC_INSTRUCTION_SETS "sse2-i32x4;sse4-i8x16") + +set(CMAKE_ISPC_HEADER_SUFFIX ".ispc.h") + +add_library(ispc_suffix_1 OBJECT simple.ispc) +add_library(ispc_suffix_2 OBJECT extra.ispc) + +set_target_properties(ispc_suffix_2 PROPERTIES ISPC_HEADER_SUFFIX "___ispc.h") + +set_target_properties(ispc_suffix_1 ispc_suffix_2 + PROPERTIES POSITION_INDEPENDENT_CODE ON +) + +add_executable(ISPCCustomHeaderSuffix main.cxx extra.cxx) +target_link_libraries(ISPCCustomHeaderSuffix PRIVATE ispc_suffix_1 ispc_suffix_2) diff --git a/Tests/ISPC/CustomHeaderSuffix/extra.cxx b/Tests/ISPC/CustomHeaderSuffix/extra.cxx new file mode 100644 index 0000000..0354e2d --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/extra.cxx @@ -0,0 +1,17 @@ +#include <stdio.h> + +#include "extra___ispc.h" + +int extra() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::extra(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} diff --git a/Tests/ISPC/CustomHeaderSuffix/extra.ispc b/Tests/ISPC/CustomHeaderSuffix/extra.ispc new file mode 100644 index 0000000..5a4a442 --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/extra.ispc @@ -0,0 +1,12 @@ + +export void extra(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/CustomHeaderSuffix/main.cxx b/Tests/ISPC/CustomHeaderSuffix/main.cxx new file mode 100644 index 0000000..4f1c9be --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/main.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +int main() +{ + float vin[16], vout[16]; + for (int i = 0; i < 16; ++i) + vin[i] = i; + + ispc::simple(vin, vout, 16); + + for (int i = 0; i < 16; ++i) + printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +} diff --git a/Tests/ISPC/CustomHeaderSuffix/simple.ispc b/Tests/ISPC/CustomHeaderSuffix/simple.ispc new file mode 100644 index 0000000..70cb588 --- /dev/null +++ b/Tests/ISPC/CustomHeaderSuffix/simple.ispc @@ -0,0 +1,12 @@ + +export void simple(uniform float vin[], uniform float vout[], + uniform int count) { + foreach (index = 0 ... count) { + float v = vin[index]; + if (v < 3.) + v = v * v; + else + v = sqrt(v); + vout[index] = v; + } +} diff --git a/Tests/ISPC/Defines/main.cxx b/Tests/ISPC/Defines/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/Defines/main.cxx +++ b/Tests/ISPC/Defines/main.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/DynamicLibrary/extra.cxx b/Tests/ISPC/DynamicLibrary/extra.cxx index b3623d1..a3d89ed 100644 --- a/Tests/ISPC/DynamicLibrary/extra.cxx +++ b/Tests/ISPC/DynamicLibrary/extra.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "extra.ispc.h" +#include "extra_ispc.h" #ifdef _WIN32 # define EXPORT __declspec(dllexport) diff --git a/Tests/ISPC/DynamicLibrary/simple.cxx b/Tests/ISPC/DynamicLibrary/simple.cxx index cb5a779..bc78bda 100644 --- a/Tests/ISPC/DynamicLibrary/simple.cxx +++ b/Tests/ISPC/DynamicLibrary/simple.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "simple.ispc.h" +#include "simple_ispc.h" #ifdef _WIN32 # define EXPORT __declspec(dllexport) diff --git a/Tests/ISPC/ObjectLibrary/extra.cxx b/Tests/ISPC/ObjectLibrary/extra.cxx index 88ef3a7..9f50df4 100644 --- a/Tests/ISPC/ObjectLibrary/extra.cxx +++ b/Tests/ISPC/ObjectLibrary/extra.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "extra.ispc.h" +#include "extra_ispc.h" int extra() { diff --git a/Tests/ISPC/ObjectLibrary/main.cxx b/Tests/ISPC/ObjectLibrary/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/ObjectLibrary/main.cxx +++ b/Tests/ISPC/ObjectLibrary/main.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/ResponseAndDefine/main.cxx b/Tests/ISPC/ResponseAndDefine/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/ResponseAndDefine/main.cxx +++ b/Tests/ISPC/ResponseAndDefine/main.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/StaticLibrary/main.cxx b/Tests/ISPC/StaticLibrary/main.cxx index 4f1c9be..a6b91a6 100644 --- a/Tests/ISPC/StaticLibrary/main.cxx +++ b/Tests/ISPC/StaticLibrary/main.cxx @@ -1,6 +1,6 @@ #include <stdio.h> -#include "simple.ispc.h" +#include "simple_ispc.h" int main() { diff --git a/Tests/ISPC/SystemIncludes/CMakeLists.txt b/Tests/ISPC/SystemIncludes/CMakeLists.txt index 95959b2..d94e75e 100644 --- a/Tests/ISPC/SystemIncludes/CMakeLists.txt +++ b/Tests/ISPC/SystemIncludes/CMakeLists.txt @@ -4,8 +4,10 @@ project(ispc_spaces_in_path ISPC CXX) add_executable(ISPCSystemIncludes main.cxx simple.ispc) set_target_properties(ISPCSystemIncludes PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(ISPCSystemIncludes PROPERTIES ISPC_HEADER_SUFFIX ".ispc.h") target_include_directories(ISPCSystemIncludes SYSTEM PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + target_compile_options(ISPCSystemIncludes PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>") if(CMAKE_SIZEOF_VOID_P EQUAL 4) target_compile_options(ISPCSystemIncludes PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--arch=x86>") diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c0e4bce..540a718 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -288,6 +288,7 @@ add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) add_RunCMake_test(CompileFeatures) +add_RunCMake_test(Policy) add_RunCMake_test(PolicyScope) add_RunCMake_test(WriteBasicConfigVersionFile) add_RunCMake_test(WriteCompilerDetectionHeader) diff --git a/Tests/RunCMake/File_Configure/AtOnly.cmake b/Tests/RunCMake/File_Configure/AtOnly.cmake new file mode 100644 index 0000000..cc5304a --- /dev/null +++ b/Tests/RunCMake/File_Configure/AtOnly.cmake @@ -0,0 +1,12 @@ +set(file_name ${CMAKE_CURRENT_BINARY_DIR}/atonly.txt) +set(var_a "a") +set(var_b "b") +file(CONFIGURE + OUTPUT ${file_name} + CONTENT "-->@var_a@<-- -->${var_b}<--" + @ONLY +) +file(READ ${file_name} file_content) +if(NOT file_content STREQUAL "-->a<-- -->${var_b}<--") + message(FATAL_ERROR "@ONLY doesn't work") +endif() diff --git a/Tests/RunCMake/File_Configure/BadArg-stderr.txt b/Tests/RunCMake/File_Configure/BadArg-stderr.txt deleted file mode 100644 index 5423a28..0000000 --- a/Tests/RunCMake/File_Configure/BadArg-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error at BadArg.cmake:[0-9]+ \(file\): - file Incorrect arguments to CONFIGURE subcommand. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArgContent-result.txt b/Tests/RunCMake/File_Configure/BadArgContent-result.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgContent-result.txt diff --git a/Tests/RunCMake/File_Configure/BadArgContent-stderr.txt b/Tests/RunCMake/File_Configure/BadArgContent-stderr.txt new file mode 100644 index 0000000..a6ea314 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgContent-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadArgContent.cmake:[0-9]+ \(file\): + file CONFIGURE CONTENT option needs a value. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArgContent.cmake b/Tests/RunCMake/File_Configure/BadArgContent.cmake new file mode 100644 index 0000000..282dc18 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgContent.cmake @@ -0,0 +1 @@ +file(CONFIGURE CONTENT) diff --git a/Tests/RunCMake/File_Configure/BadArg-result.txt b/Tests/RunCMake/File_Configure/BadArgOutput-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/File_Configure/BadArg-result.txt +++ b/Tests/RunCMake/File_Configure/BadArgOutput-result.txt diff --git a/Tests/RunCMake/File_Configure/BadArgOutput-stderr.txt b/Tests/RunCMake/File_Configure/BadArgOutput-stderr.txt new file mode 100644 index 0000000..b5a924c --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgOutput-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadArgOutput.cmake:[0-9]+ \(file\): + file CONFIGURE OUTPUT option needs a value. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArg.cmake b/Tests/RunCMake/File_Configure/BadArgOutput.cmake index 7c7fcda..7c7fcda 100644 --- a/Tests/RunCMake/File_Configure/BadArg.cmake +++ b/Tests/RunCMake/File_Configure/BadArgOutput.cmake diff --git a/Tests/RunCMake/File_Configure/EscapeQuotes.cmake b/Tests/RunCMake/File_Configure/EscapeQuotes.cmake new file mode 100644 index 0000000..1136c87 --- /dev/null +++ b/Tests/RunCMake/File_Configure/EscapeQuotes.cmake @@ -0,0 +1,12 @@ +set(file_name ${CMAKE_CURRENT_BINARY_DIR}/escape_quotes.txt) +set(var "\t") +set(ref "${var}") +file(CONFIGURE + CONTENT "-->@ref@<--" + OUTPUT ${file_name} + ESCAPE_QUOTES +) +file(READ ${file_name} file_content) +if(NOT file_content MATCHES "^-->\t<--$") + message(FATAL_ERROR "ESCAPE_QUOTES doesn't work") +endif() diff --git a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake index e79de79..5022985 100644 --- a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake @@ -1,10 +1,14 @@ include(RunCMake) run_cmake(AngleBracketsContent) -run_cmake(BadArg) +run_cmake(BadArgOutput) +run_cmake(BadArgContent) run_cmake(BadArgGeneratorExpressionOutput) +run_cmake(UnrecognizedArgs) run_cmake(DirOutput) run_cmake(NewLineStyle-NoArg) run_cmake(NewLineStyle-ValidArg) run_cmake(NewLineStyle-WrongArg) run_cmake(SubDir) +run_cmake(AtOnly) +run_cmake(EscapeQuotes) diff --git a/Tests/RunCMake/File_Configure/UnrecognizedArgs-result.txt b/Tests/RunCMake/File_Configure/UnrecognizedArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Configure/UnrecognizedArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Configure/UnrecognizedArgs-stderr.txt b/Tests/RunCMake/File_Configure/UnrecognizedArgs-stderr.txt new file mode 100644 index 0000000..1dd1a20 --- /dev/null +++ b/Tests/RunCMake/File_Configure/UnrecognizedArgs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at UnrecognizedArgs.cmake:[0-9]+ \(file\): + file CONFIGURE Unrecognized argument: "INPUT" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/File_Configure/UnrecognizedArgs.cmake b/Tests/RunCMake/File_Configure/UnrecognizedArgs.cmake new file mode 100644 index 0000000..93ea7b5 --- /dev/null +++ b/Tests/RunCMake/File_Configure/UnrecognizedArgs.cmake @@ -0,0 +1 @@ +file(CONFIGURE INPUT) diff --git a/Tests/RunCMake/Policy/CMakeLists.txt b/Tests/RunCMake/Policy/CMakeLists.txt new file mode 100644 index 0000000..667561e --- /dev/null +++ b/Tests/RunCMake/Policy/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/Policy/InvalidMaxVersion-result.txt b/Tests/RunCMake/Policy/InvalidMaxVersion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidMaxVersion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Policy/InvalidMaxVersion-stderr.txt b/Tests/RunCMake/Policy/InvalidMaxVersion-stderr.txt new file mode 100644 index 0000000..25d22f5 --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidMaxVersion-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at InvalidMaxVersion.cmake:[0-9]+ \(cmake_policy\): + Invalid policy max version value "[A-Za-z0-9]+.[A-Za-z0-9]*.[A-Za-z0-9]*.[A-Za-z0-9]*"\. A numeric + major.minor\[\.patch\[\.tweak\]\] must be given\. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/InvalidMaxVersion.cmake b/Tests/RunCMake/Policy/InvalidMaxVersion.cmake new file mode 100644 index 0000000..be3270f --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidMaxVersion.cmake @@ -0,0 +1,5 @@ +if(NOT version) + message(SEND_ERROR "Vesrion string is empty: ${version}") +endif() + +cmake_policy(VERSION 3.1...${version}) diff --git a/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-result.txt b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-result.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-result.txt diff --git a/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-stderr.txt b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-stderr.txt new file mode 100644 index 0000000..a48feb3 --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at InvalidRangeMaxVersionNotGiven.cmake:[0-9]+ \(cmake_policy\): + cmake_policy VERSION "3.15..." does not have a version on both sides of + "...". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven.cmake b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven.cmake new file mode 100644 index 0000000..e55803c --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven.cmake @@ -0,0 +1 @@ +cmake_policy(VERSION 3.15...) diff --git a/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-result.txt b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-stderr.txt b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-stderr.txt new file mode 100644 index 0000000..84e9b88 --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at InvalidRangeMinVersionNotGiven.cmake:[0-9]+ \(cmake_policy\): + cmake_policy VERSION "...3.15" does not have a version on both sides of + "...". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven.cmake b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven.cmake new file mode 100644 index 0000000..60e7e25 --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven.cmake @@ -0,0 +1 @@ +cmake_policy(VERSION ...3.15) diff --git a/Tests/RunCMake/Policy/InvalidVersion-result.txt b/Tests/RunCMake/Policy/InvalidVersion-result.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidVersion-result.txt diff --git a/Tests/RunCMake/Policy/InvalidVersion-stderr.txt b/Tests/RunCMake/Policy/InvalidVersion-stderr.txt new file mode 100644 index 0000000..783f4ed --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidVersion-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at InvalidVersion.cmake:[0-9]+ \(cmake_policy\): + Invalid policy version value "[A-Za-z0-9]+.[A-Za-z0-9]*.[A-Za-z0-9]*.[A-Za-z0-9]*"\. A numeric + major\.minor\[\.patch\[\.tweak\]\] must be given\. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/InvalidVersion.cmake b/Tests/RunCMake/Policy/InvalidVersion.cmake new file mode 100644 index 0000000..b135ba6 --- /dev/null +++ b/Tests/RunCMake/Policy/InvalidVersion.cmake @@ -0,0 +1,5 @@ +if(NOT version) + message(SEND_ERROR "Vesrion string is empty: ${version}") +endif() + +cmake_policy(VERSION ${version}) diff --git a/Tests/RunCMake/Policy/MinVersionLargerThanMax-result.txt b/Tests/RunCMake/Policy/MinVersionLargerThanMax-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Policy/MinVersionLargerThanMax-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Policy/MinVersionLargerThanMax-stderr.txt b/Tests/RunCMake/Policy/MinVersionLargerThanMax-stderr.txt new file mode 100644 index 0000000..0b0308f --- /dev/null +++ b/Tests/RunCMake/Policy/MinVersionLargerThanMax-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at MinVersionLargerThanMax.cmake:[0-9]+ \(cmake_policy\): + Policy VERSION range "3.12...3.8" specifies a larger minimum than maximum. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/MinVersionLargerThanMax.cmake b/Tests/RunCMake/Policy/MinVersionLargerThanMax.cmake new file mode 100644 index 0000000..67d5f85 --- /dev/null +++ b/Tests/RunCMake/Policy/MinVersionLargerThanMax.cmake @@ -0,0 +1 @@ +cmake_policy(VERSION 3.12...3.8) diff --git a/Tests/RunCMake/Policy/RunCMakeTest.cmake b/Tests/RunCMake/Policy/RunCMakeTest.cmake new file mode 100644 index 0000000..74c7d63 --- /dev/null +++ b/Tests/RunCMake/Policy/RunCMakeTest.cmake @@ -0,0 +1,19 @@ +include(RunCMake) + +run_cmake(VersionNotGiven) +run_cmake(TooManyVersionsGiven) +run_cmake(InvalidRangeMinVersionNotGiven) +run_cmake(InvalidRangeMaxVersionNotGiven) + +set(RunCMake_TEST_OPTIONS "-Dversion=three") +run_cmake(InvalidVersion) +run_cmake(InvalidMaxVersion) +unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS "-Dversion=3.one") +run_cmake(InvalidVersion) +run_cmake(InvalidMaxVersion) +unset(RunCMake_TEST_OPTIONS) + +run_cmake(VersionLowerThan2_4) +run_cmake(MinVersionLargerThanMax) +run_cmake(VeryHighVersion) diff --git a/Tests/RunCMake/Policy/TooManyVersionsGiven-result.txt b/Tests/RunCMake/Policy/TooManyVersionsGiven-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Policy/TooManyVersionsGiven-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Policy/TooManyVersionsGiven-stderr.txt b/Tests/RunCMake/Policy/TooManyVersionsGiven-stderr.txt new file mode 100644 index 0000000..7a4f8c7 --- /dev/null +++ b/Tests/RunCMake/Policy/TooManyVersionsGiven-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TooManyVersionsGiven.cmake:[0-9]+ \(cmake_policy\): + cmake_policy VERSION given too many arguments +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/TooManyVersionsGiven.cmake b/Tests/RunCMake/Policy/TooManyVersionsGiven.cmake new file mode 100644 index 0000000..6c99af2 --- /dev/null +++ b/Tests/RunCMake/Policy/TooManyVersionsGiven.cmake @@ -0,0 +1 @@ +cmake_policy(VERSION 1 2 3) diff --git a/Tests/RunCMake/Policy/VersionLowerThan2_4-result.txt b/Tests/RunCMake/Policy/VersionLowerThan2_4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Policy/VersionLowerThan2_4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Policy/VersionLowerThan2_4-stderr.txt b/Tests/RunCMake/Policy/VersionLowerThan2_4-stderr.txt new file mode 100644 index 0000000..3f19192 --- /dev/null +++ b/Tests/RunCMake/Policy/VersionLowerThan2_4-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at VersionLowerThan2_4.cmake:[0-9]+ \(cmake_policy\): + Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. For + compatibility with older versions please use any CMake 2.8.x release or + lower. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/VersionLowerThan2_4.cmake b/Tests/RunCMake/Policy/VersionLowerThan2_4.cmake new file mode 100644 index 0000000..f1a4fd9 --- /dev/null +++ b/Tests/RunCMake/Policy/VersionLowerThan2_4.cmake @@ -0,0 +1 @@ +cmake_policy(VERSION 2.2) diff --git a/Tests/RunCMake/Policy/VersionNotGiven-result.txt b/Tests/RunCMake/Policy/VersionNotGiven-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Policy/VersionNotGiven-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Policy/VersionNotGiven-stderr.txt b/Tests/RunCMake/Policy/VersionNotGiven-stderr.txt new file mode 100644 index 0000000..8eeb177 --- /dev/null +++ b/Tests/RunCMake/Policy/VersionNotGiven-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VersionNotGiven.cmake:[0-9]+ \(cmake_policy\): + cmake_policy VERSION not given an argument +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/VersionNotGiven.cmake b/Tests/RunCMake/Policy/VersionNotGiven.cmake new file mode 100644 index 0000000..53b3d7f --- /dev/null +++ b/Tests/RunCMake/Policy/VersionNotGiven.cmake @@ -0,0 +1 @@ +cmake_policy(VERSION) diff --git a/Tests/RunCMake/Policy/VeryHighVersion-result.txt b/Tests/RunCMake/Policy/VeryHighVersion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Policy/VeryHighVersion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Policy/VeryHighVersion-stderr.txt b/Tests/RunCMake/Policy/VeryHighVersion-stderr.txt new file mode 100644 index 0000000..7cca91b --- /dev/null +++ b/Tests/RunCMake/Policy/VeryHighVersion-stderr.txt @@ -0,0 +1,7 @@ +CMake Error at VeryHighVersion.cmake:[0-9]+ \(cmake_policy\): + An attempt was made to set the policy version of CMake to "99.1" which is + greater than this version of CMake. This is not allowed because the + greater version may have new policies not known to this CMake. You may + need a newer CMake version to build this project. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Policy/VeryHighVersion.cmake b/Tests/RunCMake/Policy/VeryHighVersion.cmake new file mode 100644 index 0000000..3d4af8c --- /dev/null +++ b/Tests/RunCMake/Policy/VeryHighVersion.cmake @@ -0,0 +1 @@ +cmake_policy(VERSION 99.1) diff --git a/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake b/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake index 4253652..c32c92d 100644 --- a/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake +++ b/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake @@ -3,16 +3,16 @@ set(CMAKE_SIZEOF_VOID_P 4) include(WriteBasicConfigVersionFile) -set(_compatibilities AnyNewerVersion - SameMajorVersion - SameMinorVersion - ExactVersion) +set(COMPATIBILITIES AnyNewerVersion + SameMajorVersion + SameMinorVersion + ExactVersion) function(TEST_WRITE_BASIC_CONFIG_VERSION_FILE_PREPARE _version_installed) set(_same_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) set(_no_CMAKE_SIZEOF_VOID_P "") math(EXPR _diff_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P} + 1") - foreach(_compat ${_compatibilities}) + foreach(_compat ${COMPATIBILITIES}) set(_pkg ${_compat}${_version_installed}) string(REPLACE "." "" _pkg ${_pkg}) set(_filename "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}ConfigVersion.cmake") @@ -71,20 +71,58 @@ function(TEST_WRITE_BASIC_CONFIG_VERSION_FILE _version_installed _expected_compatible_SameMajorVersion _expected_compatible_SameMinorVersion _expected_compatible_ExactVersion) - set(PACKAGE_FIND_VERSION ${_version_requested}) - if("${PACKAGE_FIND_VERSION}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) - set(PACKAGE_FIND_VERSION_MAJOR "${CMAKE_MATCH_2}") - set(PACKAGE_FIND_VERSION_MINOR "${CMAKE_MATCH_4}") - set(PACKAGE_FIND_VERSION_PATCH "${CMAKE_MATCH_6}") - set(PACKAGE_FIND_VERSION_TWEAK "${CMAKE_MATCH_8}") - else() - message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version number") - endif() - - if ("${_version_installed}" STREQUAL "${_version_requested}") - set(_expected_exact 1) - else() + if("${_version_requested}" MATCHES [[^([0-9]+(\.[0-9]+)*)\.\.\.(<)?([0-9]+(\.[0-9]+)*)$]]) + set (_compatibilities ${COMPATIBILITIES}) + # ExactVersion must not be tested + list(POP_BACK _compatibilities) + set(PACKAGE_FIND_VERSION_RANGE TRUE) + set(PACKAGE_FIND_VERSION_RANGE_MIN INCLUDE) + if ("${CMAKE_MATCH_3}" STREQUAL "<") + set(PACKAGE_FIND_VERSION_RANGE_MAX EXCLUDE) + else() + set(PACKAGE_FIND_VERSION_RANGE_MAX INCLUDE) + endif() + set(PACKAGE_FIND_VERSION_MIN "${CMAKE_MATCH_1}") + set(PACKAGE_FIND_VERSION_MAX "${CMAKE_MATCH_4}") + if("${PACKAGE_FIND_VERSION_MIN}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) + set(PACKAGE_FIND_VERSION_MIN_MAJOR "${CMAKE_MATCH_2}") + set(PACKAGE_FIND_VERSION_MIN_MINOR "${CMAKE_MATCH_4}") + set(PACKAGE_FIND_VERSION_MIN_PATCH "${CMAKE_MATCH_6}") + set(PACKAGE_FIND_VERSION_MIN_TWEAK "${CMAKE_MATCH_8}") + else() + message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version range") + endif() + set(PACKAGE_FIND_VERSION "${PACKAGE_FIND_VERSION_MIN}") + set(PACKAGE_FIND_VERSION_MAJOR "${PACKAGE_FIND_VERSION_MIN_MAJOR}") + set(PACKAGE_FIND_VERSION_MINOR "${PACKAGE_FIND_VERSION_MIN_MINOR}") + set(PACKAGE_FIND_VERSION_PATCH "${PACKAGE_FIND_VERSION_MIN_PATCH}") + set(PACKAGE_FIND_VERSION_TWEAK "${PACKAGE_FIND_VERSION_MIN_TWEAK}") + if("${PACKAGE_FIND_VERSION_MAX}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) + set(PACKAGE_FIND_VERSION_MAX_MAJOR "${CMAKE_MATCH_2}") + set(PACKAGE_FIND_VERSION_MAX_MINOR "${CMAKE_MATCH_4}") + set(PACKAGE_FIND_VERSION_MAX_PATCH "${CMAKE_MATCH_6}") + set(PACKAGE_FIND_VERSION_MAX_TWEAK "${CMAKE_MATCH_8}") + else() + message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version range") + endif() set(_expected_exact 0) + else() + set (_compatibilities ${COMPATIBILITIES}) + set(PACKAGE_FIND_VERSION ${_version_requested}) + if("${PACKAGE_FIND_VERSION}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]]) + set(PACKAGE_FIND_VERSION_MAJOR "${CMAKE_MATCH_2}") + set(PACKAGE_FIND_VERSION_MINOR "${CMAKE_MATCH_4}") + set(PACKAGE_FIND_VERSION_PATCH "${CMAKE_MATCH_6}") + set(PACKAGE_FIND_VERSION_TWEAK "${CMAKE_MATCH_8}") + else() + message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version number") + endif() + + if ("${_version_installed}" STREQUAL "${_version_requested}") + set(_expected_exact 1) + else() + set(_expected_exact 0) + endif() endif() unset(PACKAGE_VERSION_COMPATIBLE) @@ -882,3 +920,54 @@ test_write_basic_config_version_file(4.5.6.7 9.9.9.0 0 0 0 0) # Request [ne test_write_basic_config_version_file(4.5.6.7 9.9.9.2 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[older tweak] test_write_basic_config_version_file(4.5.6.7 9.9.9.7 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[same tweak] test_write_basic_config_version_file(4.5.6.7 9.9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[newer tweak] + +test_write_basic_config_version_file(4 0...5 1 0 0 0) +test_write_basic_config_version_file(4 2...5 1 0 0 0) +test_write_basic_config_version_file(4 2...4 1 0 0 0) +test_write_basic_config_version_file(4 4...<5 1 1 0 0) +test_write_basic_config_version_file(4 9...10 0 0 0 0) + +test_write_basic_config_version_file(4 0.1...5 1 0 0 0) +test_write_basic_config_version_file(4 2.1...5 1 0 0 0) +test_write_basic_config_version_file(4 2.8...5 1 0 0 0) +test_write_basic_config_version_file(4 2.1...4 1 0 0 0) +test_write_basic_config_version_file(4 2.8...4 1 0 0 0) +test_write_basic_config_version_file(4 4.0...<5 1 1 0 0) +test_write_basic_config_version_file(4 4.8...<5 0 0 0 0) +test_write_basic_config_version_file(4 4.1...5 0 0 0 0) +test_write_basic_config_version_file(4 4.8...5 0 0 0 0) +test_write_basic_config_version_file(4 9.1...10 0 0 0 0) +test_write_basic_config_version_file(4 9.8...10 0 0 0 0) + + +test_write_basic_config_version_file(4.5 0.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5 2.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5 2.8...5 1 0 0 0) +test_write_basic_config_version_file(4.5 2.1...4 0 0 0 0) +test_write_basic_config_version_file(4.5 2.8...4 0 0 0 0) +test_write_basic_config_version_file(4.5 2.8...4.8 1 0 0 0) +test_write_basic_config_version_file(4.5 4.1...<5 1 1 0 0) +test_write_basic_config_version_file(4.5 4.8...<5 0 0 0 0) +test_write_basic_config_version_file(4.5 4.5...4.5.8 1 1 1 0) +test_write_basic_config_version_file(4.5 4.5...<4.6 1 1 1 0) +test_write_basic_config_version_file(4.5 4.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5 4.8...5 0 0 0 0) +test_write_basic_config_version_file(4.5 9.1...10 0 0 0 0) +test_write_basic_config_version_file(4.5 9.8...10 0 0 0 0) + + +test_write_basic_config_version_file(4.5.6 0.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 2.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 2.8...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 2.1...4 0 0 0 0) +test_write_basic_config_version_file(4.5.6 2.8...4 0 0 0 0) +test_write_basic_config_version_file(4.5.6 2.8...4.8 1 0 0 0) +test_write_basic_config_version_file(4.5.6 4.1...<5 1 1 0 0) +test_write_basic_config_version_file(4.5.6 4.8...<5 0 0 0 0) +test_write_basic_config_version_file(4.5.6 4.5...4.5.4 0 0 0 0) +test_write_basic_config_version_file(4.5.6 4.5...4.5.8 1 1 1 0) +test_write_basic_config_version_file(4.5.6 4.5...<4.6 1 1 1 0) +test_write_basic_config_version_file(4.5.6 4.1...5 1 0 0 0) +test_write_basic_config_version_file(4.5.6 4.8...5 0 0 0 0) +test_write_basic_config_version_file(4.5.6 9.1...10 0 0 0 0) +test_write_basic_config_version_file(4.5.6 9.8...10 0 0 0 0) |