Browse Source

CMake: Move translation file processing to main pcsx2 directory

Reduces workarounds for cmake dumbness
patch-1
TellowKrinkle 7 months ago committed by tellowkrinkle
parent
commit
90e3d9e460
  1. 7
      CMakeLists.txt
  2. 13
      cmake/Translation.cmake
  3. 18
      locales/CMakeLists.txt
  4. 16
      pcsx2/CMakeLists.txt

7
CMakeLists.txt

@ -44,13 +44,6 @@ if (QT_BUILD) @@ -44,13 +44,6 @@ if (QT_BUILD)
add_subdirectory(pcsx2-qt)
endif()
if(NOT NO_TRANSLATION AND NOT PCSX2_CORE)
# make the translation
if(EXISTS "${CMAKE_SOURCE_DIR}/locales")
add_subdirectory(locales)
endif()
endif()
# tests
if(ACTUALLY_ENABLE_TESTS)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

13
cmake/Translation.cmake

@ -88,11 +88,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg) @@ -88,11 +88,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg)
ENDIF (CMAKE_BUILD_PO)
IF(APPLE)
set_source_files_properties(${_moFile} TARGET_DIRECTORY PCSX2 PROPERTIES
MACOSX_PACKAGE_LOCATION Resources/locale/${_lang}
GENERATED 1
)
target_sources(PCSX2 PRIVATE ${_moFile})
set_source_files_properties(${_moFile} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/locale/${_lang})
source_group(Resources/locale/${__lang} FILES ${_moFile})
ELSEIF(PACKAGE_MODE)
INSTALL(FILES ${_moFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/PCSX2/resources/locale/${_lang})
@ -104,12 +101,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg) @@ -104,12 +101,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg)
ENDFOREACH (_currentPoFile)
if(APPLE)
# CMake doesn't properly add dependencies because PCSX2 is not in the same directory as locales
add_custom_target(translations_${_potBasename} DEPENDS ${_moFiles})
add_dependencies(PCSX2 translations_${_potBasename})
ELSEIF(NOT LINUX_PACKAGE)
IF(NOT LINUX_PACKAGE AND NOT APPLE)
ADD_CUSTOM_TARGET(translations_${_potBasename} ${_addToAll} DEPENDS ${_moFiles})
ENDIF()
ENDIF(NOT LINUX_PACKAGE AND NOT APPLE)
ENDMACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2)

18
locales/CMakeLists.txt

@ -1,18 +0,0 @@ @@ -1,18 +0,0 @@
# Check that people use the good file
if(NOT TOP_CMAKE_WAS_SOURCED)
message(FATAL_ERROR "
You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir.
It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt")
endif(NOT TOP_CMAKE_WAS_SOURCED)
if (GETTEXT_FOUND)
include(Translation)
file (GLOB_RECURSE PO_ICO_FILES ${CMAKE_SOURCE_DIR}}/locales pcsx2_Iconized.po)
file (GLOB_RECURSE PO_MAIN_FILES ${CMAKE_SOURCE_DIR}/locales pcsx2_Main.po)
# Macro to compile po file and install them
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${CMAKE_SOURCE_DIR}/locales/templates/pcsx2_Iconized.pot ALL ${PO_ICO_FILES})
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${CMAKE_SOURCE_DIR}/locales/templates/pcsx2_Main.pot ALL ${PO_MAIN_FILES})
endif (GETTEXT_FOUND)

16
pcsx2/CMakeLists.txt

@ -1646,7 +1646,7 @@ foreach(path IN LISTS RESOURCE_FILES) @@ -1646,7 +1646,7 @@ foreach(path IN LISTS RESOURCE_FILES)
if (NOT WIN32 AND "${path}" MATCHES "/dx11/") # Don't include unneccessary stuff
continue()
endif()
if ((GETTEXT_FOUND OR NO_TRANSLATION) AND "${path}" MATCHES "/locale/") # Generate locales with gettext instead of copying them from bin
if ((GETTEXT_FOUND OR NO_TRANSLATION OR PCSX2_CORE) AND "${path}" MATCHES "/locale/") # Generate locales with gettext instead of copying them from bin
continue()
endif()
pcsx2_resource(${path} ${CMAKE_SOURCE_DIR}/bin/resources/)
@ -1658,6 +1658,20 @@ if (NOT APPLE) @@ -1658,6 +1658,20 @@ if (NOT APPLE)
)
endif()
# Translation files
# CMake is dumb and can't properly associate custom command outputs with targets if they're made in different directories
# So this has to be here (and not in a CMakeLists.txt file in locales/)
if(GETTEXT_FOUND AND NOT NO_TRANSLATION AND NOT PCSX2_CORE)
include(Translation)
file(GLOB_RECURSE PO_ICO_FILES ${CMAKE_SOURCE_DIR}/locales/*/pcsx2_Iconized.po)
file(GLOB_RECURSE PO_MAIN_FILES ${CMAKE_SOURCE_DIR}/locales/*/pcsx2_Main.po)
# Macro to compile po file and install them
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${CMAKE_SOURCE_DIR}/locales/templates/pcsx2_Iconized.pot ALL ${PO_ICO_FILES})
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${CMAKE_SOURCE_DIR}/locales/templates/pcsx2_Main.pot ALL ${PO_MAIN_FILES})
endif()
if (APPLE)
# MacOS defaults to having a maximum protection of the __DATA segment of rw (non-executable)
# We have a bunch of page-sized arrays in bss that we use for jit

Loading…
Cancel
Save