summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-03-30 13:54:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-03-30 13:54:09 (GMT)
commitc0092247fe380ec9df065c4fbdafcd610ef09ddc (patch)
tree880ca70591ba149b719f49c0bb79455291997f92 /Tests
parent16b4d5fc8413f30c2c746d793f82f106626dd742 (diff)
parentca7c76269b0dbf899f206c6d0c6d7b26fd0af223 (diff)
downloadCMake-c0092247fe380ec9df065c4fbdafcd610ef09ddc.zip
CMake-c0092247fe380ec9df065c4fbdafcd610ef09ddc.tar.gz
CMake-c0092247fe380ec9df065c4fbdafcd610ef09ddc.tar.bz2
Merge topic 'ninja-automoc-cycle' into release-3.20
ca7c76269b Tests: Add test for Ninja automoc dependency cyle 54ad3e4958 autogen: Don't include SKIP_AUTOMOC files in depfile Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Jörg Bornemann <joerg.bornemann@qt.io> Acked-by: Craig Scott <craig.scott@crascit.com> Merge-request: !5956
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt9
-rw-r--r--Tests/RunCMake/Ninja/MyWindow.cpp7
-rw-r--r--Tests/RunCMake/Ninja/MyWindow.h16
-rw-r--r--Tests/RunCMake/Ninja/MyWindow.ui5
-rw-r--r--Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake8
-rw-r--r--Tests/RunCMake/Ninja/RunCMakeTest.cmake23
6 files changed, 51 insertions, 17 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 91fe6ca..5ee0612 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -141,6 +141,9 @@ endif()
if(CMAKE_GENERATOR MATCHES "Make")
add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU})
endif()
+if(CMake_TEST_Qt5)
+ find_package(Qt5Widgets QUIET NO_MODULE)
+endif()
if(CMAKE_GENERATOR MATCHES "Ninja")
set(Ninja_ARGS
-DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION}
@@ -151,6 +154,9 @@ if(CMAKE_GENERATOR MATCHES "Ninja")
endif()
if(CMake_TEST_Qt5 AND Qt5Core_FOUND)
list(APPEND Ninja_ARGS -DCMake_TEST_Qt5=1 -DQt5Core_DIR=${Qt5Core_DIR} -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION})
+ if(Qt5Widgets_FOUND)
+ list(APPEND Ninja_ARGS -DQt5Widgets_DIR=${Qt5Widgets_DIR})
+ endif()
endif()
add_RunCMake_test(Ninja)
set(NinjaMultiConfig_ARGS
@@ -190,9 +196,6 @@ if(CMake_TEST_APPLE_SILICON)
add_RunCMake_test(AppleSilicon)
endif()
set(autogen_with_qt5 FALSE)
-if(CMake_TEST_Qt5)
- find_package(Qt5Widgets QUIET NO_MODULE)
-endif()
if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND)
set(autogen_with_qt5 TRUE)
endif ()
diff --git a/Tests/RunCMake/Ninja/MyWindow.cpp b/Tests/RunCMake/Ninja/MyWindow.cpp
new file mode 100644
index 0000000..d87c2e9
--- /dev/null
+++ b/Tests/RunCMake/Ninja/MyWindow.cpp
@@ -0,0 +1,7 @@
+#include "MyWindow.h"
+
+MyWindow::MyWindow(QWidget* parent)
+ : QWidget(parent)
+{
+ this->m_ui.setupUi(this);
+}
diff --git a/Tests/RunCMake/Ninja/MyWindow.h b/Tests/RunCMake/Ninja/MyWindow.h
new file mode 100644
index 0000000..c267610
--- /dev/null
+++ b/Tests/RunCMake/Ninja/MyWindow.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <QWidget>
+
+#include "ui_MyWindow.h"
+
+class MyWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit MyWindow(QWidget* parent = nullptr);
+
+private:
+ Ui::MyWindow m_ui;
+};
diff --git a/Tests/RunCMake/Ninja/MyWindow.ui b/Tests/RunCMake/Ninja/MyWindow.ui
new file mode 100644
index 0000000..fbf294c
--- /dev/null
+++ b/Tests/RunCMake/Ninja/MyWindow.ui
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MyWindow</class>
+ <widget class="QWidget" name="MyWindow"/>
+</ui>
diff --git a/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake
index 7456608..46b840f 100644
--- a/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake
+++ b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake
@@ -8,6 +8,14 @@ add_library(simple_lib SHARED simple_lib.cpp)
add_executable(app_with_qt app.cpp app_qt.cpp)
target_link_libraries(app_with_qt PRIVATE simple_lib Qt5::Core)
+if(Qt5Widgets_DIR)
+ find_package(Qt5Widgets REQUIRED)
+ qt5_wrap_ui(_headers MyWindow.ui)
+ add_executable(app_with_widget app.cpp MyWindow.cpp ${_headers})
+ target_link_libraries(app_with_widget PRIVATE Qt5::Widgets)
+ target_include_directories(app_with_widget PRIVATE "${CMAKE_BINARY_DIR}")
+endif()
+
add_subdirectory(QtSubDir1)
add_subdirectory(QtSubDir2)
add_subdirectory(QtSubDir3)
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 1b252cd..0c0619d 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -186,16 +186,6 @@ function(sleep delay)
endif()
endfunction(sleep)
-function(touch path)
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E touch ${path}
- RESULT_VARIABLE result
- )
- if(NOT result EQUAL 0)
- message(FATAL_ERROR "failed to touch main ${path} file.")
- endif()
-endfunction(touch)
-
macro(ninja_escape_path path out)
string(REPLACE "\$ " "\$\$" "${out}" "${path}")
string(REPLACE " " "\$ " "${out}" "${${out}}")
@@ -264,8 +254,8 @@ build build.ninja: RERUN ${escaped_build_ninja_dep} || ${escaped_ninja_output_pa
# Test regeneration rules run in order.
set(main_cmakelists "${RunCMake_SOURCE_DIR}/CMakeLists.txt")
sleep(${fs_delay})
- touch("${main_cmakelists}")
- touch("${build_ninja_dep}")
+ file(TOUCH "${main_cmakelists}")
+ file(TOUCH "${build_ninja_dep}")
run_ninja("${top_build_dir}")
file(TIMESTAMP "${main_cmakelists}" mtime_main_cmakelists UTC)
file(TIMESTAMP "${sub_build_ninja}" mtime_sub_build_ninja UTC)
@@ -329,14 +319,14 @@ run_ChangeBuildType()
function(run_Qt5AutoMocDeps)
if(CMake_TEST_Qt5 AND CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5AutoMocDeps-build)
- set(RunCMake_TEST_OPTIONS "-DQt5Core_DIR=${Qt5Core_DIR}")
+ set(RunCMake_TEST_OPTIONS "-DQt5Core_DIR=${Qt5Core_DIR}" "-DQt5Widgets_DIR=${Qt5Widgets_DIR}")
run_cmake(Qt5AutoMocDeps)
unset(RunCMake_TEST_OPTIONS)
# Build the project.
run_ninja("${RunCMake_TEST_BINARY_DIR}")
# Touch just the library source file, which shouldn't cause a rerun of AUTOMOC
# for app_with_qt target.
- touch("${RunCMake_SOURCE_DIR}/simple_lib.cpp")
+ file(TOUCH "${RunCMake_SOURCE_DIR}/simple_lib.cpp")
# Build and assert that AUTOMOC was not run for app_with_qt.
run_ninja("${RunCMake_TEST_BINARY_DIR}")
if(ninja_stdout MATCHES "Automatic MOC for target app_with_qt")
@@ -352,6 +342,11 @@ function(run_Qt5AutoMocDeps)
message(FATAL_ERROR
"AUTOMOC should not have executed for 'sub_exe_2' target:\nstdout:\n${ninja_stdout}")
endif()
+ # Touch a header file to make sure an automoc dependency cycle is not introduced.
+ file(TOUCH "${RunCMake_SOURCE_DIR}/MyWindow.h")
+ run_ninja("${RunCMake_TEST_BINARY_DIR}")
+ # Need to run a second time to hit the dependency cycle.
+ run_ninja("${RunCMake_TEST_BINARY_DIR}")
endif()
endfunction()
run_Qt5AutoMocDeps()