summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_moc_macro_target
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake/test_moc_macro_target')
-rw-r--r--tests/auto/cmake/test_moc_macro_target/CMakeLists.txt32
-rw-r--r--tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake15
-rw-r--r--tests/auto/cmake/test_moc_macro_target/interface/myinterface.h2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/mywrapobject.h2
6 files changed, 51 insertions, 4 deletions
diff --git a/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt b/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
index eaf8bda1bb..f9ca294bd2 100644
--- a/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
+++ b/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
@@ -11,7 +14,14 @@ qt_generate_moc(main_gen_test.cpp
"${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc"
TARGET QtGenerateMacroTest
)
+list(APPEND CMAKE_AUTOMOC_MACRO_NAMES MySpecialMacro)
add_executable(QtGenerateMacroTest main_gen_test.cpp "${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc")
+get_target_property(current_macros QtGenerateMacroTest AUTOMOC_MACRO_NAMES)
+
+if(NOT "${CMAKE_AUTOMOC_MACRO_NAMES}" STREQUAL "${current_macros}")
+ message(FATAL_ERROR "Expected ${CMAKE_AUTOMOC_MACRO_NAMES} but received ${current_macros}")
+endif()
+
target_include_directories(QtGenerateMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
target_link_libraries(QtGenerateMacroTest PRIVATE Qt6::Core)
@@ -21,3 +31,25 @@ qt_wrap_cpp(moc_file mywrapobject.h
add_executable(QtWrapMacroTest main_wrap_test.cpp ${moc_file})
target_include_directories(QtWrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
target_link_libraries(QtWrapMacroTest PRIVATE Qt::Core)
+
+target_compile_definitions(QtWrapMacroTest PRIVATE "$<$<BOOL:TRUE>:MY_OPTION>"
+ "$<$<BOOL:TRUE>:DEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int$<COMMA> int$<ANGLE-R> &i)>"
+ "DEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int, int> &i)")
+
+set(parameters_file_base "${CMAKE_CURRENT_BINARY_DIR}/moc_mywrapobject.cpp_parameters")
+# check if generator is multi-config
+if(CMAKE_CONFIGURATION_TYPES)
+ set(parameters_file "${parameters_file_base}_$<CONFIG>")
+else()
+ if(NOT CMAKE_BUILD_TYPE STREQUAL "")
+ set(parameters_file "${parameters_file_base}_${CMAKE_BUILD_TYPE}")
+ else()
+ set(parameters_file "${parameters_file_base}")
+ endif()
+endif()
+
+add_custom_command(TARGET QtWrapMacroTest
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} "-DPARAMETERS_FILE_PATH=${parameters_file}" -P check_moc_parameters.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
diff --git a/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake b/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake
new file mode 100644
index 0000000000..4ca8fab119
--- /dev/null
+++ b/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake
@@ -0,0 +1,15 @@
+
+function(check_parameters file_path)
+ file(READ ${file_path} file_content)
+ foreach(compile_option IN ITEMS "-DDEFINE_CMDLINE_SIGNAL" "-DMY_OPTION")
+ string(REGEX MATCHALL "${compile_option}" matches ${file_content})
+ list(LENGTH matches matches_length)
+ if(matches_length GREATER 1)
+ message(FATAL_ERROR "${compile_option} is defined multiple times in ${file_path}")
+ elseif(matches_length EQUAL 0)
+ message(FATAL_ERROR "${compile_option} is not defined in ${file_path}")
+ endif()
+ endforeach()
+endfunction()
+
+check_parameters(${PARAMETERS_FILE_PATH})
diff --git a/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h b/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h
index 60ff102037..3c18c9a10d 100644
--- a/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h
+++ b/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h
@@ -1,5 +1,5 @@
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYINTERFACE_H
#define MYINTERFACE_H
diff --git a/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp b/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
index 5ffb740e9d..ef58aa025a 100644
--- a/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
+++ b/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
diff --git a/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp b/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
index 2f403d95c6..bf4b6193fe 100644
--- a/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
+++ b/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
diff --git a/tests/auto/cmake/test_moc_macro_target/mywrapobject.h b/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
index 7398cce9ee..28030a5832 100644
--- a/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
+++ b/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
@@ -1,5 +1,5 @@
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYWRAPOBJECT_H
#define MYWRAPOBJECT_H