cmake: (WIP) rule to compile translation file on linux.

Note: to install them, you must call "make install" with root access. Files will be install into /usr/local/share/locales...


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4238 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut@gmail.com 2011-01-20 20:45:07 +00:00
parent 6d4fd157b8
commit 2382c35b83
4 changed files with 99 additions and 0 deletions

View File

@ -42,6 +42,11 @@ include_directories(${PROJECT_SOURCE_DIR}/common/include
${PROJECT_SOURCE_DIR}/common/include/Utilities
${PROJECT_SOURCE_DIR}/common/include/x86emitter)
# make the translation
if(EXISTS "${PROJECT_SOURCE_DIR}/locales")
add_subdirectory(locales)
endif(EXISTS "${PROJECT_SOURCE_DIR}/locales")
# make 3rdParty
if(EXISTS "${PROJECT_SOURCE_DIR}/3rdparty")
add_subdirectory(3rdparty)

View File

@ -28,6 +28,7 @@ endif(Linux)
## Use cmake package to find module
find_package(ALSA)
find_package(BZip2)
find_package(Gettext) # translation tool
find_package(JPEG)
find_package(OpenGL)
# Tell cmake that we use SDL as a library and not as an application

71
cmake/Translation.cmake Normal file
View File

@ -0,0 +1,71 @@
# Macro to compile po file
# It based on FindGettext.cmake files.
# The macro was adapted for PCSX2 need. Several pot file, language based on directory instead of file
# Copyright (c) 2007-2009 Kitware, Inc., Insight Consortium
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg)
# make it a real variable, so we can modify it here
SET(_firstPoFile "${_firstPoFileArg}")
SET(_gmoFiles)
GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
SET(_addToAll)
IF(${_firstPoFile} STREQUAL "ALL")
SET(_addToAll "ALL")
SET(_firstPoFile)
ENDIF(${_firstPoFile} STREQUAL "ALL")
FOREACH (_currentPoFile ${_firstPoFile} ${ARGN})
GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE)
GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH)
GET_FILENAME_COMPONENT(_gmoBase ${_absFile} NAME_WE)
GET_FILENAME_COMPONENT(_lang ${_abs_PATH} NAME_WE)
SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}/${_gmoBase}.gmo)
ADD_CUSTOM_COMMAND( OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
DEPENDS ${_absPotFile} ${_absFile} )
INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
ENDFOREACH (_currentPoFile )
IF(NOT LINUX_PACKAGE)
ADD_CUSTOM_TARGET(translations_${_potBasename} ${_addToAll} DEPENDS ${_gmoFiles})
ENDIF(NOT LINUX_PACKAGE)
ENDMACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 )

22
locales/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
# 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_DEV_FILES ${PROJECT_SOURCE_DIR}}/locales pcsx2_Devel.po)
file (GLOB_RECURSE PO_ICO_FILES ${PROJECT_SOURCE_DIR}}/locales pcsx2_Iconized.po)
file (GLOB_RECURSE PO_MAIN_FILES ${PROJECT_SOURCE_DIR}/locales pcsx2_Main.po)
file (GLOB_RECURSE PO_TER_FILES ${PROJECT_SOURCE_DIR}}/locales pcsx2_Tertiary.po)
# Macro to compile po file and install them
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${PROJECT_SOURCE_DIR}/locales/templates/pcsx2_Devel.pot ALL ${PO_DEV_FILES})
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${PROJECT_SOURCE_DIR}/locales/templates/pcsx2_Iconized.pot ALL ${PO_ICO_FILES})
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${PROJECT_SOURCE_DIR}/locales/templates/pcsx2_Main.pot ALL ${PO_MAIN_FILES})
GETTEXT_CREATE_TRANSLATIONS_PCSX2(${PROJECT_SOURCE_DIR}/locales/templates/pcsx2_Tertiary.pot ALL ${PO_TER_FILES})
endif (GETTEXT_FOUND)