-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert this into a standalone library. (#2)
- Got rid of the nested namespaces in favor of simpler function calls. - Accept a reference to a tatami::Matrix instead of a pointer. - Added an install check workflow.
- Loading branch information
Showing
14 changed files
with
528 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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: Configure the build | ||
run: cmake -S . -B build -DSCRAN_PCA_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_pca) | ||
target_link_libraries(whee libscran::scran_pca) | ||
EOF | ||
cd _downstream && cmake -S . -B build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,77 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project(scran_principal_component_analysis | ||
project(scran_pca | ||
VERSION 1.0.0 | ||
DESCRIPTION "Principal components analysis for single-cell data" | ||
LANGUAGES CXX) | ||
|
||
add_library(scran_principal_component_analysis INTERFACE) | ||
target_compile_features(scran_principal_component_analysis INTERFACE cxx_std_17) | ||
target_include_directories(scran_principal_component_analysis INTERFACE include/scran) | ||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
add_subdirectory(extern) | ||
target_link_libraries(scran_principal_component_analysis INTERFACE scran_core_utils tatami::tatami tatami::tatami_stats ltla::irlba Eigen3::Eigen) | ||
# Library | ||
add_library(scran_pca INTERFACE) | ||
add_library(libscran::scran_pca ALIAS scran_pca) | ||
|
||
target_include_directories(scran_pca INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scran_pca>) | ||
target_compile_features(scran_pca INTERFACE cxx_std_17) | ||
|
||
# Dependencies | ||
option(SCRAN_PCA_FETCH_EXTERN "Automatically fetch scran_pca's external dependencies." ON) | ||
if(SCRAN_PCA_FETCH_EXTERN) | ||
add_subdirectory(extern) | ||
else() | ||
find_package(tatami_tatami 3.0.0 CONFIG REQUIRED) | ||
find_package(tatami_tatami_stats 1.0.0 CONFIG REQUIRED) | ||
find_package(libscran_scran_blocks 1.0.0 CONFIG REQUIRED) | ||
find_package(ltla_irlba 2.0.0 CONFIG REQUIRED) | ||
find_package(Eigen3 3.4.0 REQUIRED NO_MODULE) | ||
endif() | ||
|
||
target_link_libraries( | ||
scran_pca INTERFACE | ||
tatami::tatami | ||
tatami::tatami_stats | ||
libscran::scran_blocks | ||
ltla::irlba | ||
Eigen3::Eigen | ||
) | ||
|
||
# Tests | ||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) | ||
option(SCRAN_PCA_TESTS "Build scran_pca's test suite." ON) | ||
else() | ||
option(SCRAN_PCA_TESTS "Build scran_pca's test suite." OFF) | ||
endif() | ||
|
||
if(SCRAN_PCA_TESTS) | ||
include(CTest) | ||
if(BUILD_TESTING) | ||
add_subdirectory(tests) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
# Install | ||
install(DIRECTORY include/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/scran_pca) | ||
|
||
install(TARGETS scran_pca | ||
EXPORT scran_pcaTargets) | ||
|
||
install(EXPORT scran_pcaTargets | ||
FILE libscran_scran_pcaTargets.cmake | ||
NAMESPACE libscran:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libscran_scran_pca) | ||
|
||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/libscran_scran_pcaConfig.cmake" | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libscran_scran_pca) | ||
|
||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/libscran_scran_pcaConfigVersion.cmake" | ||
COMPATIBILITY SameMajorVersion) | ||
|
||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libscran_scran_pcaConfig.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/libscran_scran_pcaConfigVersion.cmake" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libscran_scran_pca) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include(CMakeFindDependencyMacro) | ||
find_dependency(tatami_tatami 3.0.0 CONFIG REQUIRED) | ||
find_dependency(tatami_tatami_stats 1.0.0 CONFIG REQUIRED) | ||
find_dependency(libscran_scran_blocks 1.0.0 CONFIG REQUIRED) | ||
find_dependency(ltla_irlba 2.0.0 CONFIG REQUIRED) | ||
find_dependency(Eigen3 3.4.0 REQUIRED NO_MODULE) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/libscran_scran_pcaTargets.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.