Kornel's cmake install changes:

New files:
        Directories:
		development/cmake/po
		development/cmake/man
        Files:
		development/cmake/po/CMakeLists.txt
			Creates lyx.pot and *.gmo-files;
			Installs ${_lang} as ${LYX_ABS_INSTALLED_DATADIR}/${LYX_LOCALEDIR}/${_lang}/LC_MESSAGES/lyx.mo
		development/cmake/man/CMakeLists.txt
			Handling of lyx-manuals.
		development/cmake/modules/FindLyXGettext.cmake
			Original: (GNU) FindGettext.cmake
			Changed the installation subdirectory of .gmo-files.
			Previously installing into "/usr/local/share/lyx2.0" led
				   to e.g. /usr/local/share/lyx2.0/share/locale/de/LC_MESSAGES/lyx.mo
				   now     /usr/local/share/lyx2.0/locale/de/LC_MESSAGES/lyx.mo
Changes:
        development/cmake/Install.cmake
                macro lyx_install _parent_src_dir
                        searches now through directories specified as simple regular expression.
                        Until now we had to specify explicitly each directory for each language.
                Mode of the DESTINATION/lyx2lyx is now corect
                Installation of the .gmo files

	development/cmake/config.h.cmake:
		Changed some #cmakedefine to #define, because config_file() did not
        	substitute the desired values in config.h.
        	Some typos corrected (TOP_SRCDIR -> TOP_SRC_DIR)

        development/cmake/configCompiler.h.cmake
                Removed doubly defined ENABLE_NLS, HAVE_LC_MESSAGES
                Installation directory still hardcoded, users need to to set environment
                variable LYX_LOCALEDIR to get the corect translations.

	development/cmake/CMakeLists.txt
		Setting correct values to LYX_ABS_INSTALLED_DATADIR,
        		LYX_ABS_INSTALLED_LOCALEDIR, LYX_ABS_TOP_SRCDIR.
			Now the lyx-executable searches on the installed places for it's data,
        		so no need to set environment anymore.
		New variable: LYX_LOCALEDIR. We need it later in FindLyXGettext.cmake,
		    	because we cannot use the absolute path LYX_ABS_INSTALLED_LOCALEDIR.
			(We need relative path when packaging to different root-directory).
                Use of module FindLyXGettext.cmake: This is a modified version
		       	of (GNU) FindGettext.cmake
                Include the new development/cmake/po directory
		Include the new development/cmake/man directory

        development/cmake/po/CMakeLists.txt
                Creation of lyx.pot and apropriate .gmo files
                Creating lyx.pot file
                        I had to use perl to simulate the unix "cat" command. Maybe Jose can
                        write the corect statement in python





git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27973 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2008-12-28 13:35:29 +00:00
parent a9f29e6f6c
commit 510c918c6c
7 changed files with 214 additions and 41 deletions

View File

