Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1a0d8d0
tdlib: update to 1.8.63
luadebug Apr 11, 2026
aad365e
vdb
luadebug Apr 11, 2026
d4af8f3
[tdlib] Improve pkg-config generation logic in CMake scripts
luadebug Apr 11, 2026
a78b637
vdb
luadebug Apr 11, 2026
f4e6fa4
retry building for all platforms
luadebug Apr 12, 2026
9a2a1c1
vdb
luadebug Apr 12, 2026
fcda619
[tdlib] Enhance cross-compilation support by explicitly setting CMAKE…
luadebug Apr 12, 2026
fbbe148
vdb
luadebug Apr 12, 2026
f02ff8e
[tdlib] Add support for host generators in cross-compilation by updat…
luadebug Apr 12, 2026
9ff4b68
vdb
luadebug Apr 12, 2026
1a0f3f7
fixup
luadebug Apr 12, 2026
16a99a6
vdb
luadebug Apr 12, 2026
77a311b
Remove tdlib from the CI baseline as it is expected to fail on arm64-…
luadebug Apr 12, 2026
61ea426
Remove tdlib from the CI baseline for arm64-linux
luadebug Apr 12, 2026
ca0b2d3
Dynamic library build provides only TdJson target
luadebug Apr 14, 2026
58e9fbc
vdb
luadebug Apr 14, 2026
e264e17
repair
luadebug Apr 14, 2026
b56ec75
repair
luadebug Apr 14, 2026
d9178d0
fixup
luadebug Apr 14, 2026
de94077
fixup
luadebug Apr 14, 2026
2bdabda
Merge branch 'microsoft:master' into tdlib
luadebug Apr 14, 2026
40b9f83
fix
luadebug Apr 14, 2026
23f9b4f
vdb
luadebug Apr 14, 2026
2923845
fixup
luadebug Apr 14, 2026
058b59c
vdb
luadebug Apr 14, 2026
821e2d6
test
luadebug Apr 15, 2026
4b22941
vdb
luadebug Apr 15, 2026
0b521d4
Merge branch 'master' into tdlib
luadebug Apr 15, 2026
fb0f8a1
try build again with /MD for executables
luadebug Apr 16, 2026
b32ad55
vdb
luadebug Apr 16, 2026
ab15e2d
Fix cross-compilation issues by excluding tools from build when not n…
luadebug Apr 18, 2026
f42a5eb
vdb
luadebug Apr 18, 2026
2a7a7fc
edit baseline
luadebug Apr 18, 2026
99c971e
Refactor CMake configuration for cross-compilation support and instal…
luadebug Apr 18, 2026
067feda
vdb
luadebug Apr 18, 2026
d312a1f
last try for x86-windows triplet
luadebug Apr 18, 2026
b3596d9
vdb
luadebug Apr 18, 2026
8bb0e44
Enhance pkg-config generation by adding interface compile definitions…
luadebug Apr 19, 2026
a63a3bd
vdb
luadebug Apr 19, 2026
80a3b9e
Write updating port note
luadebug Apr 19, 2026
39b73cc
vdb
luadebug Apr 19, 2026
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
27 changes: 27 additions & 0 deletions ports/tdlib/fix-cross-compile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/td/generate/CMakeLists.txt b/td/generate/CMakeLists.txt
--- a/td/generate/CMakeLists.txt
+++ b/td/generate/CMakeLists.txt
@@ -249,4 +249,10 @@
DEPENDS td_generate_dotnet_api tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DotnetTlDocumentationGenerator.php
)
endif()
+
+ if (TD_INSTALL_HOST_GENERATORS)
+ install(TARGETS tl-parser generate_mtproto generate_common generate_json
+ CONFIGURATIONS Release
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ endif()
endif()
diff --git a/tdutils/generate/CMakeLists.txt b/tdutils/generate/CMakeLists.txt
--- a/tdutils/generate/CMakeLists.txt
+++ b/tdutils/generate/CMakeLists.txt
@@ -60,3 +60,9 @@
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/auto/extension_to_mime_type.gperf
)
+
+ if (TD_INSTALL_HOST_GENERATORS)
+ install(TARGETS generate_mime_types_gperf
+ CONFIGURATIONS Release
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ endif()
endif()
147 changes: 55 additions & 92 deletions ports/tdlib/fix-pc.patch
Original file line number Diff line number Diff line change
@@ -1,113 +1,71 @@
diff --git a/CMake/GeneratePkgConfig.cmake b/CMake/GeneratePkgConfig.cmake
index 3d3fa01d1..9303a2f43 100644
index 3d3fa01d1f69..499b1c86be93 100644
--- a/CMake/GeneratePkgConfig.cmake
+++ b/CMake/GeneratePkgConfig.cmake
@@ -9,10 +9,20 @@ function(get_relative_link OUTPUT PATH)
@@ -8,12 +8,13 @@ function(get_relative_link OUTPUT PATH)
get_filename_component(NAME "${PATH}" NAME_WE)
if (IS_ABSOLUTE ${PATH})
get_filename_component(DIRECTORY_NAME "${PATH}" DIRECTORY)
if (WIN32)
- if (WIN32)
- set(${OUTPUT} "-l\"${DIRECTORY_NAME}/${NAME}\"" PARENT_SCOPE)
+ # On Windows, library files can be libname.lib or name.lib
+ get_filename_component(FULL_NAME "${PATH}" NAME)
+ # Extract library name without lib prefix and extension
+ string(REGEX REPLACE "^lib(.+)\\.[^.]+$" "\\1" LIB_NAME "${FULL_NAME}")
+ # If the regex didn't match (no lib prefix), use the name without extension
+ if ("${LIB_NAME}" STREQUAL "${FULL_NAME}")
+ set(LIB_NAME "${NAME}")
+ endif()
+ set(${OUTPUT} "-L\"${DIRECTORY_NAME}\" -l${LIB_NAME}" PARENT_SCOPE)
else()
get_filename_component(FULL_NAME "${PATH}" NAME)
- else()
- get_filename_component(FULL_NAME "${PATH}" NAME)
- set(${OUTPUT} "-L\"${DIRECTORY_NAME}\" -l:${FULL_NAME}" PARENT_SCOPE)
+ # Extract library name without lib prefix and extension for all platforms
+ string(REGEX REPLACE "^lib(.+)\\.[^.]+$" "\\1" LIB_NAME "${FULL_NAME}")
+ set(${OUTPUT} "-L\"${DIRECTORY_NAME}\" -l${LIB_NAME}" PARENT_SCOPE)
+ get_filename_component(FULL_NAME "${PATH}" NAME)
+ string(REGEX REPLACE "^lib([^.]+).*$" "\\1" LIB_NAME "${FULL_NAME}")
+ # If the regex didn't match (no lib prefix), fall back to name without extension
+ if ("${LIB_NAME}" STREQUAL "${FULL_NAME}")
+ set(LIB_NAME "${NAME}")
endif()
+ set(${OUTPUT} "-L\"${DIRECTORY_NAME}\" -l${LIB_NAME}" PARENT_SCOPE)
return()
endif()
@@ -31,17 +41,86 @@ function(generate_pkgconfig TARGET DESCRIPTION)

@@ -31,7 +32,42 @@ function(generate_pkgconfig TARGET DESCRIPTION)
# message("Generating pkg-config for ${TARGET}")
get_filename_component(PREFIX "${CMAKE_INSTALL_PREFIX}" REALPATH)

- get_target_property(LIST "${TARGET}" LINK_LIBRARIES)
+ # Get the target type to handle interface libraries differently
+ get_target_property(LIBRARY_TYPE "${TARGET}" TYPE)
+
+ # For interface libraries, use INTERFACE_LINK_LIBRARIES instead of LINK_LIBRARIES
+ if ("${LIBRARY_TYPE}" STREQUAL "INTERFACE_LIBRARY")
+ get_target_property(LIST "${TARGET}" INTERFACE_LINK_LIBRARIES)
+ else()
+ get_target_property(LIST "${TARGET}" LINK_LIBRARIES)
+ endif()
+
+ # Handle the case when no libraries are found
+
+ if ("${LIST}" STREQUAL "LIST-NOTFOUND")
+ set(LIST "")
+ endif()
+
+ # Special handling for tdcore interface library
+ if ("${TARGET}" STREQUAL "tdcore" AND "${LIBRARY_TYPE}" STREQUAL "INTERFACE_LIBRARY")
+ # For tdcore interface library, we need to link to the actual part libraries
+ # instead of the non-existent tdcore library
+ set(TDCORE_LIBS "")
+ set(COMBINED_REQS "")
+ set(COMBINED_LIBS "")
+
+ foreach (PART_LIB ${LIST})
+ if (TARGET "${PART_LIB}" AND "${PART_LIB}" MATCHES "^tdcore_part[0-9]+$")
+ # Add the actual part library to link against
+ list(APPEND TDCORE_LIBS "-l${PART_LIB}")
+
+ # Collect dependencies from the parts
+ get_target_property(PART_LIST "${PART_LIB}" LINK_LIBRARIES)
+ if (NOT "${PART_LIST}" STREQUAL "PART_LIST-NOTFOUND")
+ foreach (PART_DEP ${PART_LIST})
+ if (TARGET "${PART_DEP}")
+ list(APPEND COMBINED_REQS "${PART_DEP}")
+ else()
+ list(APPEND COMBINED_LIBS "${PART_DEP}")
+ endif()
+ endforeach()
+
+ set(INTERFACE_LIBS "")
+ if ("${LIBRARY_TYPE}" STREQUAL "INTERFACE_LIBRARY")
+ set(PROPAGATED "")
+ foreach (DEP ${LIST})
+ if (TARGET "${DEP}")
+ get_target_property(DEP_TYPE "${DEP}" TYPE)
+ if ("${DEP_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${DEP_TYPE}" STREQUAL "SHARED_LIBRARY")
+ list(APPEND INTERFACE_LIBS "${DEP}")
+ get_target_property(DEP_LIBS "${DEP}" LINK_LIBRARIES)
+ if (NOT "${DEP_LIBS}" STREQUAL "DEP_LIBS-NOTFOUND")
+ list(APPEND PROPAGATED ${DEP_LIBS})
+ endif()
+ else()
+ list(APPEND PROPAGATED "${DEP}")
+ endif()
+ elseif (TARGET "${PART_LIB}")
+ list(APPEND COMBINED_REQS "${PART_LIB}")
+ else()
+ list(APPEND COMBINED_LIBS "${PART_LIB}")
+ list(APPEND PROPAGATED "${DEP}")
+ endif()
+ endforeach()
+
+ # Remove duplicates
+ if (COMBINED_REQS)
+ list(REMOVE_DUPLICATES COMBINED_REQS)
+ endif()
+ if (COMBINED_LIBS)
+ list(REMOVE_DUPLICATES COMBINED_LIBS)
+ endif()
+ if (TDCORE_LIBS)
+ list(REMOVE_DUPLICATES TDCORE_LIBS)
+ if (PROPAGATED)
+ list(REMOVE_DUPLICATES PROPAGATED)
+ endif()
+
+ set(LIST "")
+ list(APPEND LIST ${COMBINED_REQS})
+ list(APPEND LIST ${COMBINED_LIBS})
+
+ # Set a flag to use different Libs line for tdcore
+ set(USE_TDCORE_PARTS TRUE)
+ else()
+ set(USE_TDCORE_PARTS FALSE)
+ set(LIST "${PROPAGATED}")
+ endif()
+
+
set(REQS "")
set(LIBS "")
foreach (LIB ${LIST})
if (TARGET "${LIB}")
- set(HAS_REQS 1)
- list(APPEND REQS "${LIB}")
+ # Skip internal tdcore parts as they don't have their own .pc files
+ if (NOT "${LIB}" MATCHES "^tdcore_part[0-9]+$")
+ set(HAS_REQS 1)
+ list(APPEND REQS "${LIB}")
+ endif()
@@ -41,7 +77,7 @@ function(generate_pkgconfig TARGET DESCRIPTION)
else()
set(HAS_LIBS 1)
get_relative_link(LINK "${LIB}")
Expand All @@ -116,27 +74,34 @@ index 3d3fa01d1..9303a2f43 100644
list(APPEND LIBS "${LINK}")
endif()
endif()
@@ -77,6 +156,19 @@ function(generate_pkgconfig TARGET DESCRIPTION)
@@ -77,6 +113,26 @@ function(generate_pkgconfig TARGET DESCRIPTION)
endif()

file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig")
+
+ # Generate the correct Libs line based on library type
+ if (USE_TDCORE_PARTS)
+ # For tdcore interface library, link to the actual part libraries
+
+ get_target_property(TARGET_OUTPUT_NAME "${TARGET}" OUTPUT_NAME)
+ if ("${TARGET_OUTPUT_NAME}" STREQUAL "TARGET_OUTPUT_NAME-NOTFOUND")
+ set(TARGET_OUTPUT_NAME "${TARGET}")
+ endif()
+
+ if ("${LIBRARY_TYPE}" STREQUAL "INTERFACE_LIBRARY")
+ set(LIBS_LINE "")
+ foreach (PART_LIB ${TDCORE_LIBS})
+ set(LIBS_LINE "${LIBS_LINE} ${PART_LIB}")
+ foreach (ILIB ${INTERFACE_LIBS})
+ get_target_property(ILIB_OUTPUT_NAME "${ILIB}" OUTPUT_NAME)
+ if ("${ILIB_OUTPUT_NAME}" STREQUAL "ILIB_OUTPUT_NAME-NOTFOUND")
+ set(ILIB_OUTPUT_NAME "${ILIB}")
+ endif()
+ set(LIBS_LINE "${LIBS_LINE} -l${ILIB_OUTPUT_NAME}")
+ endforeach()
+ set(LIBS_LINE "Libs: -L\"${PKGCONFIG_LIBDIR}\"${LIBS_LINE}")
+ else()
+ set(LIBS_LINE "Libs: -L\"${PKGCONFIG_LIBDIR}\" -l${TARGET}")
+ set(LIBS_LINE "Libs: -L\"${PKGCONFIG_LIBDIR}\" -l${TARGET_OUTPUT_NAME}")
+ endif()
+
+
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${TARGET}.pc" CONTENT
"prefix=${PREFIX}

@@ -85,14 +177,14 @@ Description: ${DESCRIPTION}
@@ -85,14 +141,12 @@ Description: ${DESCRIPTION}
Version: ${PROJECT_VERSION}

CFlags: -I\"${PKGCONFIG_INCLUDEDIR}\"
Expand All @@ -146,10 +111,8 @@ index 3d3fa01d1..9303a2f43 100644

- get_target_property(LIBRARY_TYPE "${TARGET}" TYPE)
- if (LIBRARY_TYPE STREQUAL "STATIC_LIBRARY" OR LIBRARY_TYPE STREQUAL "SHARED_LIBRARY")
+ if ("${LIBRARY_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${LIBRARY_TYPE}" STREQUAL "SHARED_LIBRARY")
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${TARGET}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+ elseif ("${LIBRARY_TYPE}" STREQUAL "INTERFACE_LIBRARY")
+ # Interface libraries are also supported, install the .pc file
+ if ("${LIBRARY_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${LIBRARY_TYPE}" STREQUAL "SHARED_LIBRARY" OR
+ "${LIBRARY_TYPE}" STREQUAL "INTERFACE_LIBRARY")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${TARGET}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
- elseif (LIBRARY_TYPE STREQUAL "INTERFACE_LIBRARY")
- # TODO: support interface libraries
Expand Down
93 changes: 90 additions & 3 deletions ports/tdlib/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,90 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO tdlib/td
REF 7d257dcda5dd2c616c1146540ef51147c5bb2c69
REF f06b0bac65278b03d26414c096080e7bfecfef52
HEAD_REF master
SHA512 fca25e017e6bc27bcc0a69b35ad478a5acfc46b511917440c3e560c18378c3f4133c1c553eb9a0752db5328f61c5813312d653f4ad5e5d0284b7a79d4f480be8
SHA512 91967a24eee9f1491b780ce72a1323aa99e228c10ecd588979e325d57417c6897eeebf375c609c99b2fd0d6137bcb950628a30f5cfc2e6838fb14d2803d02b7a
PATCHES
fix-pc.patch
fix-cross-compile.patch
)

vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/gperf")

# When cross-compiling, run the generator executables that were installed by
# the host build of tdlib[tools] (declared as a host:true dependency in
# vcpkg.json). Running them directly avoids a cmake sub-invocation and
# therefore sidesteps the Windows ARM64 problem where a cmake subprocess
# inherits the vcvarsall cross-compiler and produces the wrong architecture.
if(VCPKG_CROSSCOMPILING)
set(_tools "${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}")
set(_exe "${VCPKG_HOST_EXECUTABLE_SUFFIX}")
set(_gperf "${CURRENT_HOST_INSTALLED_DIR}/tools/gperf/gperf${_exe}")

# ── MIME type sources ────────────────────────────────────────────────────
file(MAKE_DIRECTORY "${SOURCE_PATH}/tdutils/generate/auto")

vcpkg_execute_required_process(
Comment thread
luadebug marked this conversation as resolved.
COMMAND "${_tools}/generate_mime_types_gperf${_exe}"
"${SOURCE_PATH}/tdutils/generate/mime_types.txt"
"${SOURCE_PATH}/tdutils/generate/auto/mime_type_to_extension.gperf"
"${SOURCE_PATH}/tdutils/generate/auto/extension_to_mime_type.gperf"
WORKING_DIRECTORY "${SOURCE_PATH}/tdutils/generate"
LOGNAME "tdlib-gen-mime-gperf-${TARGET_TRIPLET}"
)
vcpkg_execute_required_process(
COMMAND "${_gperf}" -m100
"--output-file=auto/mime_type_to_extension.cpp"
"auto/mime_type_to_extension.gperf"
WORKING_DIRECTORY "${SOURCE_PATH}/tdutils/generate"
LOGNAME "tdlib-gen-mime-to-ext-${TARGET_TRIPLET}"
)
vcpkg_execute_required_process(
COMMAND "${_gperf}" -m100
"--output-file=auto/extension_to_mime_type.cpp"
"auto/extension_to_mime_type.gperf"
WORKING_DIRECTORY "${SOURCE_PATH}/tdutils/generate"
LOGNAME "tdlib-gen-ext-to-mime-${TARGET_TRIPLET}"
)

