Skip to content

Commit

Permalink
Merge pull request #34 from leetal/dev
Browse files Browse the repository at this point in the history
New combined build support on newer CMake versions (3.14+).
  • Loading branch information
leetal authored Apr 7, 2019
2 parents 4a70452 + 7a1f215 commit 23f5495
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Project specific
build/
.DS_Store

# Xcode
Expand All @@ -25,6 +24,7 @@ xcuserdata/
*.moved-aside
*.xccheckout
*.xcscmblueprint
.idea/

## Obj-C/Swift specific
*.hmap
Expand Down
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,61 @@ matrix:
fast_finish: true
include:
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=SIMULATOR
- BUILD_SHARED=0
- USE_XCODE=0
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=SIMULATOR64
- BUILD_SHARED=0
- USE_XCODE=0
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=OS
- BUILD_SHARED=0
- USE_XCODE=0
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=OS64
- BUILD_SHARED=0
- USE_XCODE=0
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=OS
- BUILD_SHARED=1
- USE_XCODE=0
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=TVOS
- BUILD_SHARED=0
- USE_XCODE=0
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=WATCHOS
- BUILD_SHARED=0
- USE_XCODE=0
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- IOS_PLATFORM=OS64COMBINED
- BUILD_SHARED=0
- USE_XCODE=1

install: true

Expand Down
12 changes: 8 additions & 4 deletions .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ if [[ $BUILD_SHARED -eq 1 ]]; then
SHARED_EXT="-DBUILD_SHARED=1 -DENABLE_VISIBILITY=1"
fi

GENERATOR_EXT=""
if [[ $USE_XCODE -eq 1 ]]; then
GENERATOR_EXT="-G Xcode"
fi

cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake \
-DIOS_PLATFORM=$IOS_PLATFORM $SHARED_EXT\
$GENERATOR_EXT -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake \
-DPLATFORM=$IOS_PLATFORM $SHARED_EXT\
|| exit 1
make -j2 || exit 1
make install || exit 1
cmake --build . --config Release --target install || exit 1
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
A CMake toolchain file for iOS, watchOS and tvOS development with full simulator support and toggable options!

### NEW!
* The toolchain now supports the new features introduced in CMake 3.14 that allows combined (FAT libraries) to be built.
* Please see below for the "COMBINED" options that will build a static, combined FAT library by default.
* The `IOS_PLATFORM` argument have been renamed to `PLATFORM` to better align with how the toolchain will be used.
* `IOS_PLATFORM` argument still exists, but is deprecated.
* MUCH better support for Xcode generated project on CMake 3.14+

ios-cmake
=========

Expand All @@ -10,32 +17,41 @@ Tested with the following combinations:
* XCode 6.1.x, iOS SDK 8.1
* XCode 8.2.x, iOS SDK 10.2
* XCode 9.4.x, iOS SDK 11.4
* XCode 10.0.x, iOS SDK 12.0
* XCode 10.2.x, iOS SDK 12.2

# Example usage
**NOTE: The below commands will build for 64-bit simulator only. Change the `-DIOS_PLATFORM` to the applicable value if targeting another platform.**
**NOTE: The below commands will build for 64-bit simulator only. Change the `-DPLATFORM` to the applicable value if targeting another platform.**

```bash
cd example/example-lib
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DIOS_PLATFORM=SIMULATOR64
make
make install
cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DPLATFORM=OS64COMBINED
cmake --build . --config Release --target install
```

This will build and install the library for the given IOS_PLATFORM.

## Options

