Skip to content

Commit

Permalink
Added an install check action, fixed the CMake variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jul 16, 2024
1 parent 9bed220 commit a21a31d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 7 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/check-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
push:
branches:
- master
pull_request:

name: Check CMake install

jobs:
install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Get latest CMake
uses: lukka/get-cmake@latest

- name: Cache installed igraph
id: cache-igraph
if: ${{ matrix.config.os == 'ubuntu-latest' }}
uses: actions/cache@v4
with:
path: _deps
key: libigraph

- name: Make and install igraph
if: ${{ matrix.config.os == 'ubuntu-latest' && steps.cache-igraph.outputs.cache-hit != 'true' }}
run: |
version=0.10.13
path=$(pwd)
wget https://github.com/igraph/igraph/releases/download/${version}/igraph-${version}.tar.gz
tar -xf igraph-${version}.tar.gz
cd igraph-${version}
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${path}/_deps
cmake --build .
sudo cmake --install .
- name: Configure the build
run: cmake -S . -B build -DSCRAN_GRAPH_CLUSTER_TESTS=OFF

- name: Install the library
run: sudo cmake --install build

- name: Test downstream usage
run: |
mkdir _downstream
touch _downstream/source.cpp
cat << EOF > _downstream/CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(test_install)
add_executable(whee source.cpp)
find_package(libscran_scran_graph_cluster)
target_link_libraries(whee libscran::scran_graph_cluster)
EOF
cd _downstream && cmake -S . -B build
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ target_include_directories(scran_graph_cluster INTERFACE
target_compile_features(scran_graph_cluster INTERFACE cxx_std_17)

# Dependencies
option(SCRAN_MARKERS_FETCH_EXTERN "Automatically fetch scran_graph_cluster's external dependencies (except for igraph)." ON)
option(SCRAN_MARKERS_FETCH_EXTERN_IGRAPH "Automatically fetch scran_graph_cluster's external igraph dependency." OFF)
option(SCRAN_GRAPH_CLUSTER_FETCH_EXTERN "Automatically fetch scran_graph_cluster's external dependencies (except for igraph)." ON)
option(SCRAN_GRAPH_CLUSTER_FETCH_EXTERN_IGRAPH "Automatically fetch scran_graph_cluster's external igraph dependency." OFF)

if (NOT SCRAN_MARKERS_FETCH_EXTERN_IGRAPH)
if (NOT SCRAN_GRAPH_CLUSTER_FETCH_EXTERN_IGRAPH)
# igraph needs compilation so we just try to get it from the system by
# default, rather than pulling it down and building the whole thing.
find_package(igraph 0.10.0 CONFIG REQUIRED)
endif()

if(SCRAN_MARKERS_FETCH_EXTERN)
if(SCRAN_GRAPH_CLUSTER_FETCH_EXTERN)
add_subdirectory(extern)
else()
find_package(ltla_raiigraph 1.0.0 CONFIG REQUIRED)
Expand All @@ -35,12 +35,12 @@ target_link_libraries(scran_graph_cluster INTERFACE igraph::igraph ltla::raiigra

# Tests
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
option(SCRAN_MARKERS_TESTS "Build scran_graph_cluster's test suite." ON)
option(SCRAN_GRAPH_CLUSTER_TESTS "Build scran_graph_cluster's test suite." ON)
else()
option(SCRAN_MARKERS_TESTS "Build scran_graph_cluster's test suite." OFF)
option(SCRAN_GRAPH_CLUSTER_TESTS "Build scran_graph_cluster's test suite." OFF)
endif()

if(SCRAN_MARKERS_TESTS)
if(SCRAN_GRAPH_CLUSTER_TESTS)
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
Expand Down

0 comments on commit a21a31d

Please sign in to comment.