From 1a7337fc94ca58d8c735d483a23dd0d129767f5d Mon Sep 17 00:00:00 2001 From: Dimitri Vlachos Date: Thu, 6 Nov 2025 15:56:54 +0000 Subject: [PATCH 1/7] Uncomment temporarily removed install --- CMakeLists.txt | 76 +++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a1887d..aed096e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,44 +75,44 @@ add_subdirectory(tests) # ####################################################################### # Installation -# install( -# TARGETS dx2 -# EXPORT DX2Targets -# LIBRARY DESTINATION lib +install( + TARGETS dx2 + EXPORT DX2Targets + LIBRARY DESTINATION lib -# # FILE_SET HEADERS DESTINATION include/dx2 -# ) -# install( -# FILES -# include/dx2/dx2.h -# DESTINATION include/dx2 -# ) + # FILE_SET HEADERS DESTINATION include/dx2 +) +install( + FILES + include/dx2/dx2.h + DESTINATION include/dx2 +) -# install( -# EXPORT DX2Targets -# FILE DX2Targets.cmake -# DESTINATION lib/cmake/DX2 -# ) +install( + EXPORT DX2Targets + FILE DX2Targets.cmake + DESTINATION lib/cmake/DX2 +) -# include(CMakePackageConfigHelpers) -# configure_package_config_file( -# ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in -# "${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake" -# INSTALL_DESTINATION "lib/cmake/DX2" -# NO_SET_AND_CHECK_MACRO -# NO_CHECK_REQUIRED_COMPONENTS_MACRO -# ) -# write_basic_package_version_file( -# "${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake" -# VERSION "${DX2_VERSION_MAJOR}.${DX2_VERSION_MINOR}" -# COMPATIBILITY AnyNewerVersion -# ) -# install( -# FILES -# ${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake -# ${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake -# DESTINATION lib/cmake/DX2 -# ) -# export(EXPORT DX2Targets -# FILE "${CMAKE_CURRENT_BINARY_DIR}/DX2Targets.cmake" -# ) +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake" + INSTALL_DESTINATION "lib/cmake/DX2" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake" + VERSION "${DX2_VERSION_MAJOR}.${DX2_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion +) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake + DESTINATION lib/cmake/DX2 +) +export(EXPORT DX2Targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/DX2Targets.cmake" +) From b565870bb35e468232a79071398783efe696833a Mon Sep 17 00:00:00 2001 From: Dimitri Vlachos Date: Thu, 6 Nov 2025 17:00:19 +0000 Subject: [PATCH 2/7] Refactor and simplify install to avoid export issues --- CMakeLists.txt | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aed096e..a0a6b1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,42 +77,12 @@ add_subdirectory(tests) # Installation install( TARGETS dx2 - EXPORT DX2Targets LIBRARY DESTINATION lib - - # FILE_SET HEADERS DESTINATION include/dx2 -) -install( - FILES - include/dx2/dx2.h - DESTINATION include/dx2 -) - -install( - EXPORT DX2Targets - FILE DX2Targets.cmake - DESTINATION lib/cmake/DX2 + COMPONENT Runtime ) -include(CMakePackageConfigHelpers) -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake" - INSTALL_DESTINATION "lib/cmake/DX2" - NO_SET_AND_CHECK_MACRO - NO_CHECK_REQUIRED_COMPONENTS_MACRO -) -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake" - VERSION "${DX2_VERSION_MAJOR}.${DX2_VERSION_MINOR}" - COMPATIBILITY AnyNewerVersion -) install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake - DESTINATION lib/cmake/DX2 -) -export(EXPORT DX2Targets - FILE "${CMAKE_CURRENT_BINARY_DIR}/DX2Targets.cmake" -) + DIRECTORY include/dx2/ + DESTINATION include/dx2 + FILES_MATCHING PATTERN "*.hpp" +) \ No newline at end of file From 15c2868f20376956f34cafc5e9c4be06511257dd Mon Sep 17 00:00:00 2001 From: Dimitri Vlachos Date: Thu, 6 Nov 2025 17:48:53 +0000 Subject: [PATCH 3/7] Fix condition check for root CMakeLists.txt inclusion --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0a6b1f..67bc547 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Only include global build-configuration features if we are the root CMakeLists.txt -if(CMAKE_CURRENT_SOURCE_DIR EQUAL CMAKE_SOURCE_DIR) +if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") include(SetDefaultBuildRelWithDebInfo) include(AlwaysColourCompilation) From b29436c92420ff5c995041fe09ec2d7127246771 Mon Sep 17 00:00:00 2001 From: Dimitri Vlachos Date: Thu, 6 Nov 2025 17:49:46 +0000 Subject: [PATCH 4/7] Add support for standalone and Docker builds --- CMakeLists.txt | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67bc547..c3e6441 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,14 +75,57 @@ add_subdirectory(tests) # ####################################################################### # Installation + +# Install FetchContent dependencies if they were fetched (not found via find_package) +if(NOT nlohmann_json_FOUND) + install(TARGETS nlohmann_json EXPORT DX2Targets) +endif() +if(NOT fmt_FOUND) + install(TARGETS fmt EXPORT DX2Targets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + ) +endif() +# Eigen3 is header-only, doesn't need runtime installation +# mdspan is header-only, doesn't need runtime installation +# GTest is test-only, doesn't need installation + install( TARGETS dx2 + EXPORT DX2Targets LIBRARY DESTINATION lib - COMPONENT Runtime + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin ) install( DIRECTORY include/dx2/ DESTINATION include/dx2 FILES_MATCHING PATTERN "*.hpp" +) + +# Export targets +install( + EXPORT DX2Targets + FILE DX2Targets.cmake + NAMESPACE dx2:: + DESTINATION lib/cmake/DX2 +) + +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake" + INSTALL_DESTINATION "lib/cmake/DX2" +) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY AnyNewerVersion +) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/DX2Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/DX2ConfigVersion.cmake + DESTINATION lib/cmake/DX2 ) \ No newline at end of file From 60780240eeb0671ffa98380a6dd18f8a1fd6d97c Mon Sep 17 00:00:00 2001 From: Dimitri Vlachos Date: Thu, 6 Nov 2025 18:08:30 +0000 Subject: [PATCH 5/7] Add COMPONENT specification for runtime installation --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3e6441..81271c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,11 +96,13 @@ install( LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin + COMPONENT Runtime ) install( DIRECTORY include/dx2/ DESTINATION include/dx2 + COMPONENT Runtime FILES_MATCHING PATTERN "*.hpp" ) From 96083433e998fb80b711a2871a5f4efbc7a0a98b Mon Sep 17 00:00:00 2001 From: Dimitri Vlachos Date: Fri, 7 Nov 2025 10:49:32 +0000 Subject: [PATCH 6/7] Refactor external dependencies handling --- CMakeLists.txt | 78 ++++++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81271c8..e456f09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,50 +19,34 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON) # External Dependencies find_package(HDF5 REQUIRED) find_package(gemmi CONFIG REQUIRED) +find_package(nlohmann_json 3.11.3 REQUIRED) +find_package(fmt 11.0 REQUIRED) +find_package(Eigen3 3.4 REQUIRED) -# ####################################################################### -# Automatic Dependencies +# mdspan and GTest can use FetchContent as fallback set(FETCHCONTENT_QUIET OFF) include(FetchContent) -FetchContent_Declare( - nlohmann_json - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG v3.11.3 - EXCLUDE_FROM_ALL - FIND_PACKAGE_ARGS -) -FetchContent_Declare( - GTest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG b514bdc898e2951020cbdca1304b75f5950d1f59 # v1.15.2 - EXCLUDE_FROM_ALL - FIND_PACKAGE_ARGS -) -FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 11.2.0 - EXCLUDE_FROM_ALL - FIND_PACKAGE_ARGS -) -FetchContent_Declare( - Eigen3 - GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git - GIT_TAG 3.4.0 - EXCLUDE_FROM_ALL - FIND_PACKAGE_ARGS -) -FetchContent_Declare( - mdspan - GIT_REPOSITORY https://github.com/kokkos/mdspan - GIT_TAG mdspan-0.6.0 - EXCLUDE_FROM_ALL - FIND_PACKAGE_ARGS -) -FetchContent_MakeAvailable(Eigen3 fmt nlohmann_json mdspan) -# GTest could have been made available under a different name -if(NOT TARGET GTest::gtest_main) +find_package(mdspan QUIET) +if(NOT mdspan_FOUND AND NOT TARGET std::mdspan) + FetchContent_Declare( + mdspan + GIT_REPOSITORY https://github.com/kokkos/mdspan + GIT_TAG mdspan-0.6.0 + EXCLUDE_FROM_ALL + ) + FetchContent_MakeAvailable(mdspan) +endif() + +# GTest for testing +find_package(GTest QUIET) +if(NOT GTest_FOUND AND NOT TARGET GTest::gtest_main) + FetchContent_Declare( + GTest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG b514bdc898e2951020cbdca1304b75f5950d1f59 # v1.15.2 + EXCLUDE_FROM_ALL + ) FetchContent_MakeAvailable(GTest) endif() @@ -76,20 +60,6 @@ add_subdirectory(tests) # ####################################################################### # Installation -# Install FetchContent dependencies if they were fetched (not found via find_package) -if(NOT nlohmann_json_FOUND) - install(TARGETS nlohmann_json EXPORT DX2Targets) -endif() -if(NOT fmt_FOUND) - install(TARGETS fmt EXPORT DX2Targets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - ) -endif() -# Eigen3 is header-only, doesn't need runtime installation -# mdspan is header-only, doesn't need runtime installation -# GTest is test-only, doesn't need installation - install( TARGETS dx2 EXPORT DX2Targets From 1fc23765a7bdd94e1bd83c8f0428c5449e313a38 Mon Sep 17 00:00:00 2001 From: Dimitri Vlachos Date: Fri, 7 Nov 2025 10:58:40 +0000 Subject: [PATCH 7/7] Update requirements.txt to include nlohmann_json, fmt, and eigen dependencies --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 257e3fb..404a177 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,6 @@ gemmi cmake hdf5=1.12.2 hdf5-external-filter-plugins +nlohmann_json>=3.11.3 +fmt>=11.0 +eigen>=3.4