From 7c5c6fa65c9f0ac8862baf8ab74ad69dd0beb4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 17 Mar 2021 13:17:39 +0200 Subject: [PATCH] MDEV-25090: Depend on libpmem where available WITH_PMEM: Change the parameter from BOOL to a ternary STRING with a default value that allows to use libpmem when it is available. In this way, a libpmem dependency will be automatically installed on other than Debian-based systems, based on what is available on the continuous integraton system for building the packages. WITH_PMEM=auto (default): Use libpmem when available. WITH_PMEM=yes: Require libpmem to be available. WITH_PMEM=no: Do not depend on libpmem. --- cmake/pmem.cmake | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cmake/pmem.cmake b/cmake/pmem.cmake index b59db3cc1f9..84c00aaed6d 100644 --- a/cmake/pmem.cmake +++ b/cmake/pmem.cmake @@ -1,13 +1,26 @@ INCLUDE(CheckIncludeFiles) -OPTION(WITH_PMEM "Enable persistent memory features" OFF) -IF(WITH_PMEM) +SET(WITH_PMEM "auto" CACHE STRING "Enable persistent memory features") +IF(WITH_PMEM STREQUAL "yes" OR WITH_PMEM STREQUAL "auto") FIND_LIBRARY(LIBPMEM pmem) CHECK_INCLUDE_FILES(libpmem.h HAVE_LIBPMEM_H) IF (NOT LIBPMEM) - MESSAGE(FATAL_ERROR "Can't find libpmem") + IF(WITH_PMEM STREQUAL "yes") + MESSAGE(FATAL_ERROR "Can't find libpmem") + ENDIF() + UNSET(HAVE_LIBPMEM_H CACHE) + UNSET(LIBPMEM CACHE) ELSEIF(NOT HAVE_LIBPMEM_H) - MESSAGE(FATAL_ERROR "Can't find libpmem.h") + IF(WITH_PMEM STREQUAL "yes") + MESSAGE(FATAL_ERROR "Can't find libpmem.h") + ENDIF() + UNSET(HAVE_LIBPMEM_H CACHE) + UNSET(LIBPMEM CACHE) ELSE() ADD_DEFINITIONS(-DHAVE_PMEM) ENDIF() +ELSEIF(WITH_PMEM STREQUAL "no") + UNSET(HAVE_LIBPMEM_H CACHE) + UNSET(LIBPMEM CACHE) +ELSE() + MESSAGE(FATAL_ERROR "Invalid value for WITH_PMEM. Must be 'yes', 'no', or 'auto'.") ENDIF()