Skip to content

Commit

Permalink
cmake/modules/Findpmem: always set pmem_VERSION_STRING
Browse files Browse the repository at this point in the history
before this change, `pmem_VERSION_STRING` is not set if it is not able
to fulfill the specified version requirement. the intention was to check
if the version is able to satisfy the requirement. but actually, passing
an empty `pmem_VERSION_STRING` to `find_package_handle_standard_args()`
as the option of `VERSION_VAR` does not fail this check. on the
contrary, it prints

-- Found pmem: pmem_pmemobj_INCLUDE_DIR;pmem_pmem_INCLUDE_DIR (Required
is at least version "1.17")

if we requires pmem 1.17, while the found version is, for instance,
1.10.

if the required version is 1.7, and the found version is 1.10, the
output from cmake is:

-- Found pmem: pmem_pmemobj_INCLUDE_DIR;pmem_pmem_INCLUDE_DIR (found
suitable version "1.10", minimum required is "1.7")

in this change, the version spec is not specified when calling
`pkg_check_modules()`. so, `PKG_${component}_VERSION` is always set.
and we can always delegate the version checking to
`find_package_handle_standard_args()`. please note, we use the lower
version returned by pkg-config if multiple components are required and
both pkg-config settings return their versions.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Apr 26, 2021
1 parent ecb8d2c commit ad85af2
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions cmake/modules/Findpmem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@ foreach(component ${pmem_FIND_COMPONENTS})
if(found EQUAL -1)
message(FATAL_ERROR "unknown libpmem component: ${component}")
endif()
set(pkg_module_spec "lib${component}")
if(pmem_FIND_VERSION_EXACT)
set(pkg_module_spec "lib${component}=${pmem_FIND_VERSION}")
elseif(pmem_FIND_VERSION)
set(pkg_module_spec "lib${component}>=${pmem_FIND_VERSION}")
endif()
pkg_check_modules(PKG_${component} QUIET ${pkg_module_spec})
pkg_check_modules(PKG_${component} QUIET "lib${component}")
if(NOT pmem_VERSION_STRING OR PKG_${component}_VERSION VERSION_LESS pmem_VERSION_STRING)
set(pmem_VERSION_STRING ${PKG_${component}_VERSION})
endif()
pkg_check_modules(PKG_${component} QUIET lib${component})
find_path(pmem_${component}_INCLUDE_DIR
NAMES lib${component}.h
HINTS ${PKG_${component}_INCLUDE_DIRS})
Expand Down

0 comments on commit ad85af2

Please sign in to comment.