aboutsummaryrefslogtreecommitdiff
path: root/3rd-party/nanosvg/CMakeLists.txt
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@proton.me>2023-07-24 00:09:16 -0600
committerLeonardo Hernández Hernández <leohdz172@proton.me>2023-12-15 23:06:16 -0600
commit51de02c51f06bda67c40474d148e21d4717ba086 (patch)
treec6f035f4b8f2e085082b24b5d1f2554fa5418b65 /3rd-party/nanosvg/CMakeLists.txt
parent423f7dc6990b1cb5afde95f8383c44b1a4dce16a (diff)
downloadwbg-51de02c51f06bda67c40474d148e21d4717ba086.tar.gz
svg: initial support for SVG images, using nanosvg
Diffstat (limited to '3rd-party/nanosvg/CMakeLists.txt')
-rw-r--r--3rd-party/nanosvg/CMakeLists.txt75
1 files changed, 75 insertions, 0 deletions
diff --git a/3rd-party/nanosvg/CMakeLists.txt b/3rd-party/nanosvg/CMakeLists.txt
new file mode 100644
index 0000000..190b5da
--- /dev/null
+++ b/3rd-party/nanosvg/CMakeLists.txt
@@ -0,0 +1,75 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(NanoSVG C)
+
+# CMake needs *.c files to do something useful
+configure_file(src/nanosvg.h ${CMAKE_CURRENT_BINARY_DIR}/nanosvg.c)
+configure_file(src/nanosvgrast.h ${CMAKE_CURRENT_BINARY_DIR}/nanosvgrast.c)
+
+add_library(nanosvg ${CMAKE_CURRENT_BINARY_DIR}/nanosvg.c)
+
+find_library(MATH_LIBRARY m) # Business as usual
+if(MATH_LIBRARY)
+ target_link_libraries(nanosvg PUBLIC ${MATH_LIBRARY})
+endif()
+
+target_include_directories(nanosvg PUBLIC $<INSTALL_INTERFACE:include/nanosvg>)
+target_compile_definitions(nanosvg PRIVATE NANOSVG_IMPLEMENTATION)
+
+# Same for nanosvgrast
+add_library(nanosvgrast ${CMAKE_CURRENT_BINARY_DIR}/nanosvgrast.c)
+target_link_libraries(nanosvgrast PUBLIC nanosvg)
+target_include_directories(nanosvgrast PRIVATE src)
+target_compile_definitions(nanosvgrast PRIVATE NANOSVGRAST_IMPLEMENTATION)
+
+# Installation and export:
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ VERSION 1.0
+ COMPATIBILITY AnyNewerVersion
+)
+
+install(TARGETS nanosvg nanosvgrast
+ EXPORT ${PROJECT_NAME}Targets
+)
+
+export(EXPORT ${PROJECT_NAME}Targets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
+ NAMESPACE ${PROJECT_NAME}::
+)
+
+set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
+
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ INSTALL_DESTINATION ${ConfigPackageLocation}
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO
+)
+
+install(
+ FILES
+ src/nanosvg.h
+ src/nanosvgrast.h
+ DESTINATION
+ include/nanosvg
+ )
+
+install(EXPORT ${PROJECT_NAME}Targets
+ FILE
+ ${PROJECT_NAME}Targets.cmake
+ NAMESPACE
+ ${PROJECT_NAME}::
+ DESTINATION
+ ${ConfigPackageLocation}
+)
+
+install(
+ FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ DESTINATION
+ ${ConfigPackageLocation}
+) \ No newline at end of file