[cmake-developers] [PATCH 5/6] Add XCTest example to test Frameworks

Gregor Jasny gjasny at googlemail.com
Sun Feb 15 15:53:02 EST 2015


Signed-off-by: Gregor Jasny <gjasny at googlemail.com>
---
 Tests/XCTest/CMakeLists.txt                        | 38 ++++++++++++++++++++++
 Tests/XCTest/FrameworkExample/FrameworkExample.c   |  6 ++++
 Tests/XCTest/FrameworkExample/FrameworkExample.h   |  1 +
 Tests/XCTest/FrameworkExample/Info.plist           | 28 ++++++++++++++++
 .../FrameworkExampleTests/FrameworkExampleTests.m  | 16 +++++++++
 Tests/XCTest/FrameworkExampleTests/Info.plist      | 24 ++++++++++++++
 6 files changed, 113 insertions(+)
 create mode 100644 Tests/XCTest/CMakeLists.txt
 create mode 100644 Tests/XCTest/FrameworkExample/FrameworkExample.c
 create mode 100644 Tests/XCTest/FrameworkExample/FrameworkExample.h
 create mode 100644 Tests/XCTest/FrameworkExample/Info.plist
 create mode 100644 Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m
 create mode 100644 Tests/XCTest/FrameworkExampleTests/Info.plist

diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt
new file mode 100644
index 0000000..e31e9ab
--- /dev/null
+++ b/Tests/XCTest/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 3.1)
+
+set(CMAKE_OSX_SYSROOT macosx)
+
+project(XCTestExamples)
+
+include(XCTestUtilities)
+
+enable_testing()
+
+# Framework
+
+add_library(FrameworkExample SHARED
+  FrameworkExample/FrameworkExample.c
+  FrameworkExample/FrameworkExample.h
+  FrameworkExample/Info.plist)
+
+target_include_directories(FrameworkExample PUBLIC .)
+
+set_target_properties(FrameworkExample PROPERTIES
+  FRAMEWORK 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
+
+add_xctest(FrameworkExampleTests FrameworkExample
+  FrameworkExampleTests/FrameworkExampleTests.m
+  FrameworkExampleTests/Info.plist)
+ 
+set_target_properties(FrameworkExampleTests PROPERTIES
+  MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/FrameworkExampleTests/Info.plist
+  )
+
+add_test_xctest(FrameworkExampleTests)
diff --git a/Tests/XCTest/FrameworkExample/FrameworkExample.c b/Tests/XCTest/FrameworkExample/FrameworkExample.c
new file mode 100644
index 0000000..2da78da
--- /dev/null
+++ b/Tests/XCTest/FrameworkExample/FrameworkExample.c
@@ -0,0 +1,6 @@
+#include "FrameworkExample.h"
+
+int FourtyTwo()
+{
+    return 42;
+}
diff --git a/Tests/XCTest/FrameworkExample/FrameworkExample.h b/Tests/XCTest/FrameworkExample/FrameworkExample.h
new file mode 100644
index 0000000..2e0b499
--- /dev/null
+++ b/Tests/XCTest/FrameworkExample/FrameworkExample.h
@@ -0,0 +1 @@
+int FourtyTwo();
diff --git a/Tests/XCTest/FrameworkExample/Info.plist b/Tests/XCTest/FrameworkExample/Info.plist
new file mode 100644
index 0000000..a22acea
--- /dev/null
+++ b/Tests/XCTest/FrameworkExample/Info.plist
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>FrameworkExample</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.cmake.FrameworkExample</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>FrameworkExample</string>
+	<key>CFBundlePackageType</key>
+	<string>FMWK</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string></string>
+	<key>NSHumanReadableCopyright</key>
+	<string></string>
+	<key>NSPrincipalClass</key>
+	<string></string>
+</dict>
+</plist>
diff --git a/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m b/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m
new file mode 100644
index 0000000..7cba23e
--- /dev/null
+++ b/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m
@@ -0,0 +1,16 @@
+#import <XCTest/XCTest.h>
+
+#import "FrameworkExample/FrameworkExample.h"
+
+ at interface FrameworkExampleTests : XCTestCase
+
+ at end
+
+ at implementation FrameworkExampleTests
+
+- (void)testFourtyTwo {
+    // This is an example of a functional test case.
+    XCTAssertEqual(42, FourtyTwo());
+}
+
+ at end
diff --git a/Tests/XCTest/FrameworkExampleTests/Info.plist b/Tests/XCTest/FrameworkExampleTests/Info.plist
new file mode 100644
index 0000000..293921b
--- /dev/null
+++ b/Tests/XCTest/FrameworkExampleTests/Info.plist
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>FrameworkExampleTests</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.cmake.FrameworkExampleTests</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>FrameworkExampleTests</string>
+	<key>CFBundlePackageType</key>
+	<string>BNDL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+</dict>
+</plist>
-- 
2.3.0



More information about the cmake-developers mailing list