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