61 lines
1.8 KiB
CMake
61 lines
1.8 KiB
CMake
#[=======================================================================[
|
|
FindVips — libvips (Sharp uses the same library).
|
|
|
|
Linux / macOS: `pkg-config vips` after installing:
|
|
Debian/Ubuntu: sudo apt install libvips-dev
|
|
macOS: brew install vips
|
|
|
|
Windows: vcpkg install vips:x64-windows, then use the vcpkg toolchain file or set
|
|
CMAKE_PREFIX_PATH to the installed prefix; alternatively set VIPS_ROOT.
|
|
#]=======================================================================]
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
if(DEFINED ENV{VIPS_ROOT} AND NOT VIPS_ROOT)
|
|
set(VIPS_ROOT "$ENV{VIPS_ROOT}")
|
|
endif()
|
|
if(VIPS_ROOT)
|
|
list(APPEND CMAKE_PREFIX_PATH "${VIPS_ROOT}")
|
|
endif()
|
|
|
|
find_package(PkgConfig QUIET)
|
|
if(PkgConfig_FOUND)
|
|
pkg_check_modules(VIPS IMPORTED_TARGET vips)
|
|
endif()
|
|
|
|
if(TARGET PkgConfig::VIPS)
|
|
if(NOT TARGET Vips::vips)
|
|
add_library(Vips::vips ALIAS PkgConfig::VIPS)
|
|
endif()
|
|
set(Vips_FOUND TRUE)
|
|
else()
|
|
find_path(
|
|
Vips_INCLUDE_DIR
|
|
NAMES vips/vips.h
|
|
PATHS "${CMAKE_PREFIX_PATH}"
|
|
PATH_SUFFIXES include
|
|
)
|
|
find_library(
|
|
Vips_LIBRARY
|
|
NAMES vips libvips vips-8.0
|
|
PATHS "${CMAKE_PREFIX_PATH}"
|
|
PATH_SUFFIXES lib lib64
|
|
)
|
|
find_package_handle_standard_args(Vips DEFAULT_MSG Vips_LIBRARY Vips_INCLUDE_DIR)
|
|
if(Vips_FOUND)
|
|
add_library(Vips::vips UNKNOWN IMPORTED)
|
|
get_filename_component(Vips_LIBRARY_DIR "${Vips_LIBRARY}" DIRECTORY)
|
|
# vips.h includes glib.h — Windows SDK bundles glib headers next to vips.
|
|
set(_VIPS_INCLUDES
|
|
"${Vips_INCLUDE_DIR}"
|
|
"${Vips_INCLUDE_DIR}/glib-2.0"
|
|
"${Vips_LIBRARY_DIR}/glib-2.0/include")
|
|
set_target_properties(
|
|
Vips::vips
|
|
PROPERTIES
|
|
IMPORTED_LOCATION "${Vips_LIBRARY}"
|
|
INTERFACE_INCLUDE_DIRECTORIES "${_VIPS_INCLUDES}"
|
|
)
|
|
endif()
|
|
endif()
|