Skip to content

Commit

Permalink
(feature) Use vcpkg, add CI
Browse files Browse the repository at this point in the history
Deprecate Travis-CI and AppVeyor, for now.
  • Loading branch information
acgetchell committed Mar 5, 2022
1 parent 2e15443 commit 4b1f168
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 193 deletions.
53 changes: 0 additions & 53 deletions .appveyor.yml

This file was deleted.

19 changes: 9 additions & 10 deletions .github/workflows/linux-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ jobs:
- name: Setup
run: |
sudo apt update
sudo apt-get install ninja-build ccache
sudo apt-get install build-essential ninja-build ccache
- uses: eic/setup-cvmfs@main
- uses: eic/setup-spack@main
- name: Restore artifacts, or setup vcpkg
uses: lukka/run-vcpkg@v10
with:
vcpkgGitCommitId: bd602277bf7fc3188b3d086b302c6840464db900

- name: Install spack packages and configure CMake
- name: Install vcpkg packages and configure CMake
shell: bash
run: |
spack install boost
spack install catch2
spack load boost
spack load catch2
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D ENABLE_TESTING:BOOL=TRUE -S . -B build
vcpkg install --feature-flags=manifests
cmake -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -S . -B build
- name: Build
run: cmake --build build
29 changes: 29 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: macOS

on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- name: Setup
run: |
brew install ninja ccache
- name: Restore artifacts, or setup vcpkg
uses: lukka/run-vcpkg@v10
with:
vcpkgGitCommitId: bd602277bf7fc3188b3d086b302c6840464db900

- name: Install vcpkg packages and configure CMake
shell: bash
run: |
vcpkg install --feature-flags=manifests
cmake -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -S . -B build
- name: Build
run: cmake --build build
31 changes: 31 additions & 0 deletions .github/workflows/windows-msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Windows

on: [workflow_dispatch]

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- name: Setup Clang
uses: egor-tensin/setup-clang@v1
with:
version: 13
platform: x64

- name: Restore artifacts, or setup vcpkg
uses: lukka/run-vcpkg@v10
with:
vcpkgGitCommitId: bd602277bf7fc3188b3d086b302c6840464db900

