summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-12-08 09:07:04 -0500
committerCMake Topic Stage <kwrobot@kitware.com>2014-12-08 09:07:04 -0500
commit90070a65d217935b71da8b4ac361f78b608648b0 (patch)
tree37deca2bf5bc7fb51cae485acb62c4c06303bf2e /Tests
parentcfe666f1a2c13e6d8093dff87b362b5e4ed64114 (diff)
parent88eb5824da12940e78d57fe254f17f64cdacd659 (diff)
downloadcmake-90070a65d217935b71da8b4ac361f78b608648b0.tar.gz
Merge topic 'try_compile-link-flags'
88eb5824 try_compile: Pass linker flags into test project (#14066) a4f9b6f0 CMakeDetermineCompilerABI: Use normal linker flags in ABI project
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/try_compile/CMP0056-stderr.txt13
-rw-r--r--Tests/RunCMake/try_compile/CMP0056-stdout.txt4
-rw-r--r--Tests/RunCMake/try_compile/CMP0056.cmake67
-rw-r--r--Tests/RunCMake/try_compile/RunCMakeTest.cmake2
4 files changed, 86 insertions, 0 deletions
diff --git a/Tests/RunCMake/try_compile/CMP0056-stderr.txt b/Tests/RunCMake/try_compile/CMP0056-stderr.txt
new file mode 100644
index 0000000000..5c1f0e4cf9
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0056-stderr.txt
@@ -0,0 +1,13 @@
+before try_compile with CMP0056 WARN-default
+after try_compile with CMP0056 WARN-default
+*
+CMake Warning \(dev\) at CMP0056.cmake:[0-9]+ \(try_compile\):
+ Policy CMP0056 is not set: Honor link flags in try_compile\(\) source-file
+ signature. Run "cmake --help-policy CMP0056" for policy details. Use the
+ cmake_policy command to set the policy and suppress this warning.
+
+ For compatibility with older versions of CMake, try_compile is not honoring
+ caller link flags \(e.g. CMAKE_EXE_LINKER_FLAGS\) in the test project.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/try_compile/CMP0056-stdout.txt b/Tests/RunCMake/try_compile/CMP0056-stdout.txt
new file mode 100644
index 0000000000..89e7c437b0
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0056-stdout.txt
@@ -0,0 +1,4 @@
+-- try_compile with CMP0056 WARN-default worked as expected
+-- try_compile with CMP0056 WARN-enabled worked as expected
+-- try_compile with CMP0056 OLD worked as expected
+-- try_compile with CMP0056 NEW worked as expected
diff --git a/Tests/RunCMake/try_compile/CMP0056.cmake b/Tests/RunCMake/try_compile/CMP0056.cmake
new file mode 100644
index 0000000000..e8d3d4a3bd
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMP0056.cmake
@@ -0,0 +1,67 @@
+enable_language(C)
+set(obj "${CMAKE_C_OUTPUT_EXTENSION}")
+if(BORLAND)
+ set(pre -)
+endif()
+set(CMAKE_EXE_LINKER_FLAGS ${pre}BADFLAG${obj})
+
+#-----------------------------------------------------------------------------
+message("before try_compile with CMP0056 WARN-default")
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ OUTPUT_VARIABLE out
+ )
+string(REPLACE "\n" "\n " out " ${out}")
+if(NOT RESULT)
+ message(FATAL_ERROR "try_compile failed but should have passed:\n${out}")
+elseif("x${out}" MATCHES "BADFLAG")
+ message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}")
+else()
+ message(STATUS "try_compile with CMP0056 WARN-default worked as expected")
+endif()
+message("after try_compile with CMP0056 WARN-default")
+
+#-----------------------------------------------------------------------------
+set(CMAKE_POLICY_WARNING_CMP0056 ON)
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ OUTPUT_VARIABLE out
+ )
+string(REPLACE "\n" "\n " out " ${out}")
+if(NOT RESULT)
+ message(FATAL_ERROR "try_compile failed but should have passed:\n${out}")
+elseif("x${out}" MATCHES "BADFLAG")
+ message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}")
+else()
+ message(STATUS "try_compile with CMP0056 WARN-enabled worked as expected")
+endif()
+
+#-----------------------------------------------------------------------------
+cmake_policy(SET CMP0056 OLD)
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ OUTPUT_VARIABLE out
+ )
+string(REPLACE "\n" "\n " out " ${out}")
+if(NOT RESULT)
+ message(FATAL_ERROR "try_compile failed but should have passed:\n${out}")
+elseif("x${out}" MATCHES "BADFLAG")
+ message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}")
+else()
+ message(STATUS "try_compile with CMP0056 OLD worked as expected")
+endif()
+
+#-----------------------------------------------------------------------------
+cmake_policy(SET CMP0056 NEW)
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ OUTPUT_VARIABLE out
+ )
+string(REPLACE "\n" "\n " out " ${out}")
+if(RESULT)
+ message(FATAL_ERROR "try_compile passed but should have failed:\n${out}")
+elseif(NOT "x${out}" MATCHES "BADFLAG")
+ message(FATAL_ERROR "try_compile did not fail with BADFLAG:\n${out}")
+else()
+ message(STATUS "try_compile with CMP0056 NEW worked as expected")
+endif()
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
index c93445876e..06096b2390 100644
--- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
@@ -15,3 +15,5 @@ run_cmake(BadSources1)
run_cmake(BadSources2)
run_cmake(NonSourceCopyFile)
run_cmake(NonSourceCompileDefinitions)
+
+run_cmake(CMP0056)