summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-11-11 15:25:38 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-11-11 15:25:47 (GMT)
commit5e328c6d74ed6b6470e1df1005d07fe930185b52 (patch)
treef9479f6963322133ba3926a3fd5e06f0a0068992 /Tests
parent8bfd4447eb150b17062e26a739b6b7975118057d (diff)
parent7447aa4b340420b0d55bc17bdd9ca1422b1806cf (diff)
downloadCMake-5e328c6d74ed6b6470e1df1005d07fe930185b52.zip
CMake-5e328c6d74ed6b6470e1df1005d07fe930185b52.tar.gz
CMake-5e328c6d74ed6b6470e1df1005d07fe930185b52.tar.bz2
Merge topic 'objc-trycompile' into release-3.16
7447aa4b34 ObjC: Add try_compile support Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4006
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/try_compile/ObjCStandard-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/ObjCStandard-stderr.txt7
-rw-r--r--Tests/RunCMake/try_compile/ObjCStandard.cmake7
-rw-r--r--Tests/RunCMake/try_compile/ObjCxxStandard-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt7
-rw-r--r--Tests/RunCMake/try_compile/ObjCxxStandard.cmake7
-rw-r--r--Tests/RunCMake/try_compile/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/try_compile/src.m4
-rw-r--r--Tests/RunCMake/try_compile/src.mm4
-rw-r--r--Tests/TryCompile/CMakeLists.txt19
-rw-r--r--Tests/TryCompile/fail.m1
-rw-r--r--Tests/TryCompile/pass.m4
13 files changed, 70 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index bf40e48..6b2f117 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -313,6 +313,8 @@ function(add_RunCMake_test_try_compile)
CMAKE_CXX_COMPILER_VERSION
CMAKE_CXX_STANDARD_DEFAULT
CMake_TEST_CUDA
+ CMAKE_OBJC_STANDARD_DEFAULT
+ CMAKE_OBJCXX_STANDARD_DEFAULT
)
if(DEFINED ${var})
list(APPEND try_compile_ARGS -D${var}=${${var}})
diff --git a/Tests/RunCMake/try_compile/ObjCStandard-result.txt b/Tests/RunCMake/try_compile/ObjCStandard-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCStandard-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt b/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt
new file mode 100644
index 0000000..f1b4df9
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Tests/RunCMake/try_compile/ObjCStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\):
+ OBJC_STANDARD is set to invalid value '3'
++
+CMake Error at ObjCStandard.cmake:[0-9]+ \(try_compile\):
+ Failed to generate test project build system.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/try_compile/ObjCStandard.cmake b/Tests/RunCMake/try_compile/ObjCStandard.cmake
new file mode 100644
index 0000000..b2066f9
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCStandard.cmake
@@ -0,0 +1,7 @@
+enable_language(OBJC)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.m
+ OBJC_STANDARD 3
+ OUTPUT_VARIABLE out
+ )
+message("try_compile output:\n${out}")
diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt b/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt b/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt
new file mode 100644
index 0000000..a2f91b4
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Tests/RunCMake/try_compile/ObjCxxStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\):
+ OBJCXX_STANDARD is set to invalid value '3'
++
+CMake Error at ObjCxxStandard.cmake:[0-9]+ \(try_compile\):
+ Failed to generate test project build system.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard.cmake b/Tests/RunCMake/try_compile/ObjCxxStandard.cmake
new file mode 100644
index 0000000..1221805
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCxxStandard.cmake
@@ -0,0 +1,7 @@
+enable_language(OBJCXX)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.mm
+ OBJCXX_STANDARD 3
+ OUTPUT_VARIABLE out
+ )
+message("try_compile output:\n${out}")
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
index 77fb7a0..91f014e 100644
--- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
@@ -37,11 +37,17 @@ if(CMAKE_C_STANDARD_DEFAULT)
elseif(DEFINED CMAKE_C_STANDARD_DEFAULT)
run_cmake(CStandardNoDefault)
endif()
+if(CMAKE_OBJC_STANDARD_DEFAULT)
+ run_cmake(ObjCStandard)
+endif()
if(CMAKE_CXX_STANDARD_DEFAULT)
run_cmake(CxxStandard)
elseif(DEFINED CMAKE_CXX_STANDARD_DEFAULT)
run_cmake(CxxStandardNoDefault)
endif()
+if(CMAKE_OBJCXX_STANDARD_DEFAULT)
+ run_cmake(ObjCxxStandard)
+endif()
if(CMake_TEST_CUDA)
if(CMAKE_HOST_WIN32)
run_cmake(CudaStandardNoDefault)
diff --git a/Tests/RunCMake/try_compile/src.m b/Tests/RunCMake/try_compile/src.m
new file mode 100644
index 0000000..f8b643a
--- /dev/null
+++ b/Tests/RunCMake/try_compile/src.m
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/try_compile/src.mm b/Tests/RunCMake/try_compile/src.mm
new file mode 100644
index 0000000..f8b643a
--- /dev/null
+++ b/Tests/RunCMake/try_compile/src.mm
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 498e556..9ec9b70 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -365,6 +365,25 @@ if (APPLE)
TEST_ASSERT(SIMPLE_OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded")
TEST_FAIL(OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_RUNS() succeeds, but should have failed")
TEST_ASSERT(OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded")
+
+ # try to compile a file that should compile
+ try_compile(SHOULD_PASS
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/pass.m
+ OUTPUT_VARIABLE TRY_OUT)
+ if(NOT SHOULD_PASS)
+ message(SEND_ERROR "should pass failed ${TRY_OUT}")
+ endif()
+
+ # try to compile a file that should not compile
+ try_compile(SHOULD_FAIL
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/fail.m
+ OUTPUT_VARIABLE TRY_OUT)
+ if(SHOULD_FAIL)
+ message(SEND_ERROR "Should fail passed ${TRY_OUT}")
+ endif()
+
endif()
#######################################################################
diff --git a/Tests/TryCompile/fail.m b/Tests/TryCompile/fail.m
new file mode 100644
index 0000000..b915ebe
--- /dev/null
+++ b/Tests/TryCompile/fail.m
@@ -0,0 +1 @@
+asdflkjasdlj
diff --git a/Tests/TryCompile/pass.m b/Tests/TryCompile/pass.m
new file mode 100644
index 0000000..f8b643a
--- /dev/null
+++ b/Tests/TryCompile/pass.m
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}