Skip to content

Commit 4c197bf

Browse files
committed
Add preliminary support for Xcode and building universal dylib
1 parent e1014b0 commit 4c197bf

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

.github/workflows/cppcmake.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,26 @@ jobs:
3939
- {name: "ubuntu-24.04", os: "ubuntu-24.04", cmake_extra: "-DLSL_BUNDLED_PUGIXML=OFF" }
4040
- {name: "windows-x64", os: "windows-latest", cmake_extra: "-T v142,host=x86"}
4141
- {name: "windows-32", os: "windows-latest", cmake_extra: "-T v142,host=x86 -A Win32"}
42-
- {name: "macOS-latest", os: "macOS-latest"}
42+
- {name: "macOS-latest", os: "macOS-latest", cmake_extra: "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=x86_64;arm64 DCMAKE_SYSTEM_NAME=Darwin -G Xcode" }
4343

4444
# runs all steps in the container configured in config.docker or as subprocesses when empty
4545
container: ${{ matrix.config.docker }}
4646
steps:
4747
- uses: actions/checkout@v4
48+
4849
- name: set up build environment in container
50+
if: ${{ matrix.config.docker }}
4951
run: |
5052
set -x
5153
apt update
5254
apt install -y --no-install-recommends g++ git ninja-build file dpkg-dev lsb-release sudo curl cmake libpugixml-dev
53-
if: ${{ matrix.config.docker }}
55+
56+
- name: Setup Xcode
57+
if: ${{ matrix.config.name == 'macOS-latest' }}
58+
uses: maxim-lobanov/setup-xcode@v1
59+
with:
60+
xcode-version: 'latest-stable'
61+
5462
- name: Configure CMake
5563
run: |
5664
if [[ "${{ matrix.config.name }}" = ubuntu-2* ]]; then
@@ -68,8 +76,12 @@ jobs:
6876
${{ matrix.config.cmake_extra }} \
6977
${{ github.event.inputs.cmakeextra }}
7078
echo ${PWD}
79+
7180
- name: make
72-
run: cmake --build build --target install --config Release -j
81+
run: cmake --build build --config Release -j
82+
83+
- name: make install
84+
run: cmake --build build --config Release --target install
7385

7486
- name: test install using examples
7587
run: |
@@ -101,6 +113,7 @@ jobs:
101113
fi
102114
cmake -E remove_directory package/_CPack_Packages
103115
cp testing/lslcfgs/default.cfg .
116+
104117
- name: upload install dir
105118
uses: actions/upload-artifact@master
106119
with:
@@ -112,6 +125,7 @@ jobs:
112125
with:
113126
name: pkg-${{ matrix.config.name }}
114127
path: package
128+
115129
- name: print network config
116130
run: |
117131
which ifconfig && ifconfig
@@ -133,12 +147,14 @@ jobs:
133147
install/bin/lsl_test_internal --order rand --wait-for-keypress never --durations yes || test ! -z "${{ matrix.config.docker }}"
134148
install/bin/lsl_test_exported --order rand --wait-for-keypress never --durations yes
135149
timeout-minutes: 10
150+
136151
- name: upload dump
137152
if: failure()
138153
uses: actions/upload-artifact@master
139154
with:
140155
name: dumps-${{ matrix.config.name }}
141156
path: dumps
157+
142158
- name: upload to release page
143159
if: github.event_name == 'release'
144160
env:

cmake/TargetLib.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,23 @@ target_compile_definitions(lsl
4747
# don't use #pragma(lib) in MSVC builds. TODO: Maybe this can be inherited from lslobj or removed on lslobj?
4848
$<$<CXX_COMPILER_ID:MSVC>:LSLNOAUTOLINK>
4949
)
50+
51+
# Extra configuration for Apple targets -- set xcode attributes
52+
if(APPLE)
53+
set_target_properties(lsl PROPERTIES
54+
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.labstreaminglayer.liblsl"
55+
)
56+
# If environment variables are set for Apple Development Team and Code Sign Identity then add these to the target
57+
# -> if `-G Xcode` generator is used then Xcode will use these variables to sign the framework.
58+
# Note, however, that it is likely that the build products will be modified post-build, invalidating the signature,
59+
# so post-hoc signing will be required. Nevertheless, this is useful for initial signing and normal Xcode workflow.
60+
if(DEFINED ENV{APPLE_DEVELOPMENT_TEAM} AND DEFINED ENV{APPLE_CODE_SIGN_IDENTITY_APP})
61+
set_target_properties(lsl PROPERTIES
62+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY $ENV{APPLE_CODE_SIGN_IDENTITY_APP}
63+
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM $ENV{APPLE_DEVELOPMENT_TEAM}
64+
XCODE_ATTRIBUTE_CODE_SIGN_STYLE "Manual"
65+
XCODE_ATTRIBUTE_DEPLOYMENT_POSTPROCESSING YES # this is needed for strip symbols
66+
XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep"
67+
)
68+
endif()
69+
endif(APPLE)

0 commit comments

Comments
 (0)