cmake_policy: Implement test cases for cmake_policy VERSION

This commit is contained in:
Asit Dhal
2020-12-13 03:58:25 +01:00
parent 4621ffb028
commit 8851637e9f
30 changed files with 92 additions and 0 deletions

View File

@@ -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)

View File

@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

@@ -0,0 +1,5 @@
if(NOT version)
message(SEND_ERROR "Vesrion string is empty: ${version}")
endif()
cmake_policy(VERSION 3.1...${version})

View File

@@ -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\)

View File

@@ -0,0 +1 @@
cmake_policy(VERSION 3.15...)

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

@@ -0,0 +1 @@
cmake_policy(VERSION ...3.15)

View File

@@ -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\)

View File

@@ -0,0 +1,5 @@
if(NOT version)
message(SEND_ERROR "Vesrion string is empty: ${version}")
endif()
cmake_policy(VERSION ${version})

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

@@ -0,0 +1 @@
cmake_policy(VERSION 3.12...3.8)

View File

@@ -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)

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

@@ -0,0 +1 @@
cmake_policy(VERSION 1 2 3)

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

@@ -0,0 +1 @@
cmake_policy(VERSION 2.2)

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

@@ -0,0 +1 @@
cmake_policy(VERSION)

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)

View File

@@ -0,0 +1 @@
cmake_policy(VERSION 99.1)