|
@@ -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)
|