Skip to content
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

Better handle libintl dependencies #693

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,37 @@ if(ENABLE_NLS)
find_package(Intl REQUIRED)
include_directories(${Intl_INCLUDE_DIRS})
link_libraries(${Intl_LIBRARIES})

# begin static libintl support
# libintl.a may depend on libiconv.a and libcharset.a
# this is the case of vcpkg + mingw, for example
macro(try_compile_intl)
set(_argv ${ARGV})
try_compile(INTLLIB ${CMAKE_BINARY_DIR}
"${CMAKE_SOURCE_DIR}/checks/intl.cpp"
LINK_LIBRARIES ${_argv}
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${Intl_INCLUDE_DIRS}")
endmacro()

try_compile_intl(${Intl_LIBRARIES})
if (NOT INTLLIB)
message(STATUS "Checking for libiconv and libcharset dependencies of libintl")
find_package(Iconv REQUIRED)
link_libraries(${Iconv_LIBRARIES})

try_compile_intl(${Intl_LIBRARIES} ${Iconv_LIBRARIES})
if (NOT INTLLIB)
find_library(Charset_LIBRARY NAMES libcharset charset HINTS Charset_DIR)
try_compile_intl(${Intl_LIBRARIES} ${Iconv_LIBRARIES} ${Charset_LIBRARY})
if (NOT INTLLIB)
message(FATAL_ERROR "LibIntl has unknown dependencies")
else()
link_libraries(${Charset_LIBRARY})
endif()
endif()
endif()
# end static libintl support

add_definitions(-DENABLE_NLS)
else()
message(STATUS "NLS is disabled. Not looking for gettext and libintl.")
Expand Down
7 changes: 7 additions & 0 deletions checks/intl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <libintl.h>

int main()
{
gettext("test");
return 0;
}