|
1 | 1 | #.rst: |
2 | | -# FindLCF |
| 2 | +# liblcf-config |
3 | 3 | # ------- |
4 | 4 | # |
5 | | -# Find the native liblcf headers and library. |
| 5 | +# Exports the native liblcf headers and library. |
6 | 6 | # |
7 | 7 | # Imported Targets |
8 | 8 | # ^^^^^^^^^^^^^^^^ |
|
26 | 26 | # ``LIBLCF_VERSION_STRING`` |
27 | 27 | # version of liblcf |
28 | 28 |
|
29 | | -find_package(PkgConfig QUIET) |
30 | | - |
31 | | -pkg_check_modules(PC_LIBLCF QUIET lcf) |
| 29 | +# Compute the installation prefix relative to this file. |
| 30 | +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) |
| 31 | +# Use original install prefix when loaded through a |
| 32 | +# cross-prefix symbolic link such as /lib -> /usr/lib. |
| 33 | +get_filename_component(_realCurr "${_IMPORT_PREFIX}" REALPATH) |
| 34 | +get_filename_component(_realOrig "@CMAKE_INSTALL_FULL_LIBDIR@/cmake/liblcf" REALPATH) |
| 35 | +if(_realCurr STREQUAL _realOrig) |
| 36 | + set(_IMPORT_PREFIX "${_realOrig}") |
| 37 | +endif() |
| 38 | +unset(_realOrig) |
| 39 | +unset(_realCurr) |
| 40 | +# peel layers until above library directory |
| 41 | +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) |
| 42 | +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) |
| 43 | +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) |
| 44 | +# debian multiarch has one layer more |
| 45 | +if(_IMPORT_PREFIX MATCHES ".+/lib$") |
| 46 | + get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) |
| 47 | +endif() |
| 48 | +if(_IMPORT_PREFIX STREQUAL "/") |
| 49 | + set(_IMPORT_PREFIX "") |
| 50 | +endif() |
32 | 51 |
|
33 | | -# Look for the header file. |
34 | | -find_path(LIBLCF_INCLUDE_DIR |
35 | | - NAMES "lcf/reader_lcf.h" |
36 | | - PATH_SUFFIXES liblcf lcf |
37 | | - HINTS ${PC_LIBLCF_INCLUDE_DIRS}) |
| 52 | +# Set the header file directory. |
| 53 | +set(LIBLCF_INCLUDE_DIR "${_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@" |
| 54 | + CACHE PATH "LCF include directory") |
38 | 55 |
|
39 | 56 | # Look for the library. |
40 | 57 | # Allow LIBLCF_LIBRARY to be set manually, as the location of the liblcf library |
41 | 58 | if(NOT LIBLCF_LIBRARY) |
42 | 59 | find_library(LIBLCF_LIBRARY_RELEASE |
43 | | - NAMES lcf liblcf |
44 | | - HINTS ${PC_LIBLCF_LIBRARY_DIRS}) |
| 60 | + NAMES lcf |
| 61 | + PATHS ${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@ |
| 62 | + DOC "LCF library (release)" |
| 63 | + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
45 | 64 |
|
46 | 65 | find_library(LIBLCF_LIBRARY_DEBUG |
47 | | - NAMES lcf@CMAKE_DEBUG_POSTFIX@ liblcf@CMAKE_DEBUG_POSTFIX@ |
48 | | - HINTS ${PC_LIBLCF_LIBRARY_DIRS}) |
| 66 | + NAMES lcf@CMAKE_DEBUG_POSTFIX@ |
| 67 | + PATHS ${_IMPORT_PREFIX}/@CMAKE_INSTALL_LIBDIR@ |
| 68 | + DOC "LCF library (debug)" |
| 69 | + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
49 | 70 |
|
50 | 71 | include(SelectLibraryConfigurations) |
51 | 72 | select_library_configurations(LIBLCF) |
@@ -107,10 +128,8 @@ if(LIBLCF_FOUND) |
107 | 128 | IMPORTED_LOCATION "${LIBLCF_LIBRARY}") |
108 | 129 | endif() |
109 | 130 |
|
110 | | - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.8") |
111 | | - set_property(TARGET liblcf::liblcf APPEND PROPERTY |
112 | | - COMPILE_FEATURES cxx_std_14) |
113 | | - endif() |
| 131 | + set_property(TARGET liblcf::liblcf APPEND PROPERTY |
| 132 | + COMPILE_FEATURES cxx_std_14) |
114 | 133 |
|
115 | 134 | mark_as_advanced(LIBLCF_LINK_LIBRARIES) |
116 | 135 | endif() |
|
0 commit comments