Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplatform support #41

Merged
merged 21 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# version format
version: 0.1.0.{build}

# Build worker image (VM template)
image: Visual Studio 2017

# clone directory
clone_folder: C:\projects\SIRIUS

# build platform, i.e. x86, x64, Any CPU. This setting is optional.
platform: x64

# build Configuration, i.e. Debug, Release, etc.
configuration: Release

# environment variables
environment:
VCPKG_DIR: C:/Tools/vcpkg
VCPKG_TRIPLET: x64-windows-release
CMAKE_GENERATOR: Visual Studio 15 2017 Win64

# scripts that run after cloning repository
install:
# check if cache exists
- IF EXIST %VCPKG_DIR%\installed (set CACHE_EXISTS=1) ELSE (set CACHE_EXISTS=0)
# if the cache exists, CI will skip install scripts
- IF "%CACHE_EXISTS%"=="1" appveyor AddMessage "Project cache exists. Skipping install scripts. Delete the cache (REST API) and re-build the commit to update cached dependencies." -Category Warning
# if the cache does not exist, this build will only generate the project cache (fftw3 and gdal dependencies)
- IF "%CACHE_EXISTS%"=="0" appveyor AddMessage "This build will only generate the project cache (fftw3 and gdal dependencies)" -Category Warning
- IF "%CACHE_EXISTS%"=="0" .appveyor\windows\install.cmd
# terminate current build with success if cache did not exist
# this build should only create the cache since dependencies build time is quite long (~50min) and cache must be saved before AppVeyor timeout (1h)
# re-build the commit to actually build the project and run its tests
- IF "%CACHE_EXISTS%"=="0" appveyor AddMessage "This build only generated the project cache (fftw3 and gdal dependencies). Re-build the commit to actually build the project and run its tests" -Category Warning
- IF "%CACHE_EXISTS%"=="0" appveyor exit

before_build:
- cd %APPVEYOR_BUILD_FOLDER%
- git fetch --tags
- mkdir %APPVEYOR_BUILD_FOLDER%\.build
- mkdir %APPVEYOR_BUILD_FOLDER%\.build-static-runtime
- mkdir %APPVEYOR_BUILD_FOLDER%\.install-directory
- cd %APPVEYOR_BUILD_FOLDER%/.build
- appveyor AddMessage "Creating Sirius Visual Studio solution..."
- cmake .. -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%/scripts/buildsystems/vcpkg.cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%/.install-directory -DENABLE_CACHE_OPTIMIZATION=ON -DENABLE_GSL_CONTRACTS=ON -DENABLE_LOGS=ON -DBUILD_TESTING=ON -DENABLE_DOCUMENTATION=OFF
- cd %APPVEYOR_BUILD_FOLDER%/.build-static-runtime
- appveyor AddMessage "Creating Sirius Visual Studio solution (static runtime)..."
- cmake .. -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%/scripts/buildsystems/vcpkg.cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%/.install-directory -DENABLE_CACHE_OPTIMIZATION=ON -DENABLE_GSL_CONTRACTS=ON -DENABLE_LOGS=ON -DBUILD_TESTING=ON -DENABLE_DOCUMENTATION=OFF -DUSE_CXX_STATIC_RUNTIME=ON

build: Script

build_script:
- cd %APPVEYOR_BUILD_FOLDER%/.build
- appveyor AddMessage "Building sirius shared library..."
- cmake --build . --target libsirius --config %configuration% -- /m
- appveyor AddMessage "Building sirius static library..."
- cmake --build . --target libsirius-static --config %configuration% -- /m
- appveyor AddMessage "Building tests..."
- cmake --build . --target build_tests --config %configuration% -- /m
- appveyor AddMessage "Building sirius executable..."
- cmake --build . --target sirius --config %configuration% -- /m
- appveyor AddMessage "Installing sirius..."
- cmake --build . --target install --config %configuration% -- /m
- cd %APPVEYOR_BUILD_FOLDER%/.build-static-runtime
- appveyor AddMessage "Compiling sirius (static runtime)..."
- cmake --build . --target sirius --config %configuration% -- /m

