From 2f8f8d7c6b015080d5ecc56a2c2625d95934fa1d Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Mon, 28 Oct 2024 00:16:03 +0100 Subject: [PATCH] fix plutosvg install --- hello_imgui_cmake/hello_imgui_build_lib.cmake | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/hello_imgui_cmake/hello_imgui_build_lib.cmake b/hello_imgui_cmake/hello_imgui_build_lib.cmake index 3f5baa59..d10f4f25 100644 --- a/hello_imgui_cmake/hello_imgui_build_lib.cmake +++ b/hello_imgui_cmake/hello_imgui_build_lib.cmake @@ -452,8 +452,9 @@ function(_him_add_freetype_to_imgui) if (IMGUI_ENABLE_FREETYPE_PLUTOSVG) set(backup_shared_lib ${BUILD_SHARED_LIBS}) - set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) include(FetchContent) + + # Fetch plutovg & MakeAvailable FetchContent_Declare(plutovg GIT_REPOSITORY https://github.com/sammycage/plutovg GIT_TAG v0.0.8 @@ -461,17 +462,21 @@ function(_him_add_freetype_to_imgui) ) FetchContent_MakeAvailable(plutovg) - set(PLUTOSVG_ENABLE_FREETYPE ON CACHE BOOL "" FORCE) - FetchContent_Declare(plutosvg - GIT_REPOSITORY https://github.com/sammycage/plutosvg - GIT_TAG v0.0.2 - GIT_PROGRESS TRUE + # Fetch plutosvg and compile manually (the stock CMakeLists of plutosvg is not compatible with a custom install of freetype) + FetchContent_Declare( + plutosvg + GIT_REPOSITORY https://github.com/sammycage/plutosvg + GIT_TAG v0.0.2 + GIT_PROGRESS TRUE ) - FetchContent_MakeAvailable(plutosvg) + FetchContent_GetProperties(plutosvg) + add_library(plutosvg ${plutosvg_SOURCE_DIR}/source/plutosvg.c) + target_include_directories(plutosvg PUBLIC $) + target_compile_definitions(plutosvg PUBLIC PLUTOSVG_HAS_FREETYPE) + target_link_libraries(plutosvg PUBLIC ${freetype_linked_library} plutovg) + him_add_installable_dependency(plutosvg) target_link_libraries(imgui PUBLIC plutosvg) - set(BUILD_SHARED_LIBS ${backup_shared_lib} CACHE BOOL "" FORCE) - target_compile_definitions(imgui PUBLIC IMGUI_ENABLE_FREETYPE IMGUI_ENABLE_FREETYPE_PLUTOSVG) else() # if not IMGUI_ENABLE_FREETYPE_PLUTOSVG -> use lunasvg if(NOT TARGET lunasvg)