summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2013-09-25 13:52:19 +0200
committerRadek Novacek <rnovacek@redhat.com>2013-09-26 09:11:59 +0200
commit19edb566554ee5bc463cd14fe7ebfd45d942fbdc (patch)
tree7f442df6e541bf4059754e549badd664a17877c7 /cmake
parent0d5670dc1fdc08d863a230f7b6423155d6c53986 (diff)
downloadopenlmi-providers-19edb566554ee5bc463cd14fe7ebfd45d942fbdc.tar.gz
openlmi-providers-19edb566554ee5bc463cd14fe7ebfd45d942fbdc.tar.xz
openlmi-providers-19edb566554ee5bc463cd14fe7ebfd45d942fbdc.zip
fan: add FindLMSensors.cmake for finding lm_sensors
This file is required for enforcing that lm_sensors-devel is installed when building the provider from sources.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindLMSensors.cmake33
1 files changed, 33 insertions, 0 deletions
diff --git a/cmake/modules/FindLMSensors.cmake b/cmake/modules/FindLMSensors.cmake
new file mode 100644
index 0000000..2043fb9
--- /dev/null
+++ b/cmake/modules/FindLMSensors.cmake
@@ -0,0 +1,33 @@
+
+find_path(LMSENSORS_INCLUDE_DIR
+ NAMES sensors.h error.h
+ HINTS $ENV{LMSENSORS_INCLUDE_DIR}
+ PATH_SUFFIXES include/sensors include
+ PATHS /usr /usr/local
+)
+
+find_library(LMSENSORS_LIBRARY
+ NAMES sensors
+ HINTS $ENV{LMSENSORS_LIB_DIR}
+ PATH_SUFFIXES lib64 lib
+ PATHS /usr /usr/local
+)
+
+if (LMSENSORS_INCLUDE_DIR AND EXISTS "${LMSENSORS_INCLUDE_DIR}/sensors.h")
+ file(STRINGS "${LMSENSORS_INCLUDE_DIR}/sensors.h" lmsensors_version_str
+ REGEX "^#[\t ]*define[\t ]+SENSORS_API_VERSION[\t ]+0x[0-9]+$")
+ string(REGEX REPLACE "^.*SENSORS_API_VERSION[\t ]+0x([0-9]+).*$" "\\1" LMSENSORS_VERSION_STR "${lmsensors_version_str}")
+ unset(lmsensors_version_str)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LMSENSORS
+ REQUIRED_VARS LMSENSORS_INCLUDE_DIR LMSENSORS_LIBRARY
+ VERSION_VAR LMSENSORS_VERSION_STR)
+
+if(LMSENSORS_FOUND)
+ set(LMSENSORS_LIBRARIES ${LMSENSORS_LIBRARY})
+ set(LMSENSORS_INCLUDE_DIRS ${LMSENSORS_INCLUDE_DIR})
+endif(LMSENSORS_FOUND)
+
+mark_as_advanced(LMSENSORS_INCLUDE_DIR LMSENSORS_LIBRARY)