-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[gettext] Add gettext cmake wrapper #18159
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
Changes from all commits
92149d4
df48398
7bb50e0
8d50643
895ef31
55b90a2
6bab7a6
f0c5c7e
d63d955
62b003d
0af6487
dc4a00b
3677e56
f35842e
644db9d
5a773e8
70cca92
3860977
a9396b4
7c7d207
b201547
5ed8d7a
1a778c3
9fc5649
95b64ac
4080bcd
119461d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| all: build-gettext-runtime-intl build-gettext-runtime-po build-gettext-runtime-src | ||
| all: build-gettext-tools build-gettext-tools-gnulib build-gettext-tools-its build-gettext-tools-m4 build-gettext-tools-misc build-gettext-tools-po build-gettext-tools-projects build-gettext-tools-styles | ||
| all: build-libtextstyle | ||
|
|
||
| install: install-gettext-runtime-intl install-gettext-runtime-po install-gettext-runtime-src | ||
| install: install-gettext-tools install-gettext-tools-gnulib install-gettext-tools-its install-gettext-tools-m4 install-gettext-tools-misc install-gettext-tools-po install-gettext-tools-projects install-gettext-tools-styles | ||
| install: install-libtextstyle | ||
|
|
||
| build-gettext-runtime-gnulib: build-gettext-runtime-intl | ||
| $(MAKE) -C gettext-runtime/gnulib-lib all | ||
| build-gettext-runtime-intl: | ||
| $(MAKE) -C gettext-runtime/intl all | ||
| build-gettext-runtime-po: | ||
| $(MAKE) -C gettext-runtime/po all | ||
| build-gettext-runtime-src: build-gettext-runtime-intl build-gettext-runtime-gnulib | ||
| $(MAKE) -C gettext-runtime/src all | ||
| build-gettext-tools: build-gettext-runtime-intl build-libtextstyle build-gettext-tools-gnulib build-gettext-tools-intl build-gettext-tools-libgrep build-gnulib-local | ||
| $(MAKE) -C gettext-tools/src all | ||
| build-gettext-tools-gnulib: build-gettext-tools-intl | ||
| $(MAKE) -C gettext-tools/gnulib-lib all | ||
| build-gettext-tools-libgrep: build-gettext-tools-gnulib | ||
| $(MAKE) -C gettext-tools/libgrep all | ||
| build-gettext-tools-intl: | ||
| $(MAKE) -C gettext-tools/intl all | ||
| build-gettext-tools-its: | ||
| $(MAKE) -C gettext-tools/its all | ||
| build-gettext-tools-m4: | ||
| $(MAKE) -C gettext-tools/m4 all | ||
| build-gettext-tools-misc: | ||
| $(MAKE) -C gettext-tools/misc all | ||
| build-gettext-tools-po: | ||
| $(MAKE) -C gettext-tools/po all | ||
| build-gettext-tools-projects: | ||
| $(MAKE) -C gettext-tools/projects all | ||
| build-gettext-tools-styles: | ||
| $(MAKE) -C gettext-tools/styles all | ||
| build-gnulib-local: | ||
| $(MAKE) -C gnulib-local all | ||
| build-libtextstyle: | ||
| $(MAKE) -C libtextstyle/lib all | ||
|
|
||
| install-gettext-runtime-intl: | ||
| $(MAKE) -C gettext-runtime/intl install | ||
| install-gettext-runtime-po: | ||
| $(MAKE) -C gettext-runtime/po install | ||
| install-gettext-runtime-src: | ||
| $(MAKE) -C gettext-runtime/src install | ||
| install-gettext-tools: | ||
| $(MAKE) -C gettext-tools/src install | ||
| install-gettext-tools-gnulib: | ||
| $(MAKE) -C gettext-tools/gnulib-lib install | ||
| install-gettext-tools-its: | ||
| $(MAKE) -C gettext-tools/its install | ||
| install-gettext-tools-m4: | ||
| $(MAKE) -C gettext-tools/m4 install | ||
| install-gettext-tools-misc: | ||
| $(MAKE) -C gettext-tools/misc install | ||
| install-gettext-tools-po: | ||
| $(MAKE) -C gettext-tools/po install | ||
| install-gettext-tools-projects: | ||
| $(MAKE) -C gettext-tools/projects install | ||
| install-gettext-tools-styles: | ||
| $(MAKE) -C gettext-tools/styles install | ||
| install-libtextstyle: | ||
| $(MAKE) -C libtextstyle/lib install | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| if(VCPKG_TARGET_IS_LINUX) | ||
| set(VCPKG_POLICY_EMPTY_PACKAGE enabled) | ||
| if (NOT EXISTS "/usr/include/libintl.h") | ||
| message(FATAL_ERROR "Please use command \"sudo apt-get install gettext\" to install gettext on linux.") | ||
| 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." | ||
| ) | ||
| endif() | ||
| if(NOT "tools" IN_LIST FEATURES) | ||
| set(VCPKG_POLICY_EMPTY_PACKAGE enabled) | ||
| return() | ||
| endif() | ||
| return() | ||
| else() | ||
| set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled) | ||
| endif() | ||
|
|
||
| set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled) | ||
|
|
||
| #Based on https://github.com/winlibs/gettext | ||
|
|
||
| set(GETTEXT_VERSION 0.21) | ||
|
|
@@ -17,13 +21,14 @@ vcpkg_download_distfile(ARCHIVE | |
| FILENAME "gettext-${GETTEXT_VERSION}.tar.gz" | ||
| SHA512 bbe590c5dd3580c75bf30ff768da99a88eb8d466ec1ac9eea20be4cab4357ecf72448e6b81b47425e39d50fa6320ba426632914d7898dfebb4f159abc39c31d1 | ||
| ) | ||
| set(PATCHES "") | ||
| if(VCPKG_TARGET_IS_UWP) | ||
| set(PATCHES uwp_remove_localcharset.patch) | ||
| endif() | ||
| vcpkg_extract_source_archive_ex( | ||
| OUT_SOURCE_PATH SOURCE_PATH | ||
| ARCHIVE ${ARCHIVE} | ||
| REF ${GETTEXT_VERSION} | ||
| ARCHIVE "${ARCHIVE}" | ||
| REF "${GETTEXT_VERSION}" | ||
| PATCHES | ||
| 0002-Fix-uwp-build.patch | ||
| 0003-Fix-win-unicode-paths.patch | ||
|
|
@@ -32,59 +37,117 @@ vcpkg_extract_source_archive_ex( | |
| ${PATCHES} | ||
| ) | ||
| vcpkg_find_acquire_program(BISON) | ||
| get_filename_component(BISON_PATH ${BISON} DIRECTORY) | ||
| vcpkg_add_to_path(${BISON_PATH}) | ||
| get_filename_component(BISON_PATH "${BISON}" DIRECTORY) | ||
| vcpkg_add_to_path("${BISON_PATH}") | ||
|
|
||
| set(OPTIONS | ||
| --enable-relocatable #symbol duplication with glib-init.c? | ||
| --enable-c++ | ||
| --disable-acl | ||
| --disable-csharp | ||
| --disable-curses | ||
| --disable-java | ||
| --disable-openmp | ||
| ) | ||
| if(VCPKG_TARGET_IS_WINDOWS) | ||
| # This is required. For some reason these do not get correctly identified for release builds. | ||
| list(APPEND OPTIONS ac_cv_func_wcslen=yes | ||
| ac_cv_func_memmove=yes | ||
| #The following are required for a full gettext built. | ||
| # Left here for future reference. | ||
| gl_cv_func_printf_directive_n=no #segfaults otherwise with popup window | ||
| ac_cv_func_memset=yes #not detected in release builds | ||
| ac_cv_header_pthread_h=no | ||
| ac_cv_header_dirent_h=no | ||
| ) | ||
| list(APPEND OPTIONS | ||
| # Avoid unnecessary test. | ||
| --with-included-glib | ||
| # This is required. For some reason these do not get correctly identified for release builds. | ||
| ac_cv_func_wcslen=yes | ||
| ac_cv_func_memmove=yes | ||
| # The following are required for a full gettext built (libintl and tools). | ||
| gl_cv_func_printf_directive_n=no # segfaults otherwise with popup window | ||
| ac_cv_func_memset=yes # not detected in release builds | ||
| ac_cv_header_pthread_h=no | ||
| ac_cv_header_dirent_h=no | ||
| ) | ||
| endif() | ||
| set(ADDITIONAL_CONFIGURE_OPTIONS) | ||
| set(ADDITIONAL_INSTALL_OPTIONS) | ||
|
|
||
| # These functions scope any changes to VCPKG_BUILD_TYPE | ||
| function(build_libintl_and_tools) | ||
| cmake_parse_arguments(arg "" "BUILD_TYPE" "" ${ARGN}) | ||
| if(DEFINED arg_BUILD_TYPE) | ||
| set(VCPKG_BUILD_TYPE "${arg_BUILD_TYPE}") | ||
| endif() | ||
| vcpkg_configure_make(SOURCE_PATH "${SOURCE_PATH}" | ||
| DETERMINE_BUILD_TRIPLET | ||
| USE_WRAPPERS | ||
| ADD_BIN_TO_PATH # So configure can check for working iconv | ||
| ADDITIONAL_MSYS_PACKAGES gzip | ||
| OPTIONS | ||
| ${OPTIONS} | ||
| ) | ||
| vcpkg_install_make(MAKEFILE "${CMAKE_CURRENT_LIST_DIR}/Makefile") | ||
| endfunction() | ||
|
|
||
| function(build_libintl_only) | ||
| cmake_parse_arguments(arg "" "BUILD_TYPE" "" ${ARGN}) | ||
| if(DEFINED arg_BUILD_TYPE) | ||
| set(VCPKG_BUILD_TYPE "${arg_BUILD_TYPE}") | ||
| endif() | ||
| vcpkg_configure_make(SOURCE_PATH "${SOURCE_PATH}/gettext-runtime" | ||
| DETERMINE_BUILD_TRIPLET | ||
| USE_WRAPPERS | ||
| ADD_BIN_TO_PATH # So configure can check for working iconv | ||
| OPTIONS | ||
| ${OPTIONS} | ||
| ) | ||
| vcpkg_install_make(SUBPATH "/intl") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to use this? Can we manually set the target intl instead of doing this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It was there before this PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish to reduce the vcpkg_configure_cmake options.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine for me. Shall I try to prepare a PR for the gettext Makefile approach? (Assuming we are not in a hurry.)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dg0yt Yes, also I will have a try. |
||
| endfunction() | ||
|
|
||
| if("tools" IN_LIST FEATURES) | ||
| set(BUILD_SOURCE_PATH ${SOURCE_PATH}) | ||
| set(ADDITIONAL_CONFIGURE_OPTIONS ADDITIONAL_MSYS_PACKAGES gzip) | ||
| # Minimization of gettext tools build time by: | ||
| # - building tools only for release configuration | ||
| # - custom top-level Makefile | ||
| # - configuration cache | ||
| list(APPEND OPTIONS "--cache-file=../config.cache-${TARGET_TRIPLET}") | ||
| file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/config.cache-${TARGET_TRIPLET}") | ||
| build_libintl_and_tools(BUILD_TYPE "release") | ||
| vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin") | ||
| file(GLOB tool_libs | ||
| LIST_DIRECTORIES false | ||
| "${CURRENT_PACKAGES_DIR}/bin/*" | ||
| "${CURRENT_PACKAGES_DIR}/lib/*" | ||
| ) | ||
| list(FILTER tool_libs EXCLUDE REGEX "intl[^/\\\\]*$") | ||
| file(REMOVE ${tool_libs}) | ||
| file(GLOB tool_includes | ||
| LIST_DIRECTORIES true | ||
| "${CURRENT_PACKAGES_DIR}/include/*" | ||
| ) | ||
| list(FILTER tool_includes EXCLUDE REGEX "intl[^/\\\\]*$") | ||
| file(REMOVE_RECURSE ${tool_includes}) | ||
| if(VCPKG_TARGET_IS_LINUX) | ||
| set(VCPKG_POLICY_EMPTY_PACKAGE enabled) | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib") | ||
| elseif(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}.release") | ||
| file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}.release") | ||
| file(READ "${CURRENT_BUILDTREES_DIR}/config.cache-${TARGET_TRIPLET}" config_cache) | ||
| string(REGEX REPLACE "\nac_cv_env[^\n]*" "" config_cache "${config_cache}") # Eliminate build type flags | ||
| file(WRITE "${CURRENT_BUILDTREES_DIR}/config.cache-${TARGET_TRIPLET}" "${config_cache}") | ||
| build_libintl_only(BUILD_TYPE "debug") | ||
| file(RENAME "${CURRENT_PACKAGES_DIR}/debug" "${CURRENT_PACKAGES_DIR}.release/debug") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}") | ||
| file(RENAME "${CURRENT_PACKAGES_DIR}.release" "${CURRENT_PACKAGES_DIR}") | ||
| endif() | ||
| else() | ||
| set(BUILD_SOURCE_PATH ${SOURCE_PATH}/gettext-runtime) # Could be its own port | ||
| set(ADDITIONAL_INSTALL_OPTIONS SUBPATH "/intl") | ||
| list(APPEND OPTIONS "--config-cache") | ||
| build_libintl_only() | ||
| endif() | ||
| vcpkg_configure_make(SOURCE_PATH ${BUILD_SOURCE_PATH} | ||
| DETERMINE_BUILD_TRIPLET | ||
| USE_WRAPPERS | ||
| ADD_BIN_TO_PATH # So configure can check for working iconv | ||
| OPTIONS --enable-relocatable #symbol duplication with glib-init.c? | ||
| --enable-c++ | ||
| --disable-java | ||
| ${OPTIONS} | ||
| ${ADDITIONAL_CONFIGURE_OPTIONS} | ||
| ) | ||
| vcpkg_install_make(${ADDITIONAL_INSTALL_OPTIONS}) | ||
|
|
||
| # Handle copyright | ||
| file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/gettext) | ||
| file(RENAME ${CURRENT_PACKAGES_DIR}/share/gettext/COPYING ${CURRENT_PACKAGES_DIR}/share/gettext/copyright) | ||
|
|
||
| vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin) | ||
| vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin) | ||
| configure_file("${SOURCE_PATH}/COPYING" "${CURRENT_PACKAGES_DIR}/share/gettext/copyright" COPYONLY) | ||
|
|
||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") | ||
|
|
||
| set(GNU_DLL_PATHS lib/ debug/lib/) | ||
| set(GNU_DLL_NAME GNU.Gettext.dll) #C# dll? | ||
| foreach(DLL_PATH IN LISTS GNU_DLL_PATHS) | ||
| if(EXISTS "${CURRENT_PACKAGES_DIR}/${DLL_PATH}${GNU_DLL_NAME}") | ||
| file(REMOVE "${CURRENT_PACKAGES_DIR}/${DLL_PATH}${GNU_DLL_NAME}") | ||
| endif() | ||
| endforeach() | ||
|
|
||
| vcpkg_copy_pdbs() | ||
|
|
||
| file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/intl) | ||
| if(NOT VCPKG_TARGET_IS_LINUX) | ||
| file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/intl") | ||
| endif() | ||
| if("tools" IN_LIST FEATURES AND NOT VCPKG_CROSSCOMPILING) | ||
| file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/gettext") | ||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| get_filename_component(gettext_tools_dir "${CMAKE_CURRENT_LIST_DIR}/../../tools/gettext/bin" ABSOLUTE) | ||
| if(CMAKE_HOST_WIN32) | ||
| set(ENV{PATH} "$ENV{PATH};${gettext_tools_dir}") | ||
| else() | ||
| set(ENV{PATH} "$ENV{PATH}:${gettext_tools_dir}") | ||
| endif() |
Uh oh!
There was an error while loading. Please reload this page.