[Build] Remove ENABLE_NLS, fix TRANSLATIONS_ONLY

* Remove the ENABLE_NLS option, it is now always enabled.
* Fix the TRANSLATIONS_ONLY build to properly build the zip file.
This commit is contained in:
Fabrice de Gans 2024-03-26 17:00:53 -07:00 committed by Fabrice de Gans
parent c3f0aa2edf
commit 98b51910eb
7 changed files with 141 additions and 146 deletions

View File

@ -292,20 +292,20 @@ if(NOT ENABLE_ASM_CORE)
endif() endif()
# Enable internationalization # Enable internationalization
if(ENABLE_NLS) set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale) add_compile_definitions(LOCALEDIR="${LOCALEDIR}")
add_compile_definitions(ENABLE_NLS)
add_compile_definitions(LOCALEDIR="${LOCALEDIR}") # for now, only GBALink.cpp uses gettext() directly
# for now, only GBALink.cpp uses gettext() directly if(APPLE)
if(APPLE)
# use Homebrew gettext if available # use Homebrew gettext if available
if(EXISTS "/usr/local/opt/gettext") if(EXISTS "/usr/local/opt/gettext")
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};/usr/local/opt/gettext/include") set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};/usr/local/opt/gettext/include")
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/local/opt/gettext/lib") set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/local/opt/gettext/lib")
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/opt/gettext/bin") set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/opt/gettext/bin")
endif() endif()
endif() endif()
if(ENABLE_LINK OR ENABLE_WX)
if(ENABLE_LINK OR ENABLE_WX)
find_path(LIBINTL_INC libintl.h) find_path(LIBINTL_INC libintl.h)
find_library(LIBINTL_LIB NAMES libintl intl) find_library(LIBINTL_LIB NAMES libintl intl)
find_library(LIBICONV_LIB NAMES libiconv iconv) find_library(LIBICONV_LIB NAMES libiconv iconv)
@ -327,7 +327,6 @@ if(ENABLE_NLS)
if(NOT (LIBINTL_INC OR GETTEXT_FN)) if(NOT (LIBINTL_INC OR GETTEXT_FN))
message(FATAL_ERROR "NLS requires libintl/gettext") message(FATAL_ERROR "NLS requires libintl/gettext")
endif() endif()
endif()
endif() endif()
if(NOT TRANSLATIONS_ONLY) if(NOT TRANSLATIONS_ONLY)
@ -336,9 +335,9 @@ if(NOT TRANSLATIONS_ONLY)
add_subdirectory(src/core) add_subdirectory(src/core)
add_subdirectory(src/components) add_subdirectory(src/components)
add_subdirectory(src/sdl) add_subdirectory(src/sdl)
add_subdirectory(src/wx)
endif() endif()
add_subdirectory(src/wx)
add_subdirectory(po/wxvbam) add_subdirectory(po/wxvbam)
set(CPACK_GENERATOR "ZIP") set(CPACK_GENERATOR "ZIP")

View File

