Skip to content

Commit

Permalink
build(port): CMake improvements (#3457)
Browse files Browse the repository at this point in the history
* Add build options from Cataclysm-common.props

* Add more build options from msvc-full-features/

* Use main-pch instead of stdafx.h

* Copy msvc-full-features/vcpkg.json to source root

* Add gettext and its tools as dependency

* Move MSVC options to own toolchain file

* Add a CMake presets file created by Visual Studio

* Uses vcpkg pointed by VCPKG_ROOT
* Uses build-scripts/MSVC.cmake
* TILES only for now

* Fix not finding .lib files

* Do not autogenerate a manifest

* Add gettext tools only duing Windows builds

* Comment CL flags

* Expose JPEG library from SDL

* Switch back to Ninja, no build performance gains wtih MSBuild

* Tell VCPKG to use static linking

* Revert "build(cmake): deduplicate library setup (#3248)"

This reverts commit a526591.

* Fix missing symbols required by SDL

* Fix validate_json.py test by removing UTF-8 BOM from presets file

* Include vcpkg.cmake instead of using as toolchain file

* Rewrite presets from scratch

* Find VCPK installation through env

* Move Ninja to MSVC preset

* Upgrade to CMake 3.20 to allow new policies

* Use CMAKE_CXX_FLAGS_INIT instead of add_compile_options()

* Typo

* Specific flag for RelWithDebInfo

* Set new policies to remove other flags

* Allow using /MT

* Add a CMake build preset

* Add x64-debug for MSVC

* Add /GF as suggested

* Removed as requested. CMake version refers

* Add /OPT as requested

* Skip PCH when generating compile_commands.json

* tab vs. spaces

* Update CMakeLists.txt

Line too long (101/100)

* Move vcpkg.json into msvc directory

* Using project's VCPKG Triplets

* Forgot ENV{} is special in if()

* Edit comments

* Use Windows path separator

* Retrieve VS environment variables from VsDevCmd

* Rewrite the list of envs to be a CMake list

* Loop over envs modified by VsDevCmd

* Split environment variable in key/value and trim value

* Set CMake environment with VsDevCmd set values

* Write a JSON string for CMakeUserPresets build environment

* Write CMakeUserPresets.json based on VsDevCmd envs

* Set the C and C++ compilers to VS

* Remove the CMake build presets now in CMakeUserPreset.json

* Moving user presets hack into the include_before script

One should not use CMAKE_SOURCE_DIR because changes during compiler features
testing and wastes time too.
Renaming the script because it's not more just looking for VCPKG.

* More MS linker flags from linking stage in .vcxproj

* Use MinGW's msgfmt.exe from Git for Windows

* Removing vcpkg triplets for gha as requested

* Set default msgfmt

* Search ninja.exe only when generator is Ninja*

* Add MSYS to find_program msgfmt.exe

* Removing gettext/msgfmt whole build, as requested

* Fix sourcing VsDevCmd.bat twice

* Enable LOCALIZE in Release

* PREFIX doesn't go through C preprocessor stringification

* Apply -Wno-unknown-warning-option to clang only

* Remove GNU C++ extensions

* Define PREFIX in prefix.h. Similar as done with version.h

Removes the Q/QUOTE stringify macros

* Fix cmake-lint

* Correct logic for -Wno-unknown-warning-option

* Correct logic for -Wno-unknown-warning-option

It looks like both AppleClang and LLVM Clang use
-Wno-unknown-warning-option instead of -Wno-unknown-warning, so this
updates the logic from b1e5ada to match that. It'd probably also be
possible to just add both -Wno-unknown-warning and
-Wno-unknown-warning-option, but who knows.

* Quote in if condition of CMakeLists.txt

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>

* Use correct cmake variable for prefix.h.in

* Use CMake 3.21 or later

* Change all target_link_libraries to interface form

* Change find_package if using VCPKG manitest

- Add all SDL2:: targets found by VCPKG
- Fix clang-tidy and cmake-lint

* Set the correct property for using ccache

* Set compiler launchers before adding subdirectories

* Fix release installation paths

* Align CMake release install

* Do not use our Find* modules under VCPKG

* Remove redundant modules from CMakeModules

CMakeParseArguments.cmake since v3.4
CMakePushCheckState.cmake since v2.8.6
CheckLibraryExists since v2.8.2
FindCurses since v3.21.0
FindPackageHandleStandardArgs since v3.1.0
FindPackageMessage since v3.0.0

* Add documentation for CMake+VCPKG build

- Move build configuration into the preset
- Explain how to use multi-config generator
- Fix "/permessive" description

Co-authored-by: akrieger <[email protected]>

* Use VCPKG triplets from build-scripts/

- Point to triplets from base configuration
- Move Ninja to basic preset requirement
- Remove x64-debug because not used

* Optmize replacing ENV vars loop with find()

* Force ninja.exe path in the INCLUDE_BEFORE file

* Add varialbes to "name" and "configurePreset"

This way CMakeUserPresets.json.in can be reused for other targets

* Rename presets to match release.yml names

Rename preset to MSVC and pre-load script to be consistent.

* Move VsDevCmd environment parsing to its dedicated script

* Fix checking for DevEnvDir

* Fix parsing non variables output

* Document and improve VsDevCmd.cmake

It uses DOS short names to workaround a CMake issue.

* Use vswhere.exe as suggested by akrieger

Fix not finding VS prereleases

* Makes Ninja generators on Windows optional

* Move hardcoded path into preset

* Build a release

* Rewrite instructions addin VS procedure. Change displayed name

* Add a missing target public interface

* Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md

Co-authored-by: akrieger <[email protected]>

* Reverting SDL2 TTF library name resolution in VCPKG

Requires VCPK at their commit 659b6b5

* Move VCPKG to Windows only builds

* Use SDL2_ttf when not using VCPKG

* Disable the MSYS build preset

* Search for gettext in one place

* Make VCPKG_ROOT optional in MSVC too

Fixes an error when using cmake-gui

* Allow to configure msgfmt and VCPKG paths

* Fix using cache var in find_program(). Remove extra find_package

* Use correct Git for Windows directory

Co-authored-by: akrieger <[email protected]>

* Make building tests optional. Use "TESTS" cache var

* Install more directories

* Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md

Co-authored-by: akrieger <[email protected]>

* Satisfy cmake-lint

* Move logic non belonging to data/ up

* Install VERSION.txt

* Switch building tests from CMake to presets

* Add shlwapi required by mpg123

* Split SDL2 mixer package names

* Enable sound

* Correct CMake install locations on *nix

* Remove x86 specific macro definitions in MSVC build in CMake (#62602)

* Fix CMake compilation and localization

Localization:
- Outdated .gitignore entry

Compilation:
- `target_link_libraries` mixed signature error

* Enable -g1 in CMake release build to produce source and line number in stack trace (#64705)

* Add CMake option for XDG directories

* Update vcpkg configuration, again

* Downgrade cmake files to v3.20

* Use CMake version 3.20 and presets version 2

* Flatten presets into one

* Use presetName for the include file

* Start using multi-config generators

* Add a Linux release configuration and build preset

* Display PROJECT_NAME during configuration

* Fix all SDL2 related target names

* Add VERSION.txt to .gitignore

* Add 'out/' to .gitignore

* Fix merge conflict related to PCH, always use PCH

* BNify link in VERSION.txt

* BNify comment

* Fix Lua build

* Makefile fix

* Restore builtin-baseline in manifest

* Make USE_PREFIX_DATA_DIR option available to Unix only

* Replace all system specific *_DIR with CMAKE_INSTALL_*

* Use relative paths, use list append command

* Configure prefix.h.in earlier

* Compact presets. VCPKG_ROOT now an env variable

* Remove cmake_minimum_required from subdirectories

* Reduce CMake configuration output for releases

* Use pkg-config to help finding mostly static libraries

The FindSDL2*.cmake modules create the *::*-static imported targets
like VCPKG does. This way we can reuse the same names and reduce the
complexity in the main and src CMakeLists.txt.

* Prefer MSBuild on Windows

* Make Linux preset name refer to VCPKG

The presets inherits from the configuration not using VCPKG

* Dynamically link SDL2_mixer

* Add a function to force an fs::path to a dir

* Use the normalized directory path

* Add SDL2 targets for dynamic linking

* Add more required libs to SDL2_image imported target

* Removing libzip not required for dynamic linking

* Hotfix: Append a path delimiter for the 'dot' directory.

* Improve CMake behavior on Unix and macOS

* Improve CMake behavior on Unix and macOS

* Make USE_PREFIX_DATA_DIR on by default on unix

* Disable lang install

* style(autofix.ci): automated formatting

* Enable Lua in presets

* Add CMake+MSVC build to CI

* Remove VCPKG_ROOT override

* Remove Strawberry Pearl from PATH

* Add freetype overlay port

* Remove brotli feature from freetype

* Small fixes in CMake build in Linux

* Resolve more dependencies

* Use dynamic linking for non-VCPKG configuration

* Fix typo for pkg-config

* Link FLAC libraries for dynamic linking too

* Add INTERFACE_INCLUDE_DIRECTORIES to SDL2 targets

* Move pkg-config required FLAC dependency inside conditions

* Fix clang-tidy workflow by installing 'required' libflac-dev

* Add libflac to matrix

* Fix merge mistakes and style differences

* Don't re-define LUA

* Style fixes

* Fix wrong merge

* Add CMake + MSYS2 build to matrix

* Update vcpkg

* BNify install dir

* Use CMake to build translations in CI

* Update documentation

* Add separate preset for VS 2022

* Implement missing members of vpart iterators

* Remove deprecated headers from stdafx.h

* Fix float conversion warnings C4244

* Show current path if failed to find data dir

* Force translation tests to end up on english

* Fix build config setup in msvc Cmake preset

* Fix path to tests

* Add RelWithDebInfo to gitignore

* Set cwd for debugging in VS

* Add Debug configuration, enable tests

* Add docs on running from VS

* style(autofix.ci): automated formatting

* Add Release configuration

style(autofix.ci): automated formatting

* ci: run MSYS on upload only

* Unify CMake and Makefile warnings

* ci: tweak msys cmake build

* Remove /permissive-

* Alt fix for compiling Lua with CXX compiler

* Add PCH to tests

* Fix more UB on global statics cleanup

* Tweaks to VS CMake guide

* Add new options to CMake guide

* Fix port mistake

* Remove automatic CMake formatter

* Only run CMake+MSVC on upload

---------

Co-authored-by: alef <[email protected]>
Co-authored-by: Perry Fraser <[email protected]>
Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>
Co-authored-by: Perry Fraser <[email protected]>
Co-authored-by: akrieger <[email protected]>
Co-authored-by: Binrui Dong <[email protected]>
Co-authored-by: Clarence "Sparr" Risher <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
9 people authored Nov 15, 2023
1 parent 5635285 commit 91175cb
Show file tree
Hide file tree
Showing 62 changed files with 1,800 additions and 1,598 deletions.
43 changes: 0 additions & 43 deletions .cmake-format.yml

This file was deleted.

1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ indent_style = tab

[*.{json,yml,yaml,md,markdown}]
indent_size = 2
charset = utf-8

[{.clang-tidy,.clang-format}]
indent_size = 2
Expand Down
65 changes: 65 additions & 0 deletions .github/vcpkg_ports/freetype/0003-Fix-UWP.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index db48e9f..5c35276 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -328,6 +328,10 @@ else ()
list(APPEND BASE_SRCS src/base/ftdebug.c)
endif ()

+if(MSVC)
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
+endif()
+
if (BUILD_FRAMEWORK)
list(APPEND BASE_SRCS builds/mac/freetype-Info.plist)
endif ()
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 4f2eaca..1e01fe4 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1038,6 +1038,11 @@ FT_BEGIN_HEADER
* Especially for TrueType fonts see also the documentation for
* @FT_Size_Metrics.
*/
+
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
+#define generic GenericFromFreeTypeLibrary
+#endif
+
typedef struct FT_FaceRec_
{
FT_Long num_faces;
@@ -1910,6 +1915,9 @@ FT_BEGIN_HEADER

} FT_GlyphSlotRec;

+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
+#undef generic
+#endif

/*************************************************************************/
/*************************************************************************/
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 3f8619d..edf03b6 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -528,6 +528,9 @@
return error;
}

+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
+#define generic GenericFromFreeTypeLibrary
+#endif

static void
ft_glyphslot_clear( FT_GlyphSlot slot )
@@ -1195,6 +1198,9 @@
FT_FREE( face );
}

+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
+#undef generic
+#endif

static void
Destroy_Driver( FT_Driver driver )
25 changes: 25 additions & 0 deletions .github/vcpkg_ports/freetype/brotli-static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/builds/cmake/FindBrotliDec.cmake b/builds/cmake/FindBrotliDec.cmake
index 46356b1fd..ed4cc2409 100644
--- a/builds/cmake/FindBrotliDec.cmake
+++ b/builds/cmake/FindBrotliDec.cmake
@@ -35,10 +35,19 @@ find_path(BROTLIDEC_INCLUDE_DIRS
PATH_SUFFIXES brotli)

find_library(BROTLIDEC_LIBRARIES
- NAMES brotlidec
+ NAMES brotlidec brotlidec-static NAMES_PER_DIR
HINTS ${PC_BROTLIDEC_LIBDIR}
${PC_BROTLIDEC_LIBRARY_DIRS})

+get_filename_component(z_vcpkg_freetype_brotlidec_name "${BROTLIDEC_LIBRARIES}" NAME)
+if(z_vcpkg_freetype_brotlidec_name MATCHES "-static")
+ find_library(BROTLICOMMON_LIBRARIES
+ NAMES brotlicommon-static
+ HINTS ${PC_BROTLIDEC_LIBDIR}
+ ${PC_BROTLIDEC_LIBRARY_DIRS})
+ set(BROTLIDEC_LIBRARIES "${BROTLIDEC_LIBRARIES};${BROTLICOMMON_LIBRARIES}")
+endif()
+unset(z_vcpkg_freetype_brotlidec_name)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
13 changes: 13 additions & 0 deletions .github/vcpkg_ports/freetype/bzip2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 469a141a2..eec19c7d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -517,7 +517,7 @@ if (BZIP2_FOUND)
if (PC_BZIP2_FOUND)
list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2")
else ()
- list(APPEND PKGCONFIG_LIBS_PRIVATE "-lbz2")
+ list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2")
endif ()
endif ()
if (PNG_FOUND)
37 changes: 37 additions & 0 deletions .github/vcpkg_ports/freetype/error-strings.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From 5672a353682a68cb76a03179739bdec0a2f5cf0e Mon Sep 17 00:00:00 2001
From: Sean Farrell <[email protected]>
Date: Fri, 19 Aug 2022 15:32:19 +0200
Subject: [PATCH] Adds config support for error strings.

---
CMakeLists.txt | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index feb4be39a..4eea860e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -215,6 +215,8 @@ cmake_dependent_option(FT_REQUIRE_BROTLI
"Require support of compressed WOFF2 fonts." OFF
"NOT FT_DISABLE_BROTLI" OFF)

+option(FT_ENABLE_ERROR_STRINGS
+ "Enable support for meaningful error descriptions" OFF)

# Disallow in-source builds
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
@@ -353,6 +355,11 @@ if (BROTLIDEC_FOUND)
"/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
FTOPTION_H "${FTOPTION_H}")
endif ()
+if (FT_ENABLE_ERROR_STRINGS)
+ string(REGEX REPLACE
+ "/\\* +(#define +FT_CONFIG_OPTION_ERROR_STRINGS) +\\*/" "\\1"
+ FTOPTION_H "${FTOPTION_H}")
+endif ()

