Skip to content

Commit

Permalink
Merge pull request #100 from leetal/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
leetal authored Mar 4, 2021
2 parents ed40511 + 812d89e commit cfa6908
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 241 deletions.
150 changes: 103 additions & 47 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,109 @@
language: objective-c

matrix:
os:
- osx

jobs:
fast_finish: true
allow_failures:
- name: "Use new *COMBINED build support in CMake 3.19.4+ [allowed failure]"
- name: "Mac Catalyst on Apple Silicon, Target iOS 13.0 [arm64] [allowed failure]"
- name: "Xcode version 12.2, Target macOS on Apple Silicon [arm64] SDK 11.0 [allowed failure]"
include:
- os: osx
osx_image: xcode11.3
env:
- PLATFORM=SIMULATOR DEPLOYMENT_TARGET=13.1
- os: osx
osx_image: xcode10.2
env:
- PLATFORM=SIMULATOR64 DEPLOYMENT_TARGET=12.1
- os: osx
osx_image: xcode11.1
env:
- PLATFORM=OS DEPLOYMENT_TARGET=13.0
- os: osx
osx_image: xcode10.2
env:
- PLATFORM=OS64 DEPLOYMENT_TARGET=12.0
- os: osx
osx_image: xcode9.4
env:
- PLATFORM=OS64 DEPLOYMENT_TARGET=11.0
- os: osx
osx_image: xcode10.2
env:
- PLATFORM=OS BUILD_SHARED=1 DEPLOYMENT_TARGET=12.0
- os: osx
osx_image: xcode10.2
env:
- PLATFORM=TVOS DEPLOYMENT_TARGET=11.0
- os: osx
osx_image: xcode10.2
env:
- PLATFORM=WATCHOS DEPLOYMENT_TARGET=5.0
- os: osx
osx_image: xcode10.2
env:
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0
- os: osx
osx_image: xcode12.2
env:
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=14.0
- os: osx
osx_image: xcode11.3
env:
- PLATFORM=OS64COMBINED BUILD_CURL=1 USE_XCODE=1 DEPLOYMENT_TARGET=11.0

install: true
- name: "Xcode version 8.3, Target iOS [arm64] SDK 9.0"
stage: "iOS builds"
osx_image: xcode8.3
env:
- PLATFORM=OS64 DEPLOYMENT_TARGET=9.0
- name: "Xcode version 9.4, Target iOS [arm64] SDK 9.0"
stage: "iOS builds"
osx_image: xcode9.4
env:
- PLATFORM=OS64 DEPLOYMENT_TARGET=9.0
- name: "Xcode version 9.4, Target iOS [arm64] SDK 11.0"
stage: "iOS builds"
osx_image: xcode10.2
env:
- PLATFORM=OS64 DEPLOYMENT_TARGET=11.0
- name: "Xcode version 9.4, Target iOS [armv7, armv7k, arm64] SDK 9.0"
stage: "iOS builds"
osx_image: xcode10.2
env:
- PLATFORM=OS DEPLOYMENT_TARGET=9.0
- name: "Xcode version 11.3, Target iOS Simulator64 [x86_64] SDK 12.0"
stage: "iOS builds"
osx_image: xcode11.3
env:
- PLATFORM=SIMULATOR64 DEPLOYMENT_TARGET=12.0

- name: "Xcode version 11.3, Target watchOS [armv7k,arm64_32] SDK 5.0"
stage: "watchOS builds"
osx_image: xcode11.3
env:
- PLATFORM=WATCHOS DEPLOYMENT_TARGET=5.0
- name: "Xcode version 12.2, Target watchOS Simulator [x86_64] SDK 7.0"
stage: "watchOS builds"
osx_image: xcode12.2
env:
- PLATFORM=SIMULATOR_WATCHOS DEPLOYMENT_TARGET=7.0

- name: "Xcode version 11.3, Target tvOS [arm64] SDK 11.0"
stage: "tvOS builds"
osx_image: xcode11.3
env:
- PLATFORM=TVOS DEPLOYMENT_TARGET=11.0

