|
13 | 13 | # LibEdit_LIBRARIES - libraries to link
|
14 | 14 | # LibEdit_VERSION_STRING - version number
|
15 | 15 |
|
16 |
| -if(LibEdit_INCLUDE_DIRS AND LibEdit_LIBRARIES) |
17 |
| - set(LibEdit_FOUND TRUE) |
18 |
| -else() |
19 |
| - find_package(PkgConfig QUIET) |
20 |
| - pkg_check_modules(PC_LIBEDIT QUIET libedit) |
| 16 | +find_package(PkgConfig QUIET) |
| 17 | +pkg_check_modules(PC_LIBEDIT QUIET libedit) |
21 | 18 |
|
22 |
| - find_path(LibEdit_INCLUDE_DIRS |
23 |
| - NAMES |
24 |
| - histedit.h |
25 |
| - HINTS |
26 |
| - ${PC_LIBEDIT_INCLUDEDIR} |
27 |
| - ${PC_LIBEDIT_INCLUDE_DIRS} |
28 |
| - "${CMAKE_INSTALL_FULL_INCLUDEDIR}") |
29 |
| - find_library(LibEdit_LIBRARIES |
30 |
| - NAMES |
31 |
| - edit libedit |
32 |
| - HINTS |
33 |
| - ${PC_LIBEDIT_LIBDIR} |
34 |
| - ${PC_LIBEDIT_LIBRARY_DIRS} |
35 |
| - "${CMAKE_INSTALL_FULL_LIBDIR}") |
| 19 | +find_path(LibEdit_INCLUDE_DIRS NAMES histedit.h HINTS ${PC_LIBEDIT_INCLUDE_DIRS}) |
| 20 | +find_library(LibEdit_LIBRARIES NAMES edit HINTS ${PC_LIBEDIT_LIBRARY_DIRS}) |
36 | 21 |
|
37 |
| - if(LibEdit_INCLUDE_DIRS AND EXISTS "${LibEdit_INCLUDE_DIRS}/histedit.h") |
| 22 | +include(CheckIncludeFile) |
| 23 | +if(LibEdit_INCLUDE_DIRS AND EXISTS "${LibEdit_INCLUDE_DIRS}/histedit.h") |
| 24 | + cmake_push_check_state() |
| 25 | + list(APPEND CMAKE_REQUIRED_INCLUDES ${LibEdit_INCLUDE_DIRS}) |
| 26 | + list(APPEND CMAKE_REQUIRED_LIBRARIES ${LibEdit_LIBRARIES}) |
| 27 | + check_include_file(histedit.h HAVE_HISTEDIT_H) |
| 28 | + cmake_pop_check_state() |
| 29 | + if (HAVE_HISTEDIT_H) |
38 | 30 | file(STRINGS "${LibEdit_INCLUDE_DIRS}/histedit.h"
|
39 |
| - libedit_major_version_str |
40 |
| - REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+") |
| 31 | + libedit_major_version_str |
| 32 | + REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+") |
41 | 33 | string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MAJOR[ \t]+([0-9]+)" "\\1"
|
42 |
| - LIBEDIT_MAJOR_VERSION "${libedit_major_version_str}") |
| 34 | + libedit_major_version "${libedit_major_version_str}") |
43 | 35 |
|
44 | 36 | file(STRINGS "${LibEdit_INCLUDE_DIRS}/histedit.h"
|
45 |
| - libedit_minor_version_str |
46 |
| - REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+") |
| 37 | + libedit_minor_version_str |
| 38 | + REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+") |
47 | 39 | string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MINOR[ \t]+([0-9]+)" "\\1"
|
48 |
| - LIBEDIT_MINOR_VERSION "${libedit_minor_version_str}") |
| 40 | + libedit_minor_version "${libedit_minor_version_str}") |
49 | 41 |
|
50 | 42 | set(LibEdit_VERSION_STRING "${libedit_major_version}.${libedit_minor_version}")
|
| 43 | + else() |
| 44 | + set(LibEdit_INCLUDE_DIRS "") |
| 45 | + set(LibEdit_LIBRARIES "") |
51 | 46 | endif()
|
52 |
| - |
53 |
| - include(FindPackageHandleStandardArgs) |
54 |
| - find_package_handle_standard_args(LibEdit |
55 |
| - FOUND_VAR |
56 |
| - LibEdit_FOUND |
57 |
| - REQUIRED_VARS |
58 |
| - LibEdit_INCLUDE_DIRS |
59 |
| - LibEdit_LIBRARIES |
60 |
| - VERSION_VAR |
61 |
| - LibEdit_VERSION_STRING) |
62 |
| - mark_as_advanced(LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) |
63 | 47 | endif()
|
64 | 48 |
|
| 49 | +include(FindPackageHandleStandardArgs) |
| 50 | +find_package_handle_standard_args(LibEdit |
| 51 | + FOUND_VAR |
| 52 | + LibEdit_FOUND |
| 53 | + REQUIRED_VARS |
| 54 | + LibEdit_INCLUDE_DIRS |
| 55 | + LibEdit_LIBRARIES |
| 56 | + VERSION_VAR |
| 57 | + LibEdit_VERSION_STRING) |
| 58 | +mark_as_advanced(LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) |
| 59 | + |
65 | 60 | if (LibEdit_FOUND AND NOT TARGET LibEdit::LibEdit)
|
66 | 61 | add_library(LibEdit::LibEdit UNKNOWN IMPORTED)
|
67 | 62 | set_target_properties(LibEdit::LibEdit PROPERTIES
|
|
0 commit comments