Fix broken CMakeLists.txt and make the lib compile again.
authorHone Jen Yee (PCMan) <pcman.tw@gmail.com>
Tue, 6 Aug 2013 15:13:27 +0000 (23:13 +0800)
committerHone Jen Yee (PCMan) <pcman.tw@gmail.com>
Tue, 6 Aug 2013 15:13:50 +0000 (23:13 +0800)
cmake/FindICU.cmake [new file with mode: 0644]
cmake/FindPulseAudio.cmake [new file with mode: 0644]
cmake/FindUDev.cmake [new file with mode: 0644]
cmake/RazorInstallConfigPath.cmake [new file with mode: 0644]
cmake/RazorLibSuffix.cmake [new file with mode: 0644]
cmake/RazorTranslate.cmake [new file with mode: 0644]
cmake/cmake_uninstall.cmake.in [new file with mode: 0644]
cmake/create_pkgconfig_file.cmake [new file with mode: 0644]
cmake/razortranslate.h.in [new file with mode: 0644]

diff --git a/cmake/FindICU.cmake b/cmake/FindICU.cmake
new file mode 100644 (file)
index 0000000..0fe5ecc
--- /dev/null
@@ -0,0 +1,290 @@
+# This module can find the International Components for Unicode (ICU) Library
+#
+# Requirements:
+# - CMake >= 2.8.3 (for new version of find_package_handle_standard_args)
+#
+# The following variables will be defined for your use:
+#   - ICU_FOUND             : were all of your specified components found (include dependencies)?
+#   - ICU_INCLUDE_DIRS      : ICU include directory
+#   - ICU_LIBRARIES         : ICU libraries
+#   - ICU_VERSION           : complete version of ICU (x.y.z)
+#   - ICU_MAJOR_VERSION     : major version of ICU
+#   - ICU_MINOR_VERSION     : minor version of ICU
+#   - ICU_PATCH_VERSION     : patch version of ICU
+#   - ICU_<COMPONENT>_FOUND : were <COMPONENT> found? (FALSE for non specified component if it is not a dependency)
+#
+# For windows or non standard installation, define ICU_ROOT variable to point to the root installation of ICU. Two ways:
+#   - run cmake with -DICU_ROOT=<PATH>
+#   - define an environment variable with the same name before running cmake
+# With cmake-gui, before pressing "Configure":
+#   1) Press "Add Entry" button
+#   2) Add a new entry defined as:
+#     - Name: ICU_ROOT
+#     - Type: choose PATH in the selection list
+#     - Press "..." button and select the root installation of ICU
+#
+# Example Usage:
+#
+#   1. Copy this file in the root of your project source directory
+#   2. Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt:
+#     set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+#   3. Finally call find_package() once, here are some examples to pick from
+#
+#   Require ICU 4.4 or later
+#     find_package(ICU 4.4 REQUIRED)
+#
+#   if(ICU_FOUND)
+#      include_directories(${ICU_INCLUDE_DIRS})
+#      add_executable(myapp myapp.c)
+#      target_link_libraries(myapp ${ICU_LIBRARIES})
+#   endif()
+
+#=============================================================================
+# Copyright (c) 2011-2012, julp
+#
+# Distributed under the OSI-approved BSD License
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#=============================================================================
+
+find_package(PkgConfig QUIET)
+
+########## Private ##########
+set(ICU_PUBLIC_VAR_NS "ICU")                          # Prefix for all ICU relative public variables
+set(ICU_PRIVATE_VAR_NS "_${ICU_PUBLIC_VAR_NS}")       # Prefix for all ICU relative internal variables
+set(PC_ICU_PRIVATE_VAR_NS "_PC${ICU_PRIVATE_VAR_NS}") # Prefix for all pkg-config relative internal variables
+
+function(icudebug _VARNAME)
+    if(${ICU_PUBLIC_VAR_NS}_DEBUG)
+        if(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
+            message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = ${${ICU_PUBLIC_VAR_NS}_${_VARNAME}}")
+        else(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
+            message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = <UNDEFINED>")
+        endif(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
+    endif(${ICU_PUBLIC_VAR_NS}_DEBUG)
+endfunction(icudebug)
+
+set(${ICU_PRIVATE_VAR_NS}_ROOT "")
+if(DEFINED ENV{ICU_ROOT})
+    set(${ICU_PRIVATE_VAR_NS}_ROOT "$ENV{ICU_ROOT}")
+endif(DEFINED ENV{ICU_ROOT})
+if (DEFINED ICU_ROOT)
+    set(${ICU_PRIVATE_VAR_NS}_ROOT "${ICU_ROOT}")
+endif(DEFINED ICU_ROOT)
+
+set(${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES )
+set(${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES )
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+    list(APPEND ${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin64")
+    list(APPEND ${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib64")
+endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
+list(APPEND ${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin")
+list(APPEND ${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib")
+
+set(${ICU_PRIVATE_VAR_NS}_COMPONENTS )
+# <icu component name> <library name 1> ... <library name N>
+macro(icu_declare_component _NAME)
+    list(APPEND ${ICU_PRIVATE_VAR_NS}_COMPONENTS ${_NAME})
+    set("${ICU_PRIVATE_VAR_NS}_COMPONENTS_${_NAME}" ${ARGN})
+endmacro(icu_declare_component)
+
+icu_declare_component(data icudata)
+icu_declare_component(uc   icuuc)         # Common and Data libraries
+icu_declare_component(i18n icui18n icuin) # Internationalization library
+icu_declare_component(io   icuio ustdio)  # Stream and I/O Library
+icu_declare_component(le   icule)         # Layout library
+icu_declare_component(lx   iculx)         # Paragraph Layout library
+
+########## Public ##########
+set(${ICU_PUBLIC_VAR_NS}_FOUND TRUE)
+set(${ICU_PUBLIC_VAR_NS}_LIBRARIES )
+set(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS )
+set(${ICU_PUBLIC_VAR_NS}_DEFINITIONS )
+foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS})
+    string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
+    set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE) # may be done in the icu_declare_component macro
+endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+
+# Check components
+if(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) # uc required at least
+    set(${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc)
+else(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+    list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc)
+    list(REMOVE_DUPLICATES ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+    foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
+        if(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
+            message(FATAL_ERROR "Unknown ICU component: ${${ICU_PRIVATE_VAR_NS}_COMPONENT}")
+        endif(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
+    endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+endif(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+
+# Includes
+find_path(
+    ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS
+    NAMES unicode/utypes.h utypes.h
+    HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT}
+    PATH_SUFFIXES "include"
+    DOC "Include directories for ICU"
+)
+
+if(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+    ########## <part to keep synced with tests/version/CMakeLists.txt> ##########
+    if(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uvernum.h") # ICU >= 4
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uvernum.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uversion.h") # ICU [2;4[
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uversion.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/utypes.h") # ICU [1.4;2[
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/utypes.h") # ICU 1.3
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    else()
+        message(FATAL_ERROR "ICU version header not found")
+    endif()
+
+    if(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *ICU_VERSION *\"([0-9]+)\".*") # ICU 1.3
+        # [1.3;1.4[ as #define ICU_VERSION "3" (no patch version, ie all 1.3.X versions will be detected as 1.3.0)
+        set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "1")
+        set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_1}")
+        set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "0")
+    elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION_MAJOR_NUM *([0-9]+).*")
+        set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}")
+        #
+        # Since version 4.9.1, ICU release version numbering was totaly changed, see:
+        # - http://site.icu-project.org/download/49
+        # - http://userguide.icu-project.org/design#TOC-Version-Numbers-in-ICU
+        #
+        if(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION LESS 49)
+            string(REGEX REPLACE ".*# *define *U_ICU_VERSION_MINOR_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}")
+            string(REGEX REPLACE ".*# *define *U_ICU_VERSION_PATCHLEVEL_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}")
+        else(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION LESS 49)
+            string(REGEX MATCH [0-9]$ ${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION}")
+            string(REGEX REPLACE [0-9]$ "" ${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION}")
+            string(REGEX REPLACE ".*# *define *U_ICU_VERSION_MINOR_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}")
+        endif(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION LESS 49)
+    elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION *\"(([0-9]+)(\\.[0-9]+)*)\".*") # ICU [1.4;1.8[
+        # [1.4;1.8[ as #define U_ICU_VERSION "1.4.1.2" but it seems that some 1.4.1(?:\.\d)? have releasing error and appears as 1.4.0
+        set(${ICU_PRIVATE_VAR_NS}_FULL_VERSION "${CMAKE_MATCH_1}") # copy CMAKE_MATCH_1, no longer valid on the following if
+        if(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)$")
+            set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}")
+            set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_2}")
+            set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "0")
+        elseif(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
+            set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}")
+            set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_2}")
+            set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "${CMAKE_MATCH_3}")
+        endif()
+    else()
+        message(FATAL_ERROR "failed to detect ICU version")
+    endif()
+    set(${ICU_PUBLIC_VAR_NS}_VERSION "${${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION}.${${ICU_PUBLIC_VAR_NS}_MINOR_VERSION}.${${ICU_PUBLIC_VAR_NS}_PATCH_VERSION}")
+    ########## </part to keep synced with tests/version/CMakeLists.txt> ##########
+
+    # Check dependencies (implies pkg-config)
+    if(PKG_CONFIG_FOUND)
+        set(${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
+        foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP})
+            pkg_check_modules(PC_ICU_PRIVATE_VAR_NS "icu-${${ICU_PRIVATE_VAR_NS}_COMPONENT}" QUIET)
+
+            if(${PC_ICU_PRIVATE_VAR_NS}_FOUND)
+                foreach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY ${PC_ICU_LIBRARIES})
+                    string(REGEX REPLACE "^icu" "" ${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY ${${PC_ICU_PRIVATE_VAR_NS}_LIBRARY})
+                    list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS ${${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY})
+                endforeach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY)
+            endif(${PC_ICU_PRIVATE_VAR_NS}_FOUND)
+        endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+        list(REMOVE_DUPLICATES ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+    endif(PKG_CONFIG_FOUND)
+
+    # Check libraries
+    foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
+        set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES )
+        set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES )
+        foreach(${ICU_PRIVATE_VAR_NS}_BASE_NAME ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT}})
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}")
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}d")
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${ICU_MAJOR_VERSION}${ICU_MINOR_VERSION}")
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${ICU_MAJOR_VERSION}${ICU_MINOR_VERSION}d")
+        endforeach(${ICU_PRIVATE_VAR_NS}_BASE_NAME)
+
+        find_library(
+            ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}
+            NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES}
+            HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT}
+            PATH_SUFFIXES ${_ICU_LIB_SUFFIXES}
+            DOC "Release libraries for ICU"
+        )
+        find_library(
+            ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}
+            NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES}
+            HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT}
+            PATH_SUFFIXES ${_ICU_LIB_SUFFIXES}
+            DOC "Debug libraries for ICU"
+        )
+
+        string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
+        if(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # both not found
+            set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE)
+            set("${ICU_PUBLIC_VAR_NS}_FOUND" FALSE)
+        else(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # one or both found
+            set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" TRUE)
+            if(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # release not found => we are in debug
+                set(${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT} "${${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}")
+            elseif(NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # debug not found => we are in release
+                set(${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT} "${${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}")
+            else() # both found
+                set(
+                    ${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT}
+                    optimized ${${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}
+                    debug ${${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}
+                )
+            endif()
+            list(APPEND ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT}})
+        endif(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
+    endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+endif(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+
+if(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+    include(FindPackageHandleStandardArgs)
+    if(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+        find_package_handle_standard_args(
+            ${ICU_PUBLIC_VAR_NS}
+            REQUIRED_VARS ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS
+            VERSION_VAR ${ICU_PUBLIC_VAR_NS}_VERSION
+        )
+    else(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+        find_package_handle_standard_args(${ICU_PUBLIC_VAR_NS} "ICU not found" ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+    endif(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+else(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+    if(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+        message(FATAL_ERROR "Could not find ICU include directory")
+    endif(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+endif(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+
+mark_as_advanced(
+    ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS
+    ${ICU_PUBLIC_VAR_NS}_LIBRARIES
+)
+
+# IN (args)
+icudebug("FIND_COMPONENTS")
+icudebug("FIND_REQUIRED")
+icudebug("FIND_QUIETLY")
+icudebug("FIND_VERSION")
+# OUT
+# Found
+icudebug("FOUND")
+icudebug("UC_FOUND")
+icudebug("I18N_FOUND")
+icudebug("IO_FOUND")
+icudebug("LE_FOUND")
+icudebug("LX_FOUND")
+icudebug("DATA_FOUND")
+# Linking
+icudebug("INCLUDE_DIRS")
+icudebug("LIBRARIES")
+# Version
+icudebug("MAJOR_VERSION")
+icudebug("MINOR_VERSION")
+icudebug("PATCH_VERSION")
+icudebug("VERSION")
diff --git a/cmake/FindPulseAudio.cmake b/cmake/FindPulseAudio.cmake
new file mode 100644 (file)
index 0000000..35bcbc2
--- /dev/null
@@ -0,0 +1,71 @@
+# Try to find the PulseAudio library
+#
+# Once done this will define:
+#
+#  PULSEAUDIO_FOUND - system has the PulseAudio library
+#  PULSEAUDIO_INCLUDE_DIR - the PulseAudio include directory
+#  PULSEAUDIO_LIBRARY - the libraries needed to use PulseAudio
+#  PULSEAUDIO_MAINLOOP_LIBRARY - the libraries needed to use PulsAudio Mainloop
+#
+# The minimum required version of PulseAudio can be specified using the
+# standard syntax, e.g. find_package(PulseAudio 1.0)
+
+# Copyright (c) 2008, Matthias Kretz, <kretz@kde.org>
+# Copyright (c) 2009, Marcus Hufgard, <Marcus.Hufgard@hufgard.de>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+# Support PULSEAUDIO_MINIMUM_VERSION for compatibility:
+if(NOT PulseAudio_FIND_VERSION)
+  set(PulseAudio_FIND_VERSION "${PULSEAUDIO_MINIMUM_VERSION}")
+endif(NOT PulseAudio_FIND_VERSION)
+
+# the minimum version of PulseAudio we require
+if(NOT PulseAudio_FIND_VERSION)
+  set(PulseAudio_FIND_VERSION "0.9.9")
+endif(NOT PulseAudio_FIND_VERSION)
+
+if (NOT WIN32)
+   include(FindPkgConfig)
+   pkg_check_modules(PC_PULSEAUDIO QUIET libpulse>=${PulseAudio_FIND_VERSION})
+   pkg_check_modules(PC_PULSEAUDIO_MAINLOOP QUIET libpulse-mainloop-glib)
+endif (NOT WIN32)
+
+find_path(PULSEAUDIO_INCLUDE_DIR pulse/pulseaudio.h
+   HINTS
+   ${PC_PULSEAUDIO_INCLUDEDIR}
+   ${PC_PULSEAUDIO_INCLUDE_DIRS}
+   )
+
+find_library(PULSEAUDIO_LIBRARY NAMES pulse libpulse
+   HINTS
+   ${PC_PULSEAUDIO_LIBDIR}
+   ${PC_PULSEAUDIO_LIBRARY_DIRS}
+   )
+
+find_library(PULSEAUDIO_MAINLOOP_LIBRARY NAMES pulse-mainloop pulse-mainloop-glib libpulse-mainloop-glib
+   HINTS
+   ${PC_PULSEAUDIO_LIBDIR}
+   ${PC_PULSEAUDIO_LIBRARY_DIRS}
+   )
+
+# Store the version number in the cache, so we don't have to search every time again:
+if (PULSEAUDIO_INCLUDE_DIR  AND NOT  PULSEAUDIO_VERSION)
+
+   # get PulseAudio's version from its version.h, and compare it with our minimum version
+   file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulse_version_h
+        REGEX ".*pa_get_headers_version\\(\\).*"
+        )
+   string(REGEX REPLACE ".*pa_get_headers_version\\(\\)\ \\(\"([0-9]+\\.[0-9]+\\.[0-9]+)[^\"]*\"\\).*" "\\1"
+                         _PULSEAUDIO_VERSION "${pulse_version_h}")
+
+   set(PULSEAUDIO_VERSION "${_PULSEAUDIO_VERSION}" CACHE STRING "Version number of PulseAudio" FORCE)
+endif (PULSEAUDIO_INCLUDE_DIR  AND NOT  PULSEAUDIO_VERSION)
+
+# Use the new extended syntax of find_package_handle_standard_args(), which also handles version checking:
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(PulseAudio REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR
+                                             VERSION_VAR PULSEAUDIO_VERSION )
+
+mark_as_advanced(PULSEAUDIO_INCLUDE_DIR PULSEAUDIO_LIBRARY PULSEAUDIO_MAINLOOP_LIBRARY)
diff --git a/cmake/FindUDev.cmake b/cmake/FindUDev.cmake
new file mode 100644 (file)
index 0000000..866608d
--- /dev/null
@@ -0,0 +1,53 @@
+# razor-de: Configure libudev environment
+#
+# UDEV_FOUND - system has a libudev
+# UDEV_INCLUDE_DIR - where to find header files
+# UDEV_LIBRARIES - the libraries to link against udev
+# UDEV_STABLE - it's true when is the version greater or equals to 143 - version when the libudev was stabilized in its API
+#
+# copyright (c) 2011 Petr Vanek <petr@scribus.info>
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+
+FIND_PATH(
+    UDEV_INCLUDE_DIR
+    libudev.h
+    /usr/include
+    /usr/local/include
+    ${UDEV_PATH_INCLUDES}
+)
+
+FIND_LIBRARY(
+    UDEV_LIBRARIES
+    NAMES udev libudev
+    PATHS
+        /usr/lib${LIB_SUFFIX}
+        /usr/local/lib${LIB_SUFFIX}
+        ${UDEV_PATH_LIB}
+)
+
+IF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
+    SET(UDEV_FOUND "YES")
+    execute_process(COMMAND pkg-config --atleast-version=143 libudev RESULT_VARIABLE UDEV_STABLE)
+    # retvale is 0 of the condition is "true" so we need to negate the value...
+    if (UDEV_STABLE)
+       set(UDEV_STABLE 0)
+    else (UDEV_STABLE)
+       set(UDEV_STABLE 1)
+    endif (UDEV_STABLE)
+    message(STATUS "libudev stable: ${UDEV_STABLE}")
+ENDIF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
+
+IF (UDEV_FOUND)
+    MESSAGE(STATUS "Found UDev: ${UDEV_LIBRARIES}")
+    MESSAGE(STATUS "   include: ${UDEV_INCLUDE_DIR}")
+ELSE (UDEV_FOUND)
+    MESSAGE(STATUS "UDev not found.")
+    MESSAGE(STATUS "UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include")
+    MESSAGE(STATUS "      currently found includes: ${UDEV_INCLUDE_DIR}")
+    MESSAGE(STATUS "UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib")
+    MESSAGE(STATUS "      currently found libs: ${UDEV_LIBRARIES}")
+    IF (UDev_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "Could not find UDev library")
+    ENDIF (UDev_FIND_REQUIRED)
+ENDIF (UDEV_FOUND)
diff --git a/cmake/RazorInstallConfigPath.cmake b/cmake/RazorInstallConfigPath.cmake
new file mode 100644 (file)
index 0000000..f7a8b99
--- /dev/null
@@ -0,0 +1,25 @@
+# XDG standards expects system-wide configuration files in the /etc/xdg/razor 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 RAZOR_ETC_XDG_DIRECTORY)
+    message(STATUS "*********************************************************************")
+    message(STATUS "RAZOR_ETC_XDG_DIRECTORY will be autodetected now")
+    message(STATUS "You can set it manually with -DRAZOR_ETC_XDG_DIRECTORY=<value>")
+
+    if (NOT QT_QMAKE_EXECUTABLE)
+        message(FATAL_ERROR "RAZOR_ETC_XDG_DIRECTORY: qmake not found or wrongly detected (inlude before qt configured?)")
+    endif (NOT QT_QMAKE_EXECUTABLE)
+
+    execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_CONFIGURATION
+                           OUTPUT_VARIABLE RAZOR_ETC_XDG_DIRECTORY
+                           OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+    message(STATUS "RAZOR_ETC_XDG_DIRECTORY autodetected as '${RAZOR_ETC_XDG_DIRECTORY}'")
+    message(STATUS "*********************************************************************")
+else ()
+    message(STATUS "RAZOR_ETC_XDG_DIRECTORY already set: ${RAZOR_ETC_XDG_DIRECTORY}")
+endif ()
+
diff --git a/cmake/RazorLibSuffix.cmake b/cmake/RazorLibSuffix.cmake
new file mode 100644 (file)
index 0000000..c321670
--- /dev/null
@@ -0,0 +1,28 @@
+# some system (rpm builds) setup LIB_SUFFIX for cmake. If there is no set, try to get it from system
+IF (NOT DEFINED LIB_SUFFIX AND NOT DEFINED LIB_SUFFIX_ALREADY_SET)
+    MESSAGE(STATUS "*********************************************************************")
+    MESSAGE(STATUS "LIB_SUFFIX variable is not defined. It will be autodetected now")
+    MESSAGE(STATUS "You can set it manually with -DLIB_SUFFIX=<value> (64 for example)")
+
+    # All 32bit system have empty lib suffix
+    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+        # If there is lib64 dir, set suffix to 64
+        if(IS_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib64)
+            set(LIB_SUFFIX 64)
+        elseif(IS_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)
+            set(LIB_SUFFIX "")
+        else()
+            message(WARNING "LIB_SUFFIX cannot be autodetected. No ${CMAKE_INSTALL_PREFIX}/lib neither ${CMAKE_INSTALL_PREFIX}/lib64 found.")
+            set(LIB_SUFFIX "")
+        endif()
+    else()
+        set(LIB_SUFFIX "")
+    endif()
+    
+    set(LIB_SUFFIX_ALREADY_SET 1)
+
+    message(STATUS "LIB_SUFFIX autodetected as '${LIB_SUFFIX}', libraries will be installed into ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
+    MESSAGE(STATUS "*********************************************************************")
+else ()
+    message(STATUS "LIB_SUFFIX already set: ${LIB_SUFFIX}")
+ENDIF ()
diff --git a/cmake/RazorTranslate.cmake b/cmake/RazorTranslate.cmake
new file mode 100644 (file)
index 0000000..5bbc0b2
--- /dev/null
@@ -0,0 +1,275 @@
+#  funtion razor_translate_ts(qm_files 
+#                           SOURCES sources ... 
+#                           [TRANSLATION_DIR] translation_directory
+#                           [INSTALLATION_DIR] qm_install_directory
+#                          )
+#     out: qm_files 
+#     generates commands to create .ts.src and .qm files from sources. 
+#     The generated filenames can be found in qm_files.
+#
+#     in: sources 
+#     List of the h, cpp and ui files
+#
+#     in: translation_directory
+#     A relative path to the directory with .ts files, it is relative 
+#     to the CMakeList.txt. By default is "translations"
+#
+#     in: qm_install_directory
+#     A full path to the directory n which will be installed .qm files.
+#     By default is "${CMAKE_INSTALL_PREFIX}/share/razor/${PROJECT_NAME}" 
+
+
+MACRO(QT4_ADD_TRANSLATION_FIXED _qm_files)
+  FOREACH (_current_FILE ${ARGN})
+    GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
+    GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME)
+    #Extract the real extension ............
+    STRING(REPLACE ".ts" "" qm ${qm})
+    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(output_location)
+      SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
+    ENDIF(output_location)
+
+    ADD_CUSTOM_COMMAND(OUTPUT ${qm}
+       COMMAND ${QT_LRELEASE_EXECUTABLE}
+       ARGS -silent -removeidentical ${_abs_FILE} -qm ${qm}
+       DEPENDS ${_abs_FILE}
+    )
+    SET(${_qm_files} ${${_qm_files}} ${qm})
+  ENDFOREACH (_current_FILE)
+ENDMACRO(QT4_ADD_TRANSLATION_FIXED)
+
+if(NOT TARGET UpdateTsFiles)
+  add_custom_target(UpdateTsFiles DEPENDS)
+endif()
+
+if(NOT TARGET UpdateTxFile)
+  file(WRITE ${CMAKE_BINARY_DIR}/tx/_updateTxFile.sh
+        "echo '[main]'\n"
+        "echo 'host = https://www.transifex.com'\n"
+        "echo 'minimum_perc = 1'\n"
+        "echo ''\n"
+        "for f in `ls ${CMAKE_BINARY_DIR}/tx/*.tx.sh`; do\n"
+        " sh $f;\n"
+        "done\n"
+      )
+
+  add_custom_target(UpdateTxFile  
+    COMMAND sh ${CMAKE_BINARY_DIR}/tx/_updateTxFile.sh > ${CMAKE_SOURCE_DIR}/.tx/config
+  )
+endif()
+
+
+function(razor_translate_ts _qmFiles)
+    set(_translationDir "translations")
+    set(_installDir "${CMAKE_INSTALL_PREFIX}/share/razor/${PROJECT_NAME}")
+    
+    # Parse arguments ***************************************
+    set(_state "")
+    foreach (_arg ${ARGN})
+        if (
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "SOURCES_I_HATE_CMAKE") OR
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "TRANSLATION_DIR_I_HATE_CMAKE") OR
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "INSTALLATION_DIR_I_HATE_CMAKE") OR
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "TS_SRC_FILE_I_HATE_CMAKE")        
+           )        
+            set(_state ${_arg})
+      
+        else()
+            if("${_state}" STREQUAL "SOURCES")
+                get_filename_component (__file ${_arg} ABSOLUTE)
+                set(_sources  ${_sources} ${__file})
+                set(_sourcesSpace  "${_sourcesSpace} ${__file}")
+            elseif("${_state}" STREQUAL "TRANSLATION_DIR")
+                set(_translationDir ${_arg})       
+                set(_state "")
+
+            elseif("${_state}" STREQUAL "INSTALLATION_DIR")
+                set(_installDir ${_arg})       
+                set(_state "")
+
+            elseif("${_state}" STREQUAL "TS_SRC_FILE")
+                set(_tsSrcFile ${_arg})       
+                set(_state "")
+        
+            else()  
+                MESSAGE(FATAL_ERROR 
+                  "Unknown argument '${_arg}'.\n"
+                  "See ${CMAKE_CURRENT_LIST_FILE} for more information.\n"
+                )
+            endif()  
+        endif()
+    endforeach(_arg)
+
+    get_filename_component (_translationDir ${_translationDir} ABSOLUTE)
+    if ("${_tsSrcFile}" STREQUAL "") 
+        set(_tsSrcFile  "${_translationDir}/${PROJECT_NAME}.ts.src")
+    endif()
+    
+    get_filename_component (_tsSrcFile  ${_tsSrcFile} ABSOLUTE)
+    get_filename_component (_tsSrcFileName  ${_tsSrcFile} NAME)
+    get_filename_component (_tsSrcFileNameWE  ${_tsSrcFile} NAME_WE)
+      
+    # TS.SRC file *******************************************    
+    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/updateTsFile.sh
+        "#/bin/sh\n"
+        "\n"
+        "mkdir -p ${_translationDir} 2>/dev/null\n"
+        "cd ${_translationDir} && "
+        "${QT_LUPDATE_EXECUTABLE} -locations none -target-language en_US ${_sourcesSpace} -ts ${_tsSrcFile}.ts &&"
+        "mv ${_tsSrcFile}.ts ${_tsSrcFile}\n"
+        "grep -q 'source' '${_tsSrcFile}' || rm '${_tsSrcFile}'\n"
+    )
+
+    add_custom_target(Update_${_tsSrcFileName}
+        COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/updateTsFile.sh
+        DEPENDS ${_sources}
+        VERBATIM
+    )
+  
+    add_dependencies(UpdateTsFiles Update_${_tsSrcFileName})
+    
+    # TX file ***********************************************
+    set(_txFile "${CMAKE_BINARY_DIR}/tx/${_tsSrcFileName}.tx.sh")
+    string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _tx_translationDir ${_translationDir})
+    string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _tx_tsSrcFile ${_tsSrcFile})
+    
+    file(WRITE ${_txFile}
+        "[ -f ${_tsSrcFile} ] || exit 0\n"
+        "echo '[razor-qt.${_tsSrcFileNameWE}]'\n"
+        "echo 'type = QT'\n"
+        "echo 'source_lang = en'\n"
+        "echo 'source_file = ${_tx_tsSrcFile}'\n"
+        "echo 'file_filter = ${_tx_translationDir}/${_tsSrcFileNameWE}_<lang>.ts'\n"
+        "echo ''\n"
+    )
+
+    # translate.h file *************************************
+    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/razortranslate.h
+        "#ifndef RAZOR_TRANSLATE_H\n"
+        "#include <QtCore/QLocale>\n"
+        "#include <QtCore/QTranslator>\n"
+        "#include <QtCore/QLibraryInfo>\n"
+        "class RazorTranslator {\n"
+        "public:\n"
+        "  static void translate()\n"
+        "  {\n"
+        "    QString locale = QLocale::system().name();\n"
+
+        "    QTranslator *qtTranslator = new QTranslator(qApp);\n"
+        "    qtTranslator->load(\"qt_\" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));\n"
+        "    qApp->installTranslator(qtTranslator);\n"
+
+        "    QTranslator *appTranslator = new QTranslator(qApp);\n"
+        "    appTranslator->load(QString(\"${_installDir}/${PROJECT_NAME}_%1.qm\").arg(locale));\n"
+        "    qApp->installTranslator(appTranslator);\n"
+        "  }\n"
+        "};\n"
+
+        "#define TRANSLATE_APP  RazorTranslator::translate();\n"
+        "#endif // RAZOR_TRANSLATE_H\n"
+    )
+
+    # QM files **********************************************    
+    file(GLOB _tsFiles ${_translationDir}/${_tsSrcFileNameWE}_*.ts)    
+    QT4_ADD_TRANSLATION_FIXED(_qmFilesLocal ${_tsFiles})
+    install(FILES ${_qmFilesLocal} DESTINATION ${_installDir})
+    
+    set(${_qmFiles} ${_qmFilesLocal} PARENT_SCOPE)
+endfunction(razor_translate_ts)
+
+
+#**********************************************************
+# DESKTOP files
+#**********************************************************
+
+function(razor_translate_desktop _RESULT)
+    set(_translationDir "translations")
+    
+    # Parse arguments ***************************************
+    set(_state "")
+    foreach (_arg ${ARGN})  
+        if (
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "SOURCES_I_HATE_CMAKE") OR
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "TRANSLATION_DIR_I_HATE_CMAKE")
+           )        
+
+            set(_state ${_arg})
+      
+        else()
+            if("${_state}" STREQUAL "SOURCES")
+                get_filename_component (__file ${_arg} ABSOLUTE)
+                set(_sources  ${_sources} ${__file})
+                #set(_sources  ${_sources} ${_arg})
+            elseif("${_state}" STREQUAL "TRANSLATION_DIR")
+                set(_translationDir ${_arg})       
+                set(_state "")
+
+            else()  
+                MESSAGE(FATAL_ERROR 
+                  "Unknown argument '${_arg}'.\n"
+                  "See ${CMAKE_CURRENT_LIST_FILE} for more information.\n"
+                )
+            endif()  
+        endif()
+    endforeach(_arg)    
+
+    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}
+            ${_translationDir}/local/${_fileName}_*${_fileExt}
+        )    
+  
+        set(_pattern "'\\[.*]\\s*='")
+        if (_translations)
+            add_custom_command(OUTPUT ${_outFile}
+                COMMAND grep -v "'#TRANSLATIONS_DIR='" ${_inFile} > ${_outFile}
+                COMMAND grep --no-filename ${_pattern} ${_translations} >> ${_outFile}
+                COMMENT "Generating ${_fileName}${_fileExt}"
+            )
+        else()
+            add_custom_command(OUTPUT ${_outFile}
+                COMMAND grep -v "'#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 '[razor-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(razor_translate_desktop)
+
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644 (file)
index 0000000..8c32e20
--- /dev/null
@@ -0,0 +1,19 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+       message(FATAL_ERROR "Cannot find install manifest: "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt"")
+endif()
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+       message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+       if((EXISTS "$ENV{DESTDIR}${file}") OR (IS_SYMLINK "$ENV{DESTDIR}${file}"))
+               exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+                       OUTPUT_VARIABLE rm_out
+                       RETURN_VALUE rm_retval)
+               if(NOT "${rm_retval}" STREQUAL 0)
+                       message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+               endif()
+       else()
+               message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+       endif()
+endforeach()
diff --git a/cmake/create_pkgconfig_file.cmake b/cmake/create_pkgconfig_file.cmake
new file mode 100644 (file)
index 0000000..2c02a9c
--- /dev/null
@@ -0,0 +1,25 @@
+#
+# Write a pkg-config pc file for given "name" with "decription"
+# Arguments:
+#   name: a library name (withoud "lib" prefix and "so" suffixes
+#   desc: a desription string
+#
+macro (create_pkgconfig_file name desc)
+    set(_pkgfname "${CMAKE_CURRENT_BINARY_DIR}/${name}.pc")
+    message(STATUS "${name}: writing pkgconfig file ${_pkgfname}")
+
+    file(WRITE "${_pkgfname}" "# file generated by razor-qt cmake build
+prefix=${CMAKE_INSTALL_PREFIX}
+libdir=\${prefix}/lib${LIB_SUFFIX}
+includedir=\${prefix}/include
+
+Name: ${name}
+Description: ${desc}
+Version: ${RAZOR_VERSION}
+Libs: -L\${libdir} -l${name}
+Cflags: -I\${includedir}
+
+")
+
+    install(FILES ${_pkgfname} DESTINATION lib${LIB_SUFFIX}/pkgconfig)
+endmacro()
diff --git a/cmake/razortranslate.h.in b/cmake/razortranslate.h.in
new file mode 100644 (file)
index 0000000..d68d418
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef RAZOR_TRANSLATE_H
+
+#include <QtCore/QLocale>
+#include <QtCore/QTranslator>
+#include <QtCore/QLibraryInfo>
+
+class RazorTranslator {
+public:
+    static void translate()
+    {
+        QString locale = QLocale::system().name();
+
+        QTranslator *qtTranslator = new QTranslator(qApp);
+        qtTranslator->load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+        qApp->installTranslator(qtTranslator);
+
+        QTranslator *appTranslator = new QTranslator(qApp);
+        appTranslator->load(QString("${TRANSLATIONS_DIR}/${PROJECT_NAME}_%1.qm").arg(locale));
+        qApp->installTranslator(appTranslator);
+    }
+};
+
+#define TRANSLATE_APP  RazorTranslator::translate();
+#endif // RAZOR_TRANSLATE_H
\ No newline at end of file