Skip to content

Commit

Permalink
Fixes to the CMake files for downstream dependencies. (#14)
Browse files Browse the repository at this point in the history
- Fixed the variable names for turning off tests, extern fetching.
- Conditionally register HDF5 as a transitive dependency.
- Bumped version to publish a new release.
  • Loading branch information
LTLA authored Aug 8, 2023
1 parent e1dc82e commit 407dcaa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
cmake -S . -B build -DTATAMI_CHUNKED_TESTS=OFF
sudo cmake --install build
- name: Install HDF5
run: sudo apt-get install libhdf5-dev

- name: Configure the build
run: cmake -S . -B build -DTATAMI_HDF5_FETCH_EXTERN=OFF -DTATAMI_HDF5_TESTS=OFF

Expand Down
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.24)

project(tatami_hdf5
VERSION 1.0.1
VERSION 1.0.2
DESCRIPTION "tatami bindings for HDF5"
LANGUAGES CXX)

Expand All @@ -10,11 +10,11 @@ set(CMAKE_CXX_STANDARD 17)
add_library(tatami_hdf5 INTERFACE)
add_library(tatami::tatami_hdf5 ALIAS tatami_hdf5)

option(TATAMI_CHUNKED_FETCH_EXTERN "Automatically fetch tatami_hdf5's external dependencies." ON)
if(TATAMI_CHUNKED_FETCH_EXTERN)
option(TATAMI_HDF5_FETCH_EXTERN "Automatically fetch tatami_hdf5's external dependencies." ON)
if(TATAMI_HDF5_FETCH_EXTERN)
add_subdirectory(extern)
else()
find_package(tatami_chunked CONFIG REQUIRED)
find_package(tatami_tatami_chunked CONFIG REQUIRED)
endif()

target_link_libraries(tatami_hdf5 INTERFACE tatami::tatami_chunked)
Expand All @@ -29,6 +29,7 @@ endif()

# Switch between include directories depending on whether the downstream is
# using the build directly or is using the installed package.
include(GNUInstallDirs)
target_include_directories(tatami_hdf5
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
Expand All @@ -37,12 +38,12 @@ target_include_directories(tatami_hdf5

# Building the test-related machinery, if we are compiling this library directly.
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
option(TATAMI_HDF5 "Build tatami_hdf5's test suite." ON)
option(TATAMI_HDF5_TESTS "Build tatami_hdf5's test suite." ON)
else()
option(TATAMI_HDF5 "Build tatami_hdf5's test suite." OFF)
option(TATAMI_HDF5_TESTS "Build tatami_hdf5's test suite." OFF)
endif()

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
if(TATAMI_HDF5_TESTS)
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
Expand Down
5 changes: 5 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

include(CMakeFindDependencyMacro)
find_dependency(tatami_tatami_chunked CONFIG REQUIRED)
if(@TATAMI_HDF5_FIND_HDF5@)
# Not REQUIRED, so don't use find_dependency according to
# https://stackoverflow.com/questions/64846805/how-do-i-specify-an-optional-dependency-in-a-cmake-package-configuration-file
find_package(HDF5 COMPONENTS C CXX)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/tatami_tatami_hdf5Targets.cmake")

0 comments on commit 407dcaa

Please sign in to comment.