summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-modules.7.rst1
-rw-r--r--Help/module/CheckIPOSupported.rst1
-rw-r--r--Help/release/dev/CheckIPOSupported.rst6
-rw-r--r--Modules/CheckIPOSupported.cmake215
-rw-r--r--Modules/CheckIPOSupported/CMakeLists-C.txt.in8
-rw-r--r--Modules/CheckIPOSupported/CMakeLists-CXX.txt.in8
-rw-r--r--Modules/CheckIPOSupported/foo.c4
-rw-r--r--Modules/CheckIPOSupported/foo.cpp4
-rw-r--r--Modules/CheckIPOSupported/main.c6
-rw-r--r--Modules/CheckIPOSupported/main.cpp6
-rw-r--r--Modules/Platform/Linux-Intel.cmake5
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake9
-rw-r--r--Tests/RunCMake/CheckIPOSupported/default-lang-none-result.txt1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt7
-rw-r--r--Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-result.txt1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt6
-rw-r--r--Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake3
-rw-r--r--Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-result.txt1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt6
-rw-r--r--Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake4
-rw-r--r--Tests/RunCMake/CheckIPOSupported/save-to-result.cmake22
-rw-r--r--Tests/RunCMake/CheckIPOSupported/unparsed-arguments-result.txt1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt5
-rw-r--r--Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt6
-rw-r--r--Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/user-lang-unknown-result.txt1
-rw-r--r--Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt6
-rw-r--r--Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake1
33 files changed, 353 insertions, 0 deletions
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 5e96d79..1e8342c 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -27,6 +27,7 @@ All Modules
/module/CheckFortranFunctionExists
/module/CheckFortranSourceCompiles
/module/CheckFunctionExists
+ /module/CheckIPOSupported
/module/CheckIncludeFileCXX
/module/CheckIncludeFile
/module/CheckIncludeFiles
diff --git a/Help/module/CheckIPOSupported.rst b/Help/module/CheckIPOSupported.rst
new file mode 100644
index 0000000..9c8a77b
--- /dev/null
+++ b/Help/module/CheckIPOSupported.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckIPOSupported.cmake
diff --git a/Help/release/dev/CheckIPOSupported.rst b/Help/release/dev/CheckIPOSupported.rst
new file mode 100644
index 0000000..dbc84e6
--- /dev/null
+++ b/Help/release/dev/CheckIPOSupported.rst
@@ -0,0 +1,6 @@
+CheckIPOSupported
+-----------------
+
+* A :module:`CheckIPOSupported` module was added to help projects
+ check whether interprocedural optimization (IPO) is supported by
+ the current toolchain and CMake version.
diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake
new file mode 100644
index 0000000..6f7bc82
--- /dev/null
+++ b/Modules/CheckIPOSupported.cmake
@@ -0,0 +1,215 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckIPOSupported
+-----------------
+
+Check whether the compiler supports an interprocedural optimization (IPO/LTO).
+Use this before enabling the :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION` target
+property.
+
+.. command:: check_ipo_supported
+
+ ::
+
+ check_ipo_supported([RESULT <result>] [OUTPUT <output>]
+ [LANGUAGES <lang>...])
+
+ Options are:
+
+ ``RESULT <result>``
+ Set ``<result>`` variable to ``YES`` if IPO is supported by the
+ compiler and ``NO`` otherwise. If this option is not given then
+ the command will issue a fatal error if IPO is not supported.
+ ``OUTPUT <output>``
+ Set ``<output>`` variable with details about any error.
+ ``LANGUAGES <lang>...``
+ Specify languages whose compilers to check.
+ Languages ``C`` and ``CXX`` are supported.
+
+Examples
+^^^^^^^^
+
+.. code-block:: cmake
+
+ check_ipo_supported() # fatal error if IPO is not supported
+ set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+
+.. code-block:: cmake
+
+ # Optional IPO. Do not use IPO if it's not supported by compiler.
+ check_ipo_supported(RESULT result OUTPUT output)
+ if(result)
+ set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+ else()
+ message(WARNING "IPO is not supported: ${output}")
+ endif()
+
+#]=======================================================================]
+
+include(CMakeParseArguments) # cmake_parse_arguments
+
+# X_RESULT - name of the final result variable
+# X_OUTPUT - name of the variable with information about error
+macro(_ipo_not_supported output)
+ string(COMPARE EQUAL "${X_RESULT}" "" is_empty)
+ if(is_empty)
+ message(FATAL_ERROR "IPO is not supported (${output}).")
+ endif()
+
+ set("${X_RESULT}" NO PARENT_SCOPE)
+ set("${X_OUTPUT}" "${output}" PARENT_SCOPE)
+endmacro()
+
+# Run IPO/LTO test
+macro(_ipo_run_language_check language)
+ set(testdir "${CMAKE_CURRENT_BINARY_DIR}/_CMakeLTOTest-${language}")
+
+ file(REMOVE_RECURSE "${testdir}")
+ file(MAKE_DIRECTORY "${testdir}")
+
+ set(bindir "${testdir}/bin")
+ set(srcdir "${testdir}/src")
+
+ file(MAKE_DIRECTORY "${bindir}")
+ file(MAKE_DIRECTORY "${srcdir}")
+
+ set(TRY_COMPILE_PROJECT_NAME "lto-test")
+
+ set(try_compile_src "${CMAKE_ROOT}/Modules/CheckIPOSupported")
+
+ # Use:
+ # * TRY_COMPILE_PROJECT_NAME
+ # * CMAKE_VERSION
+ configure_file(
+ "${try_compile_src}/CMakeLists-${language}.txt.in"
+ "${srcdir}/CMakeLists.txt"
+ @ONLY
+ )
+
+ string(COMPARE EQUAL "${language}" "C" is_c)
+ string(COMPARE EQUAL "${language}" "CXX" is_cxx)
+
+ if(is_c)
+ set(copy_sources foo.c main.c)
+ elseif(is_cxx)
+ set(copy_sources foo.cpp main.cpp)
+ else()
+ message(FATAL_ERROR "Language not supported")
+ endif()
+
+ foreach(x ${copy_sources})
+ configure_file(
+ "${try_compile_src}/${x}"
+ "${srcdir}/${x}"
+ COPYONLY
+ )
+ endforeach()
+
+ try_compile(
+ result
+ "${bindir}"
+ "${srcdir}"
+ "${TRY_COMPILE_PROJECT_NAME}"
+ CMAKE_FLAGS
+ "-DCMAKE_VERBOSE_MAKEFILE=ON"
+ "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
+ OUTPUT_VARIABLE output
+ )
+
+ if(NOT result)
+ _ipo_not_supported("${output}")
+ return()
+ endif()
+endmacro()
+
+function(check_ipo_supported)
+ # TODO: IPO policy
+
+ set(optional)
+ set(one RESULT OUTPUT)
+ set(multiple LANGUAGES)
+
+ # Introduce:
+ # * X_RESULT
+ # * X_OUTPUT
+ # * X_LANGUAGES
+ cmake_parse_arguments(X "${optional}" "${one}" "${multiple}" "${ARGV}")
+
+ string(COMPARE NOTEQUAL "${X_UNPARSED_ARGUMENTS}" "" has_unparsed)
+ if(has_unparsed)
+ message(FATAL_ERROR "Unparsed arguments: ${X_UNPARSED_ARGUMENTS}")
+ endif()
+
+ string(COMPARE EQUAL "${X_LANGUAGES}" "" no_languages)
+ if(no_languages)
+ # User did not set any languages, use defaults
+ get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+ string(COMPARE EQUAL "${enabled_languages}" "" no_languages)
+ if(no_languages)
+ _ipo_not_supported(
+ "no languages found in ENABLED_LANGUAGES global property"
+ )
+ return()
+ endif()
+
+ set(languages "")
+ list(FIND enabled_languages "CXX" result)
+ if(NOT result EQUAL -1)
+ list(APPEND languages "CXX")
+ endif()
+
+ list(FIND enabled_languages "C" result)
+ if(NOT result EQUAL -1)
+ list(APPEND languages "C")
+ endif()
+
+ list(FIND enabled_languages "Fortran" result)
+ if(NOT result EQUAL -1)
+ list(APPEND languages "Fortran")
+ endif()
+
+ string(COMPARE EQUAL "${languages}" "" no_languages)
+ if(no_languages)
+ _ipo_not_supported(
+ "no C/CXX/Fortran languages found in ENABLED_LANGUAGES global property"
+ )
+ return()
+ endif()
+ else()
+ set(languages "${X_LANGUAGES}")
+
+ set(unsupported_languages "${languages}")
+ list(REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran")
+ string(COMPARE NOTEQUAL "${unsupported_languages}" "" has_unsupported)
+ if(has_unsupported)
+ _ipo_not_supported(
+ "language(s) '${unsupported_languages}' not supported"
+ )
+ return()
+ endif()
+ endif()
+
+ list(FIND languages "Fortran" result)
+ if(NOT result EQUAL -1)
+ _ipo_not_supported("Fortran is not supported")
+ return()
+ endif()
+
+ if(NOT _CMAKE_IPO_SUPPORTED_BY_CMAKE)
+ _ipo_not_supported("CMake doesn't support IPO for current compiler")
+ return()
+ endif()
+
+ if(NOT _CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER)
+ _ipo_not_supported("compiler doesn't support IPO")
+ return()
+ endif()
+
+ foreach(x ${languages})
+ _ipo_run_language_check(${x})
+ endforeach()
+
+ set("${X_RESULT}" YES PARENT_SCOPE)
+endfunction()
diff --git a/Modules/CheckIPOSupported/CMakeLists-C.txt.in b/Modules/CheckIPOSupported/CMakeLists-C.txt.in
new file mode 100644
index 0000000..d20f31f
--- /dev/null
+++ b/Modules/CheckIPOSupported/CMakeLists-C.txt.in
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION "@CMAKE_VERSION@")
+project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES C)
+
+# TODO: IPO policy
+
+add_library(foo foo.c)
+add_executable(boo main.c)
+target_link_libraries(boo PUBLIC foo)
diff --git a/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in b/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in
new file mode 100644
index 0000000..4b55c70
--- /dev/null
+++ b/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION "@CMAKE_VERSION@")
+project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES CXX)
+
+# TODO: IPO policy
+
+add_library(foo foo.cpp)
+add_executable(boo main.cpp)
+target_link_libraries(boo PUBLIC foo)
diff --git a/Modules/CheckIPOSupported/foo.c b/Modules/CheckIPOSupported/foo.c
new file mode 100644
index 0000000..1e56597
--- /dev/null
+++ b/Modules/CheckIPOSupported/foo.c
@@ -0,0 +1,4 @@
+int foo()
+{
+ return 0x42;
+}
diff --git a/Modules/CheckIPOSupported/foo.cpp b/Modules/CheckIPOSupported/foo.cpp
new file mode 100644
index 0000000..1e56597
--- /dev/null
+++ b/Modules/CheckIPOSupported/foo.cpp
@@ -0,0 +1,4 @@
+int foo()
+{
+ return 0x42;
+}
diff --git a/Modules/CheckIPOSupported/main.c b/Modules/CheckIPOSupported/main.c
new file mode 100644
index 0000000..5be0864
--- /dev/null
+++ b/Modules/CheckIPOSupported/main.c
@@ -0,0 +1,6 @@
+int foo();
+
+int main()
+{
+ return foo();
+}
diff --git a/Modules/CheckIPOSupported/main.cpp b/Modules/CheckIPOSupported/main.cpp
new file mode 100644
index 0000000..5be0864
--- /dev/null
+++ b/Modules/CheckIPOSupported/main.cpp
@@ -0,0 +1,6 @@
+int foo();
+
+int main()
+{
+ return foo();
+}
diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake
index 85a0772..45dc36f 100644
--- a/Modules/Platform/Linux-Intel.cmake
+++ b/Modules/Platform/Linux-Intel.cmake
@@ -30,12 +30,17 @@ macro(__linux_compiler_intel lang)
# executables that use dlopen but do not set ENABLE_EXPORTS.
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
+ set(_CMAKE_IPO_SUPPORTED_BY_CMAKE YES)
+
if(XIAR)
# INTERPROCEDURAL_OPTIMIZATION
set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo)
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO
"${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> "
"${XIAR} -s <TARGET> ")
+ set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
+ else()
+ set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
endif()
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 5157b9f..217f0d5 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -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)
diff --git a/Tests/RunCMake/CheckIPOSupported/CMakeLists.txt b/Tests/RunCMake/CheckIPOSupported/CMakeLists.txt
new file mode 100644
index 0000000..a0effc9
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(CheckIPOSupported)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
new file mode 100644
index 0000000..e304c61
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/CheckIPOSupported/default-lang-none-result.txt b/Tests/RunCMake/CheckIPOSupported/default-lang-none-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/default-lang-none-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt b/Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt
new file mode 100644
index 0000000..dc2c3ad
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt
@@ -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\)$
diff --git a/Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake b/Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake
new file mode 100644
index 0000000..0a2ac69
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake
@@ -0,0 +1 @@
+check_ipo_supported()
diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-result.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt
new file mode 100644
index 0000000..f63f30f
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt
@@ -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\)$
diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake
new file mode 100644
index 0000000..6f61f7e
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake
@@ -0,0 +1,3 @@
+project(${RunCMake_TEST} LANGUAGES C)
+set(_CMAKE_IPO_SUPPORTED_BY_CMAKE NO)
+check_ipo_supported()
diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-result.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt
new file mode 100644
index 0000000..73e2f26
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt
@@ -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\)$
diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake
new file mode 100644
index 0000000..652cfd5
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake
@@ -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()
diff --git a/Tests/RunCMake/CheckIPOSupported/save-to-result.cmake b/Tests/RunCMake/CheckIPOSupported/save-to-result.cmake
new file mode 100644
index 0000000..f76db72
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/save-to-result.cmake
@@ -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()
diff --git a/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-result.txt b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt
new file mode 100644
index 0000000..a3fee53
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt
@@ -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\)$
diff --git a/Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake
new file mode 100644
index 0000000..3ee7326
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake
@@ -0,0 +1 @@
+check_ipo_supported(RESULT result OUTPUT output xxx)
diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt
new file mode 100644
index 0000000..2cb595d
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt
@@ -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\)$
diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake
new file mode 100644
index 0000000..275dbd9
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake
@@ -0,0 +1 @@
+check_ipo_supported(LANGUAGES "Fortran")
diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-result.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt
new file mode 100644
index 0000000..278ba0b
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt
@@ -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\)$
diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake
new file mode 100644
index 0000000..ac743ad
--- /dev/null
+++ b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake
@@ -0,0 +1 @@
+check_ipo_supported(LANGUAGES UnknownLanguage)