Tests for 'CheckIPOSupported' module

This commit is contained in:
Ruslan Baratov
2017-03-11 19:56:00 +08:00
parent fdb2ba2521
commit 6c8326749f
22 changed files with 89 additions and 0 deletions

View File

@@ -293,6 +293,7 @@ add_RunCMake_test(target_link_libraries)
add_RunCMake_test(target_compile_features)
add_RunCMake_test(CheckModules)
add_RunCMake_test(CheckIPOSupported)
add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
add_RunCMake_test(CommandLineTar)

View File

@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.0)
project(${RunCMake_TEST} NONE)
include(CheckIPOSupported)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,9 @@
include(RunCMake)
run_cmake(unparsed-arguments)
run_cmake(user-lang-unknown)
run_cmake(user-lang-fortran)
run_cmake(default-lang-none)
run_cmake(not-supported-by-cmake)
run_cmake(not-supported-by-compiler)
run_cmake(save-to-result)

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,7 @@
^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\):
IPO is not supported \(no C/CXX/Fortran languages found in ENABLED_LANGUAGES
global property\)\.
Call Stack \(most recent call first\):
.*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\)
default-lang-none\.cmake:[0-9]+ \(check_ipo_supported\)
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@@ -0,0 +1 @@
check_ipo_supported()

View File

@@ -0,0 +1,6 @@
^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\):
IPO is not supported \(CMake doesn't support IPO for current compiler\)\.
Call Stack \(most recent call first\):
.*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\)
not-supported-by-cmake\.cmake:[0-9]+ \(check_ipo_supported\)
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@@ -0,0 +1,3 @@
project(${RunCMake_TEST} LANGUAGES C)
set(_CMAKE_IPO_SUPPORTED_BY_CMAKE NO)
check_ipo_supported()

View File

@@ -0,0 +1,6 @@
^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\):
IPO is not supported \(compiler doesn't support IPO\)\.
Call Stack \(most recent call first\):
.*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\)
not-supported-by-compiler\.cmake:[0-9]+ \(check_ipo_supported\)
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@@ -0,0 +1,4 @@
project(${RunCMake_TEST} LANGUAGES C)
set(_CMAKE_IPO_SUPPORTED_BY_CMAKE YES)
set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
check_ipo_supported()

View File

@@ -0,0 +1,22 @@
project(${RunCMake_TEST} LANGUAGES C)
check_ipo_supported(RESULT result OUTPUT output)
string(COMPARE EQUAL "${result}" "" is_empty)
if(is_empty)
message(FATAL_ERROR "Result variable is empty")
endif()
string(COMPARE EQUAL "${result}" "YES" is_yes)
string(COMPARE EQUAL "${result}" "NO" is_no)
if(is_yes)
# Compiler supports IPO
elseif(is_no)
# Compiler doesn't support IPO, output should not be empty.
string(COMPARE EQUAL "${output}" "" is_empty)
if(is_empty)
message(FATAL_ERROR "Output is empty")
endif()
else()
message(FATAL_ERROR "Unexpected result: ${result}")
endif()

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,5 @@
^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\):
Unparsed arguments: xxx
Call Stack \(most recent call first\):
unparsed-arguments\.cmake:[0-9]+ \(check_ipo_supported\)
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@@ -0,0 +1 @@
check_ipo_supported(RESULT result OUTPUT output xxx)

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,6 @@
^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\):
IPO is not supported \(Fortran is not supported\)\.
Call Stack \(most recent call first\):
.*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\)
user-lang-fortran\.cmake:[0-9]+ \(check_ipo_supported\)
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@@ -0,0 +1 @@
check_ipo_supported(LANGUAGES "Fortran")

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,6 @@
^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\):
IPO is not supported \(language\(s\) 'UnknownLanguage' not supported\)\.
Call Stack \(most recent call first\):
.*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\)
user-lang-unknown\.cmake:[0-9]+ \(check_ipo_supported\)
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@@ -0,0 +1 @@
check_ipo_supported(LANGUAGES UnknownLanguage)