|
0 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
1 |
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
2 |
|
|
3 |
#[=======================================================================[.rst:
|
|
4 |
FindCheck
|
|
5 |
--------
|
|
6 |
|
|
7 |
Find the Check (Unit Testing Framework for C) library
|
|
8 |
|
|
9 |
Imported targets
|
|
10 |
^^^^^^^^^^^^^^^^
|
|
11 |
|
|
12 |
This module defines the following :prop_tgt:`IMPORTED` targets:
|
|
13 |
|
|
14 |
``Check::Check``
|
|
15 |
The Check library, if found.
|
|
16 |
|
|
17 |
Result variables
|
|
18 |
^^^^^^^^^^^^^^^^
|
|
19 |
|
|
20 |
This module will set the following variables in your project:
|
|
21 |
|
|
22 |
``Check_FOUND``
|
|
23 |
If false, do not try to use Check.
|
|
24 |
``CHECK_INCLUDE_DIR``
|
|
25 |
where to find check.h, etc.
|
|
26 |
``CHECK_LIBRARIES``
|
|
27 |
the libraries needed to use Check.
|
|
28 |
``CHECK_VERSION``
|
|
29 |
the version of the Check library found
|
|
30 |
|
|
31 |
#]=======================================================================]
|
|
32 |
|
|
33 |
find_path(CHECK_INCLUDE_DIR check.h
|
|
34 |
HINTS
|
|
35 |
${PC_CHECK_INCLUDEDIR}
|
|
36 |
${PC_CHECK_INCLUDE_DIRS}
|
|
37 |
)
|
|
38 |
|
|
39 |
# Check for PIC and non-PIC libraries. If PIC present, use that
|
|
40 |
# in preference (as per Debian check.pc).
|
|
41 |
find_library(CHECK_LIBRARY NAMES check_pic libcheck_pic
|
|
42 |
HINTS
|
|
43 |
${PC_CHECK_LIBDIR}
|
|
44 |
${PC_CHECK_LIBRARY_DIRS}
|
|
45 |
)
|
|
46 |
|
|
47 |
if (NOT CHECK_LIBRARY)
|
|
48 |
find_library(CHECK_LIBRARY NAMES check libcheck
|
|
49 |
HINTS
|
|
50 |
${PC_CHECK_LIBDIR}
|
|
51 |
${PC_CHECK_LIBRARY_DIRS}
|
|
52 |
)
|
|
53 |
endif ()
|
|
54 |
|
|
55 |
set(CHECK_LIBRARIES "")
|
|
56 |
|
|
57 |
# Check may need the math, subunit and rt libraries on Unix
|
|
58 |
if (UNIX)
|
|
59 |
find_library(CHECK_MATH_LIBRARY m)
|
|
60 |
find_library(CHECK_RT_LIBRARY rt)
|
|
61 |
find_library(CHECK_SUBUNIT_LIBRARY subunit)
|
|
62 |
|
|
63 |
if (CHECK_MATH_LIBRARY)
|
|
64 |
list(APPEND CHECK_LIBRARIES "${CHECK_MATH_LIBRARY}")
|
|
65 |
endif ()
|
|
66 |
if (CHECK_RT_LIBRARY)
|
|
67 |
list(APPEND CHECK_LIBRARIES "${CHECK_RT_LIBRARY}")
|
|
68 |
endif ()
|
|
69 |
if (CHECK_SUBUNIT_LIBRARY)
|
|
70 |
list(APPEND CHECK_LIBRARIES "${CHECK_SUBUNIT_LIBRARY}")
|
|
71 |
endif ()
|
|
72 |
endif()
|
|
73 |
|
|
74 |
if (CHECK_INCLUDE_DIR AND CHECK_LIBRARY)
|
|
75 |
if (NOT TARGET Check::Check)
|
|
76 |
add_library(Check::Check UNKNOWN IMPORTED)
|
|
77 |
set_target_properties(Check::Check PROPERTIES
|
|
78 |
INTERFACE_INCLUDE_DIRECTORIES "${CHECK_INCLUDE_DIR}"
|
|
79 |
INTERFACE_LINK_LIBRARIES "${CHECK_LIBRARIES}"
|
|
80 |
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
|
81 |
IMPORTED_LOCATION "${CHECK_LIBRARY}"
|
|
82 |
)
|
|
83 |
endif ()
|
|
84 |
|
|
85 |
if (NOT CHECK_VERSION AND CHECK_INCLUDE_DIR AND EXISTS "${CHECK_INCLUDE_DIR}/check.h")
|
|
86 |
file(STRINGS "${CHECK_INCLUDE_DIR}/check.h" CHECK_H REGEX "^#define CHECK_M[A-Z]+_VERSION")
|
|
87 |
string(REGEX REPLACE "^.*\(([0-9]+)\).*\(([0-9]+)\).*\(([0-9]+)\).*$" "\\1.\\2.\\3" CHECK_VERSION "${CHECK_H}")
|
|
88 |
endif ()
|
|
89 |
endif()
|
|
90 |
|
|
91 |
list(APPEND CHECK_LIBRARIES "${CHECK_LIBRARY}")
|
|
92 |
|
|
93 |
include(FindPackageHandleStandardArgs)
|
|
94 |
find_package_handle_standard_args(Check
|
|
95 |
REQUIRED_VARS CHECK_LIBRARIES CHECK_INCLUDE_DIR
|
|
96 |
VERSION_VAR CHECK_VERSION
|
|
97 |
)
|
|
98 |
|
|
99 |
mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARIES)
|