set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
if (EXISTS "${FTOPTION_H_NAME}")
--
2.33.0.windows.2

40 changes: 40 additions & 0 deletions .github/vcpkg_ports/freetype/fix-exports.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb1b9a0f2..edca5d579 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -508,7 +508,6 @@ set(PKG_CONFIG_REQUIRED_PRIVATE "")
set(PKGCONFIG_LIBS_PRIVATE "")

if (ZLIB_FOUND)
- target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
+ target_link_libraries(freetype PRIVATE ZLIB::ZLIB)
- target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
list(APPEND PKGCONFIG_REQUIRES_PRIVATE "zlib")
endif ()
@@ -596,12 +596,25 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
install(
EXPORT freetype-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
- FILE freetype-config.cmake
COMPONENT headers)
install(
FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
COMPONENT headers)
+
+ if(ZLIB_FOUND)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake"
+[[include(CMakeFindDependencyMacro)
+find_dependency(ZLIB)
+include("${CMAKE_CURRENT_LIST_DIR}/freetype-targets.cmake")
+]])
+ else()
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake"
+[[include("${CMAKE_CURRENT_LIST_DIR}/freetype-targets.cmake")
+]])
+ endif()
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype)
endif ()


85 changes: 85 additions & 0 deletions .github/vcpkg_ports/freetype/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
set(FT_VERSION 2.12.1)

vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO freetype/freetype2
REF ${FT_VERSION}
FILENAME freetype-${FT_VERSION}.tar.xz
SHA512 6482de1748dc2cc01e033d21a3b492dadb1f039d13d9179685fdcf985e24d7f587cbca4c27ed8a7fdb7d9ad59612642ac5f4db062443154753295363f45c052f
PATCHES
0003-Fix-UWP.patch
brotli-static.patch
bzip2.patch
fix-exports.patch
error-strings.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
zlib FT_REQUIRE_ZLIB
bzip2 FT_REQUIRE_BZIP2
error-strings FT_ENABLE_ERROR_STRINGS
png FT_REQUIRE_PNG
brotli FT_REQUIRE_BROTLI
INVERTED_FEATURES
zlib FT_DISABLE_ZLIB
bzip2 FT_DISABLE_BZIP2
png FT_DISABLE_PNG
brotli FT_DISABLE_BROTLI
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DFT_DISABLE_HARFBUZZ=ON
${FEATURE_OPTIONS}
)

vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/freetype)

# Rename for easy usage (VS integration; CMake and autotools will not care)
file(RENAME "${CURRENT_PACKAGES_DIR}/include/freetype2/freetype" "${CURRENT_PACKAGES_DIR}/include/freetype")
file(RENAME "${CURRENT_PACKAGES_DIR}/include/freetype2/ft2build.h" "${CURRENT_PACKAGES_DIR}/include/ft2build.h")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/freetype2")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