- name: Install vcpkg packages and configure CMake
run: |
vcpkg install --feature-flags=manifests
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -S . -B build
- name: Build
run: cmake --build build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
build/*
xcode/*
cmake-build-debug/*
vcpkg_installed/*

# MacOS cruft
*.DS_Store
Expand Down
92 changes: 0 additions & 92 deletions .travis.yml

This file was deleted.

32 changes: 30 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.16)

# vcpkg settings must be set before project()
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()

# In Manifest mode CMake invokes vcpkg automatically This makes setup easier, however, in CI or Docker we may want to
# turn this off
option(VCPKG_MANIFEST_MODE "Build vcpkg ports from manifest" ON)

# Ensure we install vcpkg ports in the same place so they can be reused between builds
set(_VCPKG_INSTALLED_DIR
"${CMAKE_CURRENT_LIST_DIR}/vcpkg_installed"
CACHE STRING "")

project(causal_sets_explorer VERSION 0.1.2 LANGUAGES CXX)

cmake_policy(SET CMP0127 NEW)

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Do not build in-source.
Please remove CMakeCache.txt and the CMakeFiles/ directory. Then build out-of-source.")
Expand All @@ -15,8 +33,18 @@ set(CMAKE_CXX_EXTENSIONS OFF)
#Disable CLion generation of RelWithDebInfo and MinSizeRel, et.al
set(CMAKE_CONFIGURATION_TYPES "Release" "Debug" CACHE STRING "" FORCE)

if(ENABLE_CLANG_TIDY)
find_program(CLANGTIDY clang-tidy)
if(CLANGTIDY)
set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY} -extra-arg=-Wno-unknown-warning-option)
message(STATUS "Clang-tidy enabled.")
else()
message(SEND_ERROR "clang-tidy requested but executable not found")
endif()
endif()

#Extra warnings
#add_definitions(-Wall)
add_definitions(-Wall)

find_package(Boost REQUIRED COMPONENTS graph)
include_directories( ${Boost_INCLUDE_DIRS} )
Expand Down
46 changes: 14 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,33 @@
# causal-sets-explorer
[![Build Status](https://img.shields.io/travis/acgetchell/causal-sets-explorer.svg?label=Linux/MacOS)](https://travis-ci.org/acgetchell/causal-sets-explorer)
[![Windows Build status](https://img.shields.io/appveyor/ci/acgetchell/causal-sets-explorer/master.svg?label=Windows)](https://ci.appveyor.com/project/acgetchell/causal-sets-explorer)
[![Linux Clang](https://github.com/acgetchell/causal-sets-explorer/actions/workflows/linux-clang.yml/badge.svg)](https://github.com/acgetchell/causal-sets-explorer/actions/workflows/linux-clang.yml)

[Causal sets][causets] explorer will eventually perform graph-theoretic calculations on Causal sets.

It's also a test-bed for [CDT-plusplus].

## Initial Set Up
This project uses [Spack].
To get started, first install `Spack`.
This project uses [vcpkg].
To get started, first install `vcpkg`.

~~~
git clone https://github.com/spack/spack.git
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
~~~

You'll need to add `Spack` to your environment, e.g. in `.zshrc` append:
[vcpkg] is then invoked by [CMake] in [vcpkg manifest][vcpkg-manifest] mode to install project dependencies listed in `vcpkg.json` into the local `vcpkg_installed` directory.

~~~
. ~/projects/spack/share/spack/setup-env.sh
~~~

(Or wherever you cloned `Spack`). Next, clone this repo:
Next, clone this repo:

~~~
git clone https://github.com/acgetchell/causal-sets-explorer.git
cd causal-sets-explorer
~~~

Now we'll install a dependencies:
~~~
spack install boost
spack install catch2
~~~

And then load into our `$CMAKE_PREFIX_PATH`:

~~~
spack load boost
spack load catch2
~~~

Verify you have the dependencies installed:

Now we'll install dependencies:
~~~
$ spack find
==> 14 installed packages
-- darwin-monterey-skylake / apple-clang@13.0.0 -----------------
berkeley-db@18.1.40 boost@1.77.0 bzip2@1.0.8 catch2@2.13.7 cmake@3.21.4 diffutils@3.8 gdbm@1.19 libiconv@1.16 ncurses@6.2 openssl@1.1.1l perl@5.34.0 pkgconf@1.8.0 readline@8.1 zlib@1.2.11
vcpkg install --feature-flags=manifests
~~~

Finally, you can build with `CMake`:
Expand All @@ -70,4 +50,6 @@ This is mostly automated in `scripts/build.sh`.

[causets]: https://en.wikipedia.org/wiki/Causal_sets
[cdt-plusplus]: https://github.com/acgetchell/CDT-plusplus
[Spack]: https://spack.io
[vcpkg]: https://vcpkg.io/en/index.html
[CMake]: https://cmake.org
[vcpkg-manifest]: https://github.com/microsoft/vcpkg/blob/master/docs/users/manifests.md
9 changes: 5 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
spack load boost
spack load catch2

cd ..
rm -rf build/
cmake -D CMAKE_BUILD_TYPE=Release -S . -B build
cmake --build build
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -S . -B build
cmake --build build
cd build || exit
ctest --output-on-failure -j2
9 changes: 9 additions & 0 deletions scripts/clang-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# Before running this script, make sure $VCPKG_ROOT is set, e.g.
# VCPKG_ROOT="$HOME"/vcpkg && export VCPKG_ROOT

cd ..
rm -rf build/
cmake -S . -B build -G Ninja -D ENABLE_CLANG_TIDY=ON
cmake --build build
Loading

0 comments on commit 4b1f168

Please sign in to comment.