8000 Make NeoN installable by greole · Pull Request #333 · exasim-project/NeoN · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make NeoN installable #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1867e08
make NeoN installable
greole May 20, 2025
f161dd7
fix NeoN.hpp relative paths
greole May 20, 2025
ffeb5e9
add find_dependency
greole May 20, 2025
965b058
add ginkgo export
greole May 20, 2025
d7ae64f
fix NeoNTargets.cmake
greole May 20, 2025
458feae
rename NeoN.cmake -> NeoNConfig.cmake
greole May 20, 2025
e40327e
wip add external exports
greole May 21, 2025
9cb4ed3
use private linkage for kokkos and others
greole May 21, 2025
85bf908
use public linkage again
greole May 21, 2025
70c3238
cleanup linkage, only export when kokkos is not bundled
greole May 21, 2025
11f339c
cleanup currently unused deps
greole May 21, 2025
fb55188
update sundials version, change fetch_content path
greole May 22, 2025
e3424b9
fix order
greole May 22, 2025
a805ad2
move sundials linkage to public api
greole May 22, 2025
f278f10
move linkage to public api
greole May 22, 2025
9b03484
add cpptrace linkage
greole May 22, 2025
03f6750
add alias
greole May 22, 2025
924b050
use public api in registry test
greole May 22, 2025
d8333a8
fixup
greole May 22, 2025
22e79b8
fix test by requiring all registered stuff to exist for now
greole May 22, 2025
133f632
fix test
greole May 22, 2025
d94d4af
format files
greole May 23, 2025
12e6bbf
dont build benchmarks as part of integration test
greole May 23, 2025
f654511
wo sundials for static checks
greole May 23, 2025
4442db9
make neon compile wo sundials
greole May 23, 2025
344b2dc
fixup!
greole May 23, 2025
56024c9
dont build RK test if wo sundials, use _deps path again
greole May 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build_adapter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
cmake --preset develop \
-DNeoN_DEVEL_TOOLS=OFF \
-DNeoN_BUILD_TESTS=OFF \
-DFOAMADAPTER_BUILD_BENCHMARKS=OFF \
-DNeoN_ENABLE_MPI_WITH_THREAD_SUPPORT=OFF \
-DFOAMADAPTER_NEON_VERSION=${{env.checkout}}
cmake --build --preset develop
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/static_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
cmake --preset develop \
-DNeoN_DEVEL_TOOLS=OFF \
-DNeoN_WITH_GINKGO=OFF \
-DNeoN_WITH_SUNDIALS=OFF \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DNeoN_ENABLE_MPI_WITH_THREAD_SUPPORT=OFF \
Expand Down
56 changes: 56 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,59 @@ if(NeoN_ENABLE_IWYU)
endif()

include(cmake/banner.cmake)

install(
TARGETS NeoN NeoN_public_api NeoN_options NeoN_warnings
EXPORT NeoNTargets
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(
EXPORT NeoNTargets
FILE NeoNTargets.cmake
NAMESPACE NeoN::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NeoN)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/NeoN/NeoN.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/NeoN)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/NeoN/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/NeoN)

include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/NeoNConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/NeoNConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NeoN)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/NeoNConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NeoN)

# install internal ginkgo version
if(ginkgo_POPULATED)
install(
TARGETS ginkgo
EXPORT GinkgoTargets
INCLUDES
DESTINATION include)
install(EXPORT GinkgoTargets NAMESPACE Ginkgo::)
endif()

# install internal cpptrace version
if(cpptrace_POPULATED)
install(
TARGETS cpptrace
EXPORT CpptraceTargets
INCLUDES
DESTINATION include)
install(EXPORT CpptraceTargets NAMESPACE cpptrace::)
endif()

# install internal sundials version if(sundials_POPULATED) install( TARGETS cvode nvec arkode
# sundials_core_shared EXPORT SundialsTargets INCLUDES DESTINATION include) install(EXPORT
# SundialsTargets NAMESPACE SUNDIALS::) endif()

