Make it possible for CMake to find linguist and dbus tools.
authorStephen Kelly <stephen.kelly@kdab.com>
Thu, 1 Dec 2011 12:33:30 +0000 (13:33 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Dec 2011 17:18:22 +0000 (18:18 +0100)
This includes the BSD licenced CMake macros for invoking
those tools.

Change-Id: I57c2994af2220353a845b6622b89291de349008d
Reviewed-by: Clinton Stimpson <clinton@elemtech.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Sanity-Review: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>

13 files changed:
src/linguist/Qt5LinguistToolsConfig.cmake.in [new file with mode: 0644]
src/linguist/Qt5LinguistToolsMacros.cmake [new file with mode: 0644]
src/linguist/linguist.pro
src/qdbus/Qt5DBusToolsConfig.cmake.in [new file with mode: 0644]
src/qdbus/Qt5DBusToolsMacros.cmake [new file with mode: 0644]
src/qdbus/qdbus.pro
tests/manual/cmake/CMakeLists.txt [new file with mode: 0644]
tests/manual/cmake/pass1/CMakeLists.txt [new file with mode: 0644]
tests/manual/cmake/pass1/mydbusobject.cpp [new file with mode: 0644]
tests/manual/cmake/pass1/mydbusobject.h [new file with mode: 0644]
tests/manual/cmake/pass2/CMakeLists.txt [new file with mode: 0644]
tests/manual/cmake/pass2/myi18nobject.cpp [new file with mode: 0644]
tests/manual/cmake/pass2/myobject_de.ts [new file with mode: 0644]

diff --git a/src/linguist/Qt5LinguistToolsConfig.cmake.in b/src/linguist/Qt5LinguistToolsConfig.cmake.in
new file mode 100644 (file)
index 0000000..bb4c127
--- /dev/null
@@ -0,0 +1,7 @@
+
+get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+
+set(QT_LRELEASE_EXECUTABLE \"${_qt5_install_prefix}/bin/lrelease$$CMAKE_BIN_SUFFIX\")
+set(QT_LUPDATE_EXECUTABLE \"${_qt5_install_prefix}/bin/lupdate$$CMAKE_BIN_SUFFIX\")
+
+include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5LinguistToolsMacros.cmake\")
diff --git a/src/linguist/Qt5LinguistToolsMacros.cmake b/src/linguist/Qt5LinguistToolsMacros.cmake
new file mode 100644 (file)
index 0000000..72efb4b
--- /dev/null
@@ -0,0 +1,112 @@
+#=============================================================================
+# 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(MacroAddFileDependencies)
+
+MACRO (QT5_EXTRACT_OPTIONS _qt5_files _qt5_options)
+  SET(${_qt5_files})
+  SET(${_qt5_options})
+  SET(_QT5_DOING_OPTIONS FALSE)
+  FOREACH(_currentArg ${ARGN})
+    IF ("${_currentArg}" STREQUAL "OPTIONS")
+      SET(_QT5_DOING_OPTIONS TRUE)
+    ELSE ("${_currentArg}" STREQUAL "OPTIONS")
+      IF(_QT5_DOING_OPTIONS)
+        LIST(APPEND ${_qt5_options} "${_currentArg}")
+      ELSE(_QT5_DOING_OPTIONS)
+        LIST(APPEND ${_qt5_files} "${_currentArg}")
+      ENDIF(_QT5_DOING_OPTIONS)
+    ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
+  ENDFOREACH(_currentArg)
+ENDMACRO (QT5_EXTRACT_OPTIONS)
+
+
+MACRO(QT5_CREATE_TRANSLATION _qm_files)
+   QT5_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN})
+   SET(_my_sources)
+   SET(_my_dirs)
+   SET(_my_tsfiles)
+   SET(_ts_pro)
+   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(_ext MATCHES "ts")
+       IF(NOT _ext)
+         LIST(APPEND _my_dirs ${_abs_FILE})
+       ELSE(NOT _ext)
+         LIST(APPEND _my_sources ${_abs_FILE})
+       ENDIF(NOT _ext)
+     ENDIF(_ext MATCHES "ts")
+   ENDFOREACH(_file)
+   FOREACH(_ts_file ${_my_tsfiles})
+     IF(_my_sources)
+       # make a .pro 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)
+       SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
+       SET(_pro_srcs)
+       FOREACH(_pro_src ${_my_sources})
+         SET(_pro_srcs "${_pro_srcs} \"${_pro_src}\"")
+       ENDFOREACH(_pro_src ${_my_sources})
+       FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
+     ENDIF(_my_sources)
+     ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
+        COMMAND ${QT_LUPDATE_EXECUTABLE}
+        ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
+        DEPENDS ${_my_sources} ${_ts_pro} VERBATIM)
+   ENDFOREACH(_ts_file)
+   QT5_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
+ENDMACRO(QT5_CREATE_TRANSLATION)
+
+
+MACRO(QT5_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_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 ${_abs_FILE} -qm ${qm}
+       DEPENDS ${_abs_FILE} VERBATIM
+    )
+    SET(${_qm_files} ${${_qm_files}} ${qm})
+  ENDFOREACH (_current_FILE)
+ENDMACRO(QT5_ADD_TRANSLATION)
index 248c89e..1b2a1b7 100644 (file)
@@ -4,3 +4,14 @@ SUBDIRS  = \
     lupdate \
     lconvert
 !no-png:!contains(QT_CONFIG, no-gui):SUBDIRS += linguist
