Files
neovim/cmake/FindUnibilium.cmake
Daniel Hahler aa090f9801 cmake: fix usage of find_package_handle_standard_args (#10288)
The package argument is case sensitive, which is important to handle
X_FIND_REQUIRED properly, i.e. error out early if it is not found:

    CMake Error at /usr/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
      Could NOT find Unibilium (missing: UNIBILIUM_LIBRARY UNIBILIUM_INCLUDE_DIR)

Otherwise it would continue until:

    CMake Error: The following variables are used in this project, but they
    are set to NOTFOUND.
    Please set them or make sure they are set and tested correctly in the
    CMake files:
    UNIBILIUM_INCLUDE_DIR (ADVANCED)

Quickly checked via `rg 'find_package_handle_standard|find_package.*REQUIRED' -I | sort`.

Ref: https://gitlab.kitware.com/cmake/cmake/issues/19413
2019-06-21 03:48:46 +02:00

48 lines
1.5 KiB
CMake

# - Try to find unibilium
# Once done this will define
# UNIBILIUM_FOUND - System has unibilium
# UNIBILIUM_INCLUDE_DIRS - The unibilium include directories
# UNIBILIUM_LIBRARIES - The libraries needed to use unibilium
if(NOT USE_BUNDLED_UNIBILIUM)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_UNIBILIUM QUIET unibilium)
endif()
else()
set(PC_UNIBILIUM_INCLUDEDIR)
set(PC_UNIBILIUM_INCLUDE_DIRS)
set(PC_UNIBILIUM_LIBDIR)
set(PC_UNIBILIUM_LIBRARY_DIRS)
set(LIMIT_SEARCH NO_DEFAULT_PATH)
endif()
set(UNIBILIUM_DEFINITIONS ${PC_UNIBILIUM_CFLAGS_OTHER})
find_path(UNIBILIUM_INCLUDE_DIR unibilium.h
PATHS ${PC_UNIBILIUM_INCLUDEDIR} ${PC_UNIBILIUM_INCLUDE_DIRS}
${LIMIT_SEARCH})
# If we're asked to use static linkage, add libunibilium.a as a preferred library name.
if(UNIBILIUM_USE_STATIC)
list(APPEND UNIBILIUM_NAMES
"${CMAKE_STATIC_LIBRARY_PREFIX}unibilium${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
list(APPEND UNIBILIUM_NAMES unibilium)
find_library(UNIBILIUM_LIBRARY NAMES ${UNIBILIUM_NAMES}
HINTS ${PC_UNIBILIUM_LIBDIR} ${PC_UNIBILIUM_LIBRARY_DIRS}
${LIMIT_SEARCH})
set(UNIBILIUM_LIBRARIES ${UNIBILIUM_LIBRARY})
set(UNIBILIUM_INCLUDE_DIRS ${UNIBILIUM_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set UNIBILIUM_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Unibilium DEFAULT_MSG
UNIBILIUM_LIBRARY UNIBILIUM_INCLUDE_DIR)
mark_as_advanced(UNIBILIUM_INCLUDE_DIR UNIBILIUM_LIBRARY)