summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2022-02-08 10:56:29 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-17 21:07:03 +0000
commitd363b9904408e92f645fda15574e00b608392b90 (patch)
tree5269ded06e452be60d19ceceee6e7c5940353aef
parent3736ef8a87386783c74524bcf5d40a6f36610d58 (diff)
cmake: Add support for using multiple ifcodegen calls in one CMakeLists.txt
This is done by changing the default value of the OUTPUT_DIR argument to be template specific. Fixes: QTBUG-100410 Change-Id: I807d10ce60965b0c1c0a06db8276e22d4658e183 Reviewed-by: Robert Griebl <robert.griebl@qt.io> (cherry picked from commit c4999abff6e2808169c89d77acf723f859ec6efa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/ifvehiclefunctions/CMakeLists.txt2
-rw-r--r--src/interfaceframework/Qt6InterfaceFrameworkMacros.cmake14
-rw-r--r--tests/auto/core/ifcodegen/CMakeLists.txt1
-rw-r--r--tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/CMakeLists.txt63
-rw-r--r--tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/backend_simulator.cpp43
5 files changed, 119 insertions, 4 deletions
diff --git a/src/ifvehiclefunctions/CMakeLists.txt b/src/ifvehiclefunctions/CMakeLists.txt
index 9b02ec90..86c26464 100644
--- a/src/ifvehiclefunctions/CMakeLists.txt
+++ b/src/ifvehiclefunctions/CMakeLists.txt
@@ -9,6 +9,7 @@ qt_ifcodegen_generate(
IDL_FILES ifvehiclefunctions.qface
TEMPLATE frontend
MODULE_NAME QtIfVehicleFunctions
+ OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}
EXTRA_HEADERS_OUTPUT_DIR ${QT_BUILD_DIR}/src/ifvehiclefunctions
)
make_directory(${QT_BUILD_DIR}/src/ifvehiclefunctions)
@@ -30,6 +31,7 @@ qt_ifcodegen_extend_target(IfVehicleFunctions
PREFIX VEHICLEFUNCTIONS
IDL_FILES ifvehiclefunctions.qface
TEMPLATE frontend
+ OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}
)
qt_internal_add_qml_module(IfVehicleFunctions
diff --git a/src/interfaceframework/Qt6InterfaceFrameworkMacros.cmake b/src/interfaceframework/Qt6InterfaceFrameworkMacros.cmake
index 3a1f86e0..5800dd90 100644
--- a/src/interfaceframework/Qt6InterfaceFrameworkMacros.cmake
+++ b/src/interfaceframework/Qt6InterfaceFrameworkMacros.cmake
@@ -97,8 +97,11 @@ function(internal_ifcodegen_import)
set(OUTPUT_DIR ${ARG_OUTPUT_DIR})
if (NOT DEFINED ARG_OUTPUT_DIR)
- set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
+ get_filename_component(TEMPLATE_NAME "${ARG_TEMPLATE}" NAME)
+ set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TEMPLATE_NAME})
endif()
+ make_directory(${OUTPUT_DIR})
+
if (NOT DEFINED ARG_IDL_FILES)
message(FATAL_ERROR
"Called without input files. Please specify some using the IDL_FILES argument."
@@ -165,7 +168,7 @@ endmacro()
# searched for. (OPTIONAL)
#
# OUTPUT_DIR: Overwrite the default output path. By default the generated code
-# will be put in ${CMAKE_CURRENT_BINARY_DIR}. Use this argument to provide
+# will be put in ${CMAKE_CURRENT_BINARY_DIR}/<template-name>. Use this argument to provide
# a replacement. (OPTIONAL)
#
# EXTRA_HEADERS_OUTPUT_DIR: An additional location where all headers will be
@@ -207,8 +210,11 @@ function(qt6_ifcodegen_generate)
endif()
set(OUTPUT_DIR ${ARG_OUTPUT_DIR})
if (NOT DEFINED ARG_OUTPUT_DIR)
- set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
+ get_filename_component(TEMPLATE_NAME "${ARG_TEMPLATE}" NAME)
+ set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TEMPLATE_NAME})
endif()
+ make_directory(${OUTPUT_DIR})
+
if (NOT DEFINED ARG_IDL_FILES)
message(FATAL_ERROR
"Called without input files. Please specify some using the IDL_FILES argument."
@@ -401,7 +407,7 @@ endif()
# searched for. (OPTIONAL)
#
# OUTPUT_DIR: Overwrite the default output path. By default the generated code
-# will be put in ${CMAKE_CURRENT_BINARY_DIR}. Use this argument to provide
+# will be put in ${CMAKE_CURRENT_BINARY_DIR}/<template-name>. Use this argument to provide
# a replacement. (OPTIONAL)
#
# EXTRA_HEADERS_OUTPUT_DIR: An additional location where all headers will be
diff --git a/tests/auto/core/ifcodegen/CMakeLists.txt b/tests/auto/core/ifcodegen/CMakeLists.txt
index 0875a648..3e816f04 100644
--- a/tests/auto/core/ifcodegen/CMakeLists.txt
+++ b/tests/auto/core/ifcodegen/CMakeLists.txt
@@ -2,6 +2,7 @@
add_subdirectory(custom-template)
add_subdirectory(org-example-echo)
+add_subdirectory(flat-cmake-hierarchy-test)
add_subdirectory(org-example-echo-noprivate)
add_subdirectory(org-example-echo-noanno)
add_subdirectory(include-test)
diff --git a/tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/CMakeLists.txt b/tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/CMakeLists.txt
new file mode 100644
index 00000000..0137f116
--- /dev/null
+++ b/tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/CMakeLists.txt
@@ -0,0 +1,63 @@
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+qt6_add_library(echo_flat_frontend)
+
+# Interface Framework Generator:
+qt6_ifcodegen_extend_target(echo_flat_frontend
+ IDL_FILES ../org.example.echo.qface
+ PREFIX ECHO
+ TEMPLATE frontend
+)
+
+target_link_libraries(echo_flat_frontend PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::InterfaceFramework
+ Qt::InterfaceFrameworkPrivate
+ Qt::Qml
+ Qt::Quick
+)
+
+####### BACKEND #######
+
+qt_add_plugin(echo_flat_simulator)
+set_target_properties(echo_flat_simulator PROPERTIES LIBRARY_OUTPUT_DIRECTORY interfaceframework)
+target_sources(echo_flat_simulator PRIVATE
+ backend_simulator.cpp
+)
+
+# Interface Framework Generator:
+qt6_ifcodegen_extend_target(echo_flat_simulator
+ IDL_FILES ../org.example.echo.qface
+ TEMPLATE backend_simulator
+)
+
+target_link_libraries(echo_flat_simulator PUBLIC
+ echo_flat_frontend
+ Qt::Core
+ Qt::Gui
+ Qt::InterfaceFramework
+)
+
+####### TEST #######
+
+file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.cpp)
+qt_internal_add_test(tst_flat-cmake-hierarchy
+ SOURCES
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.cpp
+ PUBLIC_LIBRARIES
+ echo_flat_frontend
+ Qt::Core
+ Qt::InterfaceFramework
+ Qt::Test
+)
+
+# Interface Framework Generator:
+qt6_ifcodegen_extend_target(tst_flat-cmake-hierarchy
+ IDL_FILES ../org.example.echo.qface
+ TEMPLATE test
+)
diff --git a/tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/backend_simulator.cpp b/tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/backend_simulator.cpp
new file mode 100644
index 00000000..aea054ee
--- /dev/null
+++ b/tests/auto/core/ifcodegen/flat-cmake-hierarchy-test/backend_simulator.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtInterfaceFramework module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "echobackend.h"
+#include "echozonedbackend.h"
+#include "echomodulesimulatorplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+extern QVector<QIfFeatureInterface *> echoInterfaceBuilder(EchomoduleSimulatorPlugin *plugin)
+{
+ QVector<QIfFeatureInterface *> res;
+ res << new EchoBackend(plugin);
+ res << new EchoZonedBackend(plugin);
+ return res;
+}
+
+QT_END_NAMESPACE