Skip to content

Commit b593af9

Browse files
dg0ytLily Wang
andauthored
[gettext-libintl] Handle atypical Linux installations (#39662)
Co-authored-by: Lily Wang <[email protected]>
1 parent 74f76df commit b593af9

File tree

5 files changed

+44
-7
lines changed

5 files changed

+44
-7
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
project(find-libintl C)
3+
4+
set(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/detected_intl.cmake" CACHE FILEPATH "Where to store results")
5+
6+
find_package(Intl)
7+
find_file(LIBINTL_H NAMES libintl.h PATHS ${Intl_INCLUDE_DIRS})
8+
9+
string(CONFIGURE [[
10+
set(VCPKG_DETECTED_Intl_FOUND "@Intl_FOUND@")
11+
set(VCPKG_DETECTED_Intl_IS_BUILT_IN "@Intl_IS_BUILT_IN@")
12+
set(VCPKG_DETECTED_Intl_INCLUDE_DIRS "@Intl_INCLUDE_DIRS@")
13+
set(VCPKG_DETECTED_LIBINTL_H "@LIBINTL_H@")
14+
]] detected_intl @ONLY ESCAPE_QUOTES)
15+
16+
file(WRITE "${OUTFILE}" "${detected_intl}")

ports/gettext-libintl/portfile.cmake

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
if(VCPKG_TARGET_IS_LINUX)
2-
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
3-
if(NOT EXISTS "/usr/include/libintl.h")
1+
if(VCPKG_TARGET_IS_LINUX AND NOT X_VCPKG_FORCE_VCPKG_GETTEXT_LIBINTL)
2+
set(detection_results "${CURRENT_BUILDTREES_DIR}/detected-intl-${TARGET_TRIPLET}.cmake.log")
3+
file(REMOVE "${detection_results}")
4+
block(SCOPE_FOR VARIABLES)
5+
set(VCPKG_BUILD_TYPE release)
6+
vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/detect" OPTIONS "-DOUTFILE=${detection_results}")
7+
endblock()
8+
include("${detection_results}")
9+
message(STATUS "libintl header: ${VCPKG_DETECTED_LIBINTL_H}")
10+
if(NOT VCPKG_DETECTED_LIBINTL_H)
411
message(FATAL_ERROR
5-
"When targeting Linux, `libintl.h` is expected to come from the C Runtime Library (glibc). "
6-
"Please use \"sudo apt-get install libc-dev\" or the equivalent to install development files."
12+
"When targeting Linux, `libintl.h` is expected to come from a system package. "
13+
"Please use the following commands or the equivalent to install development files.\n"
14+
"On Debian and Ubuntu derivatives: \"sudo apt-get install libc-dev\"\n"
15+
"On Alpine: \"apk add gettext-dev\"\n"
716
)
817
endif()
18+
19+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
920
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
1021
return()
1122
endif()

ports/gettext-libintl/vcpkg.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gettext-libintl",
33
"version": "0.22.5",
4-
"port-version": 1,
4+
"port-version": 2,
55
"description": "The libintl C library from GNU gettext-runtime.",
66
"homepage": "https://www.gnu.org/software/gettext/",
77
"license": "LGPL-2.1-or-later",
@@ -10,6 +10,11 @@
1010
{
1111
"name": "libiconv",
1212
"platform": "!linux"
13+
},
14+
{
15+
"name": "vcpkg-cmake",
16+
"host": true,
17+
"platform": "linux"
1318
}
1419
]
1520
}

versions/baseline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,7 @@
30223022
},
30233023
"gettext-libintl": {
30243024
"baseline": "0.22.5",
3025-
"port-version": 1
3025+
"port-version": 2
30263026
},
30273027
"gettimeofday": {
30283028
"baseline": "2017-10-14",

versions/g-/gettext-libintl.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"versions": [
3+
{
4+
"git-tree": "f41e983c85004eb6ee8d290ecb2465832fce8c00",
5+
"version": "0.22.5",
6+
"port-version": 2
7+
},
38
{
49
"git-tree": "ac89519d5ec11430978a4e45619befb7a1c4a062",
510
"version": "0.22.5",

0 commit comments

Comments
 (0)