test_script:
- cd %APPVEYOR_BUILD_FOLDER%/.build
- appveyor AddMessage "Running tests..."
- ctest -C %configuration% --output-on-failure
- appveyor AddMessage "Running sirius..."
- bin\sirius.exe -h
- bin\sirius.exe -v trace -r 2 ..\data\input\lena.jpg lena_z2.tif
- appveyor AddMessage "Testing find_package(SIRIUS)..."
- mkdir %APPVEYOR_BUILD_FOLDER%\.build-test-find-package
- cd %APPVEYOR_BUILD_FOLDER%\.build-test-find-package
- cmake ..\tests\find-package-test -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%/scripts/buildsystems/vcpkg.cmake -G "%CMAKE_GENERATOR%" -DSIRIUS_ROOT=%APPVEYOR_BUILD_FOLDER%/.install-directory -DENABLE_FIND_PACKAGE_SIRIUS_CONFIG=OFF
- cmake --build . --config %configuration% -- /m
- Release\basic_sirius_static_test.exe
- appveyor AddMessage "Testing find_package(SIRIUS CONFIG)..."
- mkdir %APPVEYOR_BUILD_FOLDER%\.build-test-find-package-config
- cd %APPVEYOR_BUILD_FOLDER%\.build-test-find-package-config
- cmake ..\tests\find-package-test -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%/scripts/buildsystems/vcpkg.cmake -G "%CMAKE_GENERATOR%" -DSIRIUS_DIR=%APPVEYOR_BUILD_FOLDER%/.install-directory/share/cmake -DENABLE_FIND_PACKAGE_SIRIUS_CONFIG=ON
- cmake --build . --config %configuration% -- /m
- Release\basic_sirius_static_test.exe

# to disable deployment
deploy: off

# build cache to preserve files/folders between builds
# workaround to clear cache: https://github.com/appveyor/ci/issues/985
cache:
- c:\tools\vcpkg\installed\
10 changes: 10 additions & 0 deletions .appveyor/vcpkg/triplets/x64-windows-release.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This vcpkg triplet is specialized to reduce build time for SIRIUS dependencies
# Appveyor build timeout is 1h and gdal and its dependencies take a long time to build...

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

# do not build debug version for packages (save space and build time for CI)
# see also: https://github.com/Microsoft/vcpkg/issues/143
set(VCPKG_BUILD_TYPE release)
32 changes: 32 additions & 0 deletions .appveyor/windows/install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo on

cd %VCPKG_DIR%

appveyor AddMessage "Updating vcpkg knowledge base..."
:: update vcpkg knowledge base
git pull

:: need to execute bootstrapping in a new process since it exits the current cmd process at the end of its execution...
cmd.exe /C "bootstrap-vcpkg.bat -disableMetrics" || goto error
appveyor AddMessage "Updating vcpkg knowledge base done"

:: force release version of the dependencies with vcpkg triplet (VCPKG_BUILD_TYPE="release") to
:: * reduce compilation time (appveyor timeout is 1h)
:: * reduce disk space for dependencies cache
copy "%APPVEYOR_BUILD_FOLDER%\.appveyor\vcpkg\triplets\%VCPKG_TRIPLET%.cmake" "%VCPKG_DIR%\triplets" || goto error
:: install fftw3 and gdal packages
:: force x64 build due to gdal package only available for x64 (libmysql only available for x64)
appveyor AddMessage "Installing FFTW3 dependency..."
vcpkg install fftw3:%VCPKG_TRIPLET% || goto error
appveyor AddMessage "Installing FFTW3 dependency done"

appveyor AddMessage "Installing GDAL dependency..."
vcpkg install gdal[core,mysql-libmariadb]:%VCPKG_TRIPLET% || goto error
appveyor AddMessage "Installing GDAL dependency done"

exit /b 0

:error
set cmd_errorlevel=%errorlevel%
appveyor AddMessage "Dependencies were not generated. Check the logs and fix vcpkg generation" -Category Error
exit /b %cmd_errorlevel%
Loading