Enabled shared library build, vcpkg update

This commit is contained in:
Chlumsky 2023-01-15 12:08:15 +01:00
parent 6185b63904
commit 10577fca9e
6 changed files with 35 additions and 20 deletions

1
.gitignore vendored
View File

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

View File

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

View File

@ -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_CPP11 "Build with C++11 enabled" ON)
option(MSDFGEN_USE_SKIA "Build with the Skia library" ON) option(MSDFGEN_USE_SKIA "Build with the Skia library" ON)
option(MSDFGEN_INSTALL "Generate installation target" OFF) 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) if(MSDFGEN_CORE_ONLY AND MSDFGEN_BUILD_STANDALONE)
message(WARNING "Option MSDFGEN_CORE_ONLY ignored - extensions are required for standalone executable") 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) set(CMAKE_BUILD_TYPE Release)
endif() endif()
if(BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
if(MSDFGEN_USE_VCPKG) if(MSDFGEN_USE_VCPKG)
# Make sure that vcpkg toolchain file is set # Make sure that vcpkg toolchain file is set
if(NOT CMAKE_TOOLCHAIN_FILE) if(NOT CMAKE_TOOLCHAIN_FILE)
@ -35,10 +40,10 @@ if(MSDFGEN_USE_VCPKG)
endif() endif()
endif() endif()
# Default to statically linked vcpkg triplet on Windows # Default to statically linked vcpkg triplet on Windows
if(WIN32 AND NOT VCPKG_TARGET_TRIPLET) if(WIN32 AND NOT VCPKG_TARGET_TRIPLET AND NOT BUILD_SHARED_LIBS)
if(${CMAKE_GENERATOR_PLATFORM} MATCHES "64$") if(CMAKE_GENERATOR_PLATFORM MATCHES "64$")
set(VCPKG_TARGET_TRIPLET "x64-windows-static") 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") set(VCPKG_TARGET_TRIPLET "x86-windows-static")
else() else()
message(WARNING "Vcpkg triplet not explicitly specified and could not be deduced. Recommend using -DVCPKG_TARGET_TRIPLET=x86-windows-static or similar") 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) target_link_libraries(msdfgen-core PUBLIC OpenMP::OpenMP_CXX)
endif() 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 # Extensions library
if(NOT MSDFGEN_CORE_ONLY) if(NOT MSDFGEN_CORE_ONLY)
if(NOT TARGET Freetype::Freetype) 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) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT msdfgen-ext)
if(MSDFGEN_USE_SKIA) if(MSDFGEN_USE_SKIA)
set(MSDFGEN_SKIA_LIB skia)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if(NOT TARGET skia) 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() endif()
target_compile_features(msdfgen-ext PUBLIC cxx_std_17) target_compile_features(msdfgen-ext PUBLIC cxx_std_17)
target_compile_definitions(msdfgen-ext PUBLIC MSDFGEN_USE_SKIA) 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() endif()
add_library(msdfgen-full INTERFACE) add_library(msdfgen-full INTERFACE)

View File

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

View File

@ -15,7 +15,8 @@
* (to load input font files) * (to load input font files)
* - TinyXML 2 by Lee Thomason * - TinyXML 2 by Lee Thomason
* (to aid in parsing input SVG files) * (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) * (to save output PNG images)
* *
*/ */

View File

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