cmake xctest_add_bundle函数说明和示例 [英] cmake xctest_add_bundle function explanation and examples
问题描述
在最新的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.
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屋!