# Fix the include dir [freetype2 -> freetype]
file(READ "${CURRENT_PACKAGES_DIR}/share/freetype/freetype-targets.cmake" CONFIG_MODULE)
string(REPLACE "\${_IMPORT_PREFIX}/include/freetype2" "\${_IMPORT_PREFIX}/include" CONFIG_MODULE "${CONFIG_MODULE}")
string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlicommon-static.lib" [[\$<\$<NOT:\$<CONFIG:DEBUG>>:${_IMPORT_PREFIX}/lib/brotlicommon-static.lib>;\$<\$<CONFIG:DEBUG>:${_IMPORT_PREFIX}/debug/lib/brotlicommon-static.lib>]] CONFIG_MODULE "${CONFIG_MODULE}")
string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlidec-static.lib" [[\$<\$<NOT:\$<CONFIG:DEBUG>>:${_IMPORT_PREFIX}/lib/brotlidec-static.lib>;\$<\$<CONFIG:DEBUG>:${_IMPORT_PREFIX}/debug/lib/brotlidec-static.lib>]] CONFIG_MODULE "${CONFIG_MODULE}")
string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlidec.lib" [[\$<\$<NOT:\$<CONFIG:DEBUG>>:${_IMPORT_PREFIX}/lib/brotlidec.lib>;\$<\$<CONFIG:DEBUG>:${_IMPORT_PREFIX}/debug/lib/brotlidec.lib>]] CONFIG_MODULE "${CONFIG_MODULE}")
string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlidec.lib" [[\$<\$<NOT:\$<CONFIG:DEBUG>>:${_IMPORT_PREFIX}/lib/brotlidec.lib>;\$<\$<CONFIG:DEBUG>:${_IMPORT_PREFIX}/debug/lib/brotlidec.lib>]] CONFIG_MODULE "${CONFIG_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/freetype/freetype-targets.cmake "${CONFIG_MODULE}")

