diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe5450..68807b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.20.1 - 2024-07-16 + +### Enhancements +- Improved installation with `CMake`: license is now installed, transitive dependencies are configured + when importing package + ## 0.20.0 - 2024-07-09 This release adds support for encoding DBN within the C++ client. diff --git a/CMakeLists.txt b/CMakeLists.txt index e96ecc0..bed28fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14) # Project details # -project("databento" VERSION 0.20.0 LANGUAGES CXX) +project("databento" VERSION 0.20.1 LANGUAGES CXX) string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE) # @@ -291,6 +291,9 @@ set(targets ${PROJECT_NAME}) if(NOT ${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_JSON) list(APPEND targets nlohmann_json) endif() +if(NOT ${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_HTTPLIB) + list(APPEND targets httplib) +endif() include(GNUInstallDirs) install( @@ -303,16 +306,9 @@ install( ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION - include + ${CMAKE_INSTALL_INCLUDEDIR} PUBLIC_HEADER DESTINATION - include -) - -install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.hpp - DESTINATION - include/${PROJECT_NAME} + ${CMAKE_INSTALL_INCLUDEDIR} ) install( @@ -330,17 +326,33 @@ install( # Install the `include` directory # +set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) install( DIRECTORY include/${PROJECT_NAME} DESTINATION - include + ${CMAKE_INSTALL_INCLUDEDIR} +) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.hpp + DESTINATION + ${INCLUDE_INSTALL_DIR} ) -verbose_message("Install targets successfully built. Install with `cmake --build --target install --config `.") +# +# Install license +# + +install( + FILES + "LICENSE" + DESTINATION + ${CMAKE_INSTALL_DATADIR}/licenses/${PROJECT_NAME} +) # -# Quick `ConfigVersion.cmake` creation +# `ConfigVersion.cmake` creation # include(CMakePackageConfigHelpers) @@ -349,24 +361,31 @@ write_basic_package_version_file( VERSION ${PROJECT_VERSION} COMPATIBILITY - SameMajorVersion + SameMinorVersion ) +# +# Generate package configuration and install it +# + configure_package_config_file( ${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake - INSTALL_DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + PATH_VARS INCLUDE_INSTALL_DIR ) - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + # Install so it can be used in databentoConfig.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindZstd.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) +verbose_message("Install targets successfully built. Install with `cmake --build --target install --config `.") + # # Generate export header if specified # @@ -378,7 +397,7 @@ if(${PROJECT_NAME_UPPERCASE}_GENERATE_EXPORT_HEADER) FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}_export.h DESTINATION - include + ${CMAKE_INSTALL_INCLUDEDIR} ) message(STATUS "Generated the export header `${PROJECT_NAME}_export.h` and installed it.") diff --git a/cmake/databentoConfig.cmake.in b/cmake/databentoConfig.cmake.in index 2ac739c..ed9c135 100644 --- a/cmake/databentoConfig.cmake.in +++ b/cmake/databentoConfig.cmake.in @@ -2,7 +2,16 @@ set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@) @PACKAGE_INIT@ -set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@") +# Reuse FindZstd +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +# Add dependencies here so end-user doesn't have to +include(CMakeFindDependencyMacro) +find_dependency(date) +find_dependency(httplib) +find_dependency(nlohmann_json) +find_dependency(Threads) +find_dependency(Zstd) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") diff --git a/pkg/PKGBUILD b/pkg/PKGBUILD index b0d95cd..40ab411 100644 --- a/pkg/PKGBUILD +++ b/pkg/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Databento _pkgname=databento-cpp pkgname=databento-cpp-git -pkgver=0.20.0 +pkgver=0.20.1 pkgrel=1 pkgdesc="Official C++ client for Databento" arch=('any') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index babdb4f..b468958 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -163,3 +163,4 @@ add_compile_definitions(TEST_BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}") verbose_message("Finished adding unit tests for ${CMAKE_PROJECT_NAME}.") add_subdirectory(cmake_fetch_content) +add_subdirectory(cmake_import) diff --git a/test/cmake_import/CMakeLists.txt b/test/cmake_import/CMakeLists.txt new file mode 100644 index 0000000..9aebc64 --- /dev/null +++ b/test/cmake_import/CMakeLists.txt @@ -0,0 +1,38 @@ +# Install locally +add_test( + NAME cmake_import_install + COMMAND + ${CMAKE_COMMAND} + --install ${CMAKE_BINARY_DIR} + --prefix ${CMAKE_CURRENT_BINARY_DIR}/pkg +) +# Configure test project +add_test( + NAME cmake_import_configure + COMMAND + ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -Ddatabento_DIR=${CMAKE_CURRENT_BINARY_DIR}/pkg/lib/cmake/databento + -Dnlohmann_json_DIR=${nlohmann_json_BINARY_DIR} + -Ddate_DIR=${CMAKE_CURRENT_BINARY_DIR}/pkg/lib/cmake/date + -Dhttplib_DIR=${CMAKE_CURRENT_BINARY_DIR}/pkg/lib/cmake/httplib + ${CMAKE_CURRENT_SOURCE_DIR}/project +) +# Build test project +add_test( + NAME cmake_import_build + COMMAND ${CMAKE_COMMAND} --build . +) +set_tests_properties( + cmake_import_install + PROPERTIES FIXTURES_SETUP cmake_import +) +set_tests_properties( + cmake_import_configure + PROPERTIES FIXTURES_SETUP cmake_import +) +set_tests_properties( + cmake_import_build + PROPERTIES FIXTURES_REQUIRED cmake_import +) diff --git a/test/cmake_import/project/CMakeLists.txt b/test/cmake_import/project/CMakeLists.txt new file mode 100644 index 0000000..193e6fe --- /dev/null +++ b/test/cmake_import/project/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.14) + +project(DummyImport LANGUAGES CXX) + +find_package(databento REQUIRED) + +add_executable(dummy main.cpp) +target_link_libraries(dummy databento::databento) diff --git a/test/cmake_import/project/main.cpp b/test/cmake_import/project/main.cpp new file mode 100644 index 0000000..012188e --- /dev/null +++ b/test/cmake_import/project/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char** argv) { + databento::RecordHeader header{}; + std::cout << header.Size() << '\n'; + + return 0; +}