From 711ec3da4f20cf1590685f03dc1256b73fa07218 Mon Sep 17 00:00:00 2001 From: Timothy Burke Date: Tue, 11 Jun 2024 12:29:31 -0600 Subject: [PATCH 1/6] Updates CMake - adds installation and relative git URLs --- CMakeLists.txt | 104 ++++++++++++++++++++++++------- cmake/acetk-config.cmake.in | 7 +++ cmake/develop_dependencies.cmake | 40 +++++++----- cmake/release_dependencies.cmake | 48 ++++++++------ cmake/unit_testing.cmake | 2 - 5 files changed, 145 insertions(+), 56 deletions(-) create mode 100644 cmake/acetk-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index b74fdf29..ca767354 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # Preamble ######################################################################## -cmake_minimum_required( VERSION 3.14 ) +cmake_minimum_required( VERSION 3.27 ) set( subproject OFF ) if( DEFINED PROJECT_NAME ) @@ -25,20 +25,24 @@ include( GNUInstallDirs ) set( CMAKE_CXX_STANDARD 17 ) set( CMAKE_CXX_STANDARD_REQUIRED YES ) -cmake_dependent_option( +cmake_dependent_option( ACEtk.tests - "Build the ACEtk unit tests and integrate with ctest" ON - "BUILD_TESTING AND NOT ${subproject}" OFF + "Build the ACEtk unit tests and integrate with ctest" ON + "BUILD_TESTING AND NOT ${subproject}" OFF ) + cmake_dependent_option( ACEtk.python "Build ACEtk python bindings" ON "NOT ${subproject} OR DEFINED require.ACEtk.python " OFF ) + if ( ACEtk.python ) set( require.tools.python CACHE BOOL ON ) endif() +option( ACEtk.installation "Install ACEtk" ON ) + ######################################################################## # Dependencies ######################################################################## @@ -66,17 +70,20 @@ endif() # Project targets ######################################################################## +string( CONCAT prefix + "$" + "$" +) + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ACEtk : library # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - add_library( ACEtk INTERFACE ) -add_library( njoy::ACEtk ALIAS ACEtk ) -target_include_directories( ACEtk - INTERFACE - $ - $ -) +add_library( njoy::ACEtk ALIAS ACEtk) + +target_include_directories( ACEtk INTERFACE ${prefix} ) + target_link_libraries( ACEtk INTERFACE njoy::tools @@ -86,11 +93,12 @@ target_link_libraries( ACEtk # ACEtk : python bindings # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -if( ACEtk.python ) +if (ACEtk.python AND NOT TARGET njoy::tools.python) + message(WARNING "njoy::tools was not built with python enabled. Disabling build of ACEtk's python API.") + set(ACEtk.python OFF) +endif() - FetchContent_MakeAvailable( - pybind11 - ) +if(ACEtk.python) pybind11_add_module( ACEtk.python ${CMAKE_CURRENT_SOURCE_DIR}/python/src/ACEtk.python.cpp @@ -202,8 +210,8 @@ if( ACEtk.python ) ${CMAKE_CURRENT_SOURCE_DIR}/python/src/PhotonuclearTable.python.cpp ) - target_link_libraries( ACEtk.python PRIVATE ACEtk ) - add_dependencies( ACEtk.python tools.python ) + target_link_libraries(ACEtk.python PRIVATE njoy::ACEtk) + add_dependencies( ACEtk.python njoy::tools.python) target_include_directories( ACEtk.python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/python/src ) target_compile_options( ACEtk.python PRIVATE -fvisibility=hidden ) set_target_properties( ACEtk.python PROPERTIES OUTPUT_NAME ACEtk ) @@ -212,8 +220,12 @@ if( ACEtk.python ) message( STATUS "Building ACEtk's python API" ) - list( APPEND ACEtk_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR} ) - list( APPEND tools_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR}/_deps/tools-build ) + set( ACEtk_PYTHONPATH "${CMAKE_CURRENT_BINARY_DIR}" ) + # Append potential installation and build paths for tools python module + set( tools_PYTHONPATH "${CMAKE_CURRENT_BINARY_DIR}/_deps/tools-build" ) + if (tools_DIR) + set( tools_PYTHONPATH "${tools_PYTHONPATH}:${tools_DIR}/../../../lib64" ) + endif() if( ACEtk.tests ) include( cmake/unit_testing_python.cmake ) @@ -221,8 +233,56 @@ if( ACEtk.python ) endif() -if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) - if( ACEtk.tests ) - include( cmake/unit_testing.cmake ) - endif() +if( ${ACEtk.tests} ) + include( cmake/unit_testing.cmake ) +endif() + +####################################################################### +# Installation +####################################################################### + +if(ACEtk.installation) + include(CMakePackageConfigHelpers) + + install(TARGETS ACEtk EXPORT ACEtk-targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) + + install(EXPORT ACEtk-targets + FILE "ACEtk-targets.cmake" + NAMESPACE njoy:: + DESTINATION share/cmake/ACEtk + ) + + install(DIRECTORY src/ + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILES_MATCHING PATTERN "*.hpp" + PATTERN "*test*" EXCLUDE + ) + + string(TOLOWER ACEtk lowercasePackageName) + + write_basic_package_version_file("${lowercasePackageName}-config-version.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) + + configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${lowercasePackageName}-config.cmake.in + ${PROJECT_BINARY_DIR}/${lowercasePackageName}-config.cmake + INSTALL_DESTINATION share/cmake/ACEtk + ) + + install(FILES + "${PROJECT_BINARY_DIR}/${lowercasePackageName}-config.cmake" + "${PROJECT_BINARY_DIR}/${lowercasePackageName}-config-version.cmake" + DESTINATION share/cmake/ACEtk + ) + + if(NOT subproject) + set(CPACK_PACKAGE_VENDOR "Los Alamos National Laboratory") + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") + include(CPack) + endif() endif() diff --git a/cmake/acetk-config.cmake.in b/cmake/acetk-config.cmake.in new file mode 100644 index 00000000..d347759c --- /dev/null +++ b/cmake/acetk-config.cmake.in @@ -0,0 +1,7 @@ +include(CMakeFindDependencyMacro) + +if (NOT TARGET njoy::tools) + find_dependency(tools) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/ACEtk-targets.cmake") diff --git a/cmake/develop_dependencies.cmake b/cmake/develop_dependencies.cmake index 4d148db4..2b69af65 100644 --- a/cmake/develop_dependencies.cmake +++ b/cmake/develop_dependencies.cmake @@ -1,4 +1,5 @@ -cmake_minimum_required( VERSION 3.14 ) +cmake_minimum_required( VERSION 3.27 ) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/.cmake) include( FetchContent ) ####################################################################### @@ -6,26 +7,37 @@ include( FetchContent ) ####################################################################### FetchContent_Declare( tools - GIT_REPOSITORY https://github.com/njoy/tools + GIT_REPOSITORY ../../njoy/tools GIT_TAG v0.3.0 GIT_SHALLOW TRUE ) -FetchContent_Declare( Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2 - GIT_TAG v3.3.2 - GIT_SHALLOW TRUE - ) - -FetchContent_Declare( pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11 - GIT_TAG v2.10.4 - ) - ####################################################################### # Load dependencies ####################################################################### +if(ACEtk.python) + FetchContent_Declare( pybind11 + GIT_REPOSITORY ../../pybind/pybind11 + GIT_TAG v2.10.4 + GIT_SHALLOW TRUE + ) + FetchContent_MakeAvailable( + pybind11 + ) +endif() + +if(ACEtk.tests) + FetchContent_Declare( Catch2 + GIT_REPOSITORY ../../catchorg/catch2 + GIT_TAG v3.3.2 + GIT_SHALLOW TRUE + ) + FetchContent_MakeAvailable( + Catch2 + ) +endif() + FetchContent_MakeAvailable( tools - ) +) diff --git a/cmake/release_dependencies.cmake b/cmake/release_dependencies.cmake index 963645cb..18346894 100644 --- a/cmake/release_dependencies.cmake +++ b/cmake/release_dependencies.cmake @@ -1,42 +1,54 @@ -cmake_minimum_required( VERSION 3.14 ) +cmake_minimum_required( VERSION 3.27 ) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/.cmake) include( FetchContent ) ####################################################################### # Declare project dependencies ####################################################################### -FetchContent_Declare( Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2 - GIT_TAG 3f0283de7a9c43200033da996ff9093be3ac84dc # tag: v3.3.2 - ) - -FetchContent_Declare( fast_float - GIT_REPOSITORY https://github.com/fastfloat/fast_float +FetchContent_Declare( FastFloat + GIT_REPOSITORY ../../fastfloat/fast_float GIT_TAG f476bc713fda06fbd34dc621b466745a574b3d4c # tag: v6.1.1 ) -FetchContent_Declare( pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11 - GIT_TAG 5b0a6fc2017fcc176545afe3e09c9f9885283242 # tag: v2.10.4 - ) - FetchContent_Declare( spdlog - GIT_REPOSITORY https://github.com/gabime/spdlog + GIT_REPOSITORY ../../gabime/spdlog GIT_TAG ad0e89cbfb4d0c1ce4d097e134eb7be67baebb36 # tag: v1.11.0 ) set( SPDLOG_BUILD_PIC CACHE INTERNAL BOOL ON ) +set( SPDLOG_INSTALL CACHE INTERNAL BOOL ON ) FetchContent_Declare( tools - GIT_REPOSITORY https://github.com/njoy/tools - GIT_TAG 368dbd9bd44754de616c46ffed0f80d2d16d8360 # tag: v0.3.0 + GIT_REPOSITORY ../../njoy/tools + GIT_TAG bfba151cc3ac3898fb6f66350a1db683d7d80035 # tag: v0.3.0 ) - ####################################################################### # Load dependencies ####################################################################### +if(ACEtk.python) + FetchContent_Declare( pybind11 + GIT_REPOSITORY ../../pybind/pybind11 + GIT_TAG 5b0a6fc2017fcc176545afe3e09c9f9885283242 # tag: v2.10.4 + ) + FetchContent_MakeAvailable( + pybind11 + ) +endif() + +if(ACEtk.tests) + FetchContent_Declare( Catch2 + GIT_REPOSITORY ../../catchorg/Catch2 + GIT_TAG 3f0283de7a9c43200033da996ff9093be3ac84dc # tag: v3.3.2 + ) + FetchContent_MakeAvailable( + Catch2 + ) +endif() + FetchContent_MakeAvailable( - fast_float + FastFloat spdlog tools ) + diff --git a/cmake/unit_testing.cmake b/cmake/unit_testing.cmake index e867fca8..f2c940b4 100644 --- a/cmake/unit_testing.cmake +++ b/cmake/unit_testing.cmake @@ -4,8 +4,6 @@ enable_testing() -FetchContent_MakeAvailable( Catch2 ) - function( add_cpp_test name source ) set( test_name "ACEtk.${name}.test" ) From 026698e3595afa46643333b0efdc2ee47ca6c95e Mon Sep 17 00:00:00 2001 From: Timothy Burke Date: Tue, 2 Jul 2024 10:27:34 -0600 Subject: [PATCH 2/6] Updates tools git hash to 0.3.1 --- cmake/release_dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/release_dependencies.cmake b/cmake/release_dependencies.cmake index 18346894..8767a844 100644 --- a/cmake/release_dependencies.cmake +++ b/cmake/release_dependencies.cmake @@ -20,7 +20,7 @@ set( SPDLOG_INSTALL CACHE INTERNAL BOOL ON ) FetchContent_Declare( tools GIT_REPOSITORY ../../njoy/tools - GIT_TAG bfba151cc3ac3898fb6f66350a1db683d7d80035 # tag: v0.3.0 + GIT_TAG 5f8429f804a842d165e0efdf1ca1d2d06e720f45 # tag: v0.3.1 ) ####################################################################### # Load dependencies From 9ff8cceae67e1f6acfde852b6f332e8b03835c04 Mon Sep 17 00:00:00 2001 From: Wim Haeck Date: Tue, 2 Jul 2024 10:31:23 -0600 Subject: [PATCH 3/6] Update ContinuousIntegration.yml From 46dc6756f8085561bc40a7be0a7b9f8a9ede64a5 Mon Sep 17 00:00:00 2001 From: Wim Haeck Date: Tue, 2 Jul 2024 10:31:51 -0600 Subject: [PATCH 4/6] Update develop_dependencies.cmake --- cmake/develop_dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/develop_dependencies.cmake b/cmake/develop_dependencies.cmake index 2b69af65..4f018a49 100644 --- a/cmake/develop_dependencies.cmake +++ b/cmake/develop_dependencies.cmake @@ -8,7 +8,7 @@ include( FetchContent ) FetchContent_Declare( tools GIT_REPOSITORY ../../njoy/tools - GIT_TAG v0.3.0 + GIT_TAG v0.3.1 GIT_SHALLOW TRUE ) From ed8f1d2679ead819371626172ccdc371fcdb2685 Mon Sep 17 00:00:00 2001 From: Wim Haeck Date: Tue, 2 Jul 2024 10:34:43 -0600 Subject: [PATCH 5/6] Update ReleaseNotes.md --- ReleaseNotes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index c44a1a15..bb9d1f07 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,6 +1,9 @@ # Release Notes—ACEtk Given here are some release notes for ACEtk. +## [ACEtk v1.0.1](https://github.com/njoy/ENDFtk/pull/133) +This updates the build system for ACEtk and contains no functional changes. + ## [ACEtk v1.0.0](https://github.com/njoy/ENDFtk/pull/130) This represents the first proper release of ACEtk. From c31d48b75c0b674f5691ed6eb2808ba4f43e9115 Mon Sep 17 00:00:00 2001 From: Wim Haeck Date: Tue, 2 Jul 2024 10:47:09 -0600 Subject: [PATCH 6/6] Update ContinuousIntegration.yml --- .github/workflows/ContinuousIntegration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ContinuousIntegration.yml b/.github/workflows/ContinuousIntegration.yml index 6441d89e..3820683e 100644 --- a/.github/workflows/ContinuousIntegration.yml +++ b/.github/workflows/ContinuousIntegration.yml @@ -16,8 +16,8 @@ jobs: runs-on: ${{matrix.os}} strategy: matrix: - os: [ ubuntu-20.04, macos-11 ] - cxx: [ clang++, g++-10 ] + os: [ ubuntu-22.04, macos-12 ] + cxx: [ clang++, g++-11 ] build_type: [ Debug, Release ] steps: