Skip to content

Commit cfa6908

Browse files
authored
Merge pull request #100 from leetal/dev
Dev
2 parents ed40511 + 812d89e commit cfa6908

File tree

5 files changed

+311
-241
lines changed

5 files changed

+311
-241
lines changed

.travis.yml

Lines changed: 103 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,109 @@
11
language: objective-c
22

3-
matrix:
3+
os:
4+
- osx
5+
6+
jobs:
7+
fast_finish: true
8+
allow_failures:
9+
- name: "Use new *COMBINED build support in CMake 3.19.4+ [allowed failure]"
10+
- name: "Mac Catalyst on Apple Silicon, Target iOS 13.0 [arm64] [allowed failure]"
11+
- name: "Xcode version 12.2, Target macOS on Apple Silicon [arm64] SDK 11.0 [allowed failure]"
412
include:
5-
- os: osx
6-
osx_image: xcode11.3
7-
env:
8-
- PLATFORM=SIMULATOR DEPLOYMENT_TARGET=13.1
9-
- os: osx
10-
osx_image: xcode10.2
11-
env:
12-
- PLATFORM=SIMULATOR64 DEPLOYMENT_TARGET=12.1
13-
- os: osx
14-
osx_image: xcode11.1
15-
env:
16-
- PLATFORM=OS DEPLOYMENT_TARGET=13.0
17-
- os: osx
18-
osx_image: xcode10.2
19-
env:
20-
- PLATFORM=OS64 DEPLOYMENT_TARGET=12.0
21-
- os: osx
22-
osx_image: xcode9.4
23-
env:
24-
- PLATFORM=OS64 DEPLOYMENT_TARGET=11.0
25-
- os: osx
26-
osx_image: xcode10.2
27-
env:
28-
- PLATFORM=OS BUILD_SHARED=1 DEPLOYMENT_TARGET=12.0
29-
- os: osx
30-
osx_image: xcode10.2
31-
env:
32-
- PLATFORM=TVOS DEPLOYMENT_TARGET=11.0
33-
- os: osx
34-
osx_image: xcode10.2
35-
env:
36-
- PLATFORM=WATCHOS DEPLOYMENT_TARGET=5.0
37-
- os: osx
38-
osx_image: xcode10.2
39-
env:
40-
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0
41-
- os: osx
42-
osx_image: xcode12.2
43-
env:
44-
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=14.0
45-
- os: osx
46-
osx_image: xcode11.3
47-
env:
48-
- PLATFORM=OS64COMBINED BUILD_CURL=1 USE_XCODE=1 DEPLOYMENT_TARGET=11.0
49-
50-
install: true
13+
- name: "Xcode version 8.3, Target iOS [arm64] SDK 9.0"
14+
stage: "iOS builds"
15+
osx_image: xcode8.3
16+
env:
17+
- PLATFORM=OS64 DEPLOYMENT_TARGET=9.0
18+
- name: "Xcode version 9.4, Target iOS [arm64] SDK 9.0"
19+
stage: "iOS builds"
20+
osx_image: xcode9.4
21+
env:
22+
- PLATFORM=OS64 DEPLOYMENT_TARGET=9.0
23+
- name: "Xcode version 9.4, Target iOS [arm64] SDK 11.0"
24+
stage: "iOS builds"
25+
osx_image: xcode10.2
26+
env:
27+
- PLATFORM=OS64 DEPLOYMENT_TARGET=11.0
28+
- name: "Xcode version 9.4, Target iOS [armv7, armv7k, arm64] SDK 9.0"
29+
stage: "iOS builds"
30+
osx_image: xcode10.2
31+
env:
32+
- PLATFORM=OS DEPLOYMENT_TARGET=9.0
33+
- name: "Xcode version 11.3, Target iOS Simulator64 [x86_64] SDK 12.0"
34+
stage: "iOS builds"
35+
osx_image: xcode11.3
36+
env:
37+
- PLATFORM=SIMULATOR64 DEPLOYMENT_TARGET=12.0
38+
39+
- name: "Xcode version 11.3, Target watchOS [armv7k,arm64_32] SDK 5.0"
40+
stage: "watchOS builds"
41+
osx_image: xcode11.3
42+
env:
43+
- PLATFORM=WATCHOS DEPLOYMENT_TARGET=5.0
44+
- name: "Xcode version 12.2, Target watchOS Simulator [x86_64] SDK 7.0"
45+
stage: "watchOS builds"
46+
osx_image: xcode12.2
47+
env:
48+
- PLATFORM=SIMULATOR_WATCHOS DEPLOYMENT_TARGET=7.0
49+
50+
- name: "Xcode version 11.3, Target tvOS [arm64] SDK 11.0"
51+
stage: "tvOS builds"
52+
osx_image: xcode11.3
53+
env:
54+
- PLATFORM=TVOS DEPLOYMENT_TARGET=11.0
55+
56+
- name: "Xcode version 11.3, Target iOS Combined Build [x86_64, arm64] SDK 12.0"
57+
stage: "Combined builds"
58+
osx_image: xcode11.3
59+
env:
60+
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=12.0
61+
- name: "Xcode version 11.3, Target watchOS [armv7k, arm64_32, x86_64] SDK 5.0"
62+
stage: "Combined builds"
63+
osx_image: xcode11.3
64+
env:
65+
- PLATFORM=WATCHOSCOMBINED USE_XCODE=1 DEPLOYMENT_TARGET=5.0
66+
- name: "Xcode version 11.3, Target tvOS [arm64, x86_64] SDK 11.0"
67+
stage: "Combined builds"
68+
osx_image: xcode11.3
69+
env:
70+
- PLATFORM=TVOSCOMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0
71+
72+
- name: "Xcode version 12.2, Target macOS [x86_64] SDK 10.13"
73+
stage: "macOS builds"
74+
osx_image: xcode12.2
75+
env:
76+
- PLATFORM=MAC DEPLOYMENT_TARGET=10.13
77+
- name: "Xcode version 12.2, Target macOS on Apple Silicon [arm64] SDK 11.0 [allowed failure]"
78+
stage: "macOS builds"
79+
osx_image: xcode12.2
80+
env:
81+
- PLATFORM=MAC_ARM64 DEPLOYMENT_TARGET=11.0
82+
83+
- name: "Mac Catalyst, iOS target 13.0 [x86_64]"
84+
stage: "Mac Catalyst builds"
85+
osx_image: xcode12.2
86+
env:
87+
- PLATFORM=MAC_CATALYST DEPLOYMENT_TARGET=13.0
88+
- name: "Mac Catalyst on Apple Silicon, Target iOS 13.0 [arm64] [allowed failure]"
89+
stage: "Mac Catalyst builds"
90+
osx_image: xcode12.2
91+
env:
92+
- PLATFORM=MAC_CATALYST_ARM64 DEPLOYMENT_TARGET=13.0
93+
94+
- name: "Use new *COMBINED build support in CMake 3.19.4+ [allowed failure]"
95+
stage: "New build system combined builds"
96+
osx_image: xcode12.2
97+
env:
98+
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0 USE_NEW_BUILD=1
99+
100+
- name: "libCURL example combined build on iOS"
101+
stage: "libCURL example builds"
102+
osx_image: xcode11.3
103+
env:
104+
- PLATFORM=OS64COMBINED USE_XCODE=1 DEPLOYMENT_TARGET=11.0 BUILD_CURL=1
105+
106+
install: skip
51107