* Set `-DIOS_PLATFORM` to "SIMULATOR" to build for iOS simulator 32 bit (i386) **DEPRECATED**
* Set `-DIOS_PLATFORM` to "SIMULATOR64" (example above) to build for iOS simulator 64 bit (x86_64)
* Set `-DIOS_PLATFORM` to "OS" to build for Device (armv7, armv7s, arm64, arm64e)
* Set `-DIOS_PLATFORM` to "OS64" to build for Device (arm64, arm64e)
* Set `-DIOS_PLATFORM` to "TVOS" to build for tvOS (arm64)
* Set `-DIOS_PLATFORM` to "SIMULATOR_TVOS" to build for tvOS Simulator (x86_64)
* Set `-DIOS_PLATFORM` to "WATCHOS" to build for watchOS (armv7k, arm64_32)
* Set `-DIOS_PLATFORM` to "SIMULATOR_WATCHOS" to build for watchOS Simulator (x86_64)
* Set `-DPLATFORM` to "SIMULATOR" to build for iOS simulator 32 bit (i386) **DEPRECATED**
* Set `-DPLATFORM` to "SIMULATOR64" (example above) to build for iOS simulator 64 bit (x86_64)
* Set `-DPLATFORM` to "OS" to build for Device (armv7, armv7s, arm64, arm64e)
* Set `-DPLATFORM` to "OS64" to build for Device (arm64, arm64e)
* Set `-DPLATFORM` to "OS64COMBINED" to build for Device & Simulator (FAT lib) (arm64, arm64e, x86_64)
* Set `-DPLATFORM` to "TVOS" to build for tvOS (arm64)
* Set `-DPLATFORM` to "TVOSCOMBINED" to build for tvOS & Simulator (arm64, x86_64)
* Set `-DPLATFORM` to "SIMULATOR_TVOS" to build for tvOS Simulator (x86_64)
* Set `-DPLATFORM` to "WATCHOS" to build for watchOS (armv7k, arm64_32)
* Set `-DPLATFORM` to "WATCHOSCOMBINED" to build for watchOS & Simulator (armv7k, arm64_32, i386)
* Set `-DPLATFORM` to "SIMULATOR_WATCHOS" to build for watchOS Simulator (i386)

### COMBINED options
The options called *COMBINED (OS64COMBINED, TVOSCOMBINED and WATCHOSCOMBINED) will build complete FAT-libraries for
the given platform. These FAT-libraries include slices for both device and simulator, making the distribution and
usage of the library much more simple!

**NOTE: The COMBINED options _ONLY_ work with the Xcode generator (-G Xcode).**

### Additional Options
`-DENABLE_BITCODE=(BOOL)` - Enabled by default, specify FALSE or 0 to disable bitcode
Expand All @@ -44,9 +60,10 @@ This will build and install the library for the given IOS_PLATFORM.

`-DENABLE_VISIBILITY=(BOOL)` - Disabled by default, specify TRUE or 1 to enable symbol visibility support

`-DIOS_ARCH=(STRING)` - Valid values are: armv7, armv7s, arm64, arm64e, i386, x86_64, armv7k, arm64_32. By default it will build for all valid architectures based on `-DIOS_PLATFORM` (see above)
`-DIOS_ARCH=(STRING)` - Valid values are: armv7, armv7s, arm64, arm64e, i386, x86_64, armv7k, arm64_32. By default it will build for all valid architectures based on `-DPLATFORM` (see above)

__*The resulting binary will consist of only one platform. To combine all platforms into the same fat-library, use the LIPO tool. More information on this is available on the net.*__
__*To combine all platforms into the same FAT-library, either build any of the "*COMBINED*" platform types OR use the
LIPO tool. More information on how to combine libraries with LIPO is readily available on the net.*__

## Thanks To

Expand Down
Binary file modified example/example-app/example-lib/lib/libexample.a
Binary file not shown.
18 changes: 9 additions & 9 deletions example/example-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ cmake_minimum_required (VERSION 3.2)
project (example-ios C CXX)

# Includes
include_directories (${example-ios_SOURCE_DIR})
include_directories(${example-ios_SOURCE_DIR})

# Source files
set (SOURCES
set(SOURCES
HelloWorld.cpp
HelloWorldIOS.mm
)

# Headers
set (HEADERS
set(HEADERS
HelloWorld.hpp
HelloWorldIOS.h
)

# Library
if (BUILD_SHARED)
if(BUILD_SHARED)
add_library (example SHARED ${SOURCES} ${HEADERS})
message(STATUS "Building shared version...")
else()
Expand All @@ -26,15 +26,15 @@ else()
endif()

# Executable
add_executable (helloworld main.cpp)
#add_executable (helloworld main.cpp)

# Link the library with the executable
target_link_libraries(helloworld example)
#target_link_libraries(helloworld example)

# Debug symbols set in XCode project
set_xcode_property (example GCC_GENERATE_DEBUGGING_SYMBOLS YES "All")
set_xcode_property(example GCC_GENERATE_DEBUGGING_SYMBOLS YES "All")

# Installation
set (CMAKE_INSTALL_PREFIX "${example-ios_SOURCE_DIR}/../example-app/example-lib")
install (TARGETS example helloworld DESTINATION lib)
set(CMAKE_INSTALL_PREFIX "${example-ios_SOURCE_DIR}/../example-app/example-lib")
install (TARGETS example DESTINATION lib)
install (FILES ${HEADERS} DESTINATION include)
Loading

0 comments on commit 23f5495

Please sign in to comment.