Skip to content

Commit

Permalink
Added buildable MDIO and config
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMichell committed Jul 31, 2024
1 parent 1d13ec3 commit 5e07afd
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 44 deletions.
3 changes: 3 additions & 0 deletions cmake/mdioConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/mdioTargets.cmake")
135 changes: 91 additions & 44 deletions mdio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,107 @@ FIND_PACKAGE(nlohmann_json_schema_validator)

# ============ Installable library ============

# Define the header-only library
# # Define the header-only library
# add_library(mdio INTERFACE)

# # Specify include directories
# target_include_directories(mdio
# INTERFACE
# $<INSTALL_INTERFACE:include> # for clients using the installed library
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # for building the library itself
# )

# # Link dependencies
# target_link_libraries(mdio
# INTERFACE
# GTest::gmock_main
# tensorstore::driver_array
# tensorstore::driver_zarr
# tensorstore::driver_json
# tensorstore::kvstore_file
# tensorstore::kvstore_memory
# tensorstore::tensorstore
# tensorstore::index_space_dim_expression
# tensorstore::index_space_index_transform
# tensorstore::util_status_testutil
# nlohmann_json_schema_validator
# tensorstore::kvstore_gcs
# )

# # Specify install rules
# install(TARGETS mdio
# EXPORT mdioTargets
# INCLUDES DESTINATION include
# )

# # This make the project importable from the install directory
# # Put config file in per-project dir (name MUST match)
# install(EXPORT mdioTargets
# FILE
# mdioTargets.cmake
# NAMESPACE
# mdio::
# DESTINATION
# lib/cmake/mdio
# )

# # This makes the project importable from the build directory
# export(TARGETS mdio FILE mdioTargets.cmake)

# # Install the header files
# install(DIRECTORY include/ DESTINATION include)

# # Make sure the fiels are installed while building
# add_custom_target(install_${PROJECT_NAME}
# ${CMAKE_COMMAND} -DCOMPONENT=${PROJECT_NAME}
# -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
# )

project(mdio VERSION 1.0.0 LANGUAGES CXX)

# Create the interface library
add_library(mdio INTERFACE)

# Specify include directories
target_include_directories(mdio
INTERFACE
$<INSTALL_INTERFACE:include> # for clients using the installed library
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # for building the library itself
# Specify the include directories for the interface library
target_include_directories(mdio INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

# Link dependencies
target_link_libraries(mdio
INTERFACE
GTest::gmock_main
tensorstore::driver_array
tensorstore::driver_zarr
tensorstore::driver_json
tensorstore::kvstore_file
tensorstore::kvstore_memory
tensorstore::tensorstore
tensorstore::index_space_dim_expression
tensorstore::index_space_index_transform
tensorstore::util_status_testutil
nlohmann_json_schema_validator
tensorstore::kvstore_gcs
)
# Set the C++ standard
target_compile_features(mdio INTERFACE cxx_std_11)

# Specify install rules
install(TARGETS mdio
EXPORT mdioTargets
INCLUDES DESTINATION include
)
# Install targets
install(TARGETS mdio EXPORT mdioTargets)
install(DIRECTORY include/ DESTINATION include)

# This make the project importable from the install directory
# Put config file in per-project dir (name MUST match)
install(EXPORT mdioTargets
FILE
mdioTargets.cmake
NAMESPACE
mdio::
DESTINATION
lib/cmake/mdio
# Export the targets to be used with FetchContent
export(EXPORT mdioTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/mdioTargets.cmake" NAMESPACE mdio::)

# Create a package configuration file for find_package
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mdioConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

# This makes the project importable from the build directory
export(TARGETS mdio FILE mdioTargets.cmake)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/../cmake/mdioConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/mdioConfig.cmake"
INSTALL_DESTINATION lib/cmake/mdio
)

# Install the header files
install(DIRECTORY include/ DESTINATION include)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/mdioConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/mdioConfigVersion.cmake"
DESTINATION lib/cmake/mdio
)

# Make sure the fiels are installed while building
add_custom_target(install_${PROJECT_NAME}
${CMAKE_COMMAND} -DCOMPONENT=${PROJECT_NAME}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
install(EXPORT mdioTargets
FILE mdioTargets.cmake
NAMESPACE mdio::
DESTINATION lib/cmake/mdio
)

# ============ End installable library ============
Expand Down

0 comments on commit 5e07afd

Please sign in to comment.