Skip to content

Commit

Permalink
Added an install check action, fixed CMake variables and versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jul 16, 2024
1 parent 9bed220 commit d09a7d3
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 9 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
uses: actions/cache@v4
with:
path: _deps
key: libigraph

- name: Make and install igraph
if: ${{ 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 -DCMAKE_PREFIX_PATH=_deps

- 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
wd=$(pwd)
cd _downstream && cmake -S . -B build -DCMAKE_PREFIX_PATH=${wd}/_deps
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
4 changes: 2 additions & 2 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include(CMakeFindDependencyMacro)
find_dependency(knncolle_knncolle 2.0.0 CONFIG REQUIRED)
find_dependency(igraph 0.1.0 CONFIG REQUIRED)
find_dependency(igraph 0.10.0 CONFIG REQUIRED)
find_dependency(ltla_raiigraph 1.0.0 CONFIG REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/libscran_scran_graph_cluster.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/libscran_scran_graph_clusterTargets.cmake")

0 comments on commit d09a7d3

Please sign in to comment.