]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake/modules/Findpmem: always set pmem_VERSION_STRING 43772/head
authorKefu Chai <kchai@redhat.com>
Mon, 26 Apr 2021 03:26:11 +0000 (11:26 +0800)
committerDeepika Upadhyay <dupadhya@redhat.com>
Tue, 9 Nov 2021 11:32:32 +0000 (17:02 +0530)
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 <kchai@redhat.com>
(cherry picked from commit ad85af2ef8b76481adc0d1500033cd5094b8f21e)

 Conflicts:
cmake/modules/Findpmem.cmake
<<<<<<< HEAD
=======
  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()
  find_path(pmem_${component}_INCLUDE_DIR
    NAMES lib${component}.h
    HINTS ${PKG_${component}_INCLUDE_DIRS})
  find_library(pmem_${component}_LIBRARY
    NAMES ${component}
    HINTS ${PKG_${component}_LIBRARY_DIRS})
>>>>>>> ad85af2ef8b (cmake/modules/Findpmem: always set pmem_VERSION_STRING)

cmake/modules/Findpmem.cmake

index b30d9ae6bbbb15fb9e273ae1e1d7c519a3b31200..9c8e21b918877ca88e39a6fbe208bf6754ea09e7 100644 (file)
@@ -14,6 +14,16 @@ foreach(component pmem ${pmem_FIND_COMPONENTS})
   else()
     message(FATAL_ERROR "unknown libpmem component: ${component}")
   endif()
+  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()
+  find_path(pmem_${component}_INCLUDE_DIR
+    NAMES lib${component}.h
+    HINTS ${PKG_${component}_INCLUDE_DIRS})
+  find_library(pmem_${component}_LIBRARY
+    NAMES ${component}
+    HINTS ${PKG_${component}_LIBRARY_DIRS})
   mark_as_advanced(
     pmem_${component}_INCLUDE_DIR
     pmem_${component}_LIBRARY)