if(NOT kokkos_POPULATED)
export(EXPORT NeoNTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/NeoNTargets.cmake")
else()
message(WARNING "Unable to create NeoNTargets.cmake with bundled Kokkos")
endif()
38 changes: 11 additions & 27 deletions cmake/CxxThirdParty.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: Unlicense
# SPDX-FileCopyrightText: 2023 NeoN authors

# set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/cmake_packages)

set(NeoN_KOKKOS_CHECKOUT_VERSION
"4.3.00"
CACHE STRING "Use specific version of Kokkos")
Expand Down Expand Up @@ -36,7 +38,7 @@ endif()

find_package(Kokkos ${NeoN_KOKKOS_CHECKOUT_VERSION} QUIET)

if(NOT ${Kokkos_FOUND})
if(NOT Kokkos_FOUND)
include(FetchContent)
include(cmake/AutoEnableDevice.cmake)

Expand All @@ -63,14 +65,8 @@ cpmaddpackage(
0.7.3
SYSTEM)

cpmaddpackage(
NAME
nlohmann_json
VERSION
3.11.3
URL
https://github.com/nlohmann/json/releases/download/v3.11.3/include.zip
SYSTEM)
# currently unused cpmaddpackage( NAME nlohmann_json VERSION 3.11.3 URL
# https://github.com/nlohmann/json/releases/download/v3.11.3/include.zip SYSTEM)

if(${NeoN_WITH_ADIOS2})

Expand Down Expand Up @@ -141,35 +137,23 @@ if(${NeoN_WITH_SUNDIALS})

cpmaddpackage(
NAME
sundials
SUNDIALS
GITHUB_REPOSITORY
LLNL/sundials
VERSION
7.1.1
7.3.0
SYSTEM
YES
OPTIONS
${SUNDIALS_OPTIONS}
${SUNDIALS_CUDA_OPTIONS})
endif()

cpmaddpackage(
NAME
spdlog
URL
https://github.com/gabime/spdlog/archive/refs/tags/v1.13.0.zip
VERSION
1.13.0
SYSTEM)
# currently no AE88 t used cpmaddpackage( NAME spdlog URL
# https://github.com/gabime/spdlog/archive/refs/tags/v1.13.0.zip VERSION 1.13.0 SYSTEM)

cpmaddpackage(
NAME
cxxopts
URL
https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.2.0.zip
VERSION
3.2.0
SYSTEM)
# currently not used cpmaddpackage( NAME cxxopts URL
# https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.2.0.zip VERSION 3.2.0 SYSTEM)

if(${NeoN_WITH_GINKGO})
cpmaddpackage(
Expand Down
32 changes: 32 additions & 0 deletions cmake/NeoNConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-License-Identifier: Unlicense
# SPDX-FileCopyrightText: 2025 NeoN authors

@PACKAGE_INIT@

#check_required_components(NeoN)

include(CMakeFindDependencyMacro)

set(NeoN_WITH_ADIOS2 @NeoN_WITH_ADIOS2@)
set(NeoN_WITH_GINKGO @NeoN_WITH_GINKGO@)
set(NeoN_WITH_SUNDIALS @NeoN_WITH_SUNDIALS@)
set(NeoN_WITH_PETSC @NeoN_WITH_PETSC@)

find_dependency(Kokkos REQUIRED)
find_dependency(cpptrace REQUIRED)
#find_dependency(nlohmann_json REQUIRED)
#find_dependency(spdlog REQUIRED)

if(${NeoN_WITH_GINKGO})
find_dependency(Ginkgo REQUIRED)
endif()

if(${NeoN_WITH_SUNDIALS})
find_dependency(SUNDIALS REQUIRED)
endif()

if(${NeoN_WITH_ADIOS2})
find_dependency(adios2 REQUIRED)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/NeoNTargets.cmake")
29 changes: 20 additions & 9 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
# SPDX-FileCopyrightText: 2023 NeoN authors

add_library(NeoN_public_api INTERFACE) # dummy target
add_library(NeoN::NeoN_public_api ALIAS NeoN_public_api) # dummy target

set_property(
TARGET NeoN_public_api
APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}")
# set_property( TARGET NeoN_public_api APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
# "${CMAKE_CURRENT_BINARY_DIR}")

set_property(
TARGET NeoN_public_api
APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(
NeoN_public_api INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:.>)

if(NeoN_WITH_GINKGO)
target_link_libraries(NeoN_public_api INTERFACE Ginkgo::ginkgo)
Expand All @@ -21,6 +19,16 @@ else()
target_compile_definitions(NeoN_public_api INTERFACE NF_WITH_GINKGO=0)
endif()

if(NeoN_WITH_SUNDIALS)
target_compile_definitions(NeoN_public_api INTERFACE NN_WITH_SUNDIALS=1)
target_link_libraries(NeoN_public_api INTERFACE SUNDIALS::arkode SUNDIALS::nvecserial
SUNDIALS::core)
else()
target_compile_definitions(NeoN_public_api INTERFACE NN_WITH_SUNDIALS=0)
endif()

target_link_libraries(NeoN_public_api INTERFACE cpptrace::cpptrace Kokkos::kokkos)

if(NeoN_WITH_PETSC)
add_definitions(${PETSc_DEFINITIONS})
target_link_libraries(NeoN_public_api INTERFACE ${PETSc_LIBRARIES})
Expand Down Expand Up @@ -55,7 +63,10 @@ if(NeoN_ENABLE_MPI_SUPPORT)
endif()

# Get list of some *.hpp files in folder include
file(GLOB_RECURSE include_files *.hpp)
file(
GLOB_RECURSE include_files
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/
*.hpp)

# Convert the list of files into #includes
foreach(include_file ${include_files})
Expand Down
4 changes: 4 additions & 0 deletions include/NeoN/timeIntegration/rungeKutta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#if NN_WITH_SUNDIALS

#include <functional>
#include <memory>

Expand Down Expand Up @@ -192,3 +194,5 @@ class RungeKutta :
};

} // namespace NeoN

#endif
4 changes: 4 additions & 0 deletions include/NeoN/timeIntegration/sundials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#if NN_WITH_SUNDIALS

#include <concepts>
#include <functional>
#include <memory>
Expand Down Expand Up @@ -487,3 +489,5 @@ class SKVector
SKVectorVariant vector_; /**< Variant storing executor-specific vector implementation */
};
}

