On Mon, Feb 2, 2026 at 10:56 AM Branko Čibej <[email protected]> wrote:
> On 2. 2. 26 10:49, Timofei Zhakov wrote:
> [...]
>
> I lied. There is a better way to check versions.
>
> As it turns out, both find_package() and pkg_search_module() have this
> functionality out-of-the-box. Here is what I would propose:
>
> [[[
> Index: CMakeLists.txt
> ===================================================================
> --- CMakeLists.txt (revision 1931642)
> +++ CMakeLists.txt (working copy)
> @@ -377,18 +377,12 @@ endif()
> ### Serf
> if (SVN_ENABLE_RA_SERF)
> if(SVN_USE_PKG_CONFIG)
> - pkg_search_module(serf IMPORTED_TARGET REQUIRED serf-2 serf-1)
> + pkg_search_module(serf IMPORTED_TARGET REQUIRED serf-2 serf-1>=1.3.4)
> add_library(external-serf ALIAS PkgConfig::serf)
> - set(DETECTED_SERF_VERSION "${serf_VERSION}")
> else()
> - find_package(Serf REQUIRED)
> + find_package(Serf REQUIRED 1.3.4)
> add_library(external-serf ALIAS Serf::Serf)
> - set(DETECTED_SERF_VERSION "${Serf_VERSION}")
> endif()
> -
> - if("${DETECTED_SERF_VERSION}" VERSION_LESS 1.3.4)
> - message(FATAL_ERROR "Serf 1.3.4 or later required, found
> ${DETECTED_SERF_VERSION}")
> - endif()
> endif()
>
> if (SVN_CHECKSUM_BACKEND STREQUAL "apr")
> ]]]
>
> I'm assuming that serf-2 with a lower version is impossible.
>
>
> That would be a deadly sin against semver. :) serf-2 will be >=2.0.0, <3.
>
I mean a stray electron could strike a CPU at any point and invert a bit
responsible for storing this version. Or an evil man might have changed it
to bring some chaos in there.
But I hope it's not the case where this should be checked ;-)
--
Timofei Zhakov