From e9bf49b7cac5201ae473a4ecf24216300b250491 Mon Sep 17 00:00:00 2001 From: LTLA Date: Mon, 15 Jul 2024 22:05:06 -0700 Subject: [PATCH] Added an install check action, fixed CMake variables and versions. --- .github/workflows/check-install.yaml | 57 ++++++++++++++++++++++++++++ CMakeLists.txt | 14 +++---- cmake/Config.cmake.in | 2 +- 3 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/check-install.yaml diff --git a/.github/workflows/check-install.yaml b/.github/workflows/check-install.yaml new file mode 100644 index 0000000..fa778ae --- /dev/null +++ b/.github/workflows/check-install.yaml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index a337b45..cbaf742 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in index be98e37..1c4ff17 100644 --- a/cmake/Config.cmake.in +++ b/cmake/Config.cmake.in @@ -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")