Neale Ranns | e3282ba | 2019-07-30 06:20:39 -0700 | [diff] [blame] | 1 | # Copyright (c) 2018 Cisco and/or its affiliates. |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | # you may not use this file except in compliance with the License. |
| 4 | # You may obtain a copy of the License at: |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. |
| 13 | |
| 14 | ######################################## |
| 15 | # |
| 16 | # Find the Libcheck library and includes |
| 17 | # This module sets: |
| 18 | # CHECK_FOUND: True if Libcheck was found |
| 19 | # CHECK_LIBRARY: The Libcheck library |
| 20 | # CHECK_INCLUDE_DIR: The Libcheck include dir |
| 21 | # |
| 22 | |
| 23 | set(CHECK_SEARCH_PATH_LIST |
| 24 | ${CHECK_HOME} |
| 25 | $ENV{CHECK_HOME} |
| 26 | /usr/local |
| 27 | /opt |
| 28 | /usr |
| 29 | ) |
| 30 | |
| 31 | find_path(CHECK_INCLUDE_DIR check.h |
| 32 | HINTS ${CHECK_SEARCH_PATH_LIST} |
| 33 | PATH_SUFFIXES include |
| 34 | DOC "Find the check includes" |
| 35 | ) |
| 36 | |
| 37 | find_library(CHECK_LIBRARY NAMES check |
| 38 | HINTS ${CHECK_SEARCH_PATH_LIST} |
| 39 | PATH_SUFFIXES lib |
| 40 | DOC "Find the check libraries" |
| 41 | ) |
| 42 | |
| 43 | execute_process( |
| 44 | COMMAND grep "CHECK_MICRO_VERSION" ${CHECK_INCLUDE_DIR}/check.h |
| 45 | COMMAND grep -Eo [0-9]+ |
| 46 | OUTPUT_VARIABLE CHECK_MICRO_VERSION |
| 47 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 48 | ) |
| 49 | |
| 50 | execute_process( |
| 51 | COMMAND grep "CHECK_MINOR_VERSION" ${CHECK_INCLUDE_DIR}/check.h |
| 52 | COMMAND grep -Eo [0-9]+ |
| 53 | OUTPUT_VARIABLE CHECK_MINOR_VERSION |
| 54 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 55 | ) |
| 56 | |
| 57 | execute_process( |
| 58 | COMMAND grep "CHECK_MAJOR_VERSION" ${CHECK_INCLUDE_DIR}/check.h |
| 59 | COMMAND grep -Eo [0-9]+ |
| 60 | OUTPUT_VARIABLE CHECK_MAJOR_VERSION |
| 61 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 62 | ) |
| 63 | |
| 64 | set(CHECK_VERSION "${CHECK_MAJOR_VERSION}.${CHECK_MINOR_VERSION}.${CHECK_MICRO_VERSION}") |
| 65 | |
| 66 | include(FindPackageHandleStandardArgs) |
| 67 | find_package_handle_standard_args( |
| 68 | Check |
| 69 | REQUIRED_VARS CHECK_LIBRARY CHECK_INCLUDE_DIR |
| 70 | VERSION_VAR CHECK_VERSION |
| 71 | ) |