summaryrefslogtreecommitdiffstats
path: root/Tests/Module/CheckIPOSupported-CXX
diff options
context:
space:
mode:
authorRuslan Baratov <ruslan_baratov@yahoo.com>2017-04-13 15:05:16 (GMT)
committerBrad King <brad.king@kitware.com>2017-04-18 15:54:33 (GMT)
commiteeb58c5c34a888acbb422e66ff7895cb35c9322a (patch)
tree6cf4d10b2c4fef5ae5064af13d49a36d19956250 /Tests/Module/CheckIPOSupported-CXX
parentf79b8fad096b08f1fbe8346e1d338cca2c444ccb (diff)
downloadCMake-eeb58c5c34a888acbb422e66ff7895cb35c9322a.zip
CMake-eeb58c5c34a888acbb422e66ff7895cb35c9322a.tar.gz
CMake-eeb58c5c34a888acbb422e66ff7895cb35c9322a.tar.bz2
Tests: Add cases for typical CheckIPOSupported usage
Diffstat (limited to 'Tests/Module/CheckIPOSupported-CXX')
-rw-r--r--Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt19
-rw-r--r--Tests/Module/CheckIPOSupported-CXX/foo.cpp4
-rw-r--r--Tests/Module/CheckIPOSupported-CXX/main.cpp9
3 files changed, 32 insertions, 0 deletions
diff --git a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt
new file mode 100644
index 0000000..2dede93
--- /dev/null
+++ b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 3.8)
+project(CheckIPOSupported-CXX LANGUAGES CXX)
+
+cmake_policy(SET CMP0069 NEW)
+
+include(CheckIPOSupported)
+check_ipo_supported(RESULT ipo_supported)
+if(ipo_supported)
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
+elseif(CMake_TEST_IPO_WORKS_CXX)
+ message(FATAL_ERROR "IPO expected to work")
+endif()
+
+add_library(foo foo.cpp)
+add_executable(CheckIPOSupported-CXX main.cpp)
+target_link_libraries(CheckIPOSupported-CXX PUBLIC foo)
+
+enable_testing()
+add_test(NAME CheckIPOSupported-CXX COMMAND CheckIPOSupported-CXX)
diff --git a/Tests/Module/CheckIPOSupported-CXX/foo.cpp b/Tests/Module/CheckIPOSupported-CXX/foo.cpp
new file mode 100644
index 0000000..1e56597
--- /dev/null
+++ b/Tests/Module/CheckIPOSupported-CXX/foo.cpp
@@ -0,0 +1,4 @@
+int foo()
+{
+ return 0x42;
+}
diff --git a/Tests/Module/CheckIPOSupported-CXX/main.cpp b/Tests/Module/CheckIPOSupported-CXX/main.cpp
new file mode 100644
index 0000000..99204ab
--- /dev/null
+++ b/Tests/Module/CheckIPOSupported-CXX/main.cpp
@@ -0,0 +1,9 @@
+int foo();
+
+int main()
+{
+ if (foo() == 0) {
+ return 1;
+ }
+ return 0;
+}