From bfa92e5725121d2c770fa6f0f47383c0436d768a Mon Sep 17 00:00:00 2001 From: Guillaume Campagna Date: Thu, 20 Apr 2017 16:09:15 -0400 Subject: XCTest: Add support for static frameworks Fixes: #16636 --- Modules/FindXCTest.cmake | 4 ++++ Tests/XCTest/CMakeLists.txt | 16 +++++++++++++++ Tests/XCTest/StaticLibExample/StaticLibExample.c | 6 ++++++ Tests/XCTest/StaticLibExample/StaticLibExample.h | 1 + Tests/XCTest/StaticLibExampleTests/Info.plist | 24 ++++++++++++++++++++++ .../StaticLibExampleTests/StaticLibExampleTests.m | 16 +++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 Tests/XCTest/StaticLibExample/StaticLibExample.c create mode 100644 Tests/XCTest/StaticLibExample/StaticLibExample.h create mode 100644 Tests/XCTest/StaticLibExampleTests/Info.plist create mode 100644 Tests/XCTest/StaticLibExampleTests/StaticLibExampleTests.m diff --git a/Modules/FindXCTest.cmake b/Modules/FindXCTest.cmake index a97bb1b..ffdf677 100644 --- a/Modules/FindXCTest.cmake +++ b/Modules/FindXCTest.cmake @@ -123,6 +123,10 @@ function(xctest_add_bundle target testee) # testee is a Framework target_link_libraries(${target} PRIVATE ${testee}) + elseif(_testee_type STREQUAL "STATIC_LIBRARY") + # testee is a static library + target_link_libraries(${target} PRIVATE ${testee}) + elseif(_testee_type STREQUAL "EXECUTABLE" AND _testee_macosx_bundle) # testee is an App Bundle add_dependencies(${target} ${testee}) diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt index e866623..d40c40e 100644 --- a/Tests/XCTest/CMakeLists.txt +++ b/Tests/XCTest/CMakeLists.txt @@ -55,3 +55,19 @@ xctest_add_bundle(CocoaExampleTests CocoaExample CocoaExampleTests/CocoaExampleTests.m) xctest_add_test(XCTest.CocoaExample CocoaExampleTests) + +# Static lib + +add_library(StaticLibExample STATIC + StaticLibExample/StaticLibExample.h + StaticLibExample/StaticLibExample.c +) + +target_include_directories(StaticLibExample PUBLIC .) + +# XCTest for Static lib + +xctest_add_bundle(StaticLibExampleTests StaticLibExample + StaticLibExampleTests/StaticLibExampleTests.m) + +xctest_add_test(XCTest.StaticLibExample StaticLibExampleTests) diff --git a/Tests/XCTest/StaticLibExample/StaticLibExample.c b/Tests/XCTest/StaticLibExample/StaticLibExample.c new file mode 100644 index 0000000..b198f80 --- /dev/null +++ b/Tests/XCTest/StaticLibExample/StaticLibExample.c @@ -0,0 +1,6 @@ +#include "StaticLibExample.h" + +int FourtyFour() +{ + return 44; +} diff --git a/Tests/XCTest/StaticLibExample/StaticLibExample.h b/Tests/XCTest/StaticLibExample/StaticLibExample.h new file mode 100644 index 0000000..147a909 --- /dev/null +++ b/Tests/XCTest/StaticLibExample/StaticLibExample.h @@ -0,0 +1 @@ +int FourtyFour(); diff --git a/Tests/XCTest/StaticLibExampleTests/Info.plist b/Tests/XCTest/StaticLibExampleTests/Info.plist new file mode 100644 index 0000000..6ad9a27 --- /dev/null +++ b/Tests/XCTest/StaticLibExampleTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + StaticLibExampleTests + CFBundleIdentifier + org.cmake.StaticLibExampleTests + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + StaticLibExampleTests + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Tests/XCTest/StaticLibExampleTests/StaticLibExampleTests.m b/Tests/XCTest/StaticLibExampleTests/StaticLibExampleTests.m new file mode 100644 index 0000000..5f8a769 --- /dev/null +++ b/Tests/XCTest/StaticLibExampleTests/StaticLibExampleTests.m @@ -0,0 +1,16 @@ +#import + +#import "StaticLibExample/StaticLibExample.h" + +@interface StaticLibExampleTests : XCTestCase + +@end + +@implementation StaticLibExampleTests + +- (void)testFourtyFour { + // This is an example of a functional test case. + XCTAssertEqual(44, FourtyFour()); +} + +@end -- cgit v0.12