@ -148,7 +148,7 @@ And the following development libraries:
- [zlib](https://zlib.net/) (required) - [zlib](https://zlib.net/) (required)
- [mesa](https://mesa3d.org/) (if using X11 or any OpenGL otherwise) - [mesa](https://mesa3d.org/) (if using X11 or any OpenGL otherwise)
- [ffmpeg](https://ffmpeg.org/) (optional, at least version `4.0.4`, for game recording) - [ffmpeg](https://ffmpeg.org/) (optional, at least version `4.0.4`, for game recording)
- [gettext](https://www.gnu.org/software/gettext/) and gettext-tools (optional, with ENABLE_NLS) - [gettext](https://www.gnu.org/software/gettext/) and gettext-tools
- [SDL2](https://www.libsdl.org/) (required) - [SDL2](https://www.libsdl.org/) (required)
- [SFML](https://www.sfml-dev.org/) (optional, for link) - [SFML](https://www.sfml-dev.org/) (optional, for link)
- [OpenAL](https://www.openal.org/) or [openal-soft](https://kcat.strangesoft.net/openal.html) (required, a sound interface) - [OpenAL](https://www.openal.org/) or [openal-soft](https://kcat.strangesoft.net/openal.html) (required, a sound interface)
@ -205,7 +205,6 @@ Here is the complete list:
| ENABLE_SDL | Build the SDL port | OFF | | ENABLE_SDL | Build the SDL port | OFF |
| ENABLE_WX | Build the wxWidgets port | ON | | ENABLE_WX | Build the wxWidgets port | ON |
| ENABLE_DEBUGGER | Enable the debugger | ON | | ENABLE_DEBUGGER | Enable the debugger | ON |
| ENABLE_NLS | Enable translations | ON |
| ENABLE_ASM_CORE | Enable x86 ASM CPU cores (**BUGGY AND DANGEROUS**) | OFF | | ENABLE_ASM_CORE | Enable x86 ASM CPU cores (**BUGGY AND DANGEROUS**) | OFF |
| ENABLE_ASM | Enable the following two ASM options | ON for 32 bit builds | | ENABLE_ASM | Enable the following two ASM options | ON for 32 bit builds |
| ENABLE_ASM_SCALERS | Enable x86 ASM graphic filters | ON for 32 bit builds | | ENABLE_ASM_SCALERS | Enable x86 ASM graphic filters | ON for 32 bit builds |

View File

@ -1,8 +1,15 @@
option(BUILD_TESTING "Build testing" ON) option(BUILD_TESTING "Build testing" ON)
option(BUILD_SHARED_LIBS "Build dynamic libraries" OFF) option(BUILD_SHARED_LIBS "Build dynamic libraries" OFF)
option(ENABLE_SDL "Build the SDL port" ON) option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
option(ENABLE_WX "Build the wxWidgets port" ON) if(TRANSLATIONS_ONLY)
set(BUILD_DEFAULT OFF)
else()
set(BUILD_DEFAULT ON)
endif()
option(ENABLE_SDL "Build the SDL port" ${BUILD_DEFAULT})
option(ENABLE_WX "Build the wxWidgets port" ${BUILD_DEFAULT})
option(ENABLE_DEBUGGER "Enable the debugger" ON) option(ENABLE_DEBUGGER "Enable the debugger" ON)
option(ENABLE_ASAN "Enable -fsanitize=address by default. Requires debug build with GCC/Clang" OFF) option(ENABLE_ASAN "Enable -fsanitize=address by default. Requires debug build with GCC/Clang" OFF)
@ -114,12 +121,8 @@ if(APPLE AND NOT DISABLE_MACOS_PACKAGE_MANAGERS)
include(MacPackageManagers) include(MacPackageManagers)
endif() endif()
option(ENABLE_NLS "Enable translations" ON)
option(UPSTREAM_RELEASE "do some optimizations and release automation tasks" OFF) option(UPSTREAM_RELEASE "do some optimizations and release automation tasks" OFF)
option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
if(WIN32) if(WIN32)
# not yet implemented # not yet implemented
option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF) option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF)

View File

@ -1,4 +1,4 @@
if(NOT ENABLE_WX OR NOT ENABLE_NLS) if(NOT TRANSLATIONS_ONLY AND NOT ENABLE_WX)
return() return()
endif() endif()

View File

@ -121,17 +121,18 @@ if(ENABLE_LINK)
) )
target_include_directories(vbam-core target_include_directories(vbam-core
PRIVATE ${SFML_INCLUDE_DIR}) PRIVATE ${SFML_INCLUDE_DIR}
)
target_link_libraries(vbam-core target_link_libraries(vbam-core
PRIVATE ${SFML_LIBRARIES}) PRIVATE ${SFML_LIBRARIES}
)
if(ENABLE_NLS)
# Add libintl.h # Add libintl.h
target_include_directories(vbam-core target_include_directories(vbam-core
PRIVATE ${LIBINTL_INC}) PRIVATE ${LIBINTL_INC}
)
target_link_libraries(vbam-core target_link_libraries(vbam-core
PRIVATE ${NLS_LIBS}) PRIVATE ${NLS_LIBS}
endif() )
endif() endif()

View File

@ -28,12 +28,8 @@
#include <SFML/Network.hpp> #include <SFML/Network.hpp>
#ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(x) gettext(x) #define _(x) gettext(x)
#else
#define _(x) x
#endif
#include "core/base/message.h" #include "core/base/message.h"
#include "core/base/port.h" #include "core/base/port.h"

View File

@ -1,3 +1,7 @@
if(NOT TRANSLATIONS_ONLY AND NOT ENABLE_WX)
return()
endif()
# Do not use this file directly. Always use the top level CMakeLists.txt file # Do not use this file directly. Always use the top level CMakeLists.txt file
include(VbamFunctions) include(VbamFunctions)
@ -114,22 +118,57 @@ if(NOT ZIP_PROGRAM)
endif() endif()
endif() endif()
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()
# Add nuget package source.
execute_process(
COMMAND nuget sources add -Name "NuGet official package source" -Source "https://api.nuget.org/v3/index.json"
OUTPUT_QUIET
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# Install the Gettext.Tools package.
execute_process(
COMMAND nuget.exe install Gettext.Tools -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
OUTPUT_QUIET
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/Gettext.Tools*)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools/bin)
endif()
find_package(Gettext REQUIRED)
find_program(XGETTEXT xgettext)
find_program(MSGINIT msginit)
if(NOT XGETTEXT OR NOT MSGINIT)
message(SEND_ERROR "Cannot find gettext xgettext:'${XGETTEXT}' msginit:'${MSGINIT}'")
endif()
# Make the translations.zip # Make the translations.zip
if(ENABLE_NLS OR TRANSLATIONS_ONLY) add_custom_command(
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/translations.zip OUTPUT ${CMAKE_BINARY_DIR}/translations.zip
COMMAND ${CMAKE_COMMAND} -D "ZIP_PROGRAM=${ZIP_PROGRAM}" -P ${CMAKE_CURRENT_SOURCE_DIR}/make-translations-zip.cmake COMMAND ${CMAKE_COMMAND} -D "ZIP_PROGRAM=${ZIP_PROGRAM}" -P ${CMAKE_CURRENT_SOURCE_DIR}/make-translations-zip.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS translations make-translations-zip.cmake DEPENDS translations make-translations-zip.cmake
) )
add_custom_target(
add_custom_target(
translations-zip translations-zip
ALL
SOURCES ${CMAKE_BINARY_DIR}/translations.zip SOURCES ${CMAKE_BINARY_DIR}/translations.zip
) )
endif()
if(TRANSLATIONS_ONLY OR NOT ENABLE_WX) if(TRANSLATIONS_ONLY)
# Nothing more to do if we are only building the translations.zip file.
return() return()
endif() endif()
@ -158,9 +197,7 @@ target_link_libraries(
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
) )
if(ENABLE_NLS) add_dependencies(visualboyadvance-m translations-zip)
add_dependencies(visualboyadvance-m translations-zip)
endif()
# on unix we have to check for X11 before we overwrite all the compile/link # on unix we have to check for X11 before we overwrite all the compile/link
# flags with the wx tests # flags with the wx tests
@ -381,44 +418,6 @@ if(ENABLE_FFMPEG)
endif() endif()
endif() endif()
if(ENABLE_NLS)
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()
# Add nuget package source.
execute_process(
COMMAND nuget sources add -Name "NuGet official package source" -Source "https://api.nuget.org/v3/index.json"
OUTPUT_QUIET
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# Install the Gettext.Tools package.
execute_process(
COMMAND nuget.exe install Gettext.Tools -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
OUTPUT_QUIET
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/Gettext.Tools*)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools/bin)
endif()
find_package(Gettext REQUIRED)
find_program(XGETTEXT xgettext)
find_program(MSGINIT msginit)
if(NOT XGETTEXT OR NOT MSGINIT)
message(SEND_ERROR "Cannot find gettext xgettext:'${XGETTEXT}' msginit:'${MSGINIT}'")
endif()
endif()
# wxrc does not support xrs files in -c output (> 10x compression) # wxrc does not support xrs files in -c output (> 10x compression)
# we do it using the bin2c.c utility. # we do it using the bin2c.c utility.
set(BIN2C ${CMAKE_BINARY_DIR}/bin2c) set(BIN2C ${CMAKE_BINARY_DIR}/bin2c)
@ -661,8 +660,7 @@ endif()
# Update the gettext pot source. # Update the gettext pot source.
# Do this automatically instead of manually to make sure we don't forget to update. # Do this automatically instead of manually to make sure we don't forget to update.
if(ENABLE_NLS) add_custom_target(
add_custom_target(
vbam-wx-xrc-strings vbam-wx-xrc-strings
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-E env -E env
@ -676,9 +674,9 @@ if(ENABLE_NLS)
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS DEPENDS
${VBAM_XRC_FILES} ${VBAM_XRC_FILES}
) )
add_custom_target( add_custom_target(
vbam-wx-pot vbam-wx-pot
COMMAND ${XGETTEXT} COMMAND ${XGETTEXT}
-k_ -kN_ -k_ -kN_
@ -689,17 +687,16 @@ if(ENABLE_NLS)
DEPENDS DEPENDS
${VBAM_LOCALIZABLE_FILES} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h ${VBAM_LOCALIZABLE_FILES} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
) )
add_custom_command( add_custom_command(
TARGET vbam-wx-pot TARGET vbam-wx-pot
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-DSRC_DIR=${CMAKE_SOURCE_DIR}/po/wxvbam -DSRC_DIR=${CMAKE_SOURCE_DIR}/po/wxvbam
-DBIN_DIR=${CMAKE_BINARY_DIR} -DBIN_DIR=${CMAKE_BINARY_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-pot-updated.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/check-pot-updated.cmake
) )
endif()
find_program(GPG_PROGRAM gpg) find_program(GPG_PROGRAM gpg)
if(GPG_PROGRAM) if(GPG_PROGRAM)