+
+win32:CMAKE_BIN_SUFFIX = ".exe"
+CMAKE_RELATIVE_INSTALL_DIR = "../../../"
+cmake_linguist_config_file.input = $$PWD/Qt5LinguistToolsConfig.cmake.in
+cmake_linguist_config_file.output = $$OUT_PWD/Qt5LinguistToolsConfig.cmake
+QMAKE_SUBSTITUTES += cmake_linguist_config_file
+
+cmake_linguist_tools_files.files += $$cmake_linguist_config_file.output $$PWD/Qt5LinguistToolsMacros.cmake
+cmake_linguist_tools_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5LinguistTools
+cmake_linguist_tools_files.CONFIG = no_check_exists
+INSTALLS += cmake_linguist_tools_files
diff --git a/src/qdbus/Qt5DBusToolsConfig.cmake.in b/src/qdbus/Qt5DBusToolsConfig.cmake.in
new file mode 100644 (file)
index 0000000..1d9907e
--- /dev/null
@@ -0,0 +1,7 @@
+
+get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+
+set(QT_DBUSCPP2XML_EXECUTABLE \"${_qt5_install_prefix}/bin/qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+set(QT_DBUSXML2CPP_EXECUTABLE \"${_qt5_install_prefix}/bin/qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+
+include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5DBusToolsMacros.cmake\")
diff --git a/src/qdbus/Qt5DBusToolsMacros.cmake b/src/qdbus/Qt5DBusToolsMacros.cmake
new file mode 100644 (file)
index 0000000..30bc27c
--- /dev/null
@@ -0,0 +1,161 @@
+#=============================================================================
+# 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(MacroAddFileDependencies)
+
+MACRO (QT5_EXTRACT_OPTIONS _qt5_files _qt5_options)
+  SET(${_qt5_files})
+  SET(${_qt5_options})
+  SET(_QT5_DOING_OPTIONS FALSE)
+  FOREACH(_currentArg ${ARGN})
+    IF ("${_currentArg}" STREQUAL "OPTIONS")
+      SET(_QT5_DOING_OPTIONS TRUE)
+    ELSE ("${_currentArg}" STREQUAL "OPTIONS")
+      IF(_QT5_DOING_OPTIONS)
+        LIST(APPEND ${_qt5_options} "${_currentArg}")
+      ELSE(_QT5_DOING_OPTIONS)
+        LIST(APPEND ${_qt5_files} "${_currentArg}")
+      ENDIF(_QT5_DOING_OPTIONS)
+    ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
+  ENDFOREACH(_currentArg)
+ENDMACRO (QT5_EXTRACT_OPTIONS)
+
+
+MACRO(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
+  GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
+  SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
+  SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
+  SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
+
+  GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE)
+  IF(_nonamespace)
+    SET(_params -N -m)
+  ELSE(_nonamespace)
+    SET(_params -m)
+  ENDIF(_nonamespace)
+
+  GET_SOURCE_FILE_PROPERTY(_classname ${_interface} CLASSNAME)
+  IF(_classname)
+    SET(_params ${_params} -c ${_classname})
+  ENDIF(_classname)
+
+  GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE)
+  IF(_include)
+    SET(_params ${_params} -i ${_include})
+  ENDIF(_include)
+
+  ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+      COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
+      DEPENDS ${_infile} VERBATIM)
+
+  SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
+
+  QT5_GENERATE_MOC(${_header} ${_moc})
+
+  SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
+  MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
+
+ENDMACRO(QT5_ADD_DBUS_INTERFACE)
+
+
+MACRO(QT5_ADD_DBUS_INTERFACES _sources)
+  FOREACH (_current_FILE ${ARGN})
+    GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
+    # get the part before the ".xml" suffix
+    STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
+    STRING(TOLOWER ${_basename} _basename)
+    QT5_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
+  ENDFOREACH (_current_FILE)
+ENDMACRO(QT5_ADD_DBUS_INTERFACES)
+
+
+MACRO(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
+  QT5_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN})
+
+  GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
+  GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
+
+  IF (_customName)
+    if (IS_ABSOLUTE ${_customName})
+      get_filename_component(_containingDir ${_customName} PATH)
+      if (NOT EXISTS ${_containingDir})
+        file(MAKE_DIRECTORY "${_containingDir}")
+      endif()
+      SET(_target ${_customName})
+    else()
+      SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
+    endif()
+  ELSE (_customName)
+    SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
+  ENDIF (_customName)
+
+  ADD_CUSTOM_COMMAND(OUTPUT ${_target}
+      COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
+      DEPENDS ${_in_file} VERBATIM
+  )
+ENDMACRO(QT5_GENERATE_DBUS_INTERFACE)
+
+
+MACRO(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
+  GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
+
+  SET(_optionalBasename "${ARGV4}")
+  IF (_optionalBasename)
+    SET(_basename ${_optionalBasename} )
+  ELSE (_optionalBasename)
+    STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
+    STRING(TOLOWER ${_basename} _basename)
+  ENDIF (_optionalBasename)
+
+  SET(_optionalClassName "${ARGV5}")
+  SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
+  SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
+  SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
+
+  IF(_optionalClassName)
+    ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+       COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
+       DEPENDS ${_infile} VERBATIM
+    )
+  ELSE(_optionalClassName)
+    ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+       COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
+       DEPENDS ${_infile} VERBATIM
+     )
+  ENDIF(_optionalClassName)
+
+  QT5_GENERATE_MOC(${_header} ${_moc})
+  SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
+  MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
+
+  SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
+ENDMACRO(QT5_ADD_DBUS_ADAPTOR)
index a264882..33897cb 100644 (file)
@@ -1,3 +1,14 @@
 TEMPLATE = subdirs
 SUBDIRS = qdbus qdbusxml2cpp qdbuscpp2xml
 !contains(QT_CONFIG, no-gui): SUBDIRS += qdbusviewer
