From ae95352ec35fd5001ad5c246250f8fe20b114abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 8 Jul 2024 18:52:29 +0200 Subject: [PATCH 01/10] Support toml11 4.0 in CMake --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e78dfcfd35..96ac0d07db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,8 +278,12 @@ if(openPMD_USE_INTERNAL_TOML11) add_subdirectory("${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/toml11") message(STATUS "toml11: Using INTERNAL version '3.7.1'") else() - find_package(toml11 3.7.1 CONFIG REQUIRED) - message(STATUS "toml11: Found version '${toml11_VERSION}'") + find_package(toml11 CONFIG REQUIRED) + if(${toml11_VERSION} VERSION_LESS 3.7.1) + message(FATAL_ERROR "toml11: Found version '${toml11_VERSION}', but requires version '3.7.1' at least.") + else() + message(STATUS "toml11: Found version '${toml11_VERSION}'") + endif() endif() add_library(openPMD::thirdparty::toml11 INTERFACE IMPORTED) target_link_libraries(openPMD::thirdparty::toml11 From 59e1a4ec035ae80c8ff8081e506f1d4055f54f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 8 Jul 2024 18:52:53 +0200 Subject: [PATCH 02/10] Fixes for toml11 4.Fixes for toml11 4.00 Still missing: proper setting for precision, backwards compatibility with toml11 3.0. Ideally, move toml::format to an internal helper that takes care of all of this. --- src/IO/ADIOS/ADIOS2File.cpp | 2 +- src/IO/ADIOS/ADIOS2IOHandler.cpp | 2 +- src/IO/HDF5/HDF5IOHandler.cpp | 2 +- src/IO/HDF5/ParallelHDF5IOHandler.cpp | 2 +- src/IO/IOTask.cpp | 2 +- src/IO/JSON/JSONIOHandlerImpl.cpp | 5 +++-- src/auxiliary/JSON.cpp | 8 ++------ test/JSONTest.cpp | 2 +- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/IO/ADIOS/ADIOS2File.cpp b/src/IO/ADIOS/ADIOS2File.cpp index 815b163053..aaecf1a0fc 100644 --- a/src/IO/ADIOS/ADIOS2File.cpp +++ b/src/IO/ADIOS/ADIOS2File.cpp @@ -565,7 +565,7 @@ void ADIOS2File::configure_IO() auto asToml = json::jsonToToml(shadow); std::cerr << "Warning: parts of the backend configuration for " "ADIOS2 remain unused:\n" - << asToml << std::endl; + << toml::format(asToml) << std::endl; break; } } diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index f1d94f4e38..bd2fab711e 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -527,7 +527,7 @@ ADIOS2IOHandlerImpl::flush(internal::ParsedFlushParams &flushParams) auto asToml = json::jsonToToml(shadow); std::cerr << "Warning: parts of the backend configuration for " "ADIOS2 remain unused:\n" - << asToml << std::endl; + << toml::format(asToml) << std::endl; break; } } diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index a2b804d564..0437dd1fab 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -174,7 +174,7 @@ HDF5IOHandlerImpl::HDF5IOHandlerImpl( std::cerr << "Warning: parts of the backend configuration for " "HDF5 remain unused:\n" - << asToml << std::endl; + << toml::format(asToml) << std::endl; break; } } diff --git a/src/IO/HDF5/ParallelHDF5IOHandler.cpp b/src/IO/HDF5/ParallelHDF5IOHandler.cpp index ecdbc8ab89..8eec6fdb99 100644 --- a/src/IO/HDF5/ParallelHDF5IOHandler.cpp +++ b/src/IO/HDF5/ParallelHDF5IOHandler.cpp @@ -334,7 +334,7 @@ ParallelHDF5IOHandlerImpl::ParallelHDF5IOHandlerImpl( auto asToml = json::jsonToToml(shadow); std::cerr << "Warning: parts of the backend configuration for " "HDF5 remain unused:\n" - << asToml << std::endl; + << toml::format(asToml) << std::endl; break; } } diff --git a/src/IO/IOTask.cpp b/src/IO/IOTask.cpp index 361d5694ab..5a6605228b 100644 --- a/src/IO/IOTask.cpp +++ b/src/IO/IOTask.cpp @@ -66,7 +66,7 @@ void Parameter::warnUnusedParameters< break; case json::SupportedLanguages::TOML: { auto asToml = json::jsonToToml(shadow); - std::cerr << warningMessage << asToml << std::endl; + std::cerr << warningMessage << toml::format(asToml) << std::endl; break; } } diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index a92d068415..b91ae1fef9 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -1378,8 +1378,9 @@ auto JSONIOHandlerImpl::putJsonContents( *fh_with_precision << *it->second << std::endl; break; case FileFormat::Toml: - *fh_with_precision << openPMD::json::jsonToToml(*it->second) - << std::endl; + *fh_with_precision + << toml::format(openPMD::json::jsonToToml(*it->second)) + << std::endl; break; } diff --git a/src/auxiliary/JSON.cpp b/src/auxiliary/JSON.cpp index e089c2dc22..9349f14c35 100644 --- a/src/auxiliary/JSON.cpp +++ b/src/auxiliary/JSON.cpp @@ -208,10 +208,6 @@ namespace } return result; } - else if (val.is_uninitialized()) - { - return nlohmann::json(); // null - } // @todo maybe generalize error type throw error::BackendConfigSchema( @@ -556,7 +552,7 @@ void warnGlobalUnusedOptions(TracingJSON const &config) std::cerr << "[Series] The following parts of the global TOML config " "remains unused:\n" - << asToml << std::endl; + << toml::format(asToml) << std::endl; } } } @@ -612,7 +608,7 @@ std::string merge(std::string const &defaultValue, std::string const &overwrite) case SupportedLanguages::TOML: { auto asToml = json::jsonToToml(res); std::stringstream sstream; - sstream << asToml; + sstream << toml::format(asToml); return sstream.str(); } } diff --git a/test/JSONTest.cpp b/test/JSONTest.cpp index 46b2459e52..161f1fa3a3 100644 --- a/test/JSONTest.cpp +++ b/test/JSONTest.cpp @@ -210,7 +210,7 @@ right = "val" raw, std::ios_base::binary | std::ios_base::in); toml::value tomlVal = toml::parse(istream); std::stringstream sstream; - sstream << tomlVal; + sstream << toml::format(tomlVal); return sort_lines(sstream.str()); }(); From 56fca117d7f5ff0fca21fa9dd0e5924232dfd19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 9 Jul 2024 11:12:36 +0200 Subject: [PATCH 03/10] Manually set precisions... --- include/openPMD/auxiliary/JSON_internal.hpp | 3 ++ src/IO/ADIOS/ADIOS2File.cpp | 2 +- src/IO/ADIOS/ADIOS2IOHandler.cpp | 2 +- src/IO/HDF5/HDF5IOHandler.cpp | 2 +- src/IO/HDF5/ParallelHDF5IOHandler.cpp | 2 +- src/IO/IOTask.cpp | 3 +- src/IO/JSON/JSONIOHandlerImpl.cpp | 6 +-- src/auxiliary/JSON.cpp | 44 +++++++++++++++++++-- 8 files changed, 53 insertions(+), 11 deletions(-) diff --git a/include/openPMD/auxiliary/JSON_internal.hpp b/include/openPMD/auxiliary/JSON_internal.hpp index 4b28ccc6fe..dc72cffbdc 100644 --- a/include/openPMD/auxiliary/JSON_internal.hpp +++ b/include/openPMD/auxiliary/JSON_internal.hpp @@ -251,5 +251,8 @@ namespace json nlohmann::json &filterByTemplate( nlohmann::json &defaultVal, nlohmann::json const &positiveMask); + + template + std::string format_toml(toml_t &&); } // namespace json } // namespace openPMD diff --git a/src/IO/ADIOS/ADIOS2File.cpp b/src/IO/ADIOS/ADIOS2File.cpp index aaecf1a0fc..8dbb9d17e9 100644 --- a/src/IO/ADIOS/ADIOS2File.cpp +++ b/src/IO/ADIOS/ADIOS2File.cpp @@ -565,7 +565,7 @@ void ADIOS2File::configure_IO() auto asToml = json::jsonToToml(shadow); std::cerr << "Warning: parts of the backend configuration for " "ADIOS2 remain unused:\n" - << toml::format(asToml) << std::endl; + << json::format_toml(asToml) << std::endl; break; } } diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index bd2fab711e..d9d1e3eeb3 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -527,7 +527,7 @@ ADIOS2IOHandlerImpl::flush(internal::ParsedFlushParams &flushParams) auto asToml = json::jsonToToml(shadow); std::cerr << "Warning: parts of the backend configuration for " "ADIOS2 remain unused:\n" - << toml::format(asToml) << std::endl; + << json::format_toml(asToml) << std::endl; break; } } diff --git a/src/IO/HDF5/HDF5IOHandler.cpp b/src/IO/HDF5/HDF5IOHandler.cpp index 0437dd1fab..75166f91a3 100644 --- a/src/IO/HDF5/HDF5IOHandler.cpp +++ b/src/IO/HDF5/HDF5IOHandler.cpp @@ -174,7 +174,7 @@ HDF5IOHandlerImpl::HDF5IOHandlerImpl( std::cerr << "Warning: parts of the backend configuration for " "HDF5 remain unused:\n" - << toml::format(asToml) << std::endl; + << json::format_toml(asToml) << std::endl; break; } } diff --git a/src/IO/HDF5/ParallelHDF5IOHandler.cpp b/src/IO/HDF5/ParallelHDF5IOHandler.cpp index 8eec6fdb99..5d1968193a 100644 --- a/src/IO/HDF5/ParallelHDF5IOHandler.cpp +++ b/src/IO/HDF5/ParallelHDF5IOHandler.cpp @@ -334,7 +334,7 @@ ParallelHDF5IOHandlerImpl::ParallelHDF5IOHandlerImpl( auto asToml = json::jsonToToml(shadow); std::cerr << "Warning: parts of the backend configuration for " "HDF5 remain unused:\n" - << toml::format(asToml) << std::endl; + << json::format_toml(asToml) << std::endl; break; } } diff --git a/src/IO/IOTask.cpp b/src/IO/IOTask.cpp index 5a6605228b..47b0bea4ca 100644 --- a/src/IO/IOTask.cpp +++ b/src/IO/IOTask.cpp @@ -66,7 +66,8 @@ void Parameter::warnUnusedParameters< break; case json::SupportedLanguages::TOML: { auto asToml = json::jsonToToml(shadow); - std::cerr << warningMessage << toml::format(asToml) << std::endl; + std::cerr << warningMessage << json::format_toml(asToml) + << std::endl; break; } } diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index b91ae1fef9..e06aa36ed8 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -1378,9 +1378,9 @@ auto JSONIOHandlerImpl::putJsonContents( *fh_with_precision << *it->second << std::endl; break; case FileFormat::Toml: - *fh_with_precision - << toml::format(openPMD::json::jsonToToml(*it->second)) - << std::endl; + *fh_with_precision << openPMD::json::format_toml( + openPMD::json::jsonToToml(*it->second)) + << std::endl; break; } diff --git a/src/auxiliary/JSON.cpp b/src/auxiliary/JSON.cpp index 9349f14c35..cffab95bd9 100644 --- a/src/auxiliary/JSON.cpp +++ b/src/auxiliary/JSON.cpp @@ -25,8 +25,9 @@ #include "openPMD/Error.hpp" #include "openPMD/auxiliary/Filesystem.hpp" #include "openPMD/auxiliary/StringManip.hpp" +#include "openPMD/auxiliary/Variant.hpp" -#include +#include #include #include @@ -552,7 +553,7 @@ void warnGlobalUnusedOptions(TracingJSON const &config) std::cerr << "[Series] The following parts of the global TOML config " "remains unused:\n" - << toml::format(asToml) << std::endl; + << json::format_toml(asToml) << std::endl; } } } @@ -608,7 +609,7 @@ std::string merge(std::string const &defaultValue, std::string const &overwrite) case SupportedLanguages::TOML: { auto asToml = json::jsonToToml(res); std::stringstream sstream; - sstream << toml::format(asToml); + sstream << json::format_toml(asToml); return sstream.str(); } } @@ -642,4 +643,41 @@ filterByTemplate(nlohmann::json &defaultVal, nlohmann::json const &positiveMask) } // else noop return defaultVal; } + +namespace +{ + auto set_precision(toml::value &) -> void; + auto set_precision(toml::value &val) -> void + { + constexpr int precision = std::numeric_limits::digits10 + 1; + if (val.is_table()) + { + for (auto &pair : val.as_table()) + { + set_precision(pair.second); + } + } + else if (val.is_array()) + { + for (auto &entry : val.as_array()) + { + set_precision(entry); + } + } + else if (val.is_floating()) + { + val.as_floating_fmt().prec = precision; + } + } +} // namespace + +template +std::string format_toml(toml_t &&val) +{ + set_precision(val); + return toml::format(val); +} + +template std::string format_toml(toml::value &&); +template std::string format_toml(toml::value &); } // namespace openPMD::json From 2f47fdb25d3e2900733657bf0cce6f8006f19b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 9 Jul 2024 11:35:19 +0200 Subject: [PATCH 04/10] Compatibility with toml11 3.* --- src/auxiliary/JSON.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/auxiliary/JSON.cpp b/src/auxiliary/JSON.cpp index cffab95bd9..7c96221026 100644 --- a/src/auxiliary/JSON.cpp +++ b/src/auxiliary/JSON.cpp @@ -644,12 +644,24 @@ filterByTemplate(nlohmann::json &defaultVal, nlohmann::json const &positiveMask) return defaultVal; } +constexpr int toml_precision = std::numeric_limits::digits10 + 1; + +#if TOML11_VERSION_MAJOR < 4 +template +std ::string format_toml(toml_t &&val) +{ + std::stringstream res; + res << std::setprecision(toml_precision) << std::forward(val); + return res.str(); +} + +#else + namespace { auto set_precision(toml::value &) -> void; auto set_precision(toml::value &val) -> void { - constexpr int precision = std::numeric_limits::digits10 + 1; if (val.is_table()) { for (auto &pair : val.as_table()) @@ -666,7 +678,7 @@ namespace } else if (val.is_floating()) { - val.as_floating_fmt().prec = precision; + val.as_floating_fmt().prec = toml_precision; } } } // namespace @@ -675,9 +687,11 @@ template std::string format_toml(toml_t &&val) { set_precision(val); - return toml::format(val); + return toml::format(std::forward(val)); } +#endif + template std::string format_toml(toml::value &&); template std::string format_toml(toml::value &); } // namespace openPMD::json From 9cd34b40f4310ae005b95ea77b9046c16d98228a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 9 Jul 2024 11:39:10 +0200 Subject: [PATCH 05/10] Add a little comment in CMake --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96ac0d07db..57f8e504f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,6 +279,9 @@ if(openPMD_USE_INTERNAL_TOML11) message(STATUS "toml11: Using INTERNAL version '3.7.1'") else() find_package(toml11 CONFIG REQUIRED) + # Need to check the version manually. toml11 4.0 was a breaking change, so + # find_package(toml11 3.7.1) would not accept versions 4.0+. + # We support both 3.* and 4.*. if(${toml11_VERSION} VERSION_LESS 3.7.1) message(FATAL_ERROR "toml11: Found version '${toml11_VERSION}', but requires version '3.7.1' at least.") else() From d075b162a555e929aa0a3748691c445dc772635f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 9 Jul 2024 13:09:10 +0200 Subject: [PATCH 06/10] Add a toml11 4.0.3 CI run --- .github/workflows/linux.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ce3bb88ade..01f9ba6cef 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -133,6 +133,17 @@ jobs: python3.11 -m venv /opt/python_venv . /opt/python_venv/bin/activate python -m pip install numpy pandas + git clone https://github.com/ToruNiina/toml11 + cd toml11 + git checkout v4.0.3 + mkdir build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=../../toml11_install \ + -DCMAKE_CXX_STANDARD_REQUIRED=OFF \ + -DCMAKE_CXX_STANDARD=11 + make -j 2 install + cd ../.. - name: Build env: {CC: clang-14, CXX: clang++-14, CXXFLAGS: -Werror} run: | @@ -144,13 +155,15 @@ jobs: . /opt/python_venv/bin/activate share/openPMD/download_samples.sh build + export CMAKE_PREFIX_PATH="$(realpath toml_install):$CMAKE_PREFIX_PATH" cmake -S . -B build \ -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_MPI=OFF \ -DopenPMD_USE_HDF5=ON \ -DopenPMD_USE_ADIOS2=ON \ - -DopenPMD_USE_INVASIVE_TESTS=ON \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DopenPMD_USE_INVASIVE_TESTS=ON \ + -DopenPMD_USE_INTERNAL_TOML11=OFF \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ -DPython_EXECUTABLE="$(which python)" cmake --build build --parallel 2 ctest --test-dir build --output-on-failure From 1f1c22d2a1865737e580459eb25f3c54d9f2650b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 9 Jul 2024 13:26:20 +0200 Subject: [PATCH 07/10] tmp --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 01f9ba6cef..c3e5bd7c24 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -155,7 +155,7 @@ jobs: . /opt/python_venv/bin/activate share/openPMD/download_samples.sh build - export CMAKE_PREFIX_PATH="$(realpath toml_install):$CMAKE_PREFIX_PATH" + export CMAKE_PREFIX_PATH="$(realpath toml11_install):$CMAKE_PREFIX_PATH" cmake -S . -B build \ -DopenPMD_USE_PYTHON=ON \ -DopenPMD_USE_MPI=OFF \ From 1f8638387fddf6880c4345280a1e47687bdbe5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Wed, 10 Jul 2024 15:07:05 +0200 Subject: [PATCH 08/10] Use two different find_package() calls --- CMakeLists.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57f8e504f5..5e1efee0ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,15 +278,13 @@ if(openPMD_USE_INTERNAL_TOML11) add_subdirectory("${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/toml11") message(STATUS "toml11: Using INTERNAL version '3.7.1'") else() - find_package(toml11 CONFIG REQUIRED) - # Need to check the version manually. toml11 4.0 was a breaking change, so - # find_package(toml11 3.7.1) would not accept versions 4.0+. - # We support both 3.* and 4.*. - if(${toml11_VERSION} VERSION_LESS 3.7.1) - message(FATAL_ERROR "toml11: Found version '${toml11_VERSION}', but requires version '3.7.1' at least.") - else() - message(STATUS "toml11: Found version '${toml11_VERSION}'") + # Since toml11 4.0 was a breaking change, + # it needs separate find_package() calls + find_package(toml11 3.7.0 CONFIG QUIET) + if(NOT toml11_FOUND) + find_package(toml11 4.0 CONFIG REQUIRED) endif() + message(STATUS "toml11: Found version '${toml11_VERSION}'") endif() add_library(openPMD::thirdparty::toml11 INTERFACE IMPORTED) target_link_libraries(openPMD::thirdparty::toml11 From 9285abf36c8cb10e9eaabccc579438f4f36ac94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 16 Jul 2024 19:34:12 +0200 Subject: [PATCH 09/10] More concise build script for toml11 Co-authored-by: Axel Huebl --- .github/workflows/linux.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c3e5bd7c24..d90fc6c863 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -133,17 +133,12 @@ jobs: python3.11 -m venv /opt/python_venv . /opt/python_venv/bin/activate python -m pip install numpy pandas - git clone https://github.com/ToruNiina/toml11 - cd toml11 - git checkout v4.0.3 - mkdir build - cd build - cmake .. \ - -DCMAKE_INSTALL_PREFIX=../../toml11_install \ + git clone -b v4.0.3 https://github.com/ToruNiina/toml11 + cmake -S toml11 -B build_toml11 \ + -DCMAKE_INSTALL_PREFIX=toml11_install \ -DCMAKE_CXX_STANDARD_REQUIRED=OFF \ -DCMAKE_CXX_STANDARD=11 - make -j 2 install - cd ../.. + cmake --build build_toml11 -j 2 --target install - name: Build env: {CC: clang-14, CXX: clang++-14, CXXFLAGS: -Werror} run: | From 51198b555751d061eadf3de6dea9de08d0ec235e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Wed, 17 Jul 2024 12:05:20 +0200 Subject: [PATCH 10/10] Some cleanup, fixes and documentation in the find_package() logic --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e1efee0ca..c17631c6cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,11 +278,14 @@ if(openPMD_USE_INTERNAL_TOML11) add_subdirectory("${openPMD_SOURCE_DIR}/share/openPMD/thirdParty/toml11") message(STATUS "toml11: Using INTERNAL version '3.7.1'") else() - # Since toml11 4.0 was a breaking change, - # it needs separate find_package() calls - find_package(toml11 3.7.0 CONFIG QUIET) + # toml11 4.0 was a breaking change. This is reflected in the library's CMake + # logic: version 4.0 is not accepted by a call to find_package(toml11 3.7). + # Since we support both incompatible versions, we use two find_package() + # calls. Search for version 4 first in order to prefer that + # in (the unlikely) case that both versions are installed. + find_package(toml11 4.0 CONFIG QUIET) if(NOT toml11_FOUND) - find_package(toml11 4.0 CONFIG REQUIRED) + find_package(toml11 3.7.1 CONFIG REQUIRED) endif() message(STATUS "toml11: Found version '${toml11_VERSION}'") endif()