# ── TL schema → .tlo → generated C++ API sources ─────────────────────────
file(MAKE_DIRECTORY "${SOURCE_PATH}/td/generate/auto/tlo")
foreach(_scheme IN ITEMS mtproto_api secret_api e2e_api td_api telegram_api)
vcpkg_execute_required_process(
COMMAND "${_tools}/tl-parser${_exe}"
-e "auto/tlo/${_scheme}.tlo" "scheme/${_scheme}.tl"
WORKING_DIRECTORY "${SOURCE_PATH}/td/generate"
LOGNAME "tdlib-gen-tlo-${_scheme}-${TARGET_TRIPLET}"
)
endforeach()

file(MAKE_DIRECTORY "${SOURCE_PATH}/td/generate/auto/td/telegram")
file(MAKE_DIRECTORY "${SOURCE_PATH}/td/generate/auto/td/mtproto")
foreach(_gen IN ITEMS generate_mtproto generate_common generate_json)
vcpkg_execute_required_process(
COMMAND "${_tools}/${_gen}${_exe}"
WORKING_DIRECTORY "${SOURCE_PATH}/td/generate/auto"
LOGNAME "tdlib-${_gen}-${TARGET_TRIPLET}"
)
endforeach()

unset(_tools)
unset(_exe)
unset(_gperf)
endif()

