mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
Improve libintl detection and linking.
This makes it so that a self-installed libintl is now detected and used. It also attempts to locate a homebrew version of the library, if that exists.
This commit is contained in:
parent
e728ce95ef
commit
95db76e280
@ -7,14 +7,31 @@ check_type_size("time_t" SIZEOF_TIME_T)
|
|||||||
check_type_size("off_t" SIZEOF_OFF_T)
|
check_type_size("off_t" SIZEOF_OFF_T)
|
||||||
|
|
||||||
if (CMAKE_HOST_APPLE)
|
if (CMAKE_HOST_APPLE)
|
||||||
execute_process(COMMAND brew --prefix gettext
|
find_program(HAVE_HOMEBREW brew)
|
||||||
OUTPUT_VARIABLE _TMP_HOMEBREW_GETTEXT_PREFIX
|
if (HAVE_HOMEBREW)
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND brew --prefix gettext
|
||||||
set(HOMEBREW_GETTEXT_PREFIX ${_TMP_HOMEBREW_GETTEXT_PREFIX}
|
OUTPUT_VARIABLE _TMP_HOMEBREW_GETTEXT_PREFIX
|
||||||
CACHE PATH "homebrew gettext directory (${_TMP_HOMEBREW_GETTEXT_PREFIX})")
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
set(CMAKE_REQUIRED_LIBRARIES intl)
|
set(HOMEBREW_GETTEXT_PREFIX ${_TMP_HOMEBREW_GETTEXT_PREFIX}
|
||||||
set(CMAKE_REQUIRED_INCLUDES "${HOMEBREW_GETTEXT_PREFIX}/include")
|
CACHE
|
||||||
set(CMAKE_REQUIRED_FLAGS "-L${HOMEBREW_GETTEXT_PREFIX}/lib")
|
PATH "homebrew gettext directory (${_TMP_HOMEBREW_GETTEXT_PREFIX})")
|
||||||
|
list(APPEND CMAKE_PREFIX_PATH "${HOMEBREW_GETTEXT_PREFIX}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_path(LIBINTL_INCLUDE_DIR libintl.h)
|
||||||
|
find_library(LIBINTL_LIB intl)
|
||||||
|
get_filename_component(LIBINTL_LIB_DIR "${LIBINTL_LIB}" NAME)
|
||||||
|
|
||||||
|
if (LIBINTL_INCLUDE_DIR)
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES "${LIBINTL_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# This is required because some operating systems don't have a separate
|
||||||
|
# libintl--it is built into glibc. So we only need to specify the library if
|
||||||
|
# one was actually found.
|
||||||
|
if (LIBINTL_LIB)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES "${LIBINTL_LIB}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
@ -25,7 +42,7 @@ int main(int argc, char** argv) {
|
|||||||
bindtextdomain(\"foo\", \"bar\");
|
bindtextdomain(\"foo\", \"bar\");
|
||||||
bind_textdomain_codeset(\"foo\", \"bar\");
|
bind_textdomain_codeset(\"foo\", \"bar\");
|
||||||
textdomain(\"foo\");
|
textdomain(\"foo\");
|
||||||
}" HAVE_WORKING_LIBINTL)
|
}" HAVE_LIBINTL)
|
||||||
|
|
||||||
# generate configuration header and update include directories
|
# generate configuration header and update include directories
|
||||||
configure_file (
|
configure_file (
|
||||||
|
@ -40,15 +40,8 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_HOST_APPLE AND HAVE_WORKING_LIBINTL)
|
if (HAVE_LIBINTL AND LIBINTL_LIB)
|
||||||
check_library_exists(intl gettext "${HOMEBREW_GETTEXT_PREFIX}/lib" HAVE_LIBINTL)
|
target_link_libraries(vim ${LIBINTL_LIB})
|
||||||
if (HAVE_LIBINTL)
|
|
||||||
include_directories("${HOMEBREW_GETTEXT_PREFIX}/include")
|
|
||||||
find_library(INTL_LIBRARY NAMES intl PATHS "${HOMEBREW_GETTEXT_PREFIX}/lib")
|
|
||||||
target_link_libraries(vim ${INTL_LIBRARY})
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "can't find something resembling -lintl")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories ("${PROJECT_SOURCE_DIR}/src/proto")
|
include_directories ("${PROJECT_SOURCE_DIR}/src/proto")
|
||||||
|
Loading…
Reference in New Issue
Block a user