Skip to content

Commit 4f85cb9

Browse files
committed
Added GitHub Actions MacOS builds
Build for Ubuntu and MacOS with both dynamic and static linking
1 parent 91f124a commit 4f85cb9

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

.github/workflows/cmake.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ env:
88

99
jobs:
1010
build:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest]
14+
linkage: [dynamic, static]
15+
1116
# The CMake configure and build commands are platform agnostic and should work equally
1217
# well on Windows or Mac. You can convert this to a matrix build if you need
1318
# cross-platform coverage.
1419
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
15-
runs-on: ubuntu-latest
20+
runs-on: ${{matrix.os}}
1621

1722
steps:
1823
- uses: actions/checkout@v2
@@ -22,11 +27,22 @@ jobs:
2227
# We'll use this as our working directory for all subsequent commands
2328
run: cmake -E make_directory ${{github.workspace}}/build
2429

25-
- name: Install dependencies
30+
- name: Install dependencies (Ubuntu)
31+
if: ${{matrix.os == 'ubuntu-latest'}}
2632
run: |
2733
sudo apt-get remove nginx libgd3
2834
sudo apt-get install libmad0-dev libid3tag0-dev libsndfile1-dev libgd-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev
2935
36+
- name: Install dependencies (MacOS)
37+
if: ${{matrix.os == 'macos-latest' && matrix.linkage == 'dynamic'}}
38+
run: |
39+
brew install mad libgd boost libpng zlib libsndfile libid3tag
40+
41+
- name: Install dependencies (MacOS)
42+
if: ${{matrix.os == 'macos-latest' && matrix.linkage == 'static'}}
43+
run: |
44+
brew install mad libgd boost libpng zlib
45+
3046
- name: Install Googletest
3147
shell: bash
3248
working-directory: ${{github.workspace}}
@@ -35,6 +51,28 @@ jobs:
3551
tar xzf release-1.12.1.tar.gz
3652
ln -s googletest-release-1.12.1 googletest
3753
54+
- name: Install libsndfile
55+
if: ${{matrix.os == 'macos-latest' && matrix.linkage == 'static'}}
56+
run: |
57+
wget https://github.com/libsndfile/libsndfile/archive/refs/tags/1.1.0.tar.gz
58+
tar xzf 1.1.0.tar.gz
59+
cd libsndfile-1.1.0
60+
mkdir build
61+
cd build
62+
cmake -D ENABLE_MPEG=0 -D ENABLE_TESTING=0 -D BUILD_SHARED_LIBS=0 -D BUILD_REGTEST=0 -D BUILD_PROGRAMS=0 -D BUILD_TESTING=0 -D BUILD_EXAMPLES=0 ..
63+
make
64+
make install
65+
66+
- name: Install libid3tag
67+
if: ${{matrix.os == 'macos-latest' && matrix.linkage == 'static'}}
68+
run: |
69+
wget http://sourceforge.net/projects/mad/files/libid3tag/0.15.1b/libid3tag-0.15.1b.tar.gz
70+
tar xzf libid3tag-0.15.1b.tar.gz
71+
cd libid3tag-0.15.1b
72+
./configure --enable-static
73+
make
74+
make install
75+
3876
- name: Configure CMake
3977
# Use a bash shell so we can use the same syntax for environment variable
4078
# access regardless of the host operating system
@@ -43,13 +81,15 @@ jobs:
4381
# Note the current convention is to use the -S and -B options here to specify source
4482
# and build directories, but this is only available with CMake 3.13 and higher.
4583
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
46-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
84+
run: cmake $GITHUB_WORKSPACE -D CMAKE_BUILD_TYPE=$BUILD_TYPE -D BUILD_STATIC=${{matrix.linkage == 'static'}}
4785

4886
- name: Build
4987
working-directory: ${{github.workspace}}/build
5088
shell: bash
5189
# Execute the build. You can specify a specific target with "--target <NAME>"
52-
run: cmake --build . --config $BUILD_TYPE
90+
run: |
91+
export LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/icu4c/lib
92+
cmake --build . --config $BUILD_TYPE
5393
5494
- name: Test
5595
working-directory: ${{github.workspace}}/build

CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ if(BUILD_STATIC)
7878
set(Boost_USE_STATIC_RUNTIME OFF)
7979
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
8080
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
81+
82+
if(APPLE)
83+
message(STATUS "Set ZLIB_ROOT for MacOS builds")
84+
cmake_policy(SET CMP0074 NEW)
85+
set(ZLIB_ROOT "/usr/local/opt/zlib")
86+
endif()
8187
endif()
8288
endif(BUILD_STATIC)
8389

@@ -200,8 +206,9 @@ set(COMMON_FLAGS "-Wall -Wextra -Wconversion -pedantic")
200206
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -DBOOST_FILESYSTEM_NO_DEPRECATED")
201207
set(CMAKE_C_FLAGS ${COMMON_FLAGS})
202208

203-
if(APPLE)
204-
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
209+
if(APPLE AND BUILD_STATIC)
210+
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
211+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
205212
endif()
206213

207214
message(STATUS "CMAKE_CXX_COMPILER_VERSION='${CMAKE_CXX_COMPILER_VERSION}'")
@@ -271,8 +278,7 @@ add_executable(audiowaveform ${SRCS})
271278
#-------------------------------------------------------------------------------
272279

273280
# Specify libraries to link against.
274-
set(
275-
LIBS
281+
set(LIBS
276282
${LIBSNDFILE_LIBRARIES}
277283
${LIBGD_LIBRARIES}
278284
${LIBMAD_LIBRARIES}

0 commit comments

Comments
 (0)