@ -31,10 +31,11 @@ set(VERSION_INFO "CMake Build")
set(LYX_DIR_VER "LYX_DIR_20x")
set(LYX_USERDIR_VER "LYX_USERDIR_20x")
set(PROGRAM_SUFFIX "")
set(LYX_ABS_INSTALLED_DATADIR "/usr/local/share/lyx${PACKAGE_VERSION}")
set(LYX_ABS_INSTALLED_LOCALEDIR "/usr/local/share/locale")
set(LYX_ABS_TOP_SRCDIR "${CMAKE_SOURCE_DIR}")
set(PROGRAM_SUFFIX "\"\"")
set(LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}")
set(LYX_LOCALEDIR "locale")
set(LYX_ABS_INSTALLED_LOCALEDIR "${LYX_ABS_INSTALLED_DATADIR}/${LYX_LOCALEDIR}")
set(LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}")
if(WIN32)
@ -58,7 +59,6 @@ include(LyXPaths)
include(LyXMacros)
include(ProjectSourceGroup)
if(merge OR merge_rebuild)
set(merge 1 CACHE TYPE STRING FORCE)
set(MERGE_FILES 1 CACHE TYPE STRING FORCE)
@ -133,7 +133,7 @@ find_package(ZLIB REQUIRED)
if(all OR aspell)
set(aspell TRUE CACHE TYPE STRING)
find_package(ASPELL REQUIRED)
find_package(ASPELL REQUIRED)
else()
find_package(ASPELL)
endif()
@ -181,11 +181,6 @@ if(WIN32)
endif()
endif()
set(PROGRAM_SUFFIX "\"\"")
set(LYX_ABS_TOP_SRCDIR "${CMAKE_SOURCE_DIR}")
set(LYX_ABS_INSTALLED_DATADIR "/usr/local/share/lyx${PACKAGE_VERSION}")
set(LYX_ABS_INSTALLED_LOCALEDIR "/usr/local/share/locale")
message("")
message("----- PROGRAM_SUFFIX : ${PROGRAM_SUFFIX}")
message("----- LYX_ABS_TOP_SRCDIR : ${LYX_ABS_TOP_SRCDIR}")
@ -306,6 +301,13 @@ if(MSVC)
endif()
if(nls OR all)
find_package(LyXGettext REQUIRED)
include_directories(${TOP_SRC_DIR}/po)
add_subdirectory(po)
endif()
# compiler tests, config.h generation
if(MSVC AND NOT CONFIGURECHECKS)
configure_file(configCompiler.h.msvc ${CMAKE_BINARY_DIR}/configCompiler.h)
@ -318,16 +320,14 @@ configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
find_package(ICONV REQUIRED)
add_definitions(-DHAVE_ICONV=1)
find_package(Gettext)
#TODO: insource is not the best place
configure_file(${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx_version.py.in
${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx_version.py)
include_directories(
${CMAKE_BINARY_DIR}
${TOP_SRC_DIR}/src
include_directories(
${CMAKE_BINARY_DIR}
${TOP_SRC_DIR}/src
${TOP_SRC_DIR}/boost)
add_subdirectory(boost)
@ -336,5 +336,8 @@ if(NOT use_external_libintl)
endif()
add_subdirectory(src)
include_directories(man)
add_subdirectory(man)
include(../Install)

View File

@ -1,27 +1,30 @@
# TODO: set correct path
#set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
message(STATUS "installing to ${CMAKE_INSTALL_PREFIX}, defined by CMAKE_INSTALL_PREFIX")
# the macro scans the directories "_parent_src_dir/_dir/_current_dir" for *._file_type files
# the macro scans the directories "_parent_src_dir/_dir/_current_dir" for *._file_type files
# and installs the files in CMAKE_INSTALL_PREFIX/_current_dir
# dir_item is on item of the remaining arguments
macro(lyx_install _parent_src_dir _dir _file_type)
foreach(_current_dir ${ARGN})
file(GLOB files_list ${_parent_src_dir}/${_dir}/${_current_dir}/*.${_file_type})
list(REMOVE_ITEM files_list "${_parent_src_dir}/${_dir}/${_current_dir}/.svn")
list(REMOVE_ITEM files_list "${_parent_src_dir}/${_dir}/${_current_dir}/Makefile.in")
list(REMOVE_ITEM files_list "${_parent_src_dir}/${_dir}/${_current_dir}/Makefile.am")
install(FILES ${files_list} DESTINATION ${_dir}/${_current_dir})
#message(STATUS "install ${_dir}/${_current_dir}: ${files_list} ")
#message(STATUS "install at ${CMAKE_INSTALL_PREFIX}/${_dir}/${_current_dir}")
endforeach(_current_dir)
foreach(_glob_dir ${ARGN})
file(GLOB _dir_list ${_parent_src_dir}/${_dir}/${_glob_dir})
foreach(_current_dir ${_dir_list})
file(GLOB files_list ${_current_dir}/*.${_file_type})
list(REMOVE_ITEM files_list "${_current_dir}/.svn")
list(REMOVE_ITEM files_list "${_current_dir}/Makefile.in")
list(REMOVE_ITEM files_list "${_current_dir}/Makefile.am")
GET_FILENAME_COMPONENT(_base_dir ${_current_dir} NAME)
install(FILES ${files_list} DESTINATION ${_dir}/${_base_dir})
#message(STATUS "install ${_dir}/${_base_dir}: ${files_list} ")
#message(STATUS "install at ${CMAKE_INSTALL_PREFIX}/${_dir}/${_base_dir}")
endforeach(_current_dir)
endforeach(_glob_dir)
endmacro(lyx_install)
lyx_install(${TOP_SRC_DIR}/lib bind bind . de fi pt sv)
lyx_install(${TOP_SRC_DIR}/lib bind bind . [a-z][a-z])
lyx_install(${TOP_SRC_DIR}/lib commands def .)
lyx_install(${TOP_SRC_DIR}/lib doc lyx . ca cs da de es eu fr gl he hu it ja nl nb pl pt ro ru sk sl sv uk)
lyx_install(${TOP_SRC_DIR}/lib doc lyx . [a-z][a-z])
lyx_install(${TOP_SRC_DIR}/lib doc * clipart)
lyx_install(${TOP_SRC_DIR}/lib doc/de * clipart)
lyx_install(${TOP_SRC_DIR}/lib doc/es * clipart)
@ -29,7 +32,7 @@ lyx_install(${TOP_SRC_DIR}/lib doc/fr * clipart)
lyx_install(${TOP_SRC_DIR}/lib doc/it * clipart)
lyx_install(${TOP_SRC_DIR}/lib doc/ja * clipart)
lyx_install(${TOP_SRC_DIR}/lib doc/uk * clipart)
lyx_install(${TOP_SRC_DIR}/lib examples * . ca cs da de es eu fr gl he hu it ja nl nb pl pt ro ru sk sl sv uk)
lyx_install(${TOP_SRC_DIR}/lib examples * . [a-z][a-z])
lyx_install(${TOP_SRC_DIR}/lib fonts * .)
lyx_install(${TOP_SRC_DIR}/lib images * . math commands attic)
lyx_install(${TOP_SRC_DIR}/lib kbd * .)
@ -42,12 +45,10 @@ lyx_install(${TOP_SRC_DIR}/lib ui * .)
lyx_install(${TOP_SRC_DIR}/lib . * .)
# TODO also get dot-less filenames in lyx_install
install(FILES ${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx DESTINATION lyx2lyx)
install(FILES ${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx DESTINATION lyx2lyx PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
foreach(_file unicodesymbols encodings languages)
install(FILES ${TOP_SRC_DIR}/lib/${_file} DESTINATION .)
endforeach(_file)
# TODO
# DESTINATION/lyx2lyx
# is mode 644 but it should be 755

View File

@ -30,10 +30,10 @@
#cmakedefine LYX_DIR_VER "${LYX_DIR_VER}"
#cmakedefine LYX_USERDIR_VER "${LYX_USERDIR_VER}"
#cmakedefine PROGRAM_SUFFIX "${PPROGRAM_SUFFIX}"
#cmakedefine LYX_ABS_INSTALLED_DATADIR "${LYX_DIR}"
#cmakedefine LYX_ABS_INSTALLED_LOCALEDIR "${LOCALEDIR}"
#cmakedefine LYX_ABS_TOP_SRCDIR "${TOP_SRCDIR}"
#define PROGRAM_SUFFIX "${PPROGRAM_SUFFIX}"
#define LYX_ABS_INSTALLED_DATADIR "${LYX_ABS_INSTALLED_DATADIR}"
#define LYX_ABS_INSTALLED_LOCALEDIR "${LYX_ABS_INSTALLED_LOCALEDIR}"
#define LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}"
#cmakedefine USE_POSIX_PACKAGING 1
#cmakedefine USE_WINDOWS_PACKAGING 1

View File

@ -99,10 +99,6 @@
#endif
#cmakedefine GETTEXT_FOUND 1
#if GETTEXT_FOUND
#define ENABLE_NLS 1
#define HAVE_LC_MESSAGES 1
#endif
#cmakedefine HAVE_ALLOCA 1
#cmakedefine HAVE_SYMBOL_ALLOCA 1

View File

@ -0,0 +1,29 @@
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# Copyright (c) 2008, Peter Kümmel, <syntheticpp@gmx.net>
# , Kornel Benko, <Kornel.Benko@berlin.de>
#
project(lyx)
SET(_manuals)
macro(add_manual _mansrc)
get_filename_component(_mandest ${_mansrc} NAME_WE)
SET(_created_manual "${CMAKE_CURRENT_BINARY_DIR}/${_mandest}.1")
configure_file("${TOP_SRC_DIR}/${_mansrc}" ${_created_manual} @ONLY)
SET_SOURCE_FILES_PROPERTIES(${_created_manual} GENERATED)
LIST(APPEND _manuals ${_created_manual})
endmacro(add_manual)
set(real_pkgdatadir ${LYX_ABS_INSTALLED_DATADIR})
foreach(_mn lyx.1in src/client/lyxclient.man src/tex2lyx/tex2lyx.1)
add_manual(${_mn})
endforeach(_mn)
ADD_CUSTOM_TARGET(man ALL DEPENDS ${_manuals})
install(FILES ${_manuals} DESTINATION man/man1)
# ADD_MANUALS("lyx")

View File

@ -0,0 +1,63 @@
# - Slightly modified Find GNU gettext tools
# This module looks for the GNU gettext tools. This module defines the
# following values:
# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
# GETTEXT_FOUND: True if gettext has been found.
#
# Additionally it provides the following macros:
# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
# This will create a target "translations" which will convert the
# given input po files into the binary output mo file. If the
# ALL option is used, the translations will also be created when
# building the default target.
FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFile)
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 ${ARGN})
GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE)
GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH)
GET_FILENAME_COMPONENT(_lang ${_absFile} NAME_WE)
SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.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 ${LYX_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
ENDFOREACH (_currentPoFile )
ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
SET(GETTEXT_FOUND TRUE)
ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )
SET(GETTEXT_FOUND FALSE)
IF (GetText_REQUIRED)
MESSAGE(FATAL_ERROR "GetText not found")
ENDIF (GetText_REQUIRED)
ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )

View File

@ -0,0 +1,81 @@
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# Copyright (c) 2008, Peter Kümmel, <syntheticpp@gmx.net>
# , Kornel Benko, <Kornel.Benko@berlin.de>
#
project(lyx)
include_directories(${TOP_SRC_DIR}/po)
SET(_py_sources)
macro(add_gettext_python _par _dir)
file(GLOB _sources ${TOP_SRC_DIR}/${_dir}/${ARGN})
SET(_dst "${CMAKE_CURRENT_BINARY_DIR}/${_par}_l10n.pot")
ADD_CUSTOM_COMMAND(
OUTPUT "${_dst}"
PRE_BUILD
COMMAND python
ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par} ${_sources}
DEPENDS ${_sources}
)
SET_SOURCE_FILES_PROPERTIES("${_dst}" GENERATED)
LIST(APPEND _py_sources "${_dst}")
endmacro(add_gettext_python)
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/lyx.cat.pot" GENERATED)
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/lyx.fmt.pot" GENERATED)
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/lyx.pot" GENERATED)
add_gettext_python(encodings lib encodings)
add_gettext_python(external lib external_templates)
add_gettext_python(formats lib configure.py)
add_gettext_python(languages lib languages)
add_gettext_python(layouts lib/layouts *.layouts *.inc *.module)
add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
add_gettext_python(ui lib/ui *.ui *.inc)
FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
FIND_PROGRAM(GETTEXT_MSGUNIQ_EXECUTABLE msguniq)
# TODO:
# We need here perl, because I don't know how
# to write the alternative for "cat" in python
# e.g. perl -e "\"while(<>){print;}\""
# But maybe Jose knows?
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/lyx.cat.pot"
COMMAND perl
ARGS -e "\"while(<>){print;}\"" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/lyx.cat.pot"
DEPENDS ${_py_sources}
)
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/lyx.fmt.pot"
COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/lyx.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/lyx.cat.pot"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/lyx.cat.pot"
)
file(STRINGS "${TOP_SRC_DIR}/po/POTFILES.in" _tmppotfiles_dep)
SET(_potfiles_dep)
foreach(_f ${_tmppotfiles_dep})
LIST(APPEND _potfiles_dep "${TOP_SRC_DIR}/${_f}")
endforeach(_f)
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/lyx.pot"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lyx.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/lyx.pot"
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
ARGS --default-domain=lyx --directory=${TOP_SRC_DIR} --add-comments=TRANSLATORS: --language=C++ --join-existing --keyword=_ --keyword=N_ --keyword=B_ --keyword=qt_ --files-from="${TOP_SRC_DIR}/po/POTFILES.in" --copyright-holder='LyX Developers' --msgid-bugs-address=lyx-devel@lists.lyx.org -o "${CMAKE_CURRENT_BINARY_DIR}/lyx.pot"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/lyx.fmt.pot" ${_potfiles_dep}
)
file(GLOB LYX_PO_FILES ${TOP_SRC_DIR}/po/*.po)
GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/lyx.pot ALL ${LYX_PO_FILES})
# ADD_POFILES("lyx")