Skip to content

Commit c4321f3

Browse files
ferdnycjonoomph
authored andcommitted
Some polishing for the cmake ReSVG discovery (#187)
* Search for libresvg.so in RESVGDIR also This means that RESVGDIR can be pointed to the `target/release` dir where resvg was built, and both `libresvg.so` and `include/resvg.h` will be found. * ReSVG: Fix up discovery module `find_package_handle_standard_args` is supposed to set the `_FOUND` variable automatically (as the comment right above it says), as well as handling things like REQUIRED, QUIETLY, etc. It should always be run at the end of a module, for this reason. This change removes the conditionals around the call, lets it handle what it's meant to handle, and defines a custom failure message for discovery that replaces the one in `src/CMakeList.txt`. In addition, the `REQRUIRED` is removed from `tests/CMakeLists.txt`, since it's _supposed_ to mark the module as required (which ReSVG is not), and was only working due to the aforementioned improper conditional wrapping of the module's cleanup. * FindRESVG.cmake does not set RESVG_DEFINITIONS Remove the comment that claims it does.
1 parent f009b0f commit c4321f3

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

cmake/Modules/FindRESVG.cmake

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# RESVG_FOUND - System has RESVG
44
# RESVG_INCLUDE_DIRS - The RESVG include directories
55
# RESVG_LIBRARIES - The libraries needed to use RESVG
6-
# RESVG_DEFINITIONS - Compiler switches required for using RESVG
76
find_path ( RESVG_INCLUDE_DIR ResvgQt.h
87
PATHS ${RESVGDIR}/include/resvg
98
$ENV{RESVGDIR}/include/resvg
@@ -16,19 +15,14 @@ find_path ( RESVG_INCLUDE_DIR ResvgQt.h
1615
find_library ( RESVG_LIBRARY NAMES resvg
1716
PATHS /usr/lib
1817
/usr/local/lib
18+
$ENV{RESVGDIR}
1919
$ENV{RESVGDIR}/lib )
2020

2121
set ( RESVG_LIBRARIES ${RESVG_LIBRARY} )
2222
set ( RESVG_INCLUDE_DIRS ${RESVG_INCLUDE_DIR} )
2323

24-
SET( RESVG_FOUND FALSE )
25-
26-
IF ( RESVG_INCLUDE_DIR AND RESVG_LIBRARY )
27-
SET ( RESVG_FOUND TRUE )
28-
29-
include ( FindPackageHandleStandardArgs )
30-
# handle the QUIETLY and REQUIRED arguments and set RESVG_FOUND to TRUE
31-
# if all listed variables are TRUE
32-
find_package_handle_standard_args ( RESVG DEFAULT_MSG RESVG_LIBRARY RESVG_INCLUDE_DIR )
33-
ENDIF ( RESVG_INCLUDE_DIR AND RESVG_LIBRARY )
34-
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 )

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ if (RESVG_FOUND)
194194
# define a global var (used in the C++)
195195
add_definitions( -DUSE_RESVG=1 )
196196
SET(CMAKE_SWIG_FLAGS "-DUSE_RESVG=1")
197-
else(RESVG_FOUND)
198-
message("-- Could NOT find libresvg (using Qt SVG parsing instead)")
199197
endif(RESVG_FOUND)
200198

201199
################### JSONCPP #####################

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ include_directories(${ZMQ_INCLUDE_DIRS})
181181

182182
################### RESVG #####################
183183
# Find resvg library (used for rendering svg files)
184-
FIND_PACKAGE(RESVG REQUIRED)
184+
FIND_PACKAGE(RESVG)
185185

186186
# Include resvg headers (optional SVG library)
187187
if (RESVG_FOUND)

0 commit comments

Comments
 (0)