parent
b6ed8c6729
commit
c12e2a7151
@ -1,4 +0,0 @@
|
||||
*.kdev4*
|
||||
CMakeLists.txt.user*
|
||||
build
|
||||
translations/liblxqt
|
@ -1,23 +0,0 @@
|
||||
# XDG standards expects system-wide configuration files in the /etc/xdg/lxqt location.
|
||||
# Unfortunately QSettings we are using internally can be overriden in the Qt compilation
|
||||
# time to use different path for system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
|
||||
# This path can be found calling Qt4's qmake:
|
||||
# qmake -query QT_INSTALL_CONFIGURATION
|
||||
#
|
||||
if(NOT DEFINED LXQT_ETC_XDG_DIR)
|
||||
get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
|
||||
message(STATUS "${QT_QMAKE_EXECUTABLE}")
|
||||
|
||||
if(NOT QT_QMAKE_EXECUTABLE)
|
||||
message(FATAL_ERROR "LXQT_ETC_XDG_DIR: qmake executable not found (included before qt was configured?)")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_CONFIGURATION
|
||||
OUTPUT_VARIABLE LXQT_ETC_XDG_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
message(STATUS "LXQT_ETC_XDG_DIR autodetected as '${LXQT_ETC_XDG_DIR}'")
|
||||
message(STATUS "You can set it manually with -DLXQT_ETC_XDG_DIR=<value>")
|
||||
message(STATUS "")
|
||||
endif ()
|
||||
|
@ -1,58 +0,0 @@
|
||||
# Creates portable headers; e.g.:
|
||||
# Creates XdgAction from xdgaction.h
|
||||
# XdgAction contents:
|
||||
# #include "xdgaction.h"
|
||||
#
|
||||
# Use:
|
||||
# set(PUBLIC_CLASSES MyClass YourClass)
|
||||
# create_portable_headers(PORTABLE_HEADERS ${PUBLIC_CLASSES})
|
||||
# PORTABLE_HEADER is an return value that contains the full name of the
|
||||
# generated headers.
|
||||
|
||||
function(create_portable_headers outfiles outDir)
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(_CREATE_PORTABLE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(class_list ${_CREATE_PORTABLE_HEADERS_UNPARSED_ARGUMENTS})
|
||||
foreach(f ${class_list})
|
||||
string(TOLOWER "${f}.h" _filename)
|
||||
|
||||
file(WRITE "${outDir}/${f}"
|
||||
"#include \"lxqt${_filename}\"\n")
|
||||
|
||||
list(APPEND ${outfiles} "${outDir}/${f}")
|
||||
endforeach()
|
||||
|
||||
set(${outfiles} "${${outfiles}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
function(check_portable_headers)
|
||||
cmake_parse_arguments(__ARGS "" "" "H_FILES;LINKS" ${ARGN})
|
||||
|
||||
foreach(f ${__ARGS_LINKS})
|
||||
file(READ ${f} content)
|
||||
|
||||
set(found False)
|
||||
foreach(line ${content})
|
||||
string(REGEX MATCH "#include \"(.*)\"" v ${line})
|
||||
set(hFile ${CMAKE_MATCH_1})
|
||||
|
||||
string(REGEX MATCH "[;/]${hFile};" v ";${__ARGS_H_FILES};")
|
||||
|
||||
if(NOT v)
|
||||
set(found True)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
if(found)
|
||||
message(FATAL_ERROR "Incorrect portable header: '${f}'")
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
@ -1,56 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
#=============================================================================
|
||||
# FindXdgUserDirs
|
||||
#
|
||||
# Try to find xdg-user-dirs-update.
|
||||
#
|
||||
# If the xdg-user-dirs-update executable is not in your PATH, you can provide
|
||||
# an alternative name or full path location with the
|
||||
# `XdgUserDirsUpdate_EXECUTABLE` variable.
|
||||
#
|
||||
# This will define the following variables:
|
||||
#
|
||||
# `XdgUserDirs_FOUND`
|
||||
# True if xdg-user-dirs-update is available.
|
||||
#
|
||||
# `XdgUserDirsUpdate_EXECUTABLE`
|
||||
# The xdg-user-dirs-update executable.
|
||||
#
|
||||
|
||||
# Find xdg-user-dirs-update
|
||||
find_program(XdgUserDirsUpdate_EXECUTABLE NAMES xdg-user-dirs-update)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(XdgUserDirs
|
||||
FOUND_VAR
|
||||
XdgUserDirs_FOUND
|
||||
REQUIRED_VARS
|
||||
XdgUserDirsUpdate_EXECUTABLE
|
||||
)
|
||||
|
||||
mark_as_advanced(XdgUserDirsUpdate_EXECUTABLE)
|
@ -1,71 +1,25 @@
|
||||
# - Finds the lxqt package
|
||||
#
|
||||
# The module defines the following variables
|
||||
#
|
||||
# LXQT_FOUND - Set to TRUE if all of the above has been found
|
||||
#
|
||||
# LXQT_SHARE_DIR - This allows to install and read the configs from non-standard locations
|
||||
#
|
||||
# LXQT_TRANSLATIONS_DIR - The default translations directory
|
||||
#
|
||||
# LXQT_ETC_XDG_DIR - XDG standards expects system-wide configuration files in the
|
||||
# /etc/xdg/lxqt location. Unfortunately QSettings we are using internally
|
||||
# can be overriden in the Qt compilation time to use different path for
|
||||
# system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
|
||||
# This path can be found calling Qt's qmake:
|
||||
# qmake -query QT_INSTALL_CONFIGURATION
|
||||
#
|
||||
# LXQT_DATA_DIR - LXQt base directory relative to which data files should
|
||||
# be searched.Defaults to CMAKE_INSTALL_FULL_DATADIR. It's
|
||||
# added to XDG_DATA_DIRS by the startlxqt script.
|
||||
#
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(LXQT_USEQT@LXQT_QT_VERSION@ ON)
|
||||
set(LXQT_QT_VERSION "@LXQT_QT_VERSION@")
|
||||
set(LXQT_MAJOR_VERSION "@LXQT_MAJOR_VERSION@")
|
||||
set(LXQT_MINOR_VERSION "@LXQT_MINOR_VERSION@")
|
||||
set(LXQT_PATCH_VERSION "@LXQT_PATCH_VERSION@")
|
||||
set(LXQT_VERSION "@LXQT_VERSION@")
|
||||
|
||||
set(LXQT_RELATIVE_SHARE_DIR "@LXQT_RELATIVE_SHARE_DIR@")
|
||||
set(LXQT_SHARE_DIR "@LXQT_SHARE_DIR@")
|
||||
set(LXQT_RELATIVE_TRANSLATIONS_DIR "@LXQT_RELATIVE_TRANSLATIONS_DIR@")
|
||||
set(LXQT_TRANSLATIONS_DIR "@LXQT_TRANSLATIONS_DIR@")
|
||||
set(LXQT_GRAPHICS_DIR "@LXQT_GRAPHICS_DIR@")
|
||||
set(LXQT_ETC_XDG_DIR "@LXQT_ETC_XDG_DIR@")
|
||||
set(LXQT_DATA_DIR "@LXQT_DATA_DIR@")
|
||||
set(LXQT_CMAKE_MODULES_DIR "@CFG_LXQT_CMAKE_MODULES_DIR@")
|
||||
set(LXQT_CMAKE_FIND_MODULES_DIR "@CFG_LXQT_CMAKE_FIND_MODULES_DIR@")
|
||||
|
||||
|
||||
set(LXQT@LXQT_QT_VERSION@_FOUND 1)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.0.2)
|
||||
message(FATAL_ERROR \"@PROJECT_NAME@ requires at least CMake version 3.0.2\")
|
||||
endif()
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
add_definitions("-DLXQT_RELATIVE_SHARE_DIR=\"${LXQT_RELATIVE_SHARE_DIR}\"")
|
||||
add_definitions("-DLXQT_SHARE_DIR=\"${LXQT_SHARE_DIR}\"")
|
||||
add_definitions("-DLXQT_RELATIVE_SHARE_TRANSLATIONS_DIR=\"${LXQT_RELATIVE_TRANSLATIONS_DIR}\"")
|
||||
add_definitions("-DLXQT_SHARE_TRANSLATIONS_DIR=\"${LXQT_TRANSLATIONS_DIR}\"")
|
||||
add_definitions("-DLXQT_GRAPHICS_DIR=\"${LXQT_GRAPHICS_DIR}\"")
|
||||
add_definitions("-DLXQT_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\"")
|
||||
add_definitions("-DLXQT_DATA_DIR=\"${LXQT_DATA_DIR}\"")
|
||||
add_definitions("-DLXQT_VERSION=\"${LXQT_VERSION}\"")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
"${LXQT_CMAKE_MODULES_DIR}"
|
||||
"${LXQT_CMAKE_FIND_MODULES_DIR}"
|
||||
)
|
||||
|
||||
find_dependency(Qt5Widgets)
|
||||
find_dependency(Qt5DBus)
|
||||
find_dependency(Qt5X11Extras)
|
||||
find_dependency(Qt5LinguistTools)
|
||||
find_dependency(Qt5Xdg)
|
||||
find_dependency(Qt5Widgets @QT_MINIMUM_VERSION@)
|
||||
find_dependency(Qt5DBus @QT_MINIMUM_VERSION@)
|
||||
find_dependency(Qt5X11Extras @QT_MINIMUM_VERSION@)
|
||||
find_dependency(Qt5LinguistTools @QT_MINIMUM_VERSION@)
|
||||
find_dependency(Qt5Xdg @QTXDG_MINIMUM_VERSION@)
|
||||
find_dependency(KF5WindowSystem)
|
||||
find_dependency(lxqt-build-tools @LXQTBT_MINIMUM_VERSION@)
|
||||
include(LXQtConfigVars)
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER 2.8.12)
|
||||
cmake_policy(SET CMP0024 OLD)
|
||||
if (NOT TARGET @LXQT_LIBRARY_NAME@)
|
||||
if (POLICY CMP0024)
|
||||
cmake_policy(SET CMP0024 NEW)
|
||||
endif()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/lxqt-targets.cmake")
|
||||
endif()
|
||||
|
@ -1,15 +0,0 @@
|
||||
/* This file has been generated by the CMake lxqt_app_translation_loader().
|
||||
* It loads LXQt application translations.
|
||||
*
|
||||
* Attention: All changes will be overwritten!!!
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <LXQt/Translator>
|
||||
|
||||
static void loadAppTranslation()
|
||||
{
|
||||
LXQt::Translator::translateApplication(QStringLiteral("@catalog_name@"));
|
||||
}
|
||||
|
||||
Q_COREAPP_STARTUP_FUNCTION(loadAppTranslation)
|
@ -1,150 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
# Copyright 2015 Palo Kisa <palo.kisa@gmail.com>
|
||||
# Copyright 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
#=============================================================================
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Honor visibility properties for all target types.
|
||||
#
|
||||
# The ``<LANG>_VISIBILITY_PRESET`` and
|
||||
# ``VISIBILITY_INLINES_HIDDEN`` target properties affect visibility
|
||||
# of symbols during dynamic linking. When first introduced these properties
|
||||
# affected compilation of sources only in shared libraries, module libraries,
|
||||
# and executables with the ``ENABLE_EXPORTS`` property set. This
|
||||
# was sufficient for the basic use cases of shared libraries and executables
|
||||
# with plugins. However, some sources may be compiled as part of static
|
||||
# libraries or object libraries and then linked into a shared library later.
|
||||
# CMake 3.3 and above prefer to honor these properties for sources compiled
|
||||
# in all target types. This policy preserves compatibility for projects
|
||||
# expecting the properties to work only for some target types.
|
||||
#
|
||||
# The ``OLD`` behavior for this policy is to ignore the visibility properties
|
||||
# for static libraries, object libraries, and executables without exports.
|
||||
# The ``NEW`` behavior for this policy is to honor the visibility properties
|
||||
# for all target types.
|
||||
#
|
||||
# This policy was introduced in CMake version 3.3. CMake version
|
||||
# 3.3.0 warns when the policy is not set and uses ``OLD`` behavior. Use
|
||||
# the ``cmake_policy()`` command to set it to ``OLD`` or ``NEW``
|
||||
# explicitly.
|
||||
#-----------------------------------------------------------------------------
|
||||
if(COMMAND CMAKE_POLICY)
|
||||
if (POLICY CMP0063)
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Global definitions
|
||||
#-----------------------------------------------------------------------------
|
||||
add_definitions(
|
||||
-DQT_USE_QSTRINGBUILDER
|
||||
)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Detect Clang compiler
|
||||
#-----------------------------------------------------------------------------
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(LXQT_COMPILER_IS_CLANGCXX 1)
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set visibility to hidden to hide symbols, unless they're exported manually
|
||||
# in the code
|
||||
#-----------------------------------------------------------------------------
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Disable exceptions
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Common warning flags
|
||||
#-----------------------------------------------------------------------------
|
||||
set(__LXQT_COMMON_WARNING_FLAGS "-Wall")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Warning flags
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__LXQT_COMMON_WARNING_FLAGS}")
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Linker flags
|
||||
# Do not allow undefined symbols
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}"
|
||||
)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS
|
||||
"-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# CXX11 and CXX0X requirements
|
||||
#-----------------------------------------------------------------------------
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
else()
|
||||
message(FATAL "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. C++11 support is required")
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Enable exceptions for an target
|
||||
#
|
||||
# lxqt_enable_target_exceptions(<target>
|
||||
# <INTERFACE|PUBLIC|PRIVATE>
|
||||
# )
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
function(lxqt_enable_target_exceptions target mode)
|
||||
target_compile_options(${target} ${mode}
|
||||
"$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-fexceptions>"
|
||||
)
|
||||
endfunction()
|
@ -1,252 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
#=============================================================================#
|
||||
|
||||
# lxqt_create_pkgconfig_file(PACKAGE_NAME <package_name>
|
||||
# VERSION <version>
|
||||
# [PREFIX <path>]
|
||||
# [EXEC_PREFIX <path>]
|
||||
# [INCLUDEDIR_PREFIX <path>]
|
||||
# [INCLUDEDIRS <path1> <path2> ... <path3>]
|
||||
# [LIBDIR_PREFIX <path>]
|
||||
# [DESCRIPTIVE_NAME <name>]
|
||||
# [DESCRIPTION <description>]
|
||||
# [URL <url>]
|
||||
# [REQUIRES <dep1> <dep2> ... <dep3>]
|
||||
# [REQUIRES_PRIVATE <dep1> <dep2> ... <dep3>]
|
||||
# [LIB_INSTALLDIR <dir>]
|
||||
# [CFLAGS <cflags>]
|
||||
# [PATH <path>]
|
||||
# [INSTALL]
|
||||
# [COMPONENT] component)
|
||||
#
|
||||
#
|
||||
# PACKAGE_NAME and VERSION are mandatory. Everything else is optional
|
||||
|
||||
include(CMakeParseArguments)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
function(lxqt_create_pkgconfig_file)
|
||||
set(options INSTALL)
|
||||
set(oneValueArgs
|
||||
PACKAGE_NAME
|
||||
PREFIX
|
||||
EXEC_PREFIX
|
||||
INCLUDEDIR_PREFIX
|
||||
LIBDIR_PREFIX
|
||||
DESCRIPTIVE_NAME
|
||||
DESCRIPTION
|
||||
URL
|
||||
VERSION
|
||||
PATH
|
||||
COMPONENT
|
||||
)
|
||||
set(multiValueArgs
|
||||
INCLUDEDIRS
|
||||
REQUIRES
|
||||
REQUIRES_PRIVATE
|
||||
CONFLICTS
|
||||
CFLAGS
|
||||
LIBS
|
||||
LIBS_PRIVATE
|
||||
)
|
||||
|
||||
cmake_parse_arguments(USER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (USER_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown keywords given to create_pkgconfig_file(): \"${USER_UNPARSED_ARGUMENTS}\"")
|
||||
endif()
|
||||
|
||||
# Check for mandatory args. Abort if not set
|
||||
if (NOT DEFINED USER_PACKAGE_NAME)
|
||||
message(FATAL_ERROR "Required argument PACKAGE_NAME missing in generate_pkgconfig_file() call")
|
||||
else()
|
||||
set(_PKGCONFIG_PACKAGE_NAME "${USER_PACKAGE_NAME}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_VERSION)
|
||||
message(FATAL_ERROR "Required argument VERSION missing in generate_pkgconfig_file() call")
|
||||
else()
|
||||
set(_PKGCONFIG_VERSION "${USER_VERSION}")
|
||||
endif()
|
||||
|
||||
|
||||
# Optional args
|
||||
if (NOT DEFINED USER_PREFIX)
|
||||
set(_PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_EXEC_PREFIX)
|
||||
set(_PKGCONFIG_EXEC_PREFIX "\${prefix}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_INCLUDEDIR_PREFIX)
|
||||
set(_PKGCONFIG_INCLUDEDIR_PREFIX "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_LIBDIR_PREFIX)
|
||||
set(_PKGCONFIG_LIBDIR_PREFIX "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_DESCRIPTIVE_NAME)
|
||||
set(_PKGCONFIG_DESCRIPTIVE_NAME "")
|
||||
else()
|
||||
set(_PKGCONFIG_DESCRIPTIVE_NAME "${USER_DESCRIPTIVE_NAME}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_INCLUDEDIRS)
|
||||
set(tmp "")
|
||||
foreach(dir ${USER_INCLUDEDIRS})
|
||||
if (NOT IS_ABSOLUTE "${dir}")
|
||||
list(APPEND tmp "-I\${includedir}/${dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
string(REPLACE ";" " " _INCLUDEDIRS "${tmp}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_REQUIRES)
|
||||
string(REPLACE ";" ", " _PKGCONFIG_REQUIRES "${USER_REQUIRES}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_REQUIRES_PRIVATE)
|
||||
string(REPLACE ";" ", " _PKGCONFIG_REQUIRES_PRIVATE "${USER_REQUIRES_PRIVATE}")
|
||||
else()
|
||||
set(_PKGCONFIG_REQUIRES_PRIVATE "")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_CFLAGS)
|
||||
set(_PKGCONFIG_CFLAGS "-I\${includedir} ${_INCLUDEDIRS}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_LIBS)
|
||||
set(_PKGCONFIG_LIBS "-L\${libdir}")
|
||||
else()
|
||||
set(tmp "-L\${libdir}")
|
||||
set(_libs "${USER_LIBS}")
|
||||
foreach(lib ${_libs})
|
||||
list(APPEND tmp "-l${lib}")
|
||||
endforeach()
|
||||
string(REPLACE ";" " " _PKGCONFIG_LIBS "${tmp}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_LIBS_PRIVATE)
|
||||
set(PKGCONFIG_LIBS "-L\${libdir}")
|
||||
else()
|
||||
set(tmp "")
|
||||
set(_libs "${USER_LIBS_PRIVATE}")
|
||||
foreach(lib ${_libs})
|
||||
list(APPEND tmp "-l${lib}")
|
||||
endforeach()
|
||||
string(REPLACE ";" " " _PKGCONFIG_LIBS_PRIVATE "${tmp}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_DESCRIPTION)
|
||||
set(_PKGCONFIG_DESCRIPTION "${USER_DESCRIPTION}")
|
||||
else()
|
||||
set(_PKGCONFIG_DESCRIPTION "")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_URL)
|
||||
set(_PKFCONFIG_URL "${USER_URL}")
|
||||
else()
|
||||
set(_PKGCONFIG_URL "")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_PATH)
|
||||
set(_PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${_PKGCONFIG_PACKAGE_NAME}.pc")
|
||||
else()
|
||||
if (IS_ABSOLUTE "${USER_PATH}")
|
||||
set(_PKGCONFIG_FILE "${USER_PATH}/${_PKGCONFIG_PACKAGE_NAME}.pc")
|
||||
else()
|
||||
set(_PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${USER_PATH}/${_PKGCONFIG_PACKAGE_NAME}.pc")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Write the .pc file
|
||||
FILE(WRITE "${_PKGCONFIG_FILE}"
|
||||
"# file generated by create_pkgconfig_file()\n"
|
||||
"prefix=${_PKGCONFIG_PREFIX}\n"
|
||||
"exec_prefix=${_PKGCONFIG_EXEC_PREFIX}\n"
|
||||
"libdir=${_PKGCONFIG_LIBDIR_PREFIX}\n"
|
||||
"includedir=${_PKGCONFIG_INCLUDEDIR_PREFIX}\n"
|
||||
"\n"
|
||||
"Name: ${_PKGCONFIG_DESCRIPTIVE_NAME}\n"
|
||||
)
|
||||
|
||||
if (NOT "${_PKGCONFIG_DESCRIPTION}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Description: ${_PKGCONFIG_DESCRIPTION}\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT "${_PKGCONFIG_URL}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE} "URL: ${_PKGCONFIG_URL}\n")
|
||||
endif()
|
||||
|
||||
FILE(APPEND ${_PKGCONFIG_FILE} "Version: ${_PKGCONFIG_VERSION}\n")
|
||||
|
||||
if (NOT "${_PKGCONFIG_REQUIRES}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE} "Requires: ${_PKGCONFIG_REQUIRES}\n")
|
||||
endif()
|
||||
|
||||
if (NOT "${_PKGCONFIG_REQUIRES_PRIVATE}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Requires.private: ${_PKGCONFIG_REQUIRES_PRIVATE}\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Cflags: ${_PKGCONFIG_CFLAGS}\n"
|
||||
"Libs: ${_PKGCONFIG_LIBS}\n"
|
||||
)
|
||||
|
||||
if (NOT "${_PKGCONFIG_LIBS_PRIVATE}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Libs.private: ${_PKGCONFIG_REQUIRES_PRIVATE}\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_INSTALL)
|
||||
# FreeBSD loves to install files to different locations
|
||||
# http://www.freebsd.org/doc/handbook/dirstructure.html
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
set(_PKGCONFIG_INSTALL_DESTINATION "libdata/pkgconfig")
|
||||
else()
|
||||
set(_PKGCONFIG_INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_COMPONENT)
|
||||
set(_COMPONENT "${USER_COMPONENT}")
|
||||
else()
|
||||
set(_COMPONENT "Devel")
|
||||
endif()
|
||||
|
||||
install(FILES "${_PKGCONFIG_FILE}"
|
||||
DESTINATION "${_PKGCONFIG_INSTALL_DESTINATION}"
|
||||
COMPONENT "${_COMPONENT}")
|
||||
endif()
|
||||
endfunction()
|
@ -1,15 +0,0 @@
|
||||
/* This file has been generated by the CMake lxqt_app_translation_loader().
|
||||
* It loads LXQt libraries translations.
|
||||
*
|
||||
* Attention: All changes will be overwritten!!!
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <LXQt/Translator>
|
||||
|
||||
static void loadLibTranslation()
|
||||
{
|
||||
LXQt::Translator::translateLibrary(QStringLiteral("@catalog_name@"));
|
||||
}
|
||||
|
||||
Q_COREAPP_STARTUP_FUNCTION(loadLibTranslation)
|
@ -1,23 +0,0 @@
|
||||
/* This file has been generated by the CMake lxqt_plugin_translation_loader().
|
||||
* It loads LXQt plugin translations.
|
||||
*
|
||||
* Attention: All changes will be overwritten!!!
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <LXQt/Translator>
|
||||
|
||||
/* Dummy helper symbol for referencing.
|
||||
* In case plugin is linked as static (lib*.a) unreferenced objects are stripped in linking time
|
||||
* => we need to reference some symbol from this file to be not stripped as a whole.
|
||||
*/
|
||||
void * loadPluginTranslation_@catalog_name@_helper = nullptr;
|
||||
|
||||
static void loadPluginTranslation()
|
||||
{
|
||||
//XXX: we don't use the QStringLiteral here because it causes SEGFAULT in static finalization time
|
||||
// (the string is stored in static QHash and it's destructor can reference already deleted static QString (generated by QStringLiteral))
|
||||
LXQt::Translator::translatePlugin("@catalog_name@", "@plugin_type@");
|
||||
}
|
||||
|
||||
Q_COREAPP_STARTUP_FUNCTION(loadPluginTranslation)
|
@ -1,32 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
#=============================================================================
|
||||
#
|
||||
# An convenience module that loads all the LXQt translations modules at once.
|
||||
|
||||
include(LXQtTranslateTs)
|
||||
include(LXQtTranslateDesktop)
|
||||
include(LXQtTranslationLoader)
|
@ -1,107 +0,0 @@
|
||||
#=============================================================================
|
||||
# The lxqt_translate_desktop() function was copied from the
|
||||
# LXQt LXQtTranslate.cmake
|
||||
#
|
||||
# Original Author: Alexander Sokolov <sokoloff.a@gmail.com>
|
||||
#
|
||||
# funtion lxqt_translate_desktop(_RESULT
|
||||
# SOURCES <sources>
|
||||
# [TRANSLATION_DIR] translation_directory
|
||||
# )
|
||||
# Output:
|
||||
# _RESULT The generated .desktop (.desktop) files
|
||||
#
|
||||
# Input:
|
||||
#
|
||||
# SOURCES List of input desktop files (.destktop.in) to be translated
|
||||
# (merged), relative to the CMakeList.txt.
|
||||
#
|
||||
# TRANSLATION_DIR Optional path to the directory with the .ts files,
|
||||
# relative to the CMakeList.txt. Defaults to
|
||||
# "translations".
|
||||
#
|
||||
#=============================================================================
|
||||
|
||||
function(lxqt_translate_desktop _RESULT)
|
||||
# Parse arguments ***************************************
|
||||
set(oneValueArgs TRANSLATION_DIR)
|
||||
set(multiValueArgs SOURCES)
|
||||
|
||||
cmake_parse_arguments(_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# check for unknown arguments
|
||||
set(_UNPARSED_ARGS ${_ARGS_UNPARSED_ARGUMENTS})
|
||||
if (NOT ${_UNPARSED_ARGS} STREQUAL "")
|
||||
MESSAGE(FATAL_ERROR
|
||||
"Unknown arguments '${_UNPARSED_ARGS}'.\n"
|
||||
"See lxqt_translate_desktop() documentation for more information.\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED _ARGS_SOURCES)
|
||||
set(${_RESULT} "" PARENT_SCOPE)
|
||||
return()
|
||||
else()
|
||||
set(_sources ${_ARGS_SOURCES})
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED _ARGS_TRANSLATION_DIR)
|
||||
set(_translationDir "translations")
|
||||
else()
|
||||
set(_translationDir ${_ARGS_TRANSLATION_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
get_filename_component (_translationDir ${_translationDir} ABSOLUTE)
|
||||
|
||||
foreach (_inFile ${_sources})
|
||||
get_filename_component(_inFile ${_inFile} ABSOLUTE)
|
||||
get_filename_component(_fileName ${_inFile} NAME_WE)
|
||||
#Extract the real extension ............
|
||||
get_filename_component(_fileExt ${_inFile} EXT)
|
||||
string(REPLACE ".in" "" _fileExt ${_fileExt})
|
||||
#.......................................
|
||||
set(_outFile "${CMAKE_CURRENT_BINARY_DIR}/${_fileName}${_fileExt}")
|
||||
|
||||
file(GLOB _translations
|
||||
${_translationDir}/${_fileName}_*${_fileExt}
|
||||
)
|
||||
|
||||
set(_pattern "'\\[.*]\\s*='")
|
||||
if (_translations)
|
||||
list(SORT _translations)
|
||||
add_custom_command(OUTPUT ${_outFile}
|
||||
COMMAND grep -v -a "'#TRANSLATIONS_DIR='" ${_inFile} > ${_outFile}
|
||||
COMMAND grep -h -a ${_pattern} ${_translations} >> ${_outFile}
|
||||
COMMENT "Generating ${_fileName}${_fileExt}"
|
||||
)
|
||||
else()
|
||||
add_custom_command(OUTPUT ${_outFile}
|
||||
COMMAND grep -v -a "'#TRANSLATIONS_DIR='" ${_inFile} > ${_outFile}
|
||||
COMMENT "Generating ${_fileName}${_fileExt}"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(__result ${__result} ${_outFile})
|
||||
|
||||
|
||||
# TX file ***********************************************
|
||||
set(_txFile "${CMAKE_BINARY_DIR}/tx/${_fileName}${_fileExt}.tx.sh")
|
||||
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _tx_translationDir ${_translationDir})
|
||||
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _tx_inFile ${_inFile})
|
||||
string(REPLACE "." "" _fileType ${_fileExt})
|
||||
|
||||
file(WRITE ${_txFile}
|
||||
"[ -f ${_inFile} ] || exit 0\n"
|
||||
"echo '[lxde-qt.${_fileName}_${_fileType}]'\n"
|
||||
"echo 'type = DESKTOP'\n"
|
||||
"echo 'source_lang = en'\n"
|
||||
"echo 'source_file = ${_tx_inFile}'\n"
|
||||
"echo 'file_filter = ${_tx_translationDir}/${_fileName}_<lang>${_fileExt}'\n"
|
||||
"echo ''\n"
|
||||
)
|
||||
|
||||
endforeach()
|
||||
|
||||
set(${_RESULT} ${__result} PARENT_SCOPE)
|
||||
endfunction(lxqt_translate_desktop)
|
@ -1,281 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
#=============================================================================
|
||||
#
|
||||
# funtion lxqt_translate_ts(qmFiles
|
||||
# [USE_QT5 [Yes | No]]
|
||||
# [UPDATE_TRANSLATIONS [Yes | No]]
|
||||
# SOURCES <sources>
|
||||
# [UPDATE_OPTIONS] update_options
|
||||
# [TEMPLATE] translation_template
|
||||
# [TRANSLATION_DIR] translation_directory
|
||||
# [INSTALL_DIR] install_directory
|
||||
# [COMPONENT] component
|
||||
# [PULL_TRANSLATIONS [Yes | No]]
|
||||
# [CLEAN_TRANSLATIONS [Yes | No]]
|
||||
# [REPO_SUBDIR] repository_subdirectory
|
||||
# [TRANSLATIONS_REPO] remote_translation_repo
|
||||
# [TRANSLATIONS_REFSPEC] translations_remote_branch
|
||||
# )
|
||||
# Output:
|
||||
# qmFiles The generated compiled translations (.qm) files
|
||||
#
|
||||
# Input:
|
||||
# USE_QT5 Optional flag to choose between Qt4 and Qt5. Defaults to Qt5
|
||||
#
|
||||
# UPDATE_TRANSLATIONS Optional flag. Setting it to Yes, extracts and
|
||||
# compiles the translations. Setting it No, only
|
||||
# compiles them.
|
||||
#
|
||||
# UPDATE_OPTIONS Optional options to lupdate when UPDATE_TRANSLATIONS
|
||||
# is True.
|
||||
#
|
||||
# TEMPLATE Optional translations files base name. Defaults to
|
||||
# ${PROJECT_NAME}. An .ts extensions is added.
|
||||
#
|
||||
# TRANSLATION_DIR Optional path to the directory with the .ts files,
|
||||
# relative to the CMakeList.txt. Defaults to
|
||||
# "translations".
|
||||
#
|
||||
# INSTALL_DIR Optional destination of the file compiled files (qmFiles).
|
||||
# If not present no installation is performed
|
||||
#
|
||||
# COMPONENT Optional install component. Only effective if INSTALL_DIR
|
||||
# present. Defaults to "Runtime".
|
||||
#
|
||||
# PULL_TRANSLATIONS Optional flag. If set, the translations are pulled
|
||||
# from external repository in cmake phase (not in build/make time)
|
||||
# into directory "${TRANSLATION_DIR}/${REPO_SUBDIR}".
|
||||
#
|
||||
# CLEAN_TRANSLATIONS Optional flag. If set, the externally pulled
|
||||
# translations are removed.
|
||||
#
|
||||
# REPO_SUBDIR Optional path in the "translations repository" to directory
|
||||
# with translations. Only effective if PULL_TRANSLATIONS enabled.
|
||||
# Defaults to "${TEMPLATE}".
|
||||
#
|
||||
# TRANSLATIONS_REPO External git repository with translations - only the ${TEMPLATE} directory
|
||||
# is pulled (using the "sparse checkout").
|
||||
# Optional (defaults to "https://github.com/lxde/lxqt-l10n.git").
|
||||
#
|
||||
# TRANSLATIONS_REFSPEC Optional refspec of external repository. Used in git pull.
|
||||
# Defaults to "master".
|
||||
|
||||
# CMake v2.8.3 needed to use the CMakeParseArguments module
|
||||
cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
|
||||
|
||||
# We use our patched version to round a annoying bug.
|
||||
include(Qt5PatchedLinguistToolsMacros)
|
||||
|
||||
option(PULL_TRANSLATIONS "Pull translations" Yes)
|
||||
option(CLEAN_TRANSLATIONS "Clean translations" No)
|
||||
|
||||
function(lxqt_translate_ts qmFiles)
|
||||
set(oneValueArgs
|
||||
USE_QT5
|
||||
UPDATE_TRANSLATIONS
|
||||
TEMPLATE
|
||||
TRANSLATION_DIR
|
||||
INSTALL_DIR
|
||||
COMPONENT
|
||||
PULL_TRANSLATIONS
|
||||
CLEAN_TRANSLATIONS
|
||||
REPO_SUBDIR
|
||||
TRANSLATIONS_REPO
|
||||
TRANSLATIONS_REFSPEC
|
||||
)
|
||||
set(multiValueArgs SOURCES UPDATE_OPTIONS)
|
||||
cmake_parse_arguments(TR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT DEFINED TR_UPDATE_TRANSLATIONS)
|
||||
set(TR_UPDATE_TRANSLATIONS "No")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED TR_UPDATE_OPTIONS)
|
||||
set(TR_UPDATE_OPTIONS "")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED TR_USE_QT5)
|
||||
set(TR_USE_QT5 "Yes")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED TR_TEMPLATE)
|
||||
set(TR_TEMPLATE "${PROJECT_NAME}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED TR_TRANSLATION_DIR)
|
||||
set(TR_TRANSLATION_DIR "translations")
|
||||
endif()
|
||||
get_filename_component(TR_TRANSLATION_DIR "${TR_TRANSLATION_DIR}" ABSOLUTE)
|
||||
|
||||
if (NOT DEFINED TR_CLEAN_TRANSLATIONS)
|
||||
set(TR_CLEAN_TRANSLATIONS "No")
|
||||
endif()
|
||||
if (NOT DEFINED TR_PULL_TRANSLATIONS)
|
||||
set(TR_PULL_TRANSLATIONS "No")
|
||||
endif()
|
||||
if (NOT DEFINED TR_REPO_SUBDIR)
|
||||
set(TR_REPO_SUBDIR "${TR_TEMPLATE}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED TR_TRANSLATIONS_REPO)
|
||||
set(TR_TRANSLATIONS_REPO "https://github.com/lxde/lxqt-l10n.git")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED TR_TRANSLATIONS_REFSPEC)
|
||||
set(TR_TRANSLATIONS_REFSPEC "master")
|
||||
endif()
|
||||
|
||||
if (TR_CLEAN_TRANSLATIONS)
|
||||
message(STATUS "Cleaning translations dir '${TR_TRANSLATION_DIR}' ...")
|
||||
set(DIR_TO_REMOVE "${TR_TRANSLATION_DIR}/${TR_REPO_SUBDIR}")
|
||||
get_filename_component(PARENT_DIR "${DIR_TO_REMOVE}" DIRECTORY)
|
||||
while (NOT "${PARENT_DIR}" STREQAL "${TR_TRANSLATION_DIR}")
|
||||
set(DIR_TO_REMOVE "${PARENT_DIR}")
|
||||
get_filename_component(PARENT_DIR "${DIR_TO_REMOVE}" DIRECTORY)
|
||||
endwhile ()
|
||||
#TODO: is there a way to check successfulness of file command !?!
|
||||
file(REMOVE_RECURSE "${TR_TRANSLATION_DIR}/.git" "${DIR_TO_REMOVE}")
|
||||
endif ()
|
||||
|
||||
if (TR_PULL_TRANSLATIONS)
|
||||
find_package(Git REQUIRED)
|
||||
if (NOT (GIT_FOUND AND GIT_VERSION_STRING VERSION_GREATER "1.7.0"))
|
||||
message(FATAL_ERROR "Git > 1.7.0 is needed For pulling translations!")
|
||||
endif ()
|
||||
if (NOT EXISTS "${TR_TRANSLATION_DIR}/${TR_REPO_SUBDIR}")
|
||||
message(STATUS "Setting git repository in the translations dir '${TR_TRANSLATION_DIR}' ...")
|
||||
if (EXISTS "${TR_TRANSLATION_DIR}/.git")
|
||||
execute_process(COMMAND rm -Rf .git
|
||||
WORKING_DIRECTORY "${TR_TRANSLATION_DIR}"
|
||||
RESULT_VARIABLE ex_result
|
||||
)
|
||||
|
||||
if (NOT "${ex_result}" EQUAL 0)
|
||||
message(FATAL_ERROR "Initialization(cleanup) of translations dir failed!")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# make sure the dir exist, otherwise git init will fail
|
||||
file(MAKE_DIRECTORY "${TR_TRANSLATION_DIR}")
|
||||
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" init
|
||||
WORKING_DIRECTORY "${TR_TRANSLATION_DIR}"
|
||||
RESULT_VARIABLE ex_result
|
||||
)
|
||||
if (NOT "${ex_result}" EQUAL 0)
|
||||
message(FATAL_ERROR "Initialization(init) of translations dir failed!")
|
||||
endif ()
|
||||
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" remote add origin "${TR_TRANSLATIONS_REPO}"
|
||||
WORKING_DIRECTORY "${TR_TRANSLATION_DIR}"
|
||||
RESULT_VARIABLE ex_result
|
||||
)
|
||||
if (NOT "${ex_result}" EQUAL 0)
|
||||
message(FATAL_ERROR "Initialization(remote) of translations dir failed!")
|
||||
endif ()
|
||||
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" config core.sparseCheckout true
|
||||
WORKING_DIRECTORY "${TR_TRANSLATION_DIR}"
|
||||
RESULT_VARIABLE ex_result
|
||||
)
|
||||
if (NOT "${ex_result}" EQUAL 0)
|
||||
message(FATAL_ERROR "Initialization(config) of translations dir failed!")
|
||||
endif ()
|
||||
|
||||
file(WRITE "${TR_TRANSLATION_DIR}/.git/info/sparse-checkout" "${TR_REPO_SUBDIR}")
|
||||
endif ()
|
||||
|
||||
message(STATUS "Pulling the translations...")
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" pull origin "${TR_TRANSLATIONS_REFSPEC}"
|
||||
WORKING_DIRECTORY "${TR_TRANSLATION_DIR}"
|
||||
RESULT_VARIABLE ex_result
|
||||
)
|
||||
if (NOT "${ex_result}" EQUAL 0)
|
||||
message(FATAL_ERROR "Pulling translations failed!")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#project/module can use it's own translations (not from external)
|
||||
if (EXISTS "${TR_TRANSLATION_DIR}/${TR_REPO_SUBDIR}/")
|
||||
file(GLOB tsFiles "${TR_TRANSLATION_DIR}/${TR_REPO_SUBDIR}/*_*.ts")
|
||||
set(templateFile "${TR_TRANSLATION_DIR}/${TR_REPO_SUBDIR}/${TR_TEMPLATE}.ts")
|
||||
else ()
|
||||
file(GLOB tsFiles "${TR_TRANSLATION_DIR}/${TR_TEMPLATE}_*.ts")
|
||||
set(templateFile "${TR_TRANSLATION_DIR}/${TR_TEMPLATE}.ts")
|
||||
endif ()
|
||||
|
||||
if(TR_USE_QT5)
|
||||
# Qt5
|
||||
if (TR_UPDATE_TRANSLATIONS)
|
||||
qt5_patched_create_translation(QMS
|
||||
${TR_SOURCES}
|
||||
${templateFile}
|
||||
OPTIONS ${TR_UPDATE_OPTIONS}
|
||||
)
|
||||
qt5_patched_create_translation(QM
|
||||
${TR_SOURCES}
|
||||
${tsFiles}
|
||||
OPTIONS ${TR_UPDATE_OPTIONS}
|
||||
)
|
||||
else()
|
||||
qt5_patched_add_translation(QM ${tsFiles})
|
||||
endif()
|
||||
else()
|
||||
# Qt4
|
||||
if(TR_UPDATE_TRANSLATIONS)
|
||||
qt4_create_translation(QMS
|
||||
${TR_SOURCES}
|
||||
${templateFile}
|
||||
OPTIONS ${TR_UPDATE_OPTIONS}
|
||||
)
|
||||
qt4_create_translation(QM
|
||||
${TR_SOURCES}
|
||||
${tsFiles}
|
||||
OPTIONS ${TR_UPDATE_OPTIONS}
|
||||
)
|
||||
else()
|
||||
qt4_add_translation(QM ${tsFiles})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TR_UPDATE_TRANSLATIONS)
|
||||
add_custom_target("update_${TR_TEMPLATE}_ts" ALL DEPENDS ${QMS})
|
||||
endif()
|
||||
|
||||
if(DEFINED TR_INSTALL_DIR)
|
||||
if(NOT DEFINED TR_COMPONENT)
|
||||
set(TR_COMPONENT "Runtime")
|
||||
endif()
|
||||
|
||||
install(FILES ${QM}
|
||||
DESTINATION "${TR_INSTALL_DIR}"
|
||||
COMPONENT "${TR_COMPONENT}"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(${qmFiles} ${QM} PARENT_SCOPE)
|
||||
endfunction()
|
@ -1,73 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
#=============================================================================
|
||||
#
|
||||
# These functions enables "automatic" translation loading in LXQt Qt5 apps
|
||||
# and libs. They generate a .cpp file that takes care of everything. The
|
||||
# user doesn't have to do anything in the source code.
|
||||
#
|
||||
# Typical use:
|
||||
# include(LXQtTranslationLoader)
|
||||
# lxqt_app_translation_loader(lxqt-app_QM_LOADER ${PROJECT_NAME})
|
||||
# add_executable(${PROJECT_NAME}
|
||||
# ${lxqt-app_QM_LOADER}
|
||||
# ...
|
||||
# )
|
||||
|
||||
|
||||
# lxqt_app_translation_loader(<source_files> <catalog_name>)
|
||||
# <source_files> The generated .cpp file is added to <source_files>
|
||||
# <catalog_name> Translations catalog to be loaded
|
||||
function(lxqt_app_translation_loader source_files catalog_name)
|
||||
configure_file(
|
||||
${LXQT_CMAKE_MODULES_DIR}/LXQtAppTranslationLoader.cpp.in
|
||||
LXQtAppTranslationLoader.cpp @ONLY
|
||||
)
|
||||
set(${source_files} ${${source_files}} ${CMAKE_CURRENT_BINARY_DIR}/LXQtAppTranslationLoader.cpp PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# lxqt_lib_translation_loader(<source_files> <catalog_name>)
|
||||
# <source_files> The generated .cpp file is added to <source_files>
|
||||
# <catalog_name> Translations catalog to be loaded
|
||||
function(lxqt_lib_translation_loader source_files catalog_name)
|
||||
configure_file(
|
||||
${LXQT_CMAKE_MODULES_DIR}/LXQtLibTranslationLoader.cpp.in
|
||||
LXQtLibTranslationLoader.cpp @ONLY
|
||||
)
|
||||
set(${source_files} ${${source_files}} ${CMAKE_CURRENT_BINARY_DIR}/LXQtLibTranslationLoader.cpp PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# lxqt_plugin_translation_loader(<source_files> <catalog_name>)
|
||||
# <source_files> The generated .cpp file is added to <source_files>
|
||||
# <catalog_name> Translations catalog to be loaded
|
||||
# <plugin_type> Plugin type. Example: lxqt-panel
|
||||
function(lxqt_plugin_translation_loader source_files catalog_name plugin_type)
|
||||
configure_file(
|
||||
${LXQT_CMAKE_MODULES_DIR}/LXQtPluginTranslationLoader.cpp.in
|
||||
LXQtPluginTranslationLoader.cpp @ONLY
|
||||
)
|
||||
set(${source_files} ${${source_files}} ${CMAKE_CURRENT_BINARY_DIR}/LXQtPluginTranslationLoader.cpp PARENT_SCOPE)
|
||||
endfunction()
|
@ -1,112 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2005-2011 Kitware, Inc.
|
||||
# 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.
|
||||
#
|
||||
# * Neither the name of Kitware, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
# HOLDER 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.
|
||||
#=============================================================================
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(QT5_PATCHED_CREATE_TRANSLATION _qm_files)
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs OPTIONS)
|
||||
|
||||
cmake_parse_arguments(_LUPDATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(_lupdate_files ${_LUPDATE_UNPARSED_ARGUMENTS})
|
||||
set(_lupdate_options ${_LUPDATE_OPTIONS})
|
||||
|
||||
set(_my_sources)
|
||||
set(_my_tsfiles)
|
||||
foreach(_file ${_lupdate_files})
|
||||
get_filename_component(_ext ${_file} EXT)
|
||||
get_filename_component(_abs_FILE ${_file} ABSOLUTE)
|
||||
if(_ext MATCHES "ts")
|
||||
list(APPEND _my_tsfiles ${_abs_FILE})
|
||||
else()
|
||||
list(APPEND _my_sources ${_abs_FILE})
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(_ts_file ${_my_tsfiles})
|
||||
if(_my_sources)
|
||||
# make a list file to call lupdate on, so we don't make our commands too
|
||||
# long for some systems
|
||||
# get_filename_component(_ts_name ${_ts_file} NAME_WE)
|
||||
|
||||
get_filename_component(_name ${_ts_file} NAME)
|
||||
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _ts_name ${_name})
|
||||
|
||||
set(_ts_lst_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lst_file")
|
||||
set(_lst_file_srcs)
|
||||
foreach(_lst_file_src ${_my_sources})
|
||||
set(_lst_file_srcs "${_lst_file_src}\n${_lst_file_srcs}")
|
||||
endforeach()
|
||||
|
||||
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
|
||||
foreach(_pro_include ${_inc_DIRS})
|
||||
get_filename_component(_abs_include "${_pro_include}" ABSOLUTE)
|
||||
set(_lst_file_srcs "-I${_pro_include}\n${_lst_file_srcs}")
|
||||
endforeach()
|
||||
|
||||
file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${_ts_file}
|
||||
COMMAND ${Qt5_LUPDATE_EXECUTABLE}
|
||||
ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
|
||||
DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM)
|
||||
endforeach()
|
||||
qt5_patched_add_translation(${_qm_files} ${_my_tsfiles})
|
||||
set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(QT5_PATCHED_ADD_TRANSLATION _qm_files)
|
||||
foreach(_current_FILE ${ARGN})
|
||||
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
|
||||
# get_filename_component(qm ${_abs_FILE} NAME_WE)
|
||||
|
||||
get_filename_component(_name ${_abs_FILE} NAME)
|
||||
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" qm ${_name})
|
||||
|
||||
get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION)
|
||||
if(output_location)
|
||||
file(MAKE_DIRECTORY "${output_location}")
|
||||
set(qm "${output_location}/${qm}.qm")
|
||||
else()
|
||||
set(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${qm}
|
||||
COMMAND ${Qt5_LRELEASE_EXECUTABLE}
|
||||
ARGS ${_abs_FILE} -qm ${qm}
|
||||
DEPENDS ${_abs_FILE} VERBATIM
|
||||
)
|
||||
list(APPEND ${_qm_files} ${qm})
|
||||
endforeach()
|
||||
set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
|
||||
endfunction()
|
@ -1,47 +0,0 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
#=============================================================================
|
||||
#
|
||||
# These functions enables "automatic" translation loading in Qt5 apps
|
||||
# and libs. They generate a .cpp file that takes care of everything. The
|
||||
# user doesn't have to do anything in the source code.
|
||||
#
|
||||
# qt5_translation_loader(<source_files> <translations_dir> <catalog_name>)
|
||||
#
|
||||
# Output:
|
||||
# <source_files> Appends the generated file to this variable.
|
||||
#
|
||||
# Input:
|
||||
# <translations_dir> Full path name to the translations dir.
|
||||
# <catalog_name> Translation catalog to be loaded.
|
||||
|
||||
function(qt5_translation_loader source_files translations_dir catalog_name)
|
||||
configure_file(
|
||||
${LXQT_CMAKE_MODULES_DIR}/Qt5TranslationLoader.cpp.in
|
||||
Qt5TranslationLoader.cpp @ONLY
|
||||
)
|
||||
set(${source_files} ${${source_files}} ${CMAKE_CURRENT_BINARY_DIR}/Qt5TranslationLoader.cpp PARENT_SCOPE)
|
||||
endfunction()
|
@ -1,33 +0,0 @@
|
||||
/* This file has been generated by the CMake qt_translation_loader().
|
||||
* It loads Qt application translations.
|
||||
*
|
||||
* Attention: All changes will be overwritten!!!
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QLocale>
|
||||
#include <QTranslator>
|
||||
#include <QLibraryInfo>
|
||||
|
||||
static void loadQtTranslation()
|
||||
{
|
||||
QString locale = QLocale::system().name();
|
||||
QTranslator *qtTranslator = new QTranslator(qApp);
|
||||
|
||||
if (qtTranslator->load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
|
||||
qApp->installTranslator(qtTranslator);
|
||||
} else {
|
||||
delete qtTranslator;
|
||||
}
|
||||
|
||||
QTranslator *appTranslator = new QTranslator(qApp);
|
||||
if (appTranslator->load(QString("@translations_dir@/@catalog_name@_%1.qm").arg(locale))) {
|
||||
QCoreApplication::installTranslator(appTranslator);
|
||||
} else if (locale == QLatin1String("C") ||
|
||||
locale.startsWith(QLatin1String("en"))) {
|
||||
// English is the default. It's translated anyway.
|
||||
delete appTranslator;
|
||||
}
|
||||
}
|
||||
|
||||
Q_COREAPP_STARTUP_FUNCTION(loadQtTranslation)
|
Loading…
Reference in new issue