فهرست منبع

Enabled shared library build, vcpkg update

Chlumsky 2 سال پیش
والد
کامیت
10577fca9e
6فایلهای تغییر یافته به همراه35 افزوده شده و 20 حذف شده
  1. 1 0
      .gitignore
  2. 1 1
      CHANGELOG.md
  3. 23 5
      CMakeLists.txt
  4. 2 2
      core/generator-config.h
  5. 2 1
      msdfgen-ext.h
  6. 6 11
      vcpkg.json

+ 1 - 0
.gitignore

@@ -9,6 +9,7 @@
 /x64/
 .vs/
 .vscode/
+.DS_Store
 *.exe
 *.zip
 *.user

+ 1 - 1
CHANGELOG.md

@@ -1,5 +1,5 @@
 
-## Version 1.10
+## Version 1.10 (2023-01-15)
 
 - Switched to vcpkg as the primary dependency management system
 - Switched to libpng as the primary PNG file encoder

+ 23 - 5
CMakeLists.txt

@@ -9,6 +9,7 @@ option(MSDFGEN_USE_OPENMP "Build with OpenMP support for multithreaded code" OFF
 option(MSDFGEN_USE_CPP11 "Build with C++11 enabled" ON)
 option(MSDFGEN_USE_SKIA "Build with the Skia library" ON)
 option(MSDFGEN_INSTALL "Generate installation target" OFF)
+option(BUILD_SHARED_LIBS "Generate dynamic library files instead of static" OFF)
 
 if(MSDFGEN_CORE_ONLY AND MSDFGEN_BUILD_STANDALONE)
     message(WARNING "Option MSDFGEN_CORE_ONLY ignored - extensions are required for standalone executable")
@@ -25,6 +26,10 @@ if(NOT MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE Release)
 endif()
 
+if(BUILD_SHARED_LIBS)
+    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+endif()
+
 if(MSDFGEN_USE_VCPKG)
     # Make sure that vcpkg toolchain file is set
     if(NOT CMAKE_TOOLCHAIN_FILE)
@@ -35,10 +40,10 @@ if(MSDFGEN_USE_VCPKG)
         endif()
     endif()
     # Default to statically linked vcpkg triplet on Windows
-    if(WIN32 AND NOT VCPKG_TARGET_TRIPLET)
-        if(${CMAKE_GENERATOR_PLATFORM} MATCHES "64$")
+    if(WIN32 AND NOT VCPKG_TARGET_TRIPLET AND NOT BUILD_SHARED_LIBS)
+        if(CMAKE_GENERATOR_PLATFORM MATCHES "64$")
             set(VCPKG_TARGET_TRIPLET "x64-windows-static")
-        elseif(${CMAKE_GENERATOR_PLATFORM} MATCHES "32$" OR ${CMAKE_GENERATOR_PLATFORM} STREQUAL "x86")
+        elseif(CMAKE_GENERATOR_PLATFORM MATCHES "32$" OR CMAKE_GENERATOR_PLATFORM STREQUAL "x86")
             set(VCPKG_TARGET_TRIPLET "x86-windows-static")
         else()
             message(WARNING "Vcpkg triplet not explicitly specified and could not be deduced. Recommend using -DVCPKG_TARGET_TRIPLET=x86-windows-static or similar")
@@ -100,6 +105,13 @@ if(MSDFGEN_USE_OPENMP)
     target_link_libraries(msdfgen-core PUBLIC OpenMP::OpenMP_CXX)
 endif()
 
+if(BUILD_SHARED_LIBS AND WIN32)
+    target_compile_definitions(msdfgen-core PRIVATE "MSDFGEN_PUBLIC=__declspec(dllexport)")
+    target_compile_definitions(msdfgen-core INTERFACE "MSDFGEN_PUBLIC=__declspec(dllimport)")
+else()
+    target_compile_definitions(msdfgen-core PUBLIC MSDFGEN_PUBLIC=)
+endif()
+
 # Extensions library
 if(NOT MSDFGEN_CORE_ONLY)
     if(NOT TARGET Freetype::Freetype)
@@ -128,15 +140,21 @@ if(NOT MSDFGEN_CORE_ONLY)
     set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT msdfgen-ext)
 
     if(MSDFGEN_USE_SKIA)
+        set(MSDFGEN_SKIA_LIB skia)
         set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
         set(THREADS_PREFER_PTHREAD_FLAG TRUE)
         find_package(Threads REQUIRED)
         if(NOT TARGET skia)
-            find_package(skia REQUIRED)
+            if(MSDFGEN_USE_VCPKG)
+                find_package(unofficial-skia REQUIRED)
+                set(MSDFGEN_SKIA_LIB unofficial::skia::skia)
+            else()
+                find_package(skia REQUIRED)
+            endif()
         endif()
         target_compile_features(msdfgen-ext PUBLIC cxx_std_17)
         target_compile_definitions(msdfgen-ext PUBLIC MSDFGEN_USE_SKIA)
-        target_link_libraries(msdfgen-ext PRIVATE Threads::Threads skia)
+        target_link_libraries(msdfgen-ext PRIVATE Threads::Threads ${MSDFGEN_SKIA_LIB})
     endif()
 
     add_library(msdfgen-full INTERFACE)

+ 2 - 2
core/generator-config.h

@@ -9,9 +9,9 @@ namespace msdfgen {
 /// The configuration of the MSDF error correction pass.
 struct ErrorCorrectionConfig {
     /// The default value of minDeviationRatio.
-    static const double defaultMinDeviationRatio;
+    static MSDFGEN_PUBLIC const double defaultMinDeviationRatio;
     /// The default value of minImproveRatio.
-    static const double defaultMinImproveRatio;
+    static MSDFGEN_PUBLIC const double defaultMinImproveRatio;
 
     /// Mode of operation.
     enum Mode {

+ 2 - 1
msdfgen-ext.h

@@ -15,7 +15,8 @@
  *   (to load input font files)
  * - TinyXML 2 by Lee Thomason
  *   (to aid in parsing input SVG files)
- * - LodePNG by Lode Vandevenne
+ * - libpng by the PNG Development Group
+ * - or LodePNG by Lode Vandevenne
  *   (to save output PNG images)
  *
  */

+ 6 - 11
vcpkg.json

@@ -13,16 +13,11 @@
         },
         "extensions": {
             "description": "Extended functionality that depends on external libraries - loading fonts and SVG files, generating PNG images",
-            "dependencies": [ {
-                "name": "freetype",
-                "version>=": "2.12.1#2"
-            }, {
-                "name": "tinyxml2",
-                "version>=": "9.0.0#1"
-            }, {
-                "name": "libpng",
-                "version>=": "1.6.37#19"
-            } ]
+            "dependencies": [
+                "freetype",
+                "tinyxml2",
+                "libpng"
+            ]
         },
         "geometry-preprocessing": {
             "description": "Preprocessing of non-compliant vector geometry via the Skia library",
@@ -33,7 +28,7 @@
             }, {
                 "name": "skia",
                 "default-features": false,
-                "version>=": "0.36.0"
+                "version>=": "0.36.0#3"
             } ]
         },
         "standalone": {