- name: "Xcode version 11.3, Target iOS Combined Build [x86_64, arm64] SDK 12.0"
stage: "Combined builds"
osx_image: xcode11.3
env:
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=12.0
- name: "Xcode version 11.3, Target watchOS [armv7k, arm64_32, x86_64] SDK 5.0"
stage: "Combined builds"
osx_image: xcode11.3
env:
- PLATFORM=WATCHOSCOMBINED USE_XCODE=1 DEPLOYMENT_TARGET=5.0
- name: "Xcode version 11.3, Target tvOS [arm64, x86_64] SDK 11.0"
stage: "Combined builds"
osx_image: xcode11.3
env:
- PLATFORM=TVOSCOMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0

- name: "Xcode version 12.2, Target macOS [x86_64] SDK 10.13"
stage: "macOS builds"
osx_image: xcode12.2
env:
- PLATFORM=MAC DEPLOYMENT_TARGET=10.13
- name: "Xcode version 12.2, Target macOS on Apple Silicon [arm64] SDK 11.0 [allowed failure]"
stage: "macOS builds"
osx_image: xcode12.2
env:
- PLATFORM=MAC_ARM64 DEPLOYMENT_TARGET=11.0

- name: "Mac Catalyst, iOS target 13.0 [x86_64]"
stage: "Mac Catalyst builds"
osx_image: xcode12.2
env:
- PLATFORM=MAC_CATALYST DEPLOYMENT_TARGET=13.0
- name: "Mac Catalyst on Apple Silicon, Target iOS 13.0 [arm64] [allowed failure]"
stage: "Mac Catalyst builds"
osx_image: xcode12.2
env:
- PLATFORM=MAC_CATALYST_ARM64 DEPLOYMENT_TARGET=13.0

- name: "Use new *COMBINED build support in CMake 3.19.4+ [allowed failure]"
stage: "New build system combined builds"
osx_image: xcode12.2
env:
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0 USE_NEW_BUILD=1

- name: "libCURL example combined build on iOS"
stage: "libCURL example builds"
osx_image: xcode11.3
env:
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0 BUILD_CURL=1

install: skip

script:
- ./.travis/build.sh
21 changes: 14 additions & 7 deletions .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ USE_XCODE=${USE_XCODE:-0}
BUILD_CURL=${BUILD_CURL:-0}
USE_STRICT_COMPILER_CHECKS=${USE_STRICT_COMPILER_CHECKS:-0}
DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET:-11.0}
USE_NEW_BUILD=${USE_NEW_BUILD:-0}

SHARED_EXT=""
if [[ ${BUILD_SHARED} -eq 1 ]]; then
Expand All @@ -23,20 +24,26 @@ fi

if [[ ${BUILD_CURL} -eq 1 ]]; then
mkdir -p example/example-curl/build
pushd example/example-curl/build
pushd example/example-curl/build || exit 1
cmake .. \
${GENERATOR_EXT} -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake \
${GENERATOR_EXT} -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DCMAKE_INSTALL_PREFIX=../out \
-DPLATFORM=${PLATFORM} -DDEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} -DENABLE_STRICT_TRY_COMPILE=${USE_STRICT_COMPILER_CHECKS} || exit 1
cmake --build . --config Release --parallel 4 || exit 1
popd
popd || exit 1
else
mkdir -p example/example-lib/build
pushd example/example-lib/build
pushd example/example-lib/build || exit 1
cmake .. \
${GENERATOR_EXT} -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DCMAKE_INSTALL_PREFIX=../out \
-DPLATFORM=${PLATFORM} -DDEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} -DENABLE_STRICT_TRY_COMPILE=${USE_STRICT_COMPILER_CHECKS} ${SHARED_EXT}\
|| exit 1
cmake --build . --config Release || exit 1
cmake --install . --config Release || exit 1
popd

# Test new way of building in newer CMake versions when building the *COMBINED platform options
if [[ ${USE_NEW_BUILD} -eq 1 ]]; then
cmake --build . --config Release || exit 1
cmake --install . --config Release || exit 1
else
cmake --build . --config Release --target install || exit 1
fi
popd || exit 1
fi
74 changes: 45 additions & 29 deletions example/example-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,18 @@ else()
message(STATUS "kqueue found!")
endif()

if(PLATFORM MATCHES "(MAC|MAC_ARM64)")
find_library(HAVE_APPKIT AppKit)
if (NOT HAVE_APPKIT)
message(FATAL_ERROR "AppKit.framework NOT found!")
else()
message(STATUS "AppKit.framework found!")
endif()
elseif(PLATFORM MATCHES "(MAC_CATALYST|MAC_CATALYST_ARM64)")
find_library(HAVE_APPKIT AppKit)
if (NOT HAVE_APPKIT)
message(FATAL_ERROR "AppKit.framework NOT found!")
else()
message(STATUS "AppKit.framework found!")
endif()
find_library(HAVE_UIKIT UIKit)
if (NOT HAVE_UIKIT)
message(FATAL_ERROR "UIKit.framework NOT found!")
else()
message(STATUS "UIKit.framework found!")
endif()
find_library(HAVE_APPKIT AppKit)
if (NOT HAVE_APPKIT)
message(STATUS "AppKit.framework NOT found!")
else()
find_library(HAVE_UIKIT UIKit)
if (NOT HAVE_UIKIT)
message(FATAL_ERROR "UIKit.framework NOT found!")
else()
message(STATUS "UIKit.framework found!")
endif()
message(STATUS "AppKit.framework found!")
endif()

find_library(HAVE_UIKIT UIKit)
if (NOT HAVE_UIKIT)
message(STATUS "UIKit.framework NOT found!")
else()
message(STATUS "UIKit.framework found!")
endif()

# Hook up XCTest for the supported plaforms (all but WatchOS)
Expand Down Expand Up @@ -72,6 +57,7 @@ set(HEADERS
# Library
if(BUILD_SHARED)
add_library (example SHARED ${SOURCES} ${HEADERS})
target_compile_definitions(example PUBLIC IS_BUILDING_SHARED)
message(STATUS "Building shared version...")
else()
add_library (example STATIC ${SOURCES} ${HEADERS})
Expand All @@ -84,14 +70,44 @@ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

# Executable
if(PLATFORM MATCHES "MAC.*")
add_executable (helloworld main.cpp)
set(APP_NAME TestApp)
add_executable (${APP_NAME} MACOSX_BUNDLE main.cpp)
set_target_properties(${APP_NAME} PROPERTIES
BUNDLE True
MACOSX_BUNDLE_GUI_IDENTIFIER leetal.com.helloworld
MACOSX_BUNDLE_BUNDLE_NAME helloworld
MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
)
# Link the library with the executable
target_link_libraries(helloworld example)
target_link_libraries(${APP_NAME} example)
endif()

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

# Installation
install (TARGETS example DESTINATION lib)
if(PLATFORM MATCHES "MAC.*")
install(TARGETS ${APP_NAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static)

# Note Mac specific extension .app
set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_NAME}.app")

# Directories to look for dependencies
set(DIRS ${CMAKE_BINARY_DIR})

install(CODE "include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")")

set(CPACK_GENERATOR "DRAGNDROP")
include(CPack)
else()
install(TARGETS example
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static)
endif()
install (FILES ${HEADERS} DESTINATION include)
13 changes: 12 additions & 1 deletion example/example-lib/HelloWorld.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#pragma once
#include <string>

class HelloWorld
#if defined(__clang__)
#define SHARED_EXPORT __attribute__((visibility("default")))
#define SHARED_LOCAL __attribute__((visibility("hidden")))
#endif

#if defined(IS_BUILDING_SHARED)
#define API SHARED_EXPORT
#else
#define API
#endif

class API HelloWorld
{
public:
std::string helloWorld();
Expand Down
Loading

0 comments on commit cfa6908

Please sign in to comment.