2020-03-14 16:11:35 -07:00
set ( languages de en fr nb nn pl pt_BR sv zh_CN )
2017-11-16 21:33:35 +08:00
2020-03-14 16:11:35 -07:00
include ( FeatureSummary )
2017-11-16 21:33:35 +08:00
2020-03-14 16:11:35 -07:00
option ( WITH_GETTEXT "translate messages if gettext is available" ON )
if ( WITH_GETTEXT )
2020-06-06 18:56:37 -07:00
find_package ( Intl QUIET )
2020-03-14 16:11:35 -07:00
find_package ( Gettext )
if ( GETTEXT_FOUND )
set ( HAVE_GETTEXT 1 )
include_directories ( ${ Intl_INCLUDE_DIR } )
endif ( )
endif ( )
add_feature_info ( gettext GETTEXT_FOUND "translate messages with gettext" )
2017-11-16 21:33:35 +08:00
# Define translations
2020-03-14 16:11:35 -07:00
if ( GETTEXT_FOUND )
foreach ( lang ${ languages } )
2018-01-22 14:30:36 +08:00
# Our translations aren't set up entirely as CMake expects, so installation is done in
# cmake/Install.cmake instead of using INSTALL_DESTINATION
2020-03-14 16:11:35 -07:00
gettext_process_po_files ( ${ lang } ALL
2017-11-16 21:33:35 +08:00
P O _ F I L E S p o / $ { l a n g } . p o )
2020-03-14 16:11:35 -07:00
endforeach ( )
endif ( )
2017-11-16 22:13:45 +08:00
2020-03-14 16:11:35 -07:00
cmake_push_check_state ( )
set ( CMAKE_REQUIRED_INCLUDES ${ CMAKE_REQUIRED_INCLUDES } ${ Intl_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ CMAKE_REQUIRED_LIBRARIES } ${ Intl_LIBRARIES } )
2017-11-16 22:13:45 +08:00
# libintl.h can be compiled into the stdlib on some GLibC systems
2020-03-14 16:11:35 -07:00
if ( Intl_FOUND AND Intl_LIBRARIES )
set ( LIBINTL_INCLUDE "#include <libintl.h>" )
endif ( )
check_cxx_source_compiles ( "
2017-11-16 22:13:45 +08:00
$ { L I B I N T L _ I N C L U D E }
#include <stdlib.h>
i n t main ( ) {
e x t e r n i n t _ n l _ m s g _ c a t _ c n t r ;
i n t t m p = _ n l _ m s g _ c a t _ c n t r ;
exit ( tmp ) ;
}
"
H A V E _ _ N L _ M S G _ C A T _ C N T R )
2020-03-14 16:11:35 -07:00
cmake_pop_check_state ( )