neovim/cmake/FindLibTermkey.cmake
Daniel Hahler 6765bbc651
build: CMake: remove usage of USE_BUNDLED_X in main project (#10354)
The variables are not meant to be defined there really, but only with
the third-party project.

Using them, e.g. with the following, would actually result in libvterm
not being found then:

    make CMAKE_EXTRA_FLAGS="-DUSE_BUNDLED_LIBVTERM=ON" \
      DEPS_CMAKE_FLAGS="-DUSE_BUNDLED=OFF -DUSE_BUNDLED_LIBVTERM=ON"

In https://github.com/neovim/neovim/pull/6357 they were renamed to
`USE_BUNDLED_X` from `X_USE_BUNDLED`, but the above reasoning applies
to the old names, too.

Internally `CMAKE_PREFIX_PATH` is used to add the built/bundled third
party packages for `find_package`, so there is no reason to e.g. query
the values via `load_cache` for example from the third-party project.
2019-06-28 02:02:19 +02:00

38 lines
1.3 KiB
CMake

# - Try to find libtermkey
# Once done this will define
# LIBTERMKEY_FOUND - System has libtermkey
# LIBTERMKEY_INCLUDE_DIRS - The libtermkey include directories
# LIBTERMKEY_LIBRARIES - The libraries needed to use libtermkey
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBTERMKEY QUIET termkey)
endif()
set(LIBTERMKEY_DEFINITIONS ${PC_LIBTERMKEY_CFLAGS_OTHER})
find_path(LIBTERMKEY_INCLUDE_DIR termkey.h
PATHS ${PC_LIBTERMKEY_INCLUDEDIR} ${PC_LIBTERMKEY_INCLUDE_DIRS})
# If we're asked to use static linkage, add libuv.a as a preferred library name.
if(LIBTERMKEY_USE_STATIC)
list(APPEND LIBTERMKEY_NAMES
"${CMAKE_STATIC_LIBRARY_PREFIX}termkey${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
list(APPEND LIBTERMKEY_NAMES termkey)
find_library(LIBTERMKEY_LIBRARY NAMES ${LIBTERMKEY_NAMES}
HINTS ${PC_LIBTERMKEY_LIBDIR} ${PC_LIBTERMKEY_LIBRARY_DIRS})
set(LIBTERMKEY_LIBRARIES ${LIBTERMKEY_LIBRARY})
set(LIBTERMKEY_INCLUDE_DIRS ${LIBTERMKEY_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBTERMKEY_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(LibTermkey DEFAULT_MSG
LIBTERMKEY_LIBRARY LIBTERMKEY_INCLUDE_DIR)
mark_as_advanced(LIBTERMKEY_INCLUDE_DIR LIBTERMKEY_LIBRARY)