Add test for OSX/iOS Framework directory structure (#15833)

This commit is contained in:
Gregor Jasny 2015-11-13 12:59:18 +01:00
parent 9f053763d7
commit f6f03ed4cc
9 changed files with 131 additions and 0 deletions

View File

@ -239,6 +239,12 @@ if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3)
add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION}) add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION})
endif() 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(File_Generate)
add_RunCMake_test(ExportWithoutLanguage) add_RunCMake_test(ExportWithoutLanguage)
add_RunCMake_test(target_link_libraries) add_RunCMake_test(target_link_libraries)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.4)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -0,0 +1 @@
int foo() { return 42; }

View File

@ -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()

View File

@ -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")

View File

@ -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")