From 3df30bf2c826c757274c976738c92f950b8dca45 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 30 Sep 2025 14:31:30 -0600 Subject: [PATCH 1/5] Add .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a1d121d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# User presets should not be committed to source control +CMakeUserPresets.json From ae380cae0a82673d85fa0826259684db99a923e9 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 30 Sep 2025 14:43:42 -0600 Subject: [PATCH 2/5] Document BOOST_NUMERIC_ODEINT_NO_ADAPTERS CMake option This makes the option visible in the cmake user front-end. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 712c7ca7..592b532a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ cmake_minimum_required(VERSION 3.5...3.20) project(boost_numeric_odeint VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) +option(BOOST_NUMERIC_ODEINT_NO_ADAPTORS "Build odeint without boost::compute and boost::mpi support" OFF) + add_library(boost_numeric_odeint INTERFACE) add_library(Boost::numeric_odeint ALIAS boost_numeric_odeint) From 8b5eb4dcb59d64ac777ad3887bcb5587e9b45c64 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 30 Sep 2025 14:44:23 -0600 Subject: [PATCH 3/5] Factor out conditional dependencies from necessary dependencies BOOST_NUMERIC_ODEINT_ADAPTORS only turns off two dependencies at this time: boost::compute and boost::mpi. Factor out the unconditional dependencies to make this clearer in the CMake script. --- CMakeLists.txt | 60 ++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 592b532a..bdb04556 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,49 +14,31 @@ add_library(Boost::numeric_odeint ALIAS boost_numeric_odeint) target_include_directories(boost_numeric_odeint INTERFACE include) -if(BOOST_NUMERIC_ODEINT_NO_ADAPTORS) +target_link_libraries(boost_numeric_odeint + INTERFACE + Boost::assert + Boost::config + Boost::core + Boost::fusion + Boost::iterator + Boost::math + Boost::mpl + Boost::multi_array + Boost::numeric_ublas + Boost::preprocessor + Boost::range + Boost::static_assert + Boost::throw_exception + Boost::type_traits + Boost::units + Boost::utility +) + +if(NOT BOOST_NUMERIC_ODEINT_NO_ADAPTORS) target_link_libraries(boost_numeric_odeint INTERFACE - Boost::assert - Boost::config - Boost::core - Boost::fusion - Boost::iterator - Boost::math - Boost::mpl - Boost::multi_array - Boost::numeric_ublas - Boost::preprocessor - Boost::range - Boost::static_assert - Boost::throw_exception - Boost::type_traits - Boost::units - Boost::utility - ) - -else() - - target_link_libraries(boost_numeric_odeint - INTERFACE - Boost::assert Boost::compute - Boost::config - Boost::core - Boost::fusion - Boost::iterator - Boost::math - Boost::mpl - Boost::multi_array - Boost::numeric_ublas - Boost::preprocessor - Boost::range - Boost::static_assert - Boost::throw_exception - Boost::type_traits - Boost::units - Boost::utility ) # From CMake 3.30 linking against MPI when it does not exist gives errors From 5561f70c3294a073502b3989bc7b9bdd0689932d Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 30 Sep 2025 14:48:32 -0600 Subject: [PATCH 4/5] Set .editorconfig style to match existing CMakeLists.txt This prevents us from accidentally using the wrong indent level in the editor, etc. --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..417d8ac0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# http://editorconfig.org + +root = true + +[{*.cmake,CMakeLists.txt}] +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true From 54108fb909dc3747692f35e3b6b343ac6531623b Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 30 Sep 2025 15:48:45 -0600 Subject: [PATCH 5/5] Add CMake support for building examples Implementation follows the existing jam files, so the following subdirectories in examples are skipped: - mtl - ublas - gmpxx - openmp - mpi --- CMakeLists.txt | 32 ++++++++++++++++++ examples/CMakeLists.txt | 47 ++++++++++++++++++++++++++ examples/multiprecision/CMakeLists.txt | 2 ++ 3 files changed, 81 insertions(+) create mode 100644 examples/CMakeLists.txt create mode 100644 examples/multiprecision/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index bdb04556..efaa8f05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,39 @@ project(boost_numeric_odeint VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES C option(BOOST_NUMERIC_ODEINT_NO_ADAPTORS "Build odeint without boost::compute and boost::mpi support" OFF) +# Enable grouping of targets in IDE views +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + add_library(boost_numeric_odeint INTERFACE) add_library(Boost::numeric_odeint ALIAS boost_numeric_odeint) target_include_directories(boost_numeric_odeint INTERFACE include) +set(BOOST_ODEINT_REQUIRED_COMPONENTS + assert + config + core + fusion + iterator + math + mpl + multi_array + numeric_ublas + preprocessor + range + static_assert + throw_exception + type_traits + units + utility) +if(NOT BOOST_NUMERIC_ODEINT_NO_ADAPTORS) + list(APPEND BOOST_ODEINT_REQUIRED_COMPONENTS compute) + if(BOOST_ENABLE_MPI) + list(APPEND BOOST_ODEINT_REQUIRED_COMPONENTS mpi) + endif() +endif() +find_package(Boost REQUIRED COMPONENTS ${BOOST_ODEINT_REQUIRED_COMPONENTS}) + target_link_libraries(boost_numeric_odeint INTERFACE Boost::assert @@ -51,6 +79,10 @@ if(NOT BOOST_NUMERIC_ODEINT_NO_ADAPTORS) endif() +if(BOOST_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt") + add_subdirectory(examples) +endif() + if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") add_subdirectory(test) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..4299923e --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,47 @@ +function(add_example name) + cmake_parse_arguments(PARSE_ARGV 1 ARG "" "CXX_STANDARD;FOLDER" "") + add_executable("${name}" "${name}.cpp") + target_compile_definitions("${name}" PRIVATE "BOOST_ALL_NO_LIB=1") + target_link_libraries("${name}" PRIVATE Boost::numeric_odeint) + if(NOT ARG_FOLDER) + set(ARG_FOLDER "Examples") + endif() + set_target_properties("${name}" PROPERTIES FOLDER "${ARG_FOLDER}") + if(ARG_CXX_STANDARD) + set_target_properties("${name}" PROPERTIES CXX_STANDARD "${ARG_CXX_STANDARD}") + endif() +endfunction() + +add_example(harmonic_oscillator) +add_example(solar_system) +add_example(chaotic_system) +add_example(stiff_system) +add_example(fpu) +add_example(phase_oscillator_ensemble) +if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_example(harmonic_oscillator_units) +endif() +add_example(stuart_landau) +add_example(two_dimensional_phase_lattice) +add_example(bulirsch_stoer) +add_example(elliptic_functions) +add_example(resizing_lattice) +add_example(list_lattice) +add_example(stepper_details) +add_example(my_vector) +add_example(lorenz) +add_example(lorenz_point) +add_example(van_der_pol_stiff) +add_example(simple1d) +add_example(stochastic_euler) +add_example(generation_functions) +add_example(heun) +add_example(bind_member_functions) +add_example(bind_member_functions_cpp11 CXX_STANDARD 14) +add_example(molecular_dynamics CXX_STANDARD 14) +add_example(molecular_dynamics_cells CXX_STANDARD 14) +add_example(abm_precision) +add_example(integrate_times) +add_example(find_crossing CXX_STANDARD 14) + +add_subdirectory(multiprecision) diff --git a/examples/multiprecision/CMakeLists.txt b/examples/multiprecision/CMakeLists.txt new file mode 100644 index 00000000..7093f355 --- /dev/null +++ b/examples/multiprecision/CMakeLists.txt @@ -0,0 +1,2 @@ +add_example(lorenz_mp FOLDER "Examples/Multiprecision") +add_example(cmp_precision FOLDER "Examples/Multiprecision")