Skip to content

Commit

Permalink
Enabled shared library build, vcpkg update
Browse files Browse the repository at this point in the history
  • Loading branch information
Chlumsky committed Jan 15, 2023
1 parent 6185b63 commit 10577fc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/x64/
.vs/
.vscode/
.DS_Store
*.exe
*.zip
*.user
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 23 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions core/generator-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion msdfgen-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*
*/
Expand Down
17 changes: 6 additions & 11 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -33,7 +28,7 @@
}, {
"name": "skia",
"default-features": false,
"version>=": "0.36.0"
"version>=": "0.36.0#3"
} ]
},
"standalone": {
Expand Down

0 comments on commit 10577fc

Please sign in to comment.