CMake: Move translation file processing to main pcsx2 directory

Reduces workarounds for cmake dumbness
This commit is contained in:
TellowKrinkle 2021-12-12 16:35:53 -06:00 committed by tellowkrinkle
parent baf9e4a9af
commit 90e3d9e460
4 changed files with 18 additions and 36 deletions

View File

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

View File

@ -88,11 +88,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg)
ENDIF (CMAKE_BUILD_PO) ENDIF (CMAKE_BUILD_PO)
IF(APPLE) IF(APPLE)
set_source_files_properties(${_moFile} TARGET_DIRECTORY PCSX2 PROPERTIES
MACOSX_PACKAGE_LOCATION Resources/locale/${_lang}
GENERATED 1
)
target_sources(PCSX2 PRIVATE ${_moFile}) target_sources(PCSX2 PRIVATE ${_moFile})
set_source_files_properties(${_moFile} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/locale/${_lang})
source_group(Resources/locale/${__lang} FILES ${_moFile}) source_group(Resources/locale/${__lang} FILES ${_moFile})
ELSEIF(PACKAGE_MODE) ELSEIF(PACKAGE_MODE)
INSTALL(FILES ${_moFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/PCSX2/resources/locale/${_lang}) INSTALL(FILES ${_moFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/PCSX2/resources/locale/${_lang})
@ -104,12 +101,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg)
ENDFOREACH (_currentPoFile) ENDFOREACH (_currentPoFile)
if(APPLE) IF(NOT LINUX_PACKAGE AND NOT 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)
ADD_CUSTOM_TARGET(translations_${_potBasename} ${_addToAll} DEPENDS ${_moFiles}) ADD_CUSTOM_TARGET(translations_${_potBasename} ${_addToAll} DEPENDS ${_moFiles})
ENDIF() ENDIF(NOT LINUX_PACKAGE AND NOT APPLE)
ENDMACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2) ENDMACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2)

View File

@ -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)

View File

@ -1646,7 +1646,7 @@ foreach(path IN LISTS RESOURCE_FILES)
if (NOT WIN32 AND "${path}" MATCHES "/dx11/") # Don't include unneccessary stuff if (NOT WIN32 AND "${path}" MATCHES "/dx11/") # Don't include unneccessary stuff
continue() continue()
endif() 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() continue()
endif() endif()
pcsx2_resource(${path} ${CMAKE_SOURCE_DIR}/bin/resources/) pcsx2_resource(${path} ${CMAKE_SOURCE_DIR}/bin/resources/)
@ -1658,6 +1658,20 @@ if (NOT APPLE)
) )
endif() 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) if (APPLE)
# MacOS defaults to having a maximum protection of the __DATA segment of rw (non-executable) # 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 # We have a bunch of page-sized arrays in bss that we use for jit