find_library(FREETYPE_DEBUG NAMES freetyped PATHS "${CURRENT_PACKAGES_DIR}/debug/lib/" NO_DEFAULT_PATH)
if(NOT VCPKG_BUILD_TYPE)
file(READ "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/freetype2.pc" _contents)
if(FREETYPE_DEBUG)
string(REPLACE "-lfreetype" "-lfreetyped" _contents "${_contents}")
endif()
string(REPLACE "-I\${includedir}/freetype2" "-I\${includedir}" _contents "${_contents}")
file(WRITE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/freetype2.pc" "${_contents}")
endif()

file(READ "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/freetype2.pc" _contents)
string(REPLACE "-I\${includedir}/freetype2" "-I\${includedir}" _contents "${_contents}")
file(WRITE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/freetype2.pc" "${_contents}")


vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake"
"${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(
FILE_LIST
"${SOURCE_PATH}/LICENSE.TXT"
"${SOURCE_PATH}/docs/FTL.TXT"
"${SOURCE_PATH}/docs/GPLv2.TXT"
)
4 changes: 4 additions & 0 deletions .github/vcpkg_ports/freetype/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
freetype is compatible with built-in CMake targets:

find_package(Freetype REQUIRED)
target_link_libraries(main PRIVATE Freetype::Freetype) # since CMake 3.10
64 changes: 64 additions & 0 deletions .github/vcpkg_ports/freetype/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0012 NEW)
cmake_policy(SET CMP0054 NEW)

_find_package(${ARGS})

if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
if("@FT_REQUIRE_ZLIB@")
find_package(ZLIB)
endif()
if("@FT_REQUIRE_BZIP2@")
find_package(BZip2)
endif()
if("@FT_REQUIRE_PNG@")
find_package(PNG)
endif()
if("@FT_REQUIRE_BROTLI@")
find_library(BROTLIDEC_LIBRARY_RELEASE NAMES brotlidec brotlidec-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLIDEC_LIBRARY_DEBUG NAMES brotlidec brotlidec-static brotlidecd brotlidec-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLICOMMON_LIBRARY_RELEASE NAMES brotlicommon brotlicommon-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLICOMMON_LIBRARY_DEBUG NAMES brotlicommon brotlicommon-static brotlicommond brotlicommon-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH)
include(SelectLibraryConfigurations)
select_library_configurations(BROTLIDEC)
select_library_configurations(BROTLICOMMON)
endif("@FT_REQUIRE_BROTLI@")

if(TARGET Freetype::Freetype)
if("@FT_REQUIRE_ZLIB@")
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
endif()
if("@FT_REQUIRE_BZIP2@")
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES BZip2::BZip2)
endif()
if("@FT_REQUIRE_PNG@")
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES PNG::PNG)
endif()
if("@FT_REQUIRE_BROTLI@")
if(BROTLIDEC_LIBRARY_DEBUG)
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$<CONFIG:DEBUG>:${BROTLIDEC_LIBRARY_DEBUG}>")
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$<CONFIG:DEBUG>:${BROTLICOMMON_LIBRARY_DEBUG}>")
endif()
if(BROTLIDEC_LIBRARY_RELEASE)
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$<NOT:$<CONFIG:DEBUG>>:${BROTLIDEC_LIBRARY_RELEASE}>")
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$<NOT:$<CONFIG:DEBUG>>:${BROTLICOMMON_LIBRARY_RELEASE}>")
endif()
endif()
endif()

if(FREETYPE_LIBRARIES)
if("@FT_REQUIRE_ZLIB@")
list(APPEND FREETYPE_LIBRARIES ${ZLIB_LIBRARIES})
endif()
if("@FT_REQUIRE_BZIP2@")
list(APPEND FREETYPE_LIBRARIES ${BZIP2_LIBRARIES})
endif()
if("@FT_REQUIRE_PNG@")
list(APPEND FREETYPE_LIBRARIES ${PNG_LIBRARIES})
endif()
if("@FT_REQUIRE_BROTLI@")
list(APPEND FREETYPE_LIBRARIES ${BROTLIDEC_LIBRARIES} ${BROTLICOMMON_LIBRARIES})
endif()
endif()
endif()
cmake_policy(POP)
Loading

0 comments on commit 91175cb

Please sign in to comment.