[490] | 1 | # - Try to find libmodbus |
---|
| 2 | # Once done this will define |
---|
| 3 | # |
---|
| 4 | # MODBUS_FOUND - system has MODBUS |
---|
| 5 | # MODBUS_INCLUDE_DIR - the MODBUS include directory |
---|
| 6 | # MODBUS_LIBRARIES - Link these to use MODBUS |
---|
| 7 | |
---|
| 8 | # Copyright (c) 2006, Jasem Mutlaq <mutlaqja@ikarustech.com> |
---|
| 9 | # Based on FindLibfacile by Carsten Niehaus, <cniehaus@gmx.de> |
---|
| 10 | # |
---|
| 11 | # Redistribution and use is allowed according to the terms of the BSD license. |
---|
| 12 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
---|
| 13 | |
---|
| 14 | if (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) |
---|
| 15 | |
---|
| 16 | # in cache already |
---|
| 17 | set(MODBUS_FOUND TRUE) |
---|
| 18 | message(STATUS "Found libmodbus: ${MODBUS_LIBRARIES}") |
---|
| 19 | |
---|
| 20 | else (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) |
---|
| 21 | |
---|
| 22 | find_path(MODBUS_INCLUDE_DIR modbus.h |
---|
| 23 | PATH_SUFFIXES modbus |
---|
| 24 | ${_obIncDir} |
---|
| 25 | ${GNUWIN32_DIR}/include |
---|
| 26 | ) |
---|
| 27 | |
---|
| 28 | find_library(MODBUS_LIBRARIES NAMES modbus |
---|
| 29 | PATHS |
---|
| 30 | ${_obLinkDir} |
---|
| 31 | ${GNUWIN32_DIR}/lib |
---|
| 32 | ) |
---|
| 33 | |
---|
| 34 | set(CMAKE_REQUIRED_INCLUDES ${MODBUS_INCLUDE_DIR}) |
---|
| 35 | set(CMAKE_REQUIRED_LIBRARIES ${MODBUS_LIBRARIES}) |
---|
| 36 | |
---|
| 37 | if(MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) |
---|
| 38 | set(MODBUS_FOUND TRUE) |
---|
| 39 | else (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) |
---|
| 40 | set(MODBUS_FOUND FALSE) |
---|
| 41 | endif(MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) |
---|
| 42 | |
---|
| 43 | if (MODBUS_FOUND) |
---|
| 44 | if (NOT MODBUS_FIND_QUIETLY) |
---|
| 45 | message(STATUS "Found libmodbus: ${MODBUS_LIBRARIES}") |
---|
| 46 | endif (NOT MODBUS_FIND_QUIETLY) |
---|
| 47 | else (MODBUS_FOUND) |
---|
| 48 | if (MODBUS_FIND_REQUIRED) |
---|
| 49 | message(FATAL_ERROR "libmodbus not found. Please install libmodbus-devel. https://launchpad.net/libmodbus/") |
---|
| 50 | endif (MODBUS_FIND_REQUIRED) |
---|
| 51 | endif (MODBUS_FOUND) |
---|
| 52 | |
---|
| 53 | mark_as_advanced(MODBUS_INCLUDE_DIR MODBUS_LIBRARIES) |
---|
| 54 | |
---|
| 55 | endif (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) |
---|
| 56 | |
---|