CMake: Support header-only NanoSVG library

Check if the NanoSVG target defines any library locations.
Add a private compile definition to wxcore, instead of adding another setup.h option.
This commit is contained in:
Maarten Bent 2022-05-06 00:17:05 +02:00
parent 603c13aaba
commit 138d1ab021
3 changed files with 17 additions and 3 deletions

View File

@ -66,6 +66,9 @@ foreach(lib JPEG PNG TIFF NANOSVG)
wx_lib_include_directories(wxcore ${${lib}_INCLUDE_DIR})
endif()
endforeach()
if(wxUSE_NANOSVG STREQUAL "sys" AND wxUSE_NANOSVG_EXTERNAL_ENABLE_IMPL)
wx_lib_compile_definitions(wxcore wxUSE_NANOSVG_EXTERNAL_ENABLE_IMPL)
endif()
if(WIN32)
wx_lib_link_libraries(wxcore PRIVATE winmm)

View File

@ -17,4 +17,12 @@ elseif(wxUSE_NANOSVG)
set(NANOSVG_LIBRARIES NanoSVG::nanosvgrast)
get_target_property(svg_incl_dir NanoSVG::nanosvg INTERFACE_INCLUDE_DIRECTORIES)
set(NANOSVG_INCLUDE_DIRS ${svg_incl_dir})
get_target_property(svg_lib_d NanoSVG::nanosvgrast IMPORTED_LOCATION_DEBUG)
get_target_property(svg_lib_r NanoSVG::nanosvgrast IMPORTED_LOCATION_RELEASE)
get_target_property(svg_lib NanoSVG::nanosvgrast IMPORTED_LOCATION)
set(wxUSE_NANOSVG_EXTERNAL_ENABLE_IMPL TRUE)
if(svg_lib_d OR svg_lib_r OR svg_lib)
set(wxUSE_NANOSVG_EXTERNAL_ENABLE_IMPL FALSE)
endif()
endif()

View File

@ -57,13 +57,16 @@
#endif
#endif
#if !wxUSE_NANOSVG_EXTERNAL || defined(wxUSE_NANOSVG_EXTERNAL_ENABLE_IMPL)
#define NANOSVG_IMPLEMENTATION
#define NANOSVGRAST_IMPLEMENTATION
#define NANOSVG_ALL_COLOR_KEYWORDS
#endif
#if wxUSE_NANOSVG_EXTERNAL
#include <nanosvg.h>
#include <nanosvgrast.h>
#else
#define NANOSVG_IMPLEMENTATION
#define NANOSVGRAST_IMPLEMENTATION
#define NANOSVG_ALL_COLOR_KEYWORDS
#include "../../3rdparty/nanosvg/src/nanosvg.h"
#include "../../3rdparty/nanosvg/src/nanosvgrast.h"
#endif