aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo Cabrera <30379873+carlocab@users.noreply.github.com>2022-06-28 23:09:20 +0800
committerCarlo Cabrera <30379873+carlocab@users.noreply.github.com>2022-06-29 02:19:42 +0800
commitbe40ba68a808b61117fb11f7f035b7f205a86dac (patch)
treed6be81a454e92d5470d0a9465c968cca423b4b17
parente0f605bfd8b40b45a7efc88ffa0ee6b4a8a3307a (diff)
downloadrneovim-be40ba68a808b61117fb11f7f035b7f205a86dac.tar.gz
rneovim-be40ba68a808b61117fb11f7f035b7f205a86dac.tar.bz2
rneovim-be40ba68a808b61117fb11f7f035b7f205a86dac.zip
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
-rw-r--r--cmake/FindLibIntl.cmake13
1 files changed, 13 insertions, 0 deletions
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 <libintl.h>
@@ -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()