2021-10-16 01:26:26 -04:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
2020-01-08 16:40:52 -05:00
|
|
|
# vim: ts=2 sw=2
|
|
|
|
|
#[=======================================================================[.rst:
|
2020-10-18 10:41:53 -04:00
|
|
|
FindResvg
|
2020-01-08 16:40:52 -05:00
|
|
|
---------
|
|
|
|
|
Try to find the shared-library build of resvg, the Rust SVG library
|
2019-01-19 02:18:52 -06:00
|
|
|
|
2020-01-08 16:40:52 -05:00
|
|
|
IMPORTED targets
|
|
|
|
|
^^^^^^^^^^^^^^^^
|
2019-01-19 02:18:52 -06:00
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
This module defines :prop_tgt:`IMPORTED` target ``Resvg::Resvg`` when
|
2020-01-08 16:40:52 -05:00
|
|
|
the library and headers are found.
|
2019-01-19 02:18:52 -06:00
|
|
|
|
2020-01-08 16:40:52 -05:00
|
|
|
Result Variables
|
|
|
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
This module defines the following variables:
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
Resvg_FOUND - Library and header files found
|
|
|
|
|
Resvg_INCLUDE_DIRS - Include directory path
|
|
|
|
|
Resvg_LIBRARIES - Link path to the library
|
|
|
|
|
Resvg_DEFINITIONS - Compiler switches (currently unused)
|
2020-01-08 16:40:52 -05:00
|
|
|
|
|
|
|
|
Backwards compatibility
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
For compatibility with previous versions of this module, uppercase names
|
|
|
|
|
for FFmpeg and for all components are also recognized, and all-uppercase
|
|
|
|
|
versions of the cache variables are also created.
|
|
|
|
|
|
|
|
|
|
Control variables
|
|
|
|
|
^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
The following variables can be used to provide path hints to the module:
|
|
|
|
|
|
|
|
|
|
RESVGDIR - Set in the calling CMakeLists.txt or on the command line
|
|
|
|
|
ENV{RESVGDIR} - An environment variable in the cmake process context
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2020, FeRD (Frank Dana) <ferdnyc@gmail.com>
|
|
|
|
|
#]=======================================================================]
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
|
2021-10-08 03:02:45 -04:00
|
|
|
### Macro: parse_resvg_version
|
|
|
|
|
#
|
|
|
|
|
# Read the resvg.h file and extract the definition
|
|
|
|
|
# for RESVG_VERSION, to use as our version string.
|
|
|
|
|
macro (parse_resvg_version)
|
|
|
|
|
set(_header "${Resvg_INCLUDE_DIRS}/resvg.h")
|
|
|
|
|
if(EXISTS "${_header}")
|
|
|
|
|
#message(STATUS "Parsing Resvg version from ${_header}")
|
|
|
|
|
file(STRINGS "${_header}" _version_def
|
|
|
|
|
REGEX "^#define[ \t]+RESVG_VERSION[ \t]+\".*\"[ \t]*$")
|
|
|
|
|
string(REGEX REPLACE
|
|
|
|
|
"^.*RESVG_VERSION[ \t]+\"(.*)\".*$"
|
|
|
|
|
"\\1"
|
|
|
|
|
Resvg_VERSION "${_version_def}")
|
|
|
|
|
#message(STATUS "Found Resvg version: ${Resvg_VERSION}")
|
|
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
|
### Begin discovery
|
|
|
|
|
###
|
|
|
|
|
|
2020-01-08 16:40:52 -05:00
|
|
|
# CMake 3.4+ only: Convert relative paths to absolute
|
|
|
|
|
if(DEFINED RESVGDIR AND CMAKE_VERSION VERSION_GREATER 3.4)
|
|
|
|
|
get_filename_component(RESVGDIR "${RESVGDIR}" ABSOLUTE
|
|
|
|
|
BASE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
find_path(Resvg_INCLUDE_DIRS
|
2020-01-08 16:40:52 -05:00
|
|
|
ResvgQt.h
|
|
|
|
|
PATHS
|
2021-01-13 10:59:34 -05:00
|
|
|
${Resvg_ROOT}
|
2020-01-08 16:40:52 -05:00
|
|
|
${RESVGDIR}
|
|
|
|
|
${RESVGDIR}/include
|
|
|
|
|
$ENV{RESVGDIR}
|
|
|
|
|
$ENV{RESVGDIR}/include
|
|
|
|
|
/usr/include
|
|
|
|
|
/usr/local/include
|
|
|
|
|
PATH_SUFFIXES
|
2021-10-08 03:02:45 -04:00
|
|
|
c-api
|
2020-01-08 16:40:52 -05:00
|
|
|
capi/include
|
2021-10-08 03:02:45 -04:00
|
|
|
resvg
|
|
|
|
|
resvg/include
|
|
|
|
|
resvg/c-api
|
2020-01-08 16:40:52 -05:00
|
|
|
resvg/capi/include
|
|
|
|
|
)
|
|
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
find_library(Resvg_LIBRARIES
|
2020-01-08 16:40:52 -05:00
|
|
|
NAMES resvg
|
|
|
|
|
PATHS
|
2021-01-13 10:59:34 -05:00
|
|
|
${Resvg_ROOT}
|
2020-01-08 16:40:52 -05:00
|
|
|
${RESVGDIR}
|
|
|
|
|
${RESVGDIR}/lib
|
|
|
|
|
$ENV{RESVGDIR}
|
|
|
|
|
$ENV{RESVGDIR}/lib
|
|
|
|
|
/usr/lib
|
|
|
|
|
/usr/local/lib
|
|
|
|
|
PATH_SUFFIXES
|
|
|
|
|
resvg
|
|
|
|
|
target/release
|
|
|
|
|
resvg/target/release
|
|
|
|
|
)
|
|
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
if (Resvg_INCLUDE_DIRS AND Resvg_LIBRARIES)
|
|
|
|
|
set(Resvg_FOUND TRUE)
|
2020-01-08 16:40:52 -05:00
|
|
|
endif()
|
2021-10-08 03:02:45 -04:00
|
|
|
parse_resvg_version()
|
|
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
set(Resvg_LIBRARIES ${Resvg_LIBRARIES} CACHE STRING "The Resvg library link path")
|
|
|
|
|
set(Resvg_INCLUDE_DIRS ${Resvg_INCLUDE_DIRS} CACHE STRING "The Resvg include directories")
|
|
|
|
|
set(Resvg_DEFINITIONS "" CACHE STRING "The Resvg CFLAGS")
|
2021-10-08 03:02:45 -04:00
|
|
|
set(Resvg_VERSION ${Resvg_VERSION} CACHE STRING "The Resvg version in use")
|
2020-01-08 16:40:52 -05:00
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
mark_as_advanced(Resvg_LIBRARIES Resvg_INCLUDE_DIRS Resvg_DEFINITIONS)
|
2020-01-08 16:40:52 -05:00
|
|
|
|
|
|
|
|
# Give a nice error message if some of the required vars are missing.
|
2020-10-18 10:41:53 -04:00
|
|
|
find_package_handle_standard_args(Resvg
|
2021-10-08 03:02:45 -04:00
|
|
|
REQUIRED_VARS Resvg_LIBRARIES Resvg_INCLUDE_DIRS
|
|
|
|
|
VERSION_VAR Resvg_VERSION
|
|
|
|
|
)
|
2020-01-08 16:40:52 -05:00
|
|
|
|
|
|
|
|
# Export target
|
2020-10-18 10:41:53 -04:00
|
|
|
if(Resvg_FOUND AND NOT TARGET Resvg::Resvg)
|
2021-10-08 03:02:45 -04:00
|
|
|
#message(STATUS "Creating IMPORTED target Resvg::Resvg")
|
2020-01-09 01:59:26 -05:00
|
|
|
if (WIN32)
|
|
|
|
|
# Windows mis-links SHARED library targets
|
2020-10-18 10:41:53 -04:00
|
|
|
add_library(Resvg::Resvg UNKNOWN IMPORTED)
|
2020-01-09 01:59:26 -05:00
|
|
|
else()
|
|
|
|
|
# Linux needs SHARED to link because libresvg has no SONAME
|
2020-10-18 10:41:53 -04:00
|
|
|
add_library(Resvg::Resvg SHARED IMPORTED)
|
|
|
|
|
set_property(TARGET Resvg::Resvg APPEND PROPERTY
|
2020-01-09 01:59:26 -05:00
|
|
|
IMPORTED_NO_SONAME TRUE)
|
|
|
|
|
endif()
|
2020-01-08 16:40:52 -05:00
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
set_property(TARGET Resvg::Resvg APPEND PROPERTY
|
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${Resvg_INCLUDE_DIRS}")
|
2020-01-08 16:40:52 -05:00
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
set_property(TARGET Resvg::Resvg APPEND PROPERTY
|
|
|
|
|
INTERFACE_COMPILE_DEFINITIONS "${Resvg_DEFINITIONS}")
|
2020-01-08 16:40:52 -05:00
|
|
|
|
2020-10-18 10:41:53 -04:00
|
|
|
set_property(TARGET Resvg::Resvg APPEND PROPERTY
|
|
|
|
|
IMPORTED_LOCATION "${Resvg_LIBRARIES}")
|
2020-01-08 16:40:52 -05:00
|
|
|
endif()
|