rework handling of libraries installed via vcpkg and fix linker issues
This commit is contained in:
49
3rdParty/msdf/CMakeLists.txt
vendored
49
3rdParty/msdf/CMakeLists.txt
vendored
@@ -18,7 +18,7 @@ if(NOT DEFINED VCPKG_REPO)
|
||||
set(VCPKG_REPO https://github.com/microsoft/vcpkg.git)
|
||||
endif()
|
||||
|
||||
set(VCPKG_SRC_DIR "${CMAKE_BINARY_DIR}/_deps/vcpkg-src")
|
||||
set(VCPKG_SRC_DIR "${CMAKE_BINARY_DIR}/_deps/vcpkg-src" CACHE INTERNAL "vcpkg source dir")
|
||||
if (NOT EXISTS ${VCPKG_SRC_DIR} OR VCPKG_EXECUTABLE STREQUAL "" OR NOT DEFINED VCPKG_EXECUTABLE)
|
||||
message("Cloning vcpkg...")
|
||||
FetchContent_Declare(
|
||||
@@ -38,37 +38,28 @@ if (NOT EXISTS ${VCPKG_SRC_DIR} OR VCPKG_EXECUTABLE STREQUAL "" OR NOT DEFINED V
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# custom triplets (looks like doesn't work)
|
||||
#if (WIN32)
|
||||
# set(VCPKG_TARGET_TRIPLET "${CMAKE_SOURCE_DIR}/cmake/x64-windows-static-triplet" CACHE STRING "VCPKG Target Triplet to use")
|
||||
#elseif(UNIX)
|
||||
# set(VCPKG_TARGET_TRIPLET "${CMAKE_SOURCE_DIR}/cmake/x64-linux-triplet" CACHE STRING "VCPKG Target Triplet to use")
|
||||
#endif()
|
||||
|
||||
if (WIN32)
|
||||
# static win build breaks find_library call. need to specify FREETYPE_LIBRARY and FREETYPE_INCLUDE_DIRS manually.
|
||||
# plain x64-windows will link freetype as dll instead of lib .......
|
||||
set(TRIPLET x64-windows-static)
|
||||
set(TRIPLET x64-windows-static-md-release CACHE INTERNAL "triplet")
|
||||
elseif(UNIX)
|
||||
set(TRIPLET x64-linux)
|
||||
set(TRIPLET x64-linux CACHE INTERNAL "triplet")
|
||||
elseif(APPLE)
|
||||
set(TRIPLET x64-osx)
|
||||
set(TRIPLET x64-osx CACHE INTERNAL "triplet")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown OS, can't build msdfgen")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${VCPKG_EXECUTABLE} install freetype:${TRIPLET})
|
||||
execute_process(COMMAND ${VCPKG_EXECUTABLE} install freetype:${TRIPLET} libpng:${TRIPLET})
|
||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_BINARY_DIR}/_deps/vcpkg-src/scripts/buildsystems/vcpkg.cmake" CACHE STRING "cmake toolchain")
|
||||
include("${VCPKG_SRC_DIR}/scripts/buildsystems/vcpkg.cmake")
|
||||
|
||||
if(WIN32)
|
||||
set(FREETYPE_LIBRARY "${VCPKG_SRC_DIR}/buildtrees/freetype/${TRIPLET}-rel/freetype.lib" CACHE STRING "freetype lib path on win")
|
||||
set(FREETYPE_INCLUDE_DIRS "${VCPKG_SRC_DIR}/packages/freetype_${TRIPLET}/include" CACHE STRING "freetype include path on win")
|
||||
endif()
|
||||
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_SRC_DIR}/installed/${TRIPLET}/lib")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_SRC_DIR}/installed/${TRIPLET}/include")
|
||||
|
||||
set(MSDFGEN_DISABLE_SVG TRUE CACHE INTERNAL "disable msdfgen svg")
|
||||
set(MSDFGEN_DISABLE_PNG TRUE CACHE INTERNAL "disable msdfgen png")
|
||||
set(MSDFGEN_USE_SKIA OFF CACHE BOOL "use skia" FORCE)
|
||||
set(MSDF_ATLAS_USE_SKIA OFF CACHE BOOL "use skia" FORCE)
|
||||
set(MSDF_ATLAS_MSDFGEN_EXTERNAL ON CACHE BOOL "do not build msdfgen submodule" FORCE)
|
||||
set(MSDFGEN_DYNAMIC_RUNTIME ON CACHE BOOL "msvc dynamic runtime" FORCE)
|
||||
set(MSDF_ATLAS_DYNAMIC_RUNTIME ON CACHE BOOL "msvc dynamic runtime" FORCE)
|
||||
|
||||
FetchContent_Declare(
|
||||
msdfgen
|
||||
@@ -79,11 +70,6 @@ FetchContent_Declare(
|
||||
)
|
||||
FetchContent_MakeAvailable(msdfgen)
|
||||
|
||||
set(MSDFGEN_DISABLE_SVG TRUE CACHE INTERNAL "disable msdfgen svg")
|
||||
set(MSDFGEN_DISABLE_PNG TRUE CACHE INTERNAL "disable msdfgen png")
|
||||
set(MSDF_ATLAS_USE_SKIA OFF CACHE BOOL "use skia" FORCE)
|
||||
set(MSDF_ATLAS_MSDFGEN_EXTERNAL ON CACHE BOOL "do not build msdfgen submodule" FORCE)
|
||||
|
||||
FetchContent_Declare(
|
||||
msdfgen_atlas
|
||||
EXCLUDE_FROM_ALL
|
||||
@@ -92,3 +78,16 @@ FetchContent_Declare(
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
FetchContent_MakeAvailable(msdfgen_atlas)
|
||||
|
||||
function(LinkMsdf TARGET)
|
||||
if(WIN32)
|
||||
set(STATIC_LIB_EXT "lib")
|
||||
else()
|
||||
set(STATIC_LIB_EXT "a")
|
||||
endif()
|
||||
file(GLOB installed_libs "${VCPKG_SRC_DIR}/installed/${TRIPLET}/lib/*.${STATIC_LIB_EXT}")
|
||||
foreach(lib ${installed_libs})
|
||||
target_link_libraries(${TARGET} PUBLIC ${lib})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user