52108
script:
53109
- ./.travis/build.sh

.travis/build.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ USE_XCODE=${USE_XCODE:-0}
1010
BUILD_CURL=${BUILD_CURL:-0}
1111
USE_STRICT_COMPILER_CHECKS=${USE_STRICT_COMPILER_CHECKS:-0}
1212
DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET:-11.0}
13+
USE_NEW_BUILD=${USE_NEW_BUILD:-0}
1314

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

2425
if [[ ${BUILD_CURL} -eq 1 ]]; then
2526
mkdir -p example/example-curl/build
26-
pushd example/example-curl/build
27+
pushd example/example-curl/build || exit 1
2728
cmake .. \
28-
${GENERATOR_EXT} -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake \
29+
${GENERATOR_EXT} -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DCMAKE_INSTALL_PREFIX=../out \
2930
-DPLATFORM=${PLATFORM} -DDEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} -DENABLE_STRICT_TRY_COMPILE=${USE_STRICT_COMPILER_CHECKS} || exit 1
3031
cmake --build . --config Release --parallel 4 || exit 1
31-
popd
32+
popd || exit 1
3233
else
3334
mkdir -p example/example-lib/build
34-
pushd example/example-lib/build
35+
pushd example/example-lib/build || exit 1
3536
cmake .. \
3637
${GENERATOR_EXT} -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DCMAKE_INSTALL_PREFIX=../out \
3738
-DPLATFORM=${PLATFORM} -DDEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} -DENABLE_STRICT_TRY_COMPILE=${USE_STRICT_COMPILER_CHECKS} ${SHARED_EXT}\
3839
|| exit 1
39-
cmake --build . --config Release || exit 1
40-
cmake --install . --config Release || exit 1
41-
popd
40+
41+
# Test new way of building in newer CMake versions when building the *COMBINED platform options
42+
if [[ ${USE_NEW_BUILD} -eq 1 ]]; then
43+
cmake --build . --config Release || exit 1
44+
cmake --install . --config Release || exit 1
45+
else
46+
cmake --build . --config Release --target install || exit 1
47+
fi
48+
popd || exit 1
4249
fi

