Skip to content

Commit

Permalink
Add GSL (#13)
Browse files Browse the repository at this point in the history
* Build gsl
* Add gh actions
  • Loading branch information
csparker247 authored Aug 16, 2024
1 parent eee0291 commit 4a70bc4
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 9 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Test build
on:
workflow_dispatch:
push:
branches: ["develop"]
pull_request:
branches:
- "develop"

jobs:
debian:
name: Debian 12
runs-on: ubuntu-latest
container: ghcr.io/educelab/ci-docker:base.12.1
if: ${{ github.event_name }} == "merge_request_event" || !(${{ github.ref }} && $CI_OPEN_MERGE_REQUESTS) || ${{ github.ref }}
timeout-minutes: 180
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build vc-deps
run: |
cmake -S . -B build/ -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_MESSAGE=NEVER
cmake --build build/
macos:
name: macOS
runs-on: macos-14
timeout-minutes: 180
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Homebrew dependencies
run: |
brew update
brew unlink libtiff libpng
brew install ninja
- name: Remove conflicting packages
run: |
sudo rm -rf /Library/Frameworks/Mono.framework/
- name: Use the Command Line Tools
run: |
sudo xcode-select -s /Library/Developer/CommandLineTools
- name: Build vc-deps
run: |
cmake -S . -B build/ -GNinja -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_MESSAGE=NEVER
cmake --build build/
macos_universal:
name: macOS Universal
runs-on: macos-14
timeout-minutes: 180
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Homebrew dependencies
run: |
brew update
brew unlink libtiff libpng
brew install ninja
- name: Remove conflicting packages
run: |
sudo rm -rf /Library/Frameworks/Mono.framework/
- name: Use the Command Line Tools
run: |
sudo xcode-select -s /Library/Developer/CommandLineTools
- name: Build vc-deps
run: |
cmake -S . -B build/ -GNinja -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_MACOS_MULTIARCH=ON -DCMAKE_INSTALL_MESSAGE=NEVER
cmake --build build/
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ endif()
# include(InstallSDK-macOS)

#### Required libs ####
# gsl
include(BuildGSL)

# zlib
include(BuildZLIB)

Expand Down
18 changes: 9 additions & 9 deletions cmake/BuildBoost.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
option(VCDEPS_BUILD_BOOST "Build Boost" ON)

# Required Boost components
set(VCDEPS_BOOST_COMPONENTS
program_options
system
)

if(VCDEPS_BUILD_BOOST)
string(REPLACE ";" "," BOOST_BUILD_LIBS "${VCDEPS_BOOST_COMPONENTS}")

# Set Boost build type to match provided release type
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(BOOST_LIB_TYPE debug)
Expand Down Expand Up @@ -33,15 +42,6 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
endif()
set(BOOST_TOOLSET ${BOOST_TOOLSET_AUTO} CACHE STRING "Boost Build toolset")

# Required Boost components
set(VCDEPS_BOOST_COMPONENTS
program_options
system
)

if(VCDEPS_BUILD_BOOST)
string(REPLACE ";" "," BOOST_BUILD_LIBS "${VCDEPS_BOOST_COMPONENTS}")

# Compiler flags
set(BOOST_CXX_FLAGS "cxxflags=-std=c++${CMAKE_CXX_STANDARD} ${BOOST_ARCH}")

Expand Down
36 changes: 36 additions & 0 deletions cmake/BuildGSL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
option(VCDEPS_BUILD_GSL "Build GNU Scientific Library" ON)

if(VCDEPS_BUILD_GSL)
# make sure the prefix is an absolute path
file(REAL_PATH ${CMAKE_INSTALL_PREFIX} GSL_INSTALL_PREFIX EXPAND_TILDE)

# enable PIC
if(CMAKE_POSITION_INDEPENDENT_CODE)
set(GSL_WITH_PIC "--with-pic")
endif()

# (macOS) universal libraries
if(BUILD_MACOS_MULTIARCH)
set(GSL_CFLAGS "-arch x86_64 -arch arm64")
endif()

# build and install
externalproject_add(
gsl
DEPENDS ${GLOBAL_DEPENDS}
URL https://ftpmirror.gnu.org/gsl/gsl-2.8.tar.gz
URL_HASH SHA512=4427f6ce59dc14eabd6d31ef1fcac1849b4d7357faf48873aef642464ddf21cc9b500d516f08b410f02a2daa9a6ff30220f3995584b0a6ae2f73c522d1abb66b
DOWNLOAD_NO_PROGRESS true
DOWNLOAD_EXTRACT_TIMESTAMP ON
PATCH_COMMAND ${GSL_PATCH_CMD}
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env CFLAGS=${GSL_CFLAGS}
./configure --prefix=${GSL_INSTALL_PREFIX} ${GSL_WITH_PIC}
BUILD_COMMAND make && make install
BUILD_IN_SOURCE true
INSTALL_COMMAND ""
)

else()
add_custom_target(gsl)
endif()

0 comments on commit 4a70bc4

Please sign in to comment.