cmake xctest_add_bundle函数说明和示例 [英] cmake xctest_add_bundle function explanation and examples

查看:88
本文介绍了cmake xctest_add_bundle函数说明和示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在最新的cmake版本(v3.3.0)中,可以使用 xctest_add_bundle 。但是,有关如何使用此功能的文档对我来说很差。是否有人可以提供示例以说明如何使用此功能?谢谢。

In latest cmake version (v3.3.0), it is possible to create a XCTests bundle for MAC and IOS by using xctest_add_bundle. However the documentation on how to use this function is poor for me. Are there someone who can provide a sample to show how to use this function? Thanks.

对于我的应用程序,我想与XCTest一起创建IOS APP。所有应该用cmake完成。

For my application, I want to create a IOS APP along with XCTest. All should be done with cmake.

推荐答案

您已经具有描述 xctest_add_bundle 和<$的链接。 c $ c> xctest_add_test 。因此,我在下面给您提供示例源代码。

You already have a link that describes about xctest_add_bundle and xctest_add_test. So i just give you an example source code in below.

我从cmake项目中找到了示例代码。它不仅包含 CMakelist.txt 文件,还包括示例测试代码。请注意该示例。

I have found an example code from cmake project. It includes not only CMakelist.txt file but also sample test codes. Please note that example.

https://cmake.org/gitweb?p=cmake.git;a=tree;f=Tests/XCTest;h=e0b3009744e263fcc81009471c34049a46e8bc7a;hb=HEAD

enable_testing()

find_package(XCTest REQUIRED)

# Framework

add_library(FrameworkExample SHARED
  ${some_source_codes}
  FrameworkExample/Info.plist)

target_include_directories(FrameworkExample PUBLIC .)

set_target_properties(FrameworkExample PROPERTIES
  FRAMEWORK TRUE      # in my experience, this property should be TRUE
  VERSION "1.0.0"
  SOVERSION "1.0.0"
  FRAMEWORK_VERSION "A"
  MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/FrameworkExample/Info.plist
  PUBLIC_HEADER FrameworkExample/FrameworkExample.h)

# XCTest for Framework

xctest_add_bundle(FrameworkExampleTests FrameworkExample
  FrameworkExampleTests/FrameworkExampleTests.m
  FrameworkExampleTests/Info.plist)

set_target_properties(FrameworkExampleTests PROPERTIES
  MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/FrameworkExampleTests/Info.plist
  )

xctest_add_test(XCTest.FrameworkExample FrameworkExampleTests)

这篇关于cmake xctest_add_bundle函数说明和示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