+
+win32:CMAKE_BIN_SUFFIX = ".exe"
+CMAKE_RELATIVE_INSTALL_DIR = "../../../"
+cmake_dbus_config_file.input = $$PWD/Qt5DBusToolsConfig.cmake.in
+cmake_dbus_config_file.output = $$OUT_PWD/Qt5DBusToolsConfig.cmake
+QMAKE_SUBSTITUTES += cmake_dbus_config_file
+
+cmake_dbus_tools_files.files += $$cmake_dbus_config_file.output $$PWD/Qt5DBusToolsMacros.cmake
+cmake_dbus_tools_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5DBusTools
+cmake_dbus_tools_files.CONFIG = no_check_exists
+INSTALLS += cmake_dbus_tools_files
diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c866630
--- /dev/null
@@ -0,0 +1,30 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(qmake_cmake_files)
+
+macro(_do_build _dir)
+    try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${_dir}
+        ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}
+        ${_dir}
+        OUTPUT_VARIABLE Out
+    )
+endmacro()
+
+macro(expect_pass _dir)
+    _do_build(${_dir})
+    if (NOT Result)
+        message(SEND_ERROR "Build failed: ${Out}")
+    endif()
+endmacro()
+
+macro(expect_fail _dir)
+    _do_build(${_dir})
+    if (Result)
+        message(SEND_ERROR "Build should fail, but did not: ${Out}")
+    endif()
+endmacro()
+
+expect_pass(pass1)
+expect_pass(pass2)
+
diff --git a/tests/manual/cmake/pass1/CMakeLists.txt b/tests/manual/cmake/pass1/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5ac6080
--- /dev/null
@@ -0,0 +1,34 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(pass1)
+
+find_package(Qt5Core REQUIRED)
+find_package(Qt5Xml REQUIRED)
+find_package(Qt5DBus REQUIRED)
+find_package(Qt5DBusTools REQUIRED)
+
+include_directories(
+    ${Qt5Core_INCLUDE_DIRS}
+    ${Qt5DBus_INCLUDE_DIRS}
+)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(my_srcs mydbusobject.cpp)
+
+qt5_wrap_cpp(moc_files mydbusobject.h)
+
+qt5_generate_dbus_interface(
+    mydbusobject.h
+    ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml
+)
+
+qt5_add_dbus_adaptor(my_srcs
+    ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml
+    mydbusobject.h
+    MyDBusObject
+)
+
+add_executable(myobject ${my_srcs} ${moc_files})
+target_link_libraries(myobject ${Qt5DBus_LIBRARIES})
diff --git a/tests/manual/cmake/pass1/mydbusobject.cpp b/tests/manual/cmake/pass1/mydbusobject.cpp
new file mode 100644 (file)
index 0000000..71d4809
--- /dev/null
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mydbusobject.h"
+#include "mydbusobjectadaptor.h"
+
+MyDBusObject::MyDBusObject(QObject *parent)
+    : QObject(parent)
+{
+    new MyDBusObjectAdaptor(this);
+    emit someSignal();
+}
+
+int main(int argc, char **argv)
+{
+    MyDBusObject myDBusObject;
+    return 0;
+}
diff --git a/tests/manual/cmake/pass1/mydbusobject.h b/tests/manual/cmake/pass1/mydbusobject.h
new file mode 100644 (file)
index 0000000..d4fda9d
--- /dev/null
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MYDBUSOBJECT_H
+#define MYDBUSOBJECT_H
+
+#include <QObject>
+
+class MyDBusObject : public QObject
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.qtProject.Tests.MyDBusObject")
+public:
+    MyDBusObject(QObject *parent = 0);
+
+signals:
+    void someSignal();
+};
+
+#endif
diff --git a/tests/manual/cmake/pass2/CMakeLists.txt b/tests/manual/cmake/pass2/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2394504
--- /dev/null
@@ -0,0 +1,18 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(pass2)
+
+find_package(Qt5Core REQUIRED)
+find_package(Qt5LinguistTools REQUIRED)
+
+include_directories(
+  ${Qt5Core_INCLUDE_DIRS}
+)
+
+set(my_srcs myi18nobject.cpp)
+
+qt5_create_translation(qm_files ${my_srcs} myobject_de.ts)
+
+add_executable(myobject ${my_srcs} ${qm_files})
+target_link_libraries(myobject ${Qt5Core_LIBRARIES})
diff --git a/tests/manual/cmake/pass2/myi18nobject.cpp b/tests/manual/cmake/pass2/myi18nobject.cpp
new file mode 100644 (file)
index 0000000..e1e0ce6
--- /dev/null
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QCoreApplication>
+#include <QTranslator>
+
+int main(int argc, char **argv)
+{
+    QCoreApplication app(argc, argv);
+    QTranslator *myappTranslator = new QTranslator;
+    QString localeName = QLocale::system().name();
+    myappTranslator->load("myobject_" + localeName + ".qm", qApp->applicationDirPath());
+    myappTranslator->setObjectName("myobject_" + localeName);
+    app.installTranslator(myappTranslator);
+
+    qDebug() << QObject::tr("Hello, world!");
+    return 0;
+}
diff --git a/tests/manual/cmake/pass2/myobject_de.ts b/tests/manual/cmake/pass2/myobject_de.ts
new file mode 100644 (file)
index 0000000..3b8f8bb
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="de_DE">
+<context>
+    <name>QObject</name>
+    <message>
+        <location filename="myi18nobject.cpp" line="15"/>
+        <source>Hello, world!</source>
+        <translation>Hallo, Welt</translation>
+    </message>
+</context>
+</TS>