summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-26 15:31:28 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-02-26 15:31:28 (GMT)
commit79d4b5bec911f057c87dd6c558cbe112afbc3a7e (patch)
tree57bc2105737882a65b89009eea8bc89fb81f9e15 /Tests/RunCMake
parentcc7a1b194152a171725ae9cb66c6de1e710b4ecb (diff)
parent7f1bd9fe6910f7633d98dec018cc01331a46b87e (diff)
downloadCMake-79d4b5bec911f057c87dd6c558cbe112afbc3a7e.zip
CMake-79d4b5bec911f057c87dd6c558cbe112afbc3a7e.tar.gz
CMake-79d4b5bec911f057c87dd6c558cbe112afbc3a7e.tar.bz2
Merge topic 'try_compile-target-type'
7f1bd9fe try_compile: Add option to control type of target
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/try_compile/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/try_compile/TargetTypeExe.cmake14
-rw-r--r--Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt5
-rw-r--r--Tests/RunCMake/try_compile/TargetTypeInvalid.cmake2
-rw-r--r--Tests/RunCMake/try_compile/TargetTypeStatic.cmake14
-rw-r--r--Tests/RunCMake/try_compile/other.c1
7 files changed, 41 insertions, 0 deletions
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
index 6cdbafa..43ce998 100644
--- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
@@ -16,6 +16,10 @@ run_cmake(BadSources2)
run_cmake(NonSourceCopyFile)
run_cmake(NonSourceCompileDefinitions)
+run_cmake(TargetTypeExe)
+run_cmake(TargetTypeInvalid)
+run_cmake(TargetTypeStatic)
+
run_cmake(CMP0056)
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
diff --git a/Tests/RunCMake/try_compile/TargetTypeExe.cmake b/Tests/RunCMake/try_compile/TargetTypeExe.cmake
new file mode 100644
index 0000000..9b6e727
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeExe.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ OUTPUT_VARIABLE out
+ COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy
+ COPY_FILE_ERROR copy_err
+ )
+if(NOT result)
+ message(FATAL_ERROR "try_compile failed:\n${out}")
+endif()
+if(copy_err)
+ message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}")
+endif()
diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt
new file mode 100644
index 0000000..08b281a
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TargetTypeInvalid.cmake:2 \(try_compile\):
+ Invalid value 'INVALID' for CMAKE_TRY_COMPILE_TARGET_TYPE. Only
+ 'EXECUTABLE' and 'STATIC_LIBRARY' are allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake
new file mode 100644
index 0000000..0bbc4ac
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_TRY_COMPILE_TARGET_TYPE INVALID)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c)
diff --git a/Tests/RunCMake/try_compile/TargetTypeStatic.cmake b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake
new file mode 100644
index 0000000..006b8b8
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/other.c
+ OUTPUT_VARIABLE out
+ COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy
+ COPY_FILE_ERROR copy_err
+ )
+if(NOT result)
+ message(FATAL_ERROR "try_compile failed:\n${out}")
+endif()
+if(copy_err)
+ message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}")
+endif()
diff --git a/Tests/RunCMake/try_compile/other.c b/Tests/RunCMake/try_compile/other.c
new file mode 100644
index 0000000..6c24f10
--- /dev/null
+++ b/Tests/RunCMake/try_compile/other.c
@@ -0,0 +1 @@
+int other(void) { return 0; }