# The "tools" feature installs the source-generator executables so that
# cross-compile builds of this port can find them in tools/tdlib/.
# It is requested via the host:true dependency in vcpkg.json, so vcpkg
# always builds tdlib[tools]:host-triplet before any cross-compile target.
if("tools" IN_LIST FEATURES AND NOT VCPKG_CROSSCOMPILING)
set(_tdlib_install_gen ON)
else()
set(_tdlib_install_gen OFF)
endif()

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DTD_INSTALL_SHARED_LIBRARIES=OFF
-DTD_INSTALL_STATIC_LIBRARIES=ON
Expand All @@ -21,15 +94,29 @@ vcpkg_cmake_configure(
-DTD_E2E_ONLY=OFF
-DTD_ENABLE_LTO=${CMAKE_HOST_WIN32}
-DTD_ENABLE_MULTI_PROCESSOR_COMPILATION=${VCPKG_DETECTED_MSVC}
-DTD_INSTALL_HOST_GENERATORS=${_tdlib_install_gen}
-DBUILD_TESTING=OFF
MAYBE_UNUSED_VARIABLES
TD_ENABLE_MULTI_PROCESSOR_COMPILATION
TD_INSTALL_HOST_GENERATORS
)

vcpkg_cmake_install()
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/Td")
vcpkg_copy_pdbs()

if("tools" IN_LIST FEATURES AND NOT VCPKG_CROSSCOMPILING)
vcpkg_copy_tools(
TOOL_NAMES
tl-parser
generate_mtproto
generate_common
generate_json
generate_mime_types_gperf
AUTO_CLEAN
)
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE_1_0.txt")
19 changes: 16 additions & 3 deletions ports/tdlib/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"name": "tdlib",
"version": "1.8.55",
"version": "1.8.63",
"description": "Cross-platform library for building Telegram clients",
"homepage": "https://github.com/tdlib/td",
"license": "BSL-1.0",
"supports": "((windows & !uwp & !arm & !arm64 & !xbox) | linux | osx) & static",
"supports": "static",
Comment thread
luadebug marked this conversation as resolved.
Outdated
"dependencies": [
{
"name": "gperf",
"host": true
},
"openssl",
{
"name": "tdlib",
"host": true,
"default-features": false,
"features": [
"tools"
]
},
{
"name": "vcpkg-cmake",
"host": true
Expand All @@ -20,5 +28,10 @@
"host": true
},
"zlib"
]
],
"features": {
"tools": {
"description": "Install source-generator executables (tl-parser, generate_mtproto, etc.) required for cross-compilation"
}
}
}
Loading
Loading