summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregor Jasny <gjasny@googlemail.com>2015-11-13 11:59:18 (GMT)
committerGregor Jasny <gjasny@googlemail.com>2015-11-13 12:58:53 (GMT)
commitf6f03ed4cc4271384ec934fd5867ccbce4e798f2 (patch)
tree28d3548c23a1572aec158edde06b7b08149ce0bd
parent9f053763d769780385fbc8e3e936f1c996d2e00a (diff)
downloadCMake-f6f03ed4cc4271384ec934fd5867ccbce4e798f2.zip
CMake-f6f03ed4cc4271384ec934fd5867ccbce4e798f2.tar.gz
CMake-f6f03ed4cc4271384ec934fd5867ccbce4e798f2.tar.bz2
Add test for OSX/iOS Framework directory structure (#15833)
-rw-r--r--Tests/RunCMake/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/Framework/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Framework/FrameworkLayout.cmake5
-rw-r--r--Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake20
-rw-r--r--Tests/RunCMake/Framework/RunCMakeTest.cmake33
-rw-r--r--Tests/RunCMake/Framework/foo.c1
-rw-r--r--Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake20
-rw-r--r--Tests/RunCMake/Framework/ios.cmake25
-rw-r--r--Tests/RunCMake/Framework/osx.cmake18
9 files changed, 131 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1a0019f..a6cbf86 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -239,6 +239,12 @@ if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3)
add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION})
endif()
+if(NOT XCODE
+ AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
+ AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0)
+ add_RunCMake_test(Framework)
+endif()
+
add_RunCMake_test(File_Generate)
add_RunCMake_test(ExportWithoutLanguage)
add_RunCMake_test(target_link_libraries)
diff --git a/Tests/RunCMake/Framework/CMakeLists.txt b/Tests/RunCMake/Framework/CMakeLists.txt
new file mode 100644
index 0000000..6dd8cdf
--- /dev/null
+++ b/Tests/RunCMake/Framework/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.4)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake
new file mode 100644
index 0000000..107afdf
--- /dev/null
+++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.4)
+enable_language(C)
+
+add_library(Framework SHARED foo.c)
+set_target_properties(Framework PROPERTIES FRAMEWORK TRUE)
diff --git a/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake
new file mode 100644
index 0000000..27d10d8
--- /dev/null
+++ b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake
@@ -0,0 +1,20 @@
+set(framework-dir "${RunCMake_TEST_BINARY_DIR}/Framework.framework")
+set(plist-file "${framework-dir}/Resources/Info.plist")
+set(framework-library "${framework-dir}/Framework")
+set(framework-versions "${framework-dir}/Versions")
+
+if(NOT IS_DIRECTORY ${framework-dir})
+ message(SEND_ERROR "Framework not found at ${framework-dir}")
+endif()
+
+if(NOT EXISTS ${plist-file})
+ message(SEND_ERROR "plist file not found at ${plist-file}")
+endif()
+
+if(NOT EXISTS ${framework-library})
+ message(SEND_ERROR "Framework library not found at ${framework-library}")
+endif()
+
+if(NOT EXISTS ${framework-versions})
+ message(SEND_ERROR "Framework versions not found at ${framework-versions}")
+endif()
diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake
new file mode 100644
index 0000000..d810283
--- /dev/null
+++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake
@@ -0,0 +1,33 @@
+include(RunCMake)
+
+# iOS
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/iOSFrameworkLayout-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/ios.cmake")
+
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+run_cmake(FrameworkLayout)
+run_cmake_command(iOSFrameworkLayout-build ${CMAKE_COMMAND} --build .)
+
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_OPTIONS)
+
+# OSX
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/OSXFrameworkLayout-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/OSX.cmake")
+
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+run_cmake(FrameworkLayout)
+run_cmake_command(OSXFrameworkLayout-build ${CMAKE_COMMAND} --build .)
+
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/Framework/foo.c b/Tests/RunCMake/Framework/foo.c
new file mode 100644
index 0000000..bf7759e
--- /dev/null
+++ b/Tests/RunCMake/Framework/foo.c
@@ -0,0 +1 @@
+int foo() { return 42; }
diff --git a/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake
new file mode 100644
index 0000000..373baad
--- /dev/null
+++ b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake
@@ -0,0 +1,20 @@
+set(framework-dir "${RunCMake_TEST_BINARY_DIR}/Framework.framework")
+set(plist-file "${framework-dir}/Info.plist")
+set(framework-library "${framework-dir}/Framework")
+set(framework-versions "${framework-dir}/Versions")
+
+if(NOT IS_DIRECTORY ${framework-dir})
+ message(SEND_ERROR "Framework not found at ${framework-dir}")
+endif()
+
+if(NOT EXISTS ${plist-file})
+ message(SEND_ERROR "plist file not found at ${plist-file}")
+endif()
+
+if(NOT EXISTS ${framework-library})
+ message(SEND_ERROR "Framework library not found at ${framework-library}")
+endif()
+
+if(EXISTS ${framework-versions})
+ message(SEND_ERROR "Framework versions found at ${framework-versions}")
+endif()
diff --git a/Tests/RunCMake/Framework/ios.cmake b/Tests/RunCMake/Framework/ios.cmake
new file mode 100644
index 0000000..209a50d
--- /dev/null
+++ b/Tests/RunCMake/Framework/ios.cmake
@@ -0,0 +1,25 @@
+set(CMAKE_SYSTEM_NAME Darwin)
+set(CMAKE_SYSTEM_VERSION 1)
+set(UNIX True)
+set(APPLE True)
+
+set(CMAKE_MACOSX_BUNDLE TRUE)
+set(CMAKE_CXX_COMPILER_WORKS TRUE)
+set(CMAKE_C_COMPILER_WORKS TRUE)
+set(CMAKE_CROSSCOMPILING TRUE)
+set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
+
+find_program(XCRUN_EXECUTABLE xcrun)
+if(NOT XCRUN_EXECUTABLE)
+ message(FATAL_ERROR "xcrun not found")
+endif()
+
+execute_process(
+ COMMAND ${XCRUN_EXECUTABLE} --sdk iphoneos --show-sdk-path
+ OUTPUT_VARIABLE IOS_SDK_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+set(CMAKE_OSX_SYSROOT ${IOS_SDK_PATH} CACHE PATH "Sysroot used for iOS support")
+set(CMAKE_OSX_ARCHITECTURES "armv7" CACHE STRING "Architectures to build for")
+set(CMAKE_FIND_ROOT_PATH ${IOS_SDK_PATH} CACHE PATH "Find search path root")
diff --git a/Tests/RunCMake/Framework/osx.cmake b/Tests/RunCMake/Framework/osx.cmake
new file mode 100644
index 0000000..e021fcd
--- /dev/null
+++ b/Tests/RunCMake/Framework/osx.cmake
@@ -0,0 +1,18 @@
+set(CMAKE_SYSTEM_NAME Darwin)
+set(CMAKE_SYSTEM_VERSION 1)
+set(UNIX True)
+set(APPLE True)
+
+find_program(XCRUN_EXECUTABLE xcrun)
+if(NOT XCRUN_EXECUTABLE)
+ message(FATAL_ERROR "xcrun not found")
+endif()
+
+execute_process(
+ COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --show-sdk-path
+ OUTPUT_VARIABLE OSX_SDK_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "Sysroot used for OSX support")
+
+set(CMAKE_FIND_ROOT_PATH ${OSX_SDK_PATH} CACHE PATH "Find search path root")