#endif
6 changes: 2 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-FileCopyrightText: 2023 NeoN authors

add_library(NeoN ${NeoN_LIB_TYPE})
add_library(NeoN::NeoN ALIAS NeoN) # dummy target

include(GNUInstallDirs)

Expand Down Expand Up @@ -64,8 +65,7 @@ enable_sanitizers(NeoN NeoN_ENABLE_SANITIZE_ADDRESS NeoN_ENABLE_SANITIZE_LEAK
NeoN_ENABLE_SANITIZE_UB NeoN_ENABLE_SANITIZE_THREAD NeoN_ENABLE_SANITIZE_MEMORY)

target_link_libraries(NeoN PRIVATE NeoN_warnings NeoN_options)
target_link_libraries(NeoN PUBLIC NeoN_public_api Kokkos::kokkos sundials_core sundials_arkode
sundials_nvecserial cpptrace::cpptrace)
target_link_libraries(NeoN PUBLIC NeoN_public_api)

if(NeoN_ENABLE_MPI_SUPPORT)
target_link_libraries(NeoN PUBLIC MPI::MPI_CXX)
Expand All @@ -77,5 +77,3 @@ if(WIN32)
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<0:>
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/$<0:>)
endif()

install(TARGETS NeoN)
4 changes: 4 additions & 0 deletions src/timeIntegration/rungeKutta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "NeoN/timeIntegration/rungeKutta.hpp"

#if NN_WITH_SUNDIALS

namespace NeoN::timeIntegration
{

Expand Down Expand Up @@ -146,3 +148,5 @@ void RungeKutta<SolutionVectorType>::initODEMemory(const scalar t)

template class RungeKutta<finiteVolume::cellCentred::VolumeField<scalar>>;
}

#endif
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function(NeoN_unit_test TEST)
endif()

add_executable(${NeoN_COMMAND} "${TEST}.cpp")
install(TARGETS ${NeoN_COMMAND})

if(NeoN_WITH_PETSC)
target_link_libraries(${NeoN_COMMAND} PRIVATE ${PETSc_LIBRARIES})
Expand All @@ -39,8 +40,7 @@ function(NeoN_unit_test TEST)
target_include_directories(${NeoN_COMMAND} PRIVATE "${TEST_CATCH2_DIR}")
set_target_properties(${NeoN_COMMAND} PROPERTIES OUTPUT_NAME ${TEST})

target_link_libraries(${NeoN_COMMAND} PRIVATE NeoN_warnings NeoN_options Kokkos::kokkos NeoN
cpptrace::cpptrace)
target_link_libraries(${NeoN_COMMAND} PRIVATE NeoN_warnings NeoN_options NeoN cpptrace::cpptrace)
if(NOT NeoN_MPI_SIZE)
target_link_libraries(${NeoN_COMMAND} PRIVATE NeoN_catch_main)
else()
Expand Down
2 changes: 1 addition & 1 deletion test/core/CMakeLists.txt F438
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ neon_unit_test(segmentedVector)

add_executable(runTimeSelectionFactory "runTimeSelectionFactory.cpp")
target_link_libraries(runTimeSelectionFactory PRIVATE Catch2::Catch2WithMain cpptrace::cpptrace
NeoN_public_api)
NeoN::NeoN_public_api)
if(WIN32)
set_target_properties(
runTimeSelectionFactory
Expand Down
1 change: 1 addition & 0 deletions test/core/runTimeSelectionFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <catch2/catch_template_test_macros.hpp>
#include <catch2/catch_approx.hpp>

// #include "NeoN/NeoN.hpp"
#include "NeoN/core/runtimeSelectionFactory.hpp"

class BaseClass : public NeoN::RuntimeSelectionFactory<BaseClass, NeoN::Parameters<>>
Expand Down
1 change: 0 additions & 1 deletion test/linearAlgebra/sparsityPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ TEST_CASE("SparsityPattern")

SECTION("has correct diagOffs" + execName)
{
auto sp = SparsityPattern {mesh};
auto diagOffs = sp.diagOffset().copyToHost();
auto diagOffsS = diagOffs.view();

Expand Down
2 changes: 1 addition & 1 deletion test/timeIntegration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

neon_unit_test(timeIntegration)
neon_unit_test(implicitTimeIntegration)
if(NOT WIN32)
if(NOT WIN32 AND NeoN_WITH_SUNDIALS)
neon_unit_test(rungeKutta)
endif()
Loading
0