example/example-lib/CMakeLists.txt

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,18 @@ else()
1313
message(STATUS "kqueue found!")
1414
endif()
1515

16-
if(PLATFORM MATCHES "(MAC|MAC_ARM64)")
17-
find_library(HAVE_APPKIT AppKit)
18-
if (NOT HAVE_APPKIT)
19-
message(FATAL_ERROR "AppKit.framework NOT found!")
20-
else()
21-
message(STATUS "AppKit.framework found!")
22-
endif()
23-
elseif(PLATFORM MATCHES "(MAC_CATALYST|MAC_CATALYST_ARM64)")
24-
find_library(HAVE_APPKIT AppKit)
25-
if (NOT HAVE_APPKIT)
26-
message(FATAL_ERROR "AppKit.framework NOT found!")
27-
else()
28-
message(STATUS "AppKit.framework found!")
29-
endif()
30-
find_library(HAVE_UIKIT UIKit)
31-
if (NOT HAVE_UIKIT)
32-
message(FATAL_ERROR "UIKit.framework NOT found!")
33-
else()
34-
message(STATUS "UIKit.framework found!")
35-
endif()
16+
find_library(HAVE_APPKIT AppKit)
17+
if (NOT HAVE_APPKIT)
18+
message(STATUS "AppKit.framework NOT found!")
3619
else()
37-
find_library(HAVE_UIKIT UIKit)
38-
if (NOT HAVE_UIKIT)
39-
message(FATAL_ERROR "UIKit.framework NOT found!")
40-
else()
41-
message(STATUS "UIKit.framework found!")
42-
endif()
20+
message(STATUS "AppKit.framework found!")
21+
endif()
22+
23+
find_library(HAVE_UIKIT UIKit)
24+
if (NOT HAVE_UIKIT)
25+
message(STATUS "UIKit.framework NOT found!")
26+
else()
27+
message(STATUS "UIKit.framework found!")
4328
endif()
4429

4530
# Hook up XCTest for the supported plaforms (all but WatchOS)
@@ -72,6 +57,7 @@ set(HEADERS
7257
# Library
7358
if(BUILD_SHARED)
7459
add_library (example SHARED ${SOURCES} ${HEADERS})
60+
target_compile_definitions(example PUBLIC IS_BUILDING_SHARED)
7561
message(STATUS "Building shared version...")
7662
else()
7763
add_library (example STATIC ${SOURCES} ${HEADERS})
@@ -84,14 +70,44 @@ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
8470

8571
# Executable
8672
if(PLATFORM MATCHES "MAC.*")
87-
add_executable (helloworld main.cpp)
73+
set(APP_NAME TestApp)
74+
add_executable (${APP_NAME} MACOSX_BUNDLE main.cpp)
75+
set_target_properties(${APP_NAME} PROPERTIES
76+
BUNDLE True
77+
MACOSX_BUNDLE_GUI_IDENTIFIER leetal.com.helloworld
78+
MACOSX_BUNDLE_BUNDLE_NAME helloworld
79+
MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
80+
MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
81+
)
8882
# Link the library with the executable
89-
target_link_libraries(helloworld example)
83+
target_link_libraries(${APP_NAME} example)
9084
endif()
9185

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

9589
# Installation
96-
install (TARGETS example DESTINATION lib)
90+
if(PLATFORM MATCHES "MAC.*")
91+
install(TARGETS ${APP_NAME}
92+
BUNDLE DESTINATION . COMPONENT Runtime
93+
RUNTIME DESTINATION bin COMPONENT Runtime
94+
LIBRARY DESTINATION lib
95+
ARCHIVE DESTINATION lib/static)
96+
97+
# Note Mac specific extension .app
98+
set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_NAME}.app")
99+
100+
# Directories to look for dependencies
101+
set(DIRS ${CMAKE_BINARY_DIR})
102+
103+
install(CODE "include(BundleUtilities)
104+
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")")
105+
106+
set(CPACK_GENERATOR "DRAGNDROP")
107+
include(CPack)
108+
else()
109+
install(TARGETS example
110+
LIBRARY DESTINATION lib
111+
ARCHIVE DESTINATION lib/static)
112+
endif()
97113
install (FILES ${HEADERS} DESTINATION include)

example/example-lib/HelloWorld.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#pragma once
22
#include <string>
33

4-
class HelloWorld
4+
#if defined(__clang__)
5+
#define SHARED_EXPORT __attribute__((visibility("default")))
6+
#define SHARED_LOCAL __attribute__((visibility("hidden")))
7+
#endif
8+
9+
#if defined(IS_BUILDING_SHARED)
10+
#define API SHARED_EXPORT
11+
#else
12+
#define API
13+
#endif
14+
15+
class API HelloWorld
516
{
617
public:
718
std::string helloWorld();

0 commit comments

Comments
 (0)