Better handle libintl dependencies
parent
91c3e618c2
commit
72bf923741
|
@ -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.")
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#include <libintl.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
gettext("test");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue