Skip to content

Commit

Permalink
[gettext-libintl] Handle atypical Linux installations (#39662)
Browse files Browse the repository at this point in the history
Co-authored-by: Lily Wang <v-lilywang@microsoft.com>
  • Loading branch information
dg0yt and Lily Wang authored Jul 5, 2024
1 parent 74f76df commit b593af9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
16 changes: 16 additions & 0 deletions ports/gettext-libintl/detect/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.20)
project(find-libintl C)

set(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/detected_intl.cmake" CACHE FILEPATH "Where to store results")

find_package(Intl)
find_file(LIBINTL_H NAMES libintl.h PATHS ${Intl_INCLUDE_DIRS})

string(CONFIGURE [[
set(VCPKG_DETECTED_Intl_FOUND "@Intl_FOUND@")
set(VCPKG_DETECTED_Intl_IS_BUILT_IN "@Intl_IS_BUILT_IN@")
set(VCPKG_DETECTED_Intl_INCLUDE_DIRS "@Intl_INCLUDE_DIRS@")
set(VCPKG_DETECTED_LIBINTL_H "@LIBINTL_H@")
]] detected_intl @ONLY ESCAPE_QUOTES)

file(WRITE "${OUTFILE}" "${detected_intl}")
21 changes: 16 additions & 5 deletions ports/gettext-libintl/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
if(VCPKG_TARGET_IS_LINUX)
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
if(NOT EXISTS "/usr/include/libintl.h")
if(VCPKG_TARGET_IS_LINUX AND NOT X_VCPKG_FORCE_VCPKG_GETTEXT_LIBINTL)
set(detection_results "${CURRENT_BUILDTREES_DIR}/detected-intl-${TARGET_TRIPLET}.cmake.log")
file(REMOVE "${detection_results}")
block(SCOPE_FOR VARIABLES)
set(VCPKG_BUILD_TYPE release)
vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/detect" OPTIONS "-DOUTFILE=${detection_results}")
endblock()
include("${detection_results}")
message(STATUS "libintl header: ${VCPKG_DETECTED_LIBINTL_H}")
if(NOT VCPKG_DETECTED_LIBINTL_H)
message(FATAL_ERROR
"When targeting Linux, `libintl.h` is expected to come from the C Runtime Library (glibc). "
"Please use \"sudo apt-get install libc-dev\" or the equivalent to install development files."
"When targeting Linux, `libintl.h` is expected to come from a system package. "
"Please use the following commands or the equivalent to install development files.\n"
"On Debian and Ubuntu derivatives: \"sudo apt-get install libc-dev\"\n"
"On Alpine: \"apk add gettext-dev\"\n"
)
endif()

set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
return()
endif()
Expand Down
7 changes: 6 additions & 1 deletion ports/gettext-libintl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gettext-libintl",
"version": "0.22.5",
"port-version": 1,
"port-version": 2,
"description": "The libintl C library from GNU gettext-runtime.",
"homepage": "https://www.gnu.org/software/gettext/",
"license": "LGPL-2.1-or-later",
Expand All @@ -10,6 +10,11 @@
{
"name": "libiconv",
"platform": "!linux"
},
{
"name": "vcpkg-cmake",
"host": true,
"platform": "linux"
}
]
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3022,7 +3022,7 @@
},
"gettext-libintl": {
"baseline": "0.22.5",
"port-version": 1
"port-version": 2
},
"gettimeofday": {
"baseline": "2017-10-14",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/gettext-libintl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f41e983c85004eb6ee8d290ecb2465832fce8c00",
"version": "0.22.5",
"port-version": 2
},
{
"git-tree": "ac89519d5ec11430978a4e45619befb7a1c4a062",
"version": "0.22.5",
Expand Down

0 comments on commit b593af9

Please sign in to comment.