|
1 | | -# - Try to find RESVG |
2 | | -# Once done this will define |
3 | | -# RESVG_FOUND - System has RESVG |
4 | | -# RESVG_INCLUDE_DIRS - The RESVG include directories |
5 | | -# RESVG_LIBRARIES - The libraries needed to use RESVG |
6 | | -find_path ( RESVG_INCLUDE_DIR ResvgQt.h |
7 | | - PATHS ${RESVGDIR}/include/resvg |
8 | | - $ENV{RESVGDIR}/include/resvg |
9 | | - $ENV{RESVGDIR}/include |
10 | | - /usr/include/resvg |
11 | | - /usr/include |
12 | | - /usr/local/include/resvg |
13 | | - /usr/local/include ) |
14 | | - |
15 | | -find_library ( RESVG_LIBRARY NAMES resvg |
16 | | - PATHS /usr/lib |
17 | | - /usr/local/lib |
18 | | - $ENV{RESVGDIR} |
19 | | - $ENV{RESVGDIR}/lib ) |
20 | | - |
21 | | -set ( RESVG_LIBRARIES ${RESVG_LIBRARY} ) |
22 | | -set ( RESVG_INCLUDE_DIRS ${RESVG_INCLUDE_DIR} ) |
23 | | - |
24 | | -include ( FindPackageHandleStandardArgs ) |
25 | | -# handle the QUIETLY and REQUIRED arguments and set RESVG_FOUND to TRUE |
26 | | -# if all listed variables are TRUE |
27 | | -find_package_handle_standard_args ( RESVG "Could NOT find RESVG, using Qt SVG parsing instead" RESVG_LIBRARY RESVG_INCLUDE_DIR ) |
28 | | -mark_as_advanced( RESVG_LIBRARY RESVG_INCLUDE_DIR ) |
| 1 | +# vim: ts=2 sw=2 |
| 2 | +#[=======================================================================[.rst: |
| 3 | +FindRESVG |
| 4 | +--------- |
| 5 | +Try to find the shared-library build of resvg, the Rust SVG library |
| 6 | +
|
| 7 | +IMPORTED targets |
| 8 | +^^^^^^^^^^^^^^^^ |
| 9 | +
|
| 10 | +This module defines :prop_tgt:`IMPORTED` target ``RESVG::resvg`` when |
| 11 | +the library and headers are found. |
| 12 | +
|
| 13 | +Result Variables |
| 14 | +^^^^^^^^^^^^^^^^ |
| 15 | +
|
| 16 | +This module defines the following variables: |
| 17 | +
|
| 18 | +:: |
| 19 | +
|
| 20 | + RESVG_FOUND - Library and header files found |
| 21 | + RESVG_INCLUDE_DIRS - Include directory path |
| 22 | + RESVG_LIBRARIES - Link path to the library |
| 23 | + RESVG_DEFINITIONS - Compiler switches (currently unused) |
| 24 | +
|
| 25 | +Backwards compatibility |
| 26 | +^^^^^^^^^^^^^^^^^^^^^^^ |
| 27 | +
|
| 28 | +For compatibility with previous versions of this module, uppercase names |
| 29 | +for FFmpeg and for all components are also recognized, and all-uppercase |
| 30 | +versions of the cache variables are also created. |
| 31 | +
|
| 32 | +Control variables |
| 33 | +^^^^^^^^^^^^^^^^^ |
| 34 | +
|
| 35 | +The following variables can be used to provide path hints to the module: |
| 36 | +
|
| 37 | +RESVGDIR - Set in the calling CMakeLists.txt or on the command line |
| 38 | +ENV{RESVGDIR} - An environment variable in the cmake process context |
| 39 | +
|
| 40 | +Copyright (c) 2020, FeRD (Frank Dana) <[email protected]> |
| 41 | +#]=======================================================================] |
| 42 | +include(FindPackageHandleStandardArgs) |
| 43 | + |
| 44 | +# CMake 3.4+ only: Convert relative paths to absolute |
| 45 | +if(DEFINED RESVGDIR AND CMAKE_VERSION VERSION_GREATER 3.4) |
| 46 | + get_filename_component(RESVGDIR "${RESVGDIR}" ABSOLUTE |
| 47 | + BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 48 | +endif() |
| 49 | + |
| 50 | +find_path(RESVG_INCLUDE_DIRS |
| 51 | + ResvgQt.h |
| 52 | + PATHS |
| 53 | + ${RESVGDIR} |
| 54 | + ${RESVGDIR}/include |
| 55 | + $ENV{RESVGDIR} |
| 56 | + $ENV{RESVGDIR}/include |
| 57 | + /usr/include |
| 58 | + /usr/local/include |
| 59 | + PATH_SUFFIXES |
| 60 | + resvg |
| 61 | + capi/include |
| 62 | + resvg/capi/include |
| 63 | +) |
| 64 | + |
| 65 | +find_library(RESVG_LIBRARIES |
| 66 | + NAMES resvg |
| 67 | + PATHS |
| 68 | + ${RESVGDIR} |
| 69 | + ${RESVGDIR}/lib |
| 70 | + $ENV{RESVGDIR} |
| 71 | + $ENV{RESVGDIR}/lib |
| 72 | + /usr/lib |
| 73 | + /usr/local/lib |
| 74 | + PATH_SUFFIXES |
| 75 | + resvg |
| 76 | + target/release |
| 77 | + resvg/target/release |
| 78 | +) |
| 79 | + |
| 80 | +if (RESVG_INCLUDE_DIRS AND RESVG_LIBRARIES) |
| 81 | + set(RESVG_FOUND TRUE) |
| 82 | +endif() |
| 83 | +set(RESVG_LIBRARIES ${RESVG_LIBRARIES} CACHE STRING "The Resvg library link path") |
| 84 | +set(RESVG_INCLUDE_DIRS ${RESVG_INCLUDE_DIRS} CACHE STRING "The Resvg include directories") |
| 85 | +set(RESVG_DEFINITIONS "" CACHE STRING "The Resvg CFLAGS") |
| 86 | + |
| 87 | +mark_as_advanced(RESVG_LIBRARIES RESVG_INCLUDE_DIRS RESVG_DEFINITIONS) |
| 88 | + |
| 89 | +# Give a nice error message if some of the required vars are missing. |
| 90 | +find_package_handle_standard_args(RESVG |
| 91 | + "Could NOT find RESVG, using Qt SVG parsing instead" |
| 92 | + RESVG_LIBRARIES RESVG_INCLUDE_DIRS ) |
| 93 | + |
| 94 | +# Export target |
| 95 | +if(RESVG_FOUND AND NOT TARGET RESVG::resvg) |
| 96 | + message(STATUS "Creating IMPORTED target RESVG::resvg") |
| 97 | + add_library(RESVG::resvg UNKNOWN IMPORTED) |
| 98 | + |
| 99 | + set_target_properties(RESVG::resvg PROPERTIES |
| 100 | + INTERFACE_INCLUDE_DIRECTORIES "${RESVG_INCLUDE_DIRS}") |
| 101 | + |
| 102 | + set_property(TARGET RESVG::resvg APPEND PROPERTY |
| 103 | + INTERFACE_COMPILE_DEFINITIONS "${RESVG_DEFINITIONS}") |
| 104 | + |
| 105 | + set_property(TARGET RESVG::resvg APPEND PROPERTY |
| 106 | + IMPORTED_LOCATION "${RESVG_LIBRARIES}") |
| 107 | +endif() |
0 commit comments