summaryrefslogtreecommitdiffstats
path: root/cmake/modules/Findndctl.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /cmake/modules/Findndctl.cmake
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/modules/Findndctl.cmake')
-rw-r--r--cmake/modules/Findndctl.cmake42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmake/modules/Findndctl.cmake b/cmake/modules/Findndctl.cmake
new file mode 100644
index 000000000..12afa1781
--- /dev/null
+++ b/cmake/modules/Findndctl.cmake
@@ -0,0 +1,42 @@
+# - Find libndctl
+# Find the ndctl libraries and includes
+#
+# ndctl_INCLUDE_DIR - where to find libndctl.h etc.
+# ndctl_LIBRARIES - List of libraries when using ndctl.
+# ndctl_FOUND - True if ndctl found.
+
+find_path(ndctl_INCLUDE_DIR ndctl/libndctl.h)
+
+if(ndctl_INCLUDE_DIR AND EXISTS "${ndctl_INCLUDE_DIR}/libndctl.h")
+ foreach(ver "MAJOR" "MINOR" "RELEASE")
+ file(STRINGS "${ndctl_INCLUDE_DIR}/libndctl.h" ndctl_VER_${ver}_LINE
+ REGEX "^#define[ \t]+ndctl_VERSION_${ver}[ \t]+[0-9]+[ \t]+.*$")
+ string(REGEX REPLACE "^#define[ \t]+ndctl_VERSION_${ver}[ \t]+([0-9]+)[ \t]+.*$"
+ "\\1" ndctl_VERSION_${ver} "${ndctl_VER_${ver}_LINE}")
+ unset(${ndctl_VER_${ver}_LINE})
+ endforeach()
+ set(ndctl_VERSION_STRING
+ "${ndctl_VERSION_MAJOR}.${ndctl_VERSION_MINOR}.${ndctl_VERSION_RELEASE}")
+endif()
+
+find_library(ndctl_LIBRARY ndctl)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ndctl
+ REQUIRED_VARS ndctl_LIBRARY ndctl_INCLUDE_DIR
+ VERSION_VAR ndctl_VERSION_STRING)
+
+mark_as_advanced(ndctl_INCLUDE_DIR ndctl_LIBRARY)
+
+if(ndctl_FOUND)
+ set(ndctl_INCLUDE_DIRS ${ndctl_INCLUDE_DIR})
+ set(ndctl_LIBRARIES ${ndctl_LIBRARY})
+ if(NOT (TARGET ndctl::ndctl))
+ add_library(ndctl::ndctl UNKNOWN IMPORTED)
+ set_target_properties(ndctl::ndctl PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${ndctl_INCLUDE_DIRS}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${ndctl_LIBRARIES}"
+ VERSION "${ndctl_VERSION_STRING}")
+ endif()
+endif()