From be40ba68a808b61117fb11f7f035b7f205a86dac Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 28 Jun 2022 23:09:20 +0800 Subject: build(cmake): fix static `libintl` test on macOS If `libintl` is a static library on macOS, we also need to explicitly link with `libiconv` and the `CoreFoundation` framework. Otherwise, our `HAVE_WORKING_LIBINTL` test erroneously fails. Closes #19127 Closes #19138 --- cmake/FindLibIntl.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmake/FindLibIntl.cmake b/cmake/FindLibIntl.cmake index 09eafb786a..8cc5cb7dd2 100644 --- a/cmake/FindLibIntl.cmake +++ b/cmake/FindLibIntl.cmake @@ -41,6 +41,16 @@ endif() if (MSVC) list(APPEND CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY}) endif() + +# On macOS, if libintl is a static library then we also need +# to link libiconv and CoreFoundation. +get_filename_component(LibIntl_EXT "${LibIntl_LIBRARY}" EXT) +if (APPLE AND (LibIntl_EXT STREQUAL ".a")) + set(LibIntl_STATIC TRUE) + find_library(CoreFoundation_FRAMEWORK CoreFoundation) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${ICONV_LIBRARY}" "${CoreFoundation_FRAMEWORK}") +endif() + check_c_source_compiles(" #include @@ -54,6 +64,9 @@ int main(int argc, char** argv) { if (MSVC) list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY}) endif() +if (LibIntl_STATIC) + list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${ICONV_LIBRARY}" "${CoreFoundation_FRAMEWORK}") +endif() if (LibIntl_INCLUDE_DIR) list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${LibIntl_INCLUDE_DIR}") endif() -- cgit From 674787feaeced1fe51f6d344e28ca522808c1292 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 29 Jun 2022 01:03:42 +0800 Subject: ci(release): link `gettext` include directory Our previous mangling of gettext broke the `HAVE_WORKING_LIBINTL` test because it prevented CMake from finding `libintl.h`. Let's fix that by linking Gettext's `include` directory into `/usr/local` too. --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d2c4a5d702..b58488ef93 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,6 +102,7 @@ jobs: brew uninstall $(brew uses --installed --recursive gettext) brew unlink gettext ln -sf "$(brew --prefix)/opt/$(readlink "${GETTEXT_PREFIX}")/bin"/* /usr/local/bin/ + ln -sf "$(brew --prefix)/opt/$(readlink "${GETTEXT_PREFIX}")/include"/* /usr/local/include/ rm -f "$GETTEXT_PREFIX" - name: Build release run: | -- cgit