summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/Ninja
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2021-03-26 11:38:56 -0400
committerKyle Edwards <kyle.edwards@kitware.com>2021-03-29 15:17:11 -0400
commitca7c76269b0dbf899f206c6d0c6d7b26fd0af223 (patch)
tree54736625c89098463990f3766bd830906d17eaa9 /Tests/RunCMake/Ninja
parent54ad3e4958952f5e0472a163f0c565592be412f9 (diff)
downloadcmake-ca7c76269b0dbf899f206c6d0c6d7b26fd0af223.tar.gz
Tests: Add test for Ninja automoc dependency cyle
Diffstat (limited to 'Tests/RunCMake/Ninja')
-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
5 files changed, 45 insertions, 14 deletions
diff --git a/Tests/RunCMake/Ninja/MyWindow.cpp b/Tests/RunCMake/Ninja/MyWindow.cpp
new file mode 100644
index 0000000000..d87c2e913e
--- /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 0000000000..c267610416
--- /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 0000000000..fbf294c845
--- /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 74566086c6..46b840f4c3 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 1b252cd188..0c0619dbfe 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()