Autogen: Add AUTOMOC_DEPEND_FILTERS test

This commit is contained in:
Sebastian Holtermann
2017-02-22 21:08:36 +01:00
parent 70ebf35cda
commit 94e3f82cf1
10 changed files with 46 additions and 6 deletions

View File

@@ -247,10 +247,7 @@ if (NOT QT_TEST_VERSION STREQUAL 4)
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${mocPluginBinDir}/jsonFiles/StyleC.json")
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${mocPluginBinDir}/jsonFiles/sub/StyleD.json")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin"
)
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPluginBinDir}")
file(TIMESTAMP "${style_a_file}" style_a_after "${timeformat}")
file(TIMESTAMP "${style_b_file}" style_b_after "${timeformat}")
@@ -269,6 +266,23 @@ if (NOT QT_TEST_VERSION STREQUAL 4)
if (NOT style_d_after GREATER style_d_before)
message(SEND_ERROR "file (${style_d_file}) should have changed!")
endif()
# Test custom macro
file(TIMESTAMP "${style_c_file}" style_c_before "${timeformat}")
file(TIMESTAMP "${style_d_file}" style_d_before "${timeformat}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${mocPluginBinDir}/jsonFiles/StyleC_Custom.json")
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${mocPluginBinDir}/jsonFiles/sub/StyleD_Custom.json")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPluginBinDir}")
file(TIMESTAMP "${style_c_file}" style_c_after "${timeformat}")
file(TIMESTAMP "${style_d_file}" style_d_after "${timeformat}")
if (NOT style_c_after GREATER style_c_before)
message(SEND_ERROR "file (${style_c_file}) should have changed!")
endif()
if (NOT style_d_after GREATER style_d_before)
message(SEND_ERROR "file (${style_d_file}) should have changed!")
endif()
endif()
# -- Test

View File

@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.8)
set(CMAKE_AUTOMOC_DEPEND_FILTERS
"A_CUSTOM_MACRO"
"[\n][ \t]*A_CUSTOM_MACRO[ \t\r\n]*\\([^,]+,[ \t\r\n]*\"([^\"]+)\""
)
if (NOT QT_TEST_VERSION STREQUAL 5)
message(SEND_ERROR "Invalid Qt version specified.")
endif()
@@ -9,8 +14,10 @@ if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
endif()
configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json @ONLY)
configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json @ONLY)
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_Custom.json)
# Enable automoc
set(CMAKE_AUTOMOC TRUE)

View File

@@ -1,6 +1,7 @@
#ifndef STYLEA_HPP
#define STYLEA_HPP
#include "StyleCommon.hpp"
#include <QStylePlugin>
class StyleA : public QStylePlugin
@@ -8,6 +9,7 @@ class StyleA : public QStylePlugin
Q_OBJECT
// Json file in local directory
Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json")
A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg)
public:
QStyle* create(const QString& key);
};

View File

@@ -0,0 +1 @@
{ "Keys": [ "Rocket", "Starbuster" ] }

View File

@@ -1,6 +1,7 @@
#ifndef STYLEB_HPP
#define STYLEB_HPP
#include "StyleCommon.hpp"
#include <QStylePlugin>
class StyleB : public QStylePlugin
@@ -8,6 +9,7 @@ class StyleB : public QStylePlugin
Q_OBJECT
// Json file in local subdirectory
Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json")
A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg)
public:
QStyle* create(const QString& key);
};

View File

@@ -1,6 +1,7 @@
#ifndef STYLEC_HPP
#define STYLEC_HPP
#include "StyleCommon.hpp"
#include <QStylePlugin>
class StyleC : public QStylePlugin
@@ -8,6 +9,7 @@ class StyleC : public QStylePlugin
Q_OBJECT
// Json file in global root directory
Q_PLUGIN_METADATA(IID "org.styles.C" FILE "StyleC.json")
A_CUSTOM_MACRO(SomeArg, "StyleC_Custom.json", AnotherArg)
public:
QStyle* create(const QString& key);
};

View File

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

View File

@@ -1,6 +1,7 @@
#ifndef STYLED_HPP
#define STYLED_HPP
#include "StyleCommon.hpp"
#include <QStylePlugin>
class StyleD : public QStylePlugin
@@ -8,6 +9,7 @@ class StyleD : public QStylePlugin
Q_OBJECT
// Json file in global sub director
Q_PLUGIN_METADATA(IID "org.styles.D" FILE "sub/StyleD.json")
A_CUSTOM_MACRO(SomeArg, "sub/StyleD_Custom.json", AnotherArg)
public:
QStyle* create(const QString& key);
};

View File

@@ -1,6 +1,7 @@
#ifndef STYLEE_HPP
#define STYLEE_HPP
#include "StyleCommon.hpp"
#include <QStylePlugin>
class StyleE : public QStylePlugin
@@ -8,6 +9,7 @@ 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);
};

View File

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