From 70a72a70582057e11ab0b216794504faa955ae04 Mon Sep 17 00:00:00 2001
From: Bartosz Kosiorek <bartosz.kosiorek@tomtom.com>
Date: Sat, 12 Dec 2015 01:19:58 +0100
Subject: [PATCH] Add examples of usage for MACOSX_PACKAGE_LOCATION,
 CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT

---
 Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst  | 69 ++++++++++++++++++++++++++++---
 Help/variable/CMAKE_OSX_ARCHITECTURES.rst | 17 +++++++-
 Help/variable/CMAKE_OSX_SYSROOT.rst       | 16 +++++++
 3 files changed, 96 insertions(+), 6 deletions(-)

diff --git a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
index 69cdcb7..ecae92c 100644
--- a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
+++ b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
@@ -1,17 +1,16 @@
 MACOSX_PACKAGE_LOCATION
 -----------------------
 
-Place a source file inside a Application Bundle
-(:prop_tgt:`MACOSX_BUNDLE`), Core Foundation Bundle (:prop_tgt:`BUNDLE`),
-or Framework Bundle (:prop_tgt:`FRAMEWORK`).  It is applicable for OS X
-and iOS.
+Place a file inside a Application Bundle (:prop_tgt:`MACOSX_BUNDLE`),
+Core Foundation Bundle (:prop_tgt:`BUNDLE`), or Framework Bundle (:prop_tgt:`FRAMEWORK`).
+It is applicable for OS X and iOS.
 
 Executable targets with the :prop_tgt:`MACOSX_BUNDLE` property set are
 built as OS X or iOS application bundles on Apple platforms.  Shared
 library targets with the :prop_tgt:`FRAMEWORK` property set are built as
 OS X or iOS frameworks on Apple platforms.  Module library targets with
 the :prop_tgt:`BUNDLE` property set are built as OS X ``CFBundle`` bundles
-on Apple platforms.  Source files listed in the target with this property
+on Apple platforms.  Files listed in the target with this property
 set will be copied to a directory inside the bundle or framework content
 folder specified by the property value.  For OS X Application Bundles the
 content folder is ``<name>.app/Contents``.  For OS X Frameworks the
@@ -21,3 +20,63 @@ extension is changed).  See the :prop_tgt:`PUBLIC_HEADER`,
 :prop_tgt:`PRIVATE_HEADER`, and :prop_tgt:`RESOURCE` target properties for
 specifying files meant for ``Headers``, ``PrivateHeaders``, or
 ``Resources`` directories.
+
+Example of usage:
+
+By set ``MACOSX_PACKAGE_LOCATION`` property to ``”Modules”``,
+the files marked with that property will be copied to corresponding directory::
+
+  set_property(SOURCE module.modulemap
+    PROPERTY MACOSX_PACKAGE_LOCATION "Modules")
+
+  set (RESLIST 
+      mulres.txt
+      resourcefile.txt
+      )
+
+  add_library(mul SHARED 
+              mul.c
+              mul.h
+              module.modulemap
+              resourcefile.txt
+              mulres.txt)
+
+  # Create an iOS Framework bundle 
+  set_target_properties(mul PROPERTIES
+    FRAMEWORK TRUE
+    FRAMEWORK_VERSION 42 #We don’t need version for iOS Framework 
+    PUBLIC_HEADER mul.h
+    RESOURCE "${RESLIST}"
+  )
+
+The directory structure for OS X will be::
+
+
+mul.framework
+  ├── Headers -> Versions/Current/Headers
+  ├── Resources -> Versions/Current/Resources
+  ├── Versions
+  │   ├── A
+  │   │   ├── Headers
+  │   │   │   └── mul.h
+  │   │   ├── Modules
+  │   │   │   └── module.modulemap
+  │   │   ├── Resources
+  │   │   │   ├── Info.plist
+  │   │   │   ├── mulres.txt
+  │   │   │   └── resourcefile.txt
+  │   │   └── mul
+  │   └── Current -> A
+  └── mul -> Versions/Current/mul
+
+The directory structure for iOS will be::
+
+mul.framework/
+  ├── Headers
+  │   └── mul.h
+  ├── Info.plist
+  ├── Modules
+  │   └── module.modulemap
+  ├── mul
+  ├── mulres.txt
+  └── resourcefile.txt
\ No newline at end of file
diff --git a/Help/variable/CMAKE_OSX_ARCHITECTURES.rst b/Help/variable/CMAKE_OSX_ARCHITECTURES.rst
index 93916dd..125b19b 100644
--- a/Help/variable/CMAKE_OSX_ARCHITECTURES.rst
+++ b/Help/variable/CMAKE_OSX_ARCHITECTURES.rst
@@ -4,7 +4,22 @@ CMAKE_OSX_ARCHITECTURES
 Target specific architectures for OS X and iOS.
 
 This variable is used to initialize the :prop_tgt:`OSX_ARCHITECTURES`
-property on each target as it is creaed.  See that target property
+property on each target as it is created.  See that target property
 for additional information.
 
 .. include:: CMAKE_OSX_VARIABLE.txt
+
+Example of usage:
+
+If user would like to build for iPhone device, it could specify::
+
+  set(CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64")
+
+User also needs to specify :variable:`CMAKE_OSX_SYSROOT` SDK which support such architectures::
+
+  set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk")
+
+Finally proper configuration needs to be provided to compiler::
+
+  set(CMAKE_C_FLAGS "-isysroot ${CMAKE_OSX_SYSROOT} -mios-version-min=9.0”)
+  set(CMAKE_CXX_FLAGS "-isysroot ${CMAKE_OSX_SYSROOT} -mios-version-min=9.0”)
\ No newline at end of file
diff --git a/Help/variable/CMAKE_OSX_SYSROOT.rst b/Help/variable/CMAKE_OSX_SYSROOT.rst
index f1d58c6..70b67e3 100644
--- a/Help/variable/CMAKE_OSX_SYSROOT.rst
+++ b/Help/variable/CMAKE_OSX_SYSROOT.rst
@@ -11,3 +11,19 @@ environment variable, if set, and otherwise computed based on the
 :variable:`CMAKE_OSX_DEPLOYMENT_TARGET` or the host platform.
 
 .. include:: CMAKE_OSX_VARIABLE.txt
+
+Example of usage:
+
+If user would like to build project for iOS Simulator, he needs to 
+setup iPhone Simulator SDK first::
+
+  set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk")
+  
+Also proper configuration needs to be provided to compiler::
+
+  set(CMAKE_C_FLAGS "-isysroot ${CMAKE_OSX_SYSROOT} -mios-version-min=9.0”)
+  set(CMAKE_CXX_FLAGS "-isysroot ${CMAKE_OSX_SYSROOT} -mios-version-min=9.0”)
+
+To create fat library for iPhone simulator he could setup :variable:`CMAKE_OSX_ARCHITECTURES`::
+
+  set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
-- 
2.5.4 (Apple Git-61)

