Skip to content

Commit 3506286

Browse files
authored
Bump macOS version and fix iOS build (#1326)
1 parent cf69613 commit 3506286

File tree

8 files changed

+127
-40
lines changed

8 files changed

+127
-40
lines changed

.github/workflows/build-ios-mac.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: C/C++ CI for iOS
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
- dev
9+
- dev/*
10+
- release/*
11+
- buildme/*
12+
13+
pull_request:
14+
branches:
15+
- master
16+
- main
17+
- dev
18+
19+
schedule:
20+
- cron: 0 2 * * 1-5
21+
22+
jobs:
23+
build:
24+
strategy:
25+
matrix:
26+
os: [macos-13, macos-15]
27+
config: [release, debug]
28+
simulator: ["'iPhone 15'", "'iPad Pro (11-inch) (4th generation)'", "'iPhone 16'", "'iPad Air 11-inch (M2)'"]
29+
exclude:
30+
- os: macos-13
31+
simulator: "'iPhone 16'"
32+
- os: macos-13
33+
simulator: "'iPad Air 11-inch (M2)'"
34+
- os: macos-15
35+
simulator: "'iPhone 15'"
36+
- os: macos-15
37+
simulator: "'iPad Pro (11-inch) (4th generation)'"
38+
runs-on: ${{ matrix.os }}
39+
steps:
40+
- name: Grant write permissions to /usr/local
41+
run: |
42+
sudo chown -R $USER:staff /usr/local
43+
- uses: actions/checkout@v2
44+
with:
45+
submodules: 'true'
46+
continue-on-error: true
47+
- name: build
48+
run: |
49+
if [[ "${{ matrix.os }}" == "macos-13" ]]; then
50+
export IOS_DEPLOYMENT_TARGET=13.0;
51+
elif [[ "${{ matrix.os }}" == "macos-15" ]]; then
52+
export IOS_DEPLOYMENT_TARGET=15.0;
53+
fi
54+
./build-tests-ios.sh ${{ matrix.config }} ${{ matrix.simulator }}

.github/workflows/build-ios-mac11.yml

-35
This file was deleted.

CMakeLists.txt

+45
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
11
cmake_minimum_required(VERSION 3.1.0)
22
project(MSTelemetry)
33

4+
# Set installation prefix for macOS and Linux
5+
if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX)
6+
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory prefix" FORCE)
7+
endif()
8+
9+
10+
# Set installation prefix for Unix systems (macOS and Linux)
11+
if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX)
12+
# First try /usr/local
13+
set(TEST_FILE "/usr/local/.ci_write_test")
14+
15+
# Try to create a test file
16+
execute_process(
17+
COMMAND ${CMAKE_COMMAND} -E touch "${TEST_FILE}"
18+
RESULT_VARIABLE WRITE_RESULT
19+
)
20+
21+
# Check if write was successful
22+
if(WRITE_RESULT EQUAL 0)
23+
# We have write access to /usr/local
24+
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory prefix" FORCE)
25+
message(STATUS "Using /usr/local as installation prefix (write access confirmed)")
26+
# Clean up test file
27+
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${TEST_FILE}")
28+
else()
29+
# No write access, fall back to HOME directory
30+
set(FALLBACK_DIR "$ENV{HOME}/mst_telemetry")
31+
32+
# Create the mst_telemetry directory
33+
execute_process(
34+
COMMAND ${CMAKE_COMMAND} -E make_directory "${FALLBACK_DIR}"
35+
RESULT_VARIABLE CREATE_DIR_RESULT
36+
)
37+
38+
if(NOT CREATE_DIR_RESULT EQUAL 0)
39+
message(FATAL_ERROR "Failed to create directory: ${FALLBACK_DIR}")
40+
endif()
41+
42+
set(CMAKE_INSTALL_PREFIX "${FALLBACK_DIR}" CACHE PATH "Installation directory prefix" FORCE)
43+
message(STATUS "No write access to /usr/local, created and using ${FALLBACK_DIR} instead")
44+
endif()
45+
endif()
46+
47+
48+
449
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
550
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
651
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")

build-gtest.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ fi
2727
echo "Add ios and arm64 build steps for googletest"
2828
cat > $GTEST_PATH/CMakeLists_temp.txt << EOF
2929
# If building for iOS, set all the iOS options
30-
if(BUILD_IOS)
30+
if(BUILD_IOS)
31+
message("-- Building for iOS simulator..")
32+
message("-- CMAKE_OSX_DEPLOYMENT_TARGET \${CMAKE_OSX_DEPLOYMENT_TARGET}")
33+
message("-- CMAKE_SYSTEM_NAME \${CMAKE_SYSTEM_NAME}")
34+
message("-- CMAKE_OSX_ARCHITECTURES \${CMAKE_OSX_ARCHITECTURES}")
3135
set(TARGET_ARCH "APPLE")
3236
set(IOS True)
3337
set(APPLE True)
34-
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
38+
set(CMAKE_SYSTEM_NAME iOS)
39+
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.2" CACHE STRING "Force set of the deployment target for iOS" FORCE)
3540
set(CMAKE_C_FLAGS "\${CMAKE_C_FLAGS} -miphoneos-version-min=10.0")
3641
set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -miphoneos-version-min=10.0 -std=c++11")
3742
set(IOS_PLATFORM "iphonesimulator")
3843
set(CMAKE_SYSTEM_PROCESSOR x86_64)
3944
execute_process(COMMAND xcodebuild -version -sdk \${IOS_PLATFORM} Path
40-
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
45+
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_OUT
4146
ERROR_QUIET
4247
OUTPUT_STRIP_TRAILING_WHITESPACE)
48+
set(CMAKE_OSX_SYSROOT \${CMAKE_OSX_SYSROOT_OUT} CACHE STRING "Force set of the sysroot for iOS" FORCE)
4349
message("-- CMAKE_OSX_SYSROOT \${CMAKE_OSX_SYSROOT}")
4450
elseif(\${ARCH} STREQUAL "arm64")
4551
set(CMAKE_C_FLAGS "\${CMAKE_C_FLAGS} -arch arm64")
@@ -67,6 +73,7 @@ cmake -Dgtest_build_samples=OFF \
6773
-DARCH=$ARCH \
6874
..
6975
make
76+
7077
popd
7178
# CTEST_OUTPUT_ON_FAILURE=1 make test
7279
# make install

build-tests-ios.sh

+7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ SKU=${1:-release}
44
SIMULATOR=${2:-iPhone 8}
55

66
set -e
7+
78
./build-ios.sh ${SKU}
89

10+
# dyld_info /Users/runner/work/cpp_client_telemetry/cpp_client_telemetry/out/lib/libmat.a
11+
912
cd tests/unittests
13+
14+
xcrun simctl list devices available
15+
echo 'End of xcrun simctl list devices available'
16+
1017
xcodebuild test -scheme iOSUnitTests -destination "platform=iOS Simulator,name=$SIMULATOR"
1118

1219
cd ../functests

tests/functests/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ else()
108108
message("Current Dir: ${CMAKE_CURRENT_SOURCE_DIR}")
109109
message("Binary Dir: ${CMAKE_BINARY_DIR}")
110110

111+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
112+
111113
find_file(LIBGTEST
112114
NAMES libgtest.a
113115
PATHS

tests/functests/functests-ios.xcodeproj/project.pbxproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@
317317
GCC_WARN_UNUSED_VARIABLE = YES;
318318
HEADER_SEARCH_PATHS = (
319319
../,
320+
../..,
320321
../../lib/,
321322
../../lib/include/,
322323
../../lib/include/mat/,
@@ -326,7 +327,7 @@
326327
../../third_party/googletest/googlemock/include/,
327328
../common/,
328329
);
329-
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
330+
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
330331
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
331332
MTL_FAST_MATH = YES;
332333
ONLY_ACTIVE_ARCH = NO;
@@ -380,6 +381,7 @@
380381
GCC_WARN_UNUSED_VARIABLE = YES;
381382
HEADER_SEARCH_PATHS = (
382383
../,
384+
../..,
383385
../../lib/,
384386
../../lib/include/,
385387
../../lib/include/mat/,
@@ -389,7 +391,7 @@
389391
../../third_party/googletest/googlemock/include/,
390392
../common/,
391393
);
392-
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
394+
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
393395
MTL_ENABLE_DEBUG_INFO = NO;
394396
MTL_FAST_MATH = YES;
395397
ONLY_ACTIVE_ARCH = YES;

tests/unittests/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ else()
147147

148148
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/ )
149149

150+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
151+
150152
find_file(LIBGTEST
151153
NAMES libgtest.a
152154
PATHS
@@ -159,6 +161,9 @@ else()
159161
${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/googletest/build/lib/
160162
)
161163

164+
message("GTEST: ${LIBGTEST}")
165+
message("GMOCK: ${LIBGMOCK}")
166+
162167
target_link_libraries(UnitTests
163168
${LIBGTEST}
164169
${LIBGMOCK}

0 commit comments

Comments
 (0)