Autogen: Tests: Extend CMAKE_AUTOMOC_DEPEND_FILTERS rebuild test

The CMAKE_AUTOMOC_DEPEND_FILTERS must also detect filtered file changes
from files that are registered to AUTOMOC by a `#include "moc_<NAME>.cpp"`
statement.
This commit is contained in:
Sebastian Holtermann
2017-09-03 22:26:09 +02:00
parent 932656527b
commit e5c6610aba
12 changed files with 71 additions and 31 deletions

View File

@@ -171,9 +171,16 @@ endif()
# -- Test
# Tests Q_PLUGIN_METADATA json file change detection
if (NOT QT_TEST_VERSION STREQUAL 4)
# Utility variables
set(timeformat "%Y%j%H%M%S")
set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin")
set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin")
# Initial buid
try_compile(MOC_PLUGIN
"${CMAKE_CURRENT_BINARY_DIR}/mocPlugin"
"${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin"
"${mocPlugBinDir}"
"${mocPlugSrcDir}"
mocPlugin
CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
@@ -183,29 +190,32 @@ if (NOT QT_TEST_VERSION STREQUAL 4)
message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}")
endif()
set(timeformat "%Y%j%H%M%S")
set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin")
set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin")
find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
# - Ensure that the timestamp will change.
# - Change the json files referenced by Q_PLUGIN_METADATA
# - Rebuild
file(TIMESTAMP "${plAFile}" plABefore "${timeformat}")
file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}")
file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}")
# Ensure that the timestamp will change and change the json files
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}")
file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}")
file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}")
if (plAAfter GREATER plABefore)
message(SEND_ERROR "file (${plAFile}) should not have changed!")
@@ -219,21 +229,35 @@ if (NOT QT_TEST_VERSION STREQUAL 4)
if (NOT plDAfter GREATER plDBefore)
message(SEND_ERROR "file (${plDFile}) should have changed!")
endif()
if (NOT plEAfter GREATER plEBefore)
message(SEND_ERROR "file (${plEFile}) should have changed!")
endif()
# Test custom macro
# - Ensure that the timestamp will change.
# - Change the json files referenced by A_CUSTOM_MACRO
# - Rebuild
file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}")
if (NOT plCAfter GREATER plCBefore)
message(SEND_ERROR "file (${plCFile}) should have changed!")
endif()
if (NOT plDAfter GREATER plDBefore)
message(SEND_ERROR "file (${plDFile}) should have changed!")
endif()
if (NOT plEAfter GREATER plEBefore)
message(SEND_ERROR "file (${plEFile}) should have changed!")
endif()
endif()

View File

@@ -16,9 +16,11 @@ if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
endif()
configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json)
configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json)
configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json)
configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json)
configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json)
configure_file(jsonIn/StyleE.json jsonFiles/StyleE.json)
configure_file(jsonIn/StyleE.json jsonFiles/StyleE_Custom.json)
# Enable automoc
set(CMAKE_AUTOMOC TRUE)

View File

@@ -1,13 +1,13 @@
#ifndef STYLEA_HPP
#define STYLEA_HPP
#include "StyleCommon.hpp"
#include "UtilityMacros.hpp"
#include <QStylePlugin>
class StyleA : public QStylePlugin
{
Q_OBJECT
// Json file in local directory
// Json file in source local directory
Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json")
A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg)
public:

View File

@@ -1,13 +1,13 @@
#ifndef STYLEB_HPP
#define STYLEB_HPP
#include "StyleCommon.hpp"
#include "UtilityMacros.hpp"
#include <QStylePlugin>
class StyleB : public QStylePlugin
{
Q_OBJECT
// Json file in local subdirectory
// Json file in source local subdirectory
Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json")
A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg)
public:

View File

@@ -1,7 +1,7 @@
#ifndef STYLEC_HPP
#define STYLEC_HPP
#include "StyleCommon.hpp"
#include "UtilityMacros.hpp"
#include <QStylePlugin>
class StyleC : public QStylePlugin

View File

@@ -1,7 +1,7 @@
#ifndef STYLED_HPP
#define STYLED_HPP
#include "StyleCommon.hpp"
#include "UtilityMacros.hpp"
#include <QStylePlugin>
class StyleD : public QStylePlugin

View File

@@ -4,3 +4,6 @@ QStyle* StyleE::create(const QString& key)
{
return 0;
}
// AUTOMOC the StyleEInclude.hpp header
#include "moc_StyleEInclude.cpp"

View File

@@ -1,17 +1,10 @@
#ifndef STYLEE_HPP
#define STYLEE_HPP
#include "StyleCommon.hpp"
#include <QStylePlugin>
class StyleE : public QStylePlugin
{
Q_OBJECT
// No Json file
Q_PLUGIN_METADATA(IID "org.styles.E")
A_CUSTOM_MACRO(SomeArg, InvalidFileArg, AnotherArg)
public:
QStyle* create(const QString& key);
};
// The included file is not in the sources list and won't be detected by
// AUTOMOC source file with the same base name.
// It is registered to AUTOMOCed via a moc_<NAME>.cpp include in StyleE.cpp
// though.
#include "StyleEInclude.hpp"
#endif

View File

@@ -0,0 +1,17 @@
#ifndef STYLEE_INCLUDE_HPP
#define STYLEE_INCLUDE_HPP
#include "UtilityMacros.hpp"
#include <QStylePlugin>
class StyleE : public QStylePlugin
{
Q_OBJECT
// Json files in global root directory
Q_PLUGIN_METADATA(IID "org.styles.E" FILE "StyleE.json")
A_CUSTOM_MACRO(SomeArg, "StyleE_Custom.json", AnotherArg)
public:
QStyle* create(const QString& key);
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef STYLECOMMON_HPP
#define STYLECOMMON_HPP
#ifndef UTILITYMACROS_HPP
#define UTILITYMACROS_HPP
// Empty test macro definition
#define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations)

View File

@@ -1 +1 @@
{ "Keys": [ "Rocket", "StarbusterB" ] }
{ "Keys": [ "Red", "Green" ] }

View File

@@ -0,0 +1 @@
{ "Keys": [ "Floor", "Ceiling" ] }