cmake: Fix localization for Visual Studio.
Default to ENABLE_NLS=ON for vcpkg builds too. Check for libintl under both the names "intl" and "libintl", likewise for libiconv. The vcpkg versions have the "lib" prefix. Use the Gettext.Tools package from NuGet for the tools to build the translation files. vcpkg does not yet have gettext-tools. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
3aefcf64c9
commit
b3932e4e3d
|
@ -380,11 +380,7 @@ if(NOT ENABLE_ASM_CORE)
|
|||
add_definitions(-DC_CORE)
|
||||
endif()
|
||||
|
||||
set(NLS_DEFAULT OFF)
|
||||
|
||||
if(NOT CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
|
||||
set(NLS_DEFAULT ON)
|
||||
endif()
|
||||
set(NLS_DEFAULT ON)
|
||||
|
||||
option(ENABLE_NLS "Enable translations" ${NLS_DEFAULT})
|
||||
|
||||
|
@ -402,17 +398,17 @@ if(ENABLE_NLS)
|
|||
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/opt/gettext/bin")
|
||||
endif()
|
||||
endif()
|
||||
if(ENABLE_LINK)
|
||||
if(ENABLE_LINK OR ENABLE_WX)
|
||||
find_path(LIBINTL_INC libintl.h)
|
||||
find_library(LIBINTL_LIB intl)
|
||||
find_library(LIBICONV_LIB iconv)
|
||||
find_library(LIBINTL_LIB NAMES intl libintl)
|
||||
find_library(LIBICONV_LIB NAMES iconv libiconv)
|
||||
if(LIBINTL_LIB)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIBINTL_LIB})
|
||||
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${LIBINTL_LIB})
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIB})
|
||||
list(APPEND VBAMCORE_LIBS ${LIBINTL_LIB})
|
||||
endif()
|
||||
if(LIBICONV_LIB)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIBICONV_LIB})
|
||||
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${LIBICONV_LIB})
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBICONV_LIB})
|
||||
list(APPEND VBAMCORE_LIBS ${LIBICONV_LIB})
|
||||
endif()
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(gettext GETTEXT_FN)
|
||||
|
|
|
@ -528,6 +528,28 @@ endif() # wxWidgets checks
|
|||
|
||||
if(CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
|
||||
find_package(unofficial-gettext REQUIRED)
|
||||
|
||||
if(MSVC)
|
||||
# install gettext tools from nuget
|
||||
|
||||
# first fetch the nuget binary
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
|
||||
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
|
||||
endif()
|
||||
|
||||
# install the Gettext.Tools package
|
||||
execute_process(
|
||||
COMMAND nuget.exe install Gettext.Tools -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
# find the path to the binaries in the package and add them to find path
|
||||
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/*)
|
||||
|
||||
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools/bin)
|
||||
|
||||
find_package(Gettext REQUIRED)
|
||||
endif()
|
||||
else()
|
||||
find_package(Gettext REQUIRED)
|
||||
|
||||
|
|
Loading…
Reference in New Issue