Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(port): CMake improvements #3457

Merged
merged 188 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
01c9ee6
Add build options from Cataclysm-common.props
alef Apr 15, 2022
2937a62
Add more build options from msvc-full-features/
alef Apr 17, 2022
7c94484
Use main-pch instead of stdafx.h
alef Apr 17, 2022
3af7c54
Copy msvc-full-features/vcpkg.json to source root
alef Apr 17, 2022
0a59992
Add gettext and its tools as dependency
alef Apr 17, 2022
e76b3b9
Move MSVC options to own toolchain file
alef Apr 17, 2022
ed077c7
Add a CMake presets file created by Visual Studio
alef Apr 17, 2022
6d19600
Fix not finding .lib files
alef Apr 18, 2022
44e5e78
Do not autogenerate a manifest
alef Apr 18, 2022
cfd4885
Add gettext tools only duing Windows builds
alef Apr 18, 2022
066296e
Comment CL flags
alef Apr 18, 2022
231707c
Expose JPEG library from SDL
alef Apr 18, 2022
f81281e
Switch back to Ninja, no build performance gains wtih MSBuild
alef Apr 18, 2022
808b030
Tell VCPKG to use static linking
alef Apr 18, 2022
202b679
Revert "build(cmake): deduplicate library setup (#3248)"
olanti-p Oct 17, 2023
b9b2979
Fix missing symbols required by SDL
alef Apr 18, 2022
8467af9
Fix validate_json.py test by removing UTF-8 BOM from presets file
alef Apr 18, 2022
33d592b
Include vcpkg.cmake instead of using as toolchain file
alef Apr 30, 2022
9128d7f
Rewrite presets from scratch
alef Apr 30, 2022
46fb1e1
Find VCPK installation through env
alef Apr 30, 2022
5d9e053
Move Ninja to MSVC preset
alef May 1, 2022
a1e326e
Upgrade to CMake 3.20 to allow new policies
alef May 1, 2022
d452725
Use CMAKE_CXX_FLAGS_INIT instead of add_compile_options()
alef May 1, 2022
581f080
Typo
alef May 1, 2022
d73fe73
Specific flag for RelWithDebInfo
alef May 1, 2022
d9669df
Set new policies to remove other flags
alef May 1, 2022
52addbe
Allow using /MT
alef May 1, 2022
233205e
Add a CMake build preset
alef May 1, 2022
a055ddb
Add x64-debug for MSVC
alef May 1, 2022
c3a7836
Add /GF as suggested
alef May 4, 2022
76359cf
Removed as requested. CMake version refers
alef May 4, 2022
09a1387
Add /OPT as requested
alef May 4, 2022
b6e64ad
Skip PCH when generating compile_commands.json
alef May 5, 2022
95ed3a5
tab vs. spaces
alef May 6, 2022
dab44d8
Update CMakeLists.txt
alef May 6, 2022
5305191
Move vcpkg.json into msvc directory
alef May 7, 2022
2a2839c
Using project's VCPKG Triplets
alef May 7, 2022
7569b52
Forgot ENV{} is special in if()
alef May 7, 2022
853d419
Edit comments
alef May 8, 2022
c5c221f
Use Windows path separator
alef May 8, 2022
836f4a9
Retrieve VS environment variables from VsDevCmd
alef May 8, 2022
f19462e
Rewrite the list of envs to be a CMake list
alef May 8, 2022
58f7a13
Loop over envs modified by VsDevCmd
alef May 8, 2022
0aa2407
Split environment variable in key/value and trim value
alef May 8, 2022
f88b80c
Set CMake environment with VsDevCmd set values
alef May 8, 2022
39df738
Write a JSON string for CMakeUserPresets build environment
alef May 8, 2022
1212b50
Write CMakeUserPresets.json based on VsDevCmd envs
alef May 8, 2022
2721e18
Set the C and C++ compilers to VS
alef May 8, 2022
224b16e
Remove the CMake build presets now in CMakeUserPreset.json
alef May 8, 2022
9a8edf2
Moving user presets hack into the include_before script
alef May 8, 2022
7bcf44f
More MS linker flags from linking stage in .vcxproj
alef May 8, 2022
10ef97f
Use MinGW's msgfmt.exe from Git for Windows
alef May 8, 2022
ef03937
Removing vcpkg triplets for gha as requested
alef May 9, 2022
2beee5c
Set default msgfmt
alef May 9, 2022
bb8336f
Search ninja.exe only when generator is Ninja*
alef May 9, 2022
e066ff8
Add MSYS to find_program msgfmt.exe
alef May 9, 2022
699450b
Removing gettext/msgfmt whole build, as requested
alef May 12, 2022
9e5a73b
Fix sourcing VsDevCmd.bat twice
alef May 15, 2022
3ede77f
Enable LOCALIZE in Release
alef May 15, 2022
c658179
PREFIX doesn't go through C preprocessor stringification
alef Jun 6, 2022
33fc433
Correct logic for -Wno-unknown-warning-option
perryprog Jun 20, 2022
1826515
Use correct cmake variable for prefix.h.in
perryprog Jul 2, 2022
366f466
Use CMake 3.21 or later
alef Aug 14, 2022
436c3b2
Change all target_link_libraries to interface form
alef May 26, 2022
5fe91dc
Change find_package if using VCPKG manitest
alef May 24, 2022
14e4db2
Set the correct property for using ccache
alef Aug 14, 2022
141ccee
Set compiler launchers before adding subdirectories
alef Aug 14, 2022
f7fd170
Fix release installation paths
alef Sep 20, 2022
c0abe81
Align CMake release install
alef Sep 20, 2022
157871a
Do not use our Find* modules under VCPKG
alef Aug 14, 2022
db6584d
Remove redundant modules from CMakeModules
alef May 27, 2022
df9a436
Add documentation for CMake+VCPKG build
alef May 24, 2022
797ea3c
Use VCPKG triplets from build-scripts/
alef May 24, 2022
39d25f9
Optmize replacing ENV vars loop with find()
alef May 26, 2022
3f97adf
Force ninja.exe path in the INCLUDE_BEFORE file
alef May 26, 2022
af1fb41
Add varialbes to "name" and "configurePreset"
alef Jun 1, 2022
23a20c4
Rename presets to match release.yml names
alef Jun 1, 2022
1f7def7
Move VsDevCmd environment parsing to its dedicated script
alef Jul 8, 2022
83de2ef
Fix checking for DevEnvDir
alef Aug 13, 2022
08a2063
Fix parsing non variables output
alef Aug 6, 2022
ca5e1d4
Document and improve VsDevCmd.cmake
alef Aug 14, 2022
2ae73c2
Use vswhere.exe as suggested by akrieger
alef Sep 9, 2022
d2662fa
Makes Ninja generators on Windows optional
alef Nov 2, 2022
c3a0994
Move hardcoded path into preset
alef Nov 4, 2022
88810ea
Build a release
alef Nov 9, 2022
dd82e65
Rewrite instructions addin VS procedure. Change displayed name
alef Nov 11, 2022
947b868
Add a missing target public interface
alef Nov 16, 2022
e9db703
Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md
alef Nov 25, 2022
d2868a4
Reverting SDL2 TTF library name resolution in VCPKG
alef Nov 25, 2022
d0d0d34
Move VCPKG to Windows only builds
alef Nov 26, 2022
4f0a8cc
Use SDL2_ttf when not using VCPKG
alef Nov 26, 2022
a03a1c7
Disable the MSYS build preset
alef Nov 27, 2022
2838315
Search for gettext in one place
alef Nov 27, 2022
d092896
Make VCPKG_ROOT optional in MSVC too
alef Nov 27, 2022
537161f
Allow to configure msgfmt and VCPKG paths
alef Nov 27, 2022
5938740
Fix using cache var in find_program(). Remove extra find_package
alef Nov 27, 2022
e526411
Use correct Git for Windows directory
alef Nov 27, 2022
c750cd1
Make building tests optional. Use "TESTS" cache var
alef Nov 27, 2022
0eb91e2
Install more directories
alef Nov 27, 2022
4982274
Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md
alef Nov 27, 2022
0aeacf7
Satisfy cmake-lint
alef Nov 27, 2022
69c968d
Move logic non belonging to data/ up
alef Nov 28, 2022
7be796b
Install VERSION.txt
alef Nov 28, 2022
d84084c
Switch building tests from CMake to presets
alef Nov 30, 2022
dde9e43
Add shlwapi required by mpg123
alef Nov 30, 2022
ee99744
Split SDL2 mixer package names
alef Nov 30, 2022
e843301
Enable sound
alef Nov 30, 2022
0825fee
Correct CMake install locations on *nix
perryprog Jan 9, 2023
b807630
Remove x86 specific macro definitions in MSVC build in CMake (#62602)
BrettDong Dec 6, 2022
c8b91f9
Fix CMake compilation and localization
Qrox Jan 22, 2023
e590c7e
Enable -g1 in CMake release build to produce source and line number i…
Qrox Mar 31, 2023
e2696e8
Add CMake option for XDG directories
sparr Apr 8, 2023
c8f30e5
Update vcpkg configuration, again
akrieger Apr 6, 2023
f3068fe
Downgrade cmake files to v3.20
alef May 2, 2023
24fcf29
Add VERSION.txt to .gitignore
BrettDong Dec 6, 2022
0b593fc
Add 'out/' to .gitignore
olanti-p Oct 24, 2023
d74bcf5
Fix merge conflict related to PCH, always use PCH
olanti-p Oct 24, 2023
7e79c00
BNify link in VERSION.txt
olanti-p Oct 24, 2023
a9390c0
BNify comment
olanti-p Oct 24, 2023
be268e7
Fix Lua build
olanti-p Oct 24, 2023
8413515
Makefile fix
olanti-p Oct 25, 2023
3afd203
Restore builtin-baseline in manifest
olanti-p Oct 25, 2023
00391f4
Make USE_PREFIX_DATA_DIR option available to Unix only
alef May 13, 2023
fb672bb
Replace all system specific *_DIR with CMAKE_INSTALL_*
alef May 13, 2023
40ab8f2
Use relative paths, use list append command
alef May 13, 2023
1d0318b
Configure prefix.h.in earlier
alef May 13, 2023
49a470a
Compact presets. VCPKG_ROOT now an env variable
alef May 13, 2023
a881c12
Remove cmake_minimum_required from subdirectories
alef May 13, 2023
e7b1485
Reduce CMake configuration output for releases
alef May 13, 2023
5f5b577
Use pkg-config to help finding mostly static libraries
alef May 22, 2023
74ff612
Prefer MSBuild on Windows
alef May 22, 2023
9aa47d3
Make Linux preset name refer to VCPKG
alef May 22, 2023
30ca871
Dynamically link SDL2_mixer
alef May 22, 2023
3a70a4a
Add a function to force an fs::path to a dir
alef May 23, 2023
3e4210f
Use the normalized directory path
alef May 23, 2023
3c6ea93
Add SDL2 targets for dynamic linking
alef May 24, 2023
03b27e4
Add more required libs to SDL2_image imported target
alef May 24, 2023
75b7551
Removing libzip not required for dynamic linking
alef May 24, 2023
7c2430a
Hotfix: Append a path delimiter for the 'dot' directory.
alef Jun 18, 2023
5a4ef86
Improve CMake behavior on Unix and macOS
perryprog Jun 25, 2023
1f2ee34
Disable lang install
olanti-p Oct 26, 2023
a8e6c8b
style(autofix.ci): automated formatting
autofix-ci[bot] Oct 26, 2023
6b04e96
Enable Lua in presets
olanti-p Oct 26, 2023
c060726
Add CMake+MSVC build to CI
olanti-p Oct 26, 2023
2a03630
Remove VCPKG_ROOT override
olanti-p Oct 26, 2023
a16d258
Remove Strawberry Pearl from PATH
olanti-p Oct 26, 2023
1aafdda
Add freetype overlay port
olanti-p Oct 26, 2023
850a411
Remove brotli feature from freetype
olanti-p Oct 27, 2023
82eaf9d
Small fixes in CMake build in Linux
alef Sep 25, 2023
f6027de
Add INTERFACE_INCLUDE_DIRECTORIES to SDL2 targets
alef Sep 28, 2023
c7bc481
Move pkg-config required FLAC dependency inside conditions
alef Sep 28, 2023
4f9fea5
Fix clang-tidy workflow by installing 'required' libflac-dev
akrieger Sep 26, 2023
47902ee
Add libflac to matrix
olanti-p Oct 27, 2023
831b371
Fix merge mistakes and style differences
olanti-p Oct 27, 2023
5d5ecfe
Don't re-define LUA
olanti-p Oct 27, 2023
69d184c
Style fixes
olanti-p Oct 27, 2023
4fad25b
Fix wrong merge
olanti-p Oct 27, 2023
b0762c8
Add CMake + MSYS2 build to matrix
olanti-p Oct 27, 2023
2e079bf
Update vcpkg
olanti-p Oct 27, 2023
e303885
BNify install dir
olanti-p Oct 27, 2023
abd783e
Use CMake to build translations in CI
olanti-p Oct 27, 2023
4063a84
Update documentation
olanti-p Oct 27, 2023
e921836
Add separate preset for VS 2022
olanti-p Oct 27, 2023
fb115a5
Implement missing members of vpart iterators
olanti-p Oct 31, 2023
b1d1053
Remove deprecated headers from stdafx.h
olanti-p Oct 31, 2023
2159cbb
Fix float conversion warnings C4244
olanti-p Oct 31, 2023
24766ed
Show current path if failed to find data dir
olanti-p Oct 31, 2023
d23d01d
Force translation tests to end up on english
olanti-p Oct 31, 2023
9295642
Fix build config setup in msvc Cmake preset
olanti-p Oct 31, 2023
8cd0326
Fix path to tests
olanti-p Oct 31, 2023
af73a1a
Add RelWithDebInfo to gitignore
olanti-p Oct 31, 2023
d5c13ac
Set cwd for debugging in VS
olanti-p Oct 31, 2023
7b56192
Add Debug configuration, enable tests
olanti-p Oct 31, 2023
1771174
Add docs on running from VS
olanti-p Oct 31, 2023
e419d52
style(autofix.ci): automated formatting
autofix-ci[bot] Oct 31, 2023
2f8c909
Add Release configuration
olanti-p Oct 31, 2023
ab845e4
ci: run MSYS on upload only
olanti-p Nov 2, 2023
dcc986f
Unify CMake and Makefile warnings
olanti-p Nov 3, 2023
3b741b8
ci: tweak msys cmake build
olanti-p Nov 3, 2023
4639045
Remove /permissive-
olanti-p Nov 7, 2023
546c1af
Alt fix for compiling Lua with CXX compiler
olanti-p Oct 27, 2023
e6ec2fd
Add PCH to tests
olanti-p Nov 13, 2023
439334d
Fix more UB on global statics cleanup
olanti-p Nov 14, 2023
620824c
Tweaks to VS CMake guide
olanti-p Nov 14, 2023
00fed13
Add new options to CMake guide
olanti-p Nov 14, 2023
c691c40
Fix port mistake
olanti-p Nov 14, 2023
edd04f0
Remove automatic CMake formatter
olanti-p Nov 14, 2023
858bbe3
Only run CMake+MSVC on upload
olanti-p Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading