Merge topic 'Qt-auto-generators'

9c87d9c Add automatic rcc invocation for Qt.
84218e1 Add automatic uic invocation for Qt.
94a0ca6 Record which files are skipped by automoc.
18fb758 Run the main executable created in the autogen tests.
e485ba1 Rename the QtAutomoc tests to QtAutogen.
7ce65c3 Add extra checks for the AUTOMOC target property.
32771fc Update output messages for generic use.
f371ab5 Rename RunAutomoc to RunAutogen.
85b3d6e Extract an SetupAutoMocTarget method.
ca124a1 Rename the AutomocInfo.cmake file to be more generic.
a342c9f Move some makefile definitions up away from moc-specific code.
98632ef Add the AUTOGEN_TARGETS_FOLDER and obsolete AUTOMOC_TARGETS_FOLDER.
63378ba Rename some variables to reflect broader scope.
97f1aa3 Rename method to reflect generic use.
4abb111 Rename local variable to reflect generic use.
03878c9 Move variable set to where it is used.
...
This commit is contained in:
Brad King 2013-10-28 15:23:09 -04:00 committed by CMake Topic Stage
commit fcbe435c23
66 changed files with 1287 additions and 264 deletions

View File

@ -10,6 +10,7 @@ Properties of Global Scope
.. toctree::
/prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS
/prop_gbl/AUTOGEN_TARGETS_FOLDER
/prop_gbl/AUTOMOC_TARGETS_FOLDER
/prop_gbl/DEBUG_CONFIGURATIONS
/prop_gbl/DISABLED_FEATURES
@ -72,6 +73,10 @@ Properties on Targets
/prop_tgt/ARCHIVE_OUTPUT_NAME
/prop_tgt/AUTOMOC_MOC_OPTIONS
/prop_tgt/AUTOMOC
/prop_tgt/AUTOUIC
/prop_tgt/AUTOUIC_OPTIONS
/prop_tgt/AUTORCC
/prop_tgt/AUTORCC_OPTIONS
/prop_tgt/BUILD_WITH_INSTALL_RPATH
/prop_tgt/BUNDLE_EXTENSION
/prop_tgt/BUNDLE
@ -235,6 +240,8 @@ Properties on Source Files
.. toctree::
/prop_sf/ABSTRACT
/prop_sf/AUTOUIC_OPTIONS
/prop_sf/AUTORCC_OPTIONS
/prop_sf/COMPILE_DEFINITIONS_CONFIG
/prop_sf/COMPILE_DEFINITIONS
/prop_sf/COMPILE_FLAGS

View File

@ -155,6 +155,10 @@ Variables that Control the Build
/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY
/variable/CMAKE_AUTOMOC_MOC_OPTIONS
/variable/CMAKE_AUTOMOC
/variable/CMAKE_AUTORCC
/variable/CMAKE_AUTORCC_OPTIONS
/variable/CMAKE_AUTOUIC
/variable/CMAKE_AUTOUIC_OPTIONS
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
/variable/CMAKE_CONFIG_POSTFIX
/variable/CMAKE_DEBUG_POSTFIX

View File

@ -0,0 +1,8 @@
AUTOGEN_TARGETS_FOLDER
----------------------
Name of FOLDER for ``*_automoc`` targets that are added automatically by CMake for targets for which AUTOMOC is enabled.
If not set, CMake uses the FOLDER property of the parent target as a
default value for this property. See also the documentation for the
FOLDER target property and the AUTOMOC target property.

View File

@ -3,6 +3,8 @@ AUTOMOC_TARGETS_FOLDER
Name of FOLDER for ``*_automoc`` targets that are added automatically by CMake for targets for which AUTOMOC is enabled.
This property is obsolete. Use AUTOGEN_TARGETS_FOLDER instead.
If not set, CMake uses the FOLDER property of the parent target as a
default value for this property. See also the documentation for the
FOLDER target property and the AUTOMOC target property.

View File

@ -0,0 +1,14 @@
AUTORCC_OPTIONS
---------------
Additional options for rcc when using autorcc (see the :prop_tgt:`AUTORCC` target
property)
This property holds additional command line options which will be used when
rcc is executed during the build via autorcc, i.e. it is equivalent to the
optional OPTIONS argument of the qt4_add_resources() macro.
By default it is empty.
The options set on the .qrc source file may override :prop_tgt:`AUTORCC_OPTIONS` set
on the target.

View File

@ -0,0 +1,14 @@
AUTOUIC_OPTIONS
---------------
Additional options for uic when using autouic (see the :prop_tgt:`AUTOUIC` target property)
This property holds additional command line options
which will be used when uic is executed during the build via autouic,
i.e. it is equivalent to the optional OPTIONS argument of the
qt4_wrap_ui() macro.
By default it is empty.
The options set on the .ui source file may override :prop_tgt:`AUTOUIC_OPTIONS` set
on the target.

21
Help/prop_tgt/AUTORCC.rst Normal file
View File

@ -0,0 +1,21 @@
AUTORCC
-------
Should the target be processed with autorcc (for Qt projects).
AUTORCC is a boolean specifying whether CMake will handle
the Qt rcc code generator automatically, i.e. without having to use
the QT4_ADD_RESOURCES() or QT5_ADD_RESOURCES() macro. Currently Qt4 and Qt5 are
supported.
When this property is set to TRUE, CMake will handle .qrc files added
as target sources at build time and invoke rcc accordingly.
This property is initialized by the value of the :variable:`CMAKE_AUTORCC`
variable if it is set when a target is created.
Additional command line options for rcc can be set via the
:prop_sf:`AUTORCC_OPTIONS` source file property on the .qrc file.
The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the
autouic targets together in an IDE, e.g. in MSVS.

View File

@ -0,0 +1,17 @@
AUTORCC_OPTIONS
---------------
Additional options for rcc when using autorcc (see the :prop_tgt:`AUTORCC` target property)
This property holds additional command line options
which will be used when rcc is executed during the build via autorcc,
i.e. it is equivalent to the optional OPTIONS argument of the
qt4_add_resources() macro.
By default it is empty.
This property is initialized by the value of the variable
:variable:`CMAKE_AUTORCC` if it is set when a target is created.
The options set on the target may be overridden by :prop_sf:`AUTORCC_OPTIONS` set
on the .qrc source file.

22
Help/prop_tgt/AUTOUIC.rst Normal file
View File

@ -0,0 +1,22 @@
AUTOUIC
-------
Should the target be processed with autouic (for Qt projects).
AUTOUIC is a boolean specifying whether CMake will handle
the Qt uic code generator automatically, i.e. without having to use
the QT4_WRAP_UI() or QT5_WRAP_UI() macro. Currently Qt4 and Qt5 are
supported.
When this property is set to TRUE, CMake will scan the source files
at build time and invoke uic accordingly.
If an #include statement like #include "ui_foo.h" is found in
foo.cpp, a foo.ui file is expected next to foo.cpp, and uic is
run on the foo.ui file.
This property is initialized by the value of the :variable:`CMAKE_AUTOUIC`
variable if it is set when a target is created.
Additional command line options for uic can be set via the
:prop_sf:`AUTOUIC_OPTIONS` source file property on the foo.ui file.
The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the
autouic targets together in an IDE, e.g. in MSVS.

View File

@ -0,0 +1,17 @@
AUTOUIC_OPTIONS
---------------
Additional options for uic when using autouic (see the :prop_tgt:`AUTOUIC` target property)
This property holds additional command line options
which will be used when uic is executed during the build via autouic,
i.e. it is equivalent to the optional OPTIONS argument of the
qt4_wrap_ui() macro.
By default it is empty.
This property is initialized by the value of the variable
:variable:`CMAKE_AUTOUIC` if it is set when a target is created.
The options set on the target may be overridden by :prop_sf:`AUTOUIC_OPTIONS` set
on the .ui source file.

View File

@ -0,0 +1,7 @@
CMAKE_AUTORCC
-------------
Whether to handle rcc automatically for Qt targets.
This variable is used to initialize the :prop_tgt:`AUTORCC` property on all the targets.
See that target property for additional information.

View File

@ -0,0 +1,7 @@
CMAKE_AUTORCC_OPTIONS
---------------------
Whether to handle rcc automatically for Qt targets.
This variable is used to initialize the :prop_tgt:`AUTORCC_OPTIONS` property on
all the targets. See that target property for additional information.

View File

@ -0,0 +1,7 @@
CMAKE_AUTOUIC
-------------
Whether to handle uic automatically for Qt targets.
This variable is used to initialize the :prop_tgt:`AUTOUIC` property on all the targets.
See that target property for additional information.

View File

@ -0,0 +1,7 @@
CMAKE_AUTOUIC_OPTIONS
---------------------
Whether to handle uic automatically for Qt targets.
This variable is used to initialize the :prop_tgt:`AUTOUIC_OPTIONS` property on
all the targets. See that target property for additional information.

View File

@ -1,4 +1,7 @@
set(AM_SOURCES @_moc_files@ )
set(AM_RCC_SOURCES @_rcc_files@ )
set(AM_SKIP_MOC @_skip_moc@ )
set(AM_SKIP_UIC @_skip_uic@ )
set(AM_HEADERS @_moc_headers@ )
set(AM_MOC_COMPILE_DEFINITIONS @_moc_compile_defs@)
set(AM_MOC_INCLUDES @_moc_incs@)
@ -7,8 +10,15 @@ set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJ
set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/")
set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/")
set(AM_QT_MOC_EXECUTABLE "@_qt_moc_executable@")
set(AM_QT_UIC_EXECUTABLE "@_qt_uic_executable@")
set(AM_QT_RCC_EXECUTABLE "@_qt_rcc_executable@")
set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
set(AM_QT_VERSION_MAJOR "@_target_qt_version@")
set(AM_TARGET_NAME @_moc_target_name@)
set(AM_RELAXED_MODE "@_moc_relaxed_mode@")
set(AM_UIC_TARGET_OPTIONS @_uic_target_options@)
set(AM_UIC_OPTIONS_FILES @_qt_uic_options_files@)
set(AM_UIC_OPTIONS_OPTIONS @_qt_uic_options_options@)
set(AM_RCC_OPTIONS_FILES @_qt_rcc_options_files@)
set(AM_RCC_OPTIONS_OPTIONS @_qt_rcc_options_options@)

View File

@ -250,8 +250,8 @@ set(SRCS
cmPropertyDefinitionMap.h
cmPropertyMap.cxx
cmPropertyMap.h
cmQtAutomoc.cxx
cmQtAutomoc.h
cmQtAutoGenerators.cxx
cmQtAutoGenerators.h
cmRST.cxx
cmRST.h
cmScriptGenerator.h

View File

@ -18,7 +18,7 @@
#include "cmExternalMakefileProjectGenerator.h"
#include "cmake.h"
#include "cmMakefile.h"
#include "cmQtAutomoc.h"
#include "cmQtAutoGenerators.h"
#include "cmSourceFile.h"
#include "cmVersion.h"
#include "cmTargetExport.h"
@ -1096,8 +1096,8 @@ void cmGlobalGenerator::Generate()
}
// Iterate through all targets and set up automoc for those which have
// the AUTOMOC property set
this->CreateAutomocTargets();
// the AUTOMOC, AUTOUIC or AUTORCC property set
this->CreateQtAutoGeneratorsTargets();
// For each existing cmLocalGenerator
unsigned int i;
@ -1253,11 +1253,11 @@ bool cmGlobalGenerator::CheckTargets()
}
//----------------------------------------------------------------------------
void cmGlobalGenerator::CreateAutomocTargets()
void cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
{
#ifdef CMAKE_BUILD_WITH_CMAKE
typedef std::vector<std::pair<cmQtAutomoc, cmTarget*> > Automocs;
Automocs automocs;
typedef std::vector<std::pair<cmQtAutoGenerators, cmTarget*> > Autogens;
Autogens autogens;
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
{
cmTargets& targets =
@ -1272,21 +1272,24 @@ void cmGlobalGenerator::CreateAutomocTargets()
target.GetType() == cmTarget::MODULE_LIBRARY ||
target.GetType() == cmTarget::OBJECT_LIBRARY)
{
if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported())
if((target.GetPropertyAsBool("AUTOMOC")
|| target.GetPropertyAsBool("AUTOUIC")
|| target.GetPropertyAsBool("AUTORCC"))
&& !target.IsImported())
{
cmQtAutomoc automoc;
if(automoc.InitializeMocSourceFile(&target))
cmQtAutoGenerators autogen;
if(autogen.InitializeMocSourceFile(&target))
{
automocs.push_back(std::make_pair(automoc, &target));
autogens.push_back(std::make_pair(autogen, &target));
}
}
}
}
}
for (Automocs::iterator it = automocs.begin(); it != automocs.end();
for (Autogens::iterator it = autogens.begin(); it != autogens.end();
++it)
{
it->first.SetupAutomocTarget(it->second);
it->first.SetupAutoGenerateTarget(it->second);
}
#endif
}

View File

@ -319,7 +319,7 @@ protected:
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS();
bool CheckTargets();
void CreateAutomocTargets();
void CreateQtAutoGeneratorsTargets();
// Fill the ProjectMap, this must be called after LocalGenerators

View File

@ -4206,6 +4206,18 @@ bool cmMakefile::EnforceUniqueDir(const char* srcPath, const char* binPath)
return false;
}
//----------------------------------------------------------------------------
void cmMakefile::AddQtUiFileWithOptions(cmSourceFile *sf)
{
this->QtUiFilesWithOptions.push_back(sf);
}
//----------------------------------------------------------------------------
std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
{
return this->QtUiFilesWithOptions;
}
//----------------------------------------------------------------------------
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id)

View File

@ -877,6 +877,9 @@ public:
bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; }
void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; }
void AddQtUiFileWithOptions(cmSourceFile *sf);
std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const;
std::set<cmStdString> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }
@ -1054,6 +1057,8 @@ private:
cmSourceFile* source);
void UpdateOutputToSourceMap(std::string const& output,
cmSourceFile* source);
std::vector<cmSourceFile*> QtUiFilesWithOptions;
};
//----------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -11,26 +11,33 @@
See the License for more information.
============================================================================*/
#ifndef cmQtAutomoc_h
#define cmQtAutomoc_h
#ifndef cmQtAutoGenerators_h
#define cmQtAutoGenerators_h
class cmGlobalGenerator;
class cmMakefile;
class cmQtAutomoc
class cmQtAutoGenerators
{
public:
cmQtAutomoc();
cmQtAutoGenerators();
bool Run(const char* targetDirectory, const char *config);
bool InitializeMocSourceFile(cmTarget* target);
void SetupAutomocTarget(cmTarget* target);
void SetupAutoGenerateTarget(cmTarget* target);
private:
void SetupAutoMocTarget(cmTarget* target,
const std::string &autogenTargetName,
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines);
void SetupAutoUicTarget(cmTarget* target);
void SetupAutoRccTarget(cmTarget* target);
cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
const char* targetDirectory);
bool ReadAutomocInfoFile(cmMakefile* makefile,
bool ReadAutogenInfoFile(cmMakefile* makefile,
const char* targetDirectory,
const char *config);
bool ReadOldMocDefinitionsFile(cmMakefile* makefile,
@ -39,22 +46,34 @@ private:
std::string MakeCompileSettingsString(cmMakefile* makefile);
bool RunAutomoc(cmMakefile* makefile);
bool RunAutogen(cmMakefile* makefile);
bool GenerateMoc(const std::string& sourceFile,
const std::string& mocFileName);
bool GenerateUi(const std::string& uiFileName);
bool GenerateQrc();
void ParseCppFile(const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs);
std::map<std::string, std::string>& includedMocs,
std::vector<std::string>& includedUis);
void StrictParseCppFile(const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
std::map<std::string, std::string>& includedMocs);
std::map<std::string, std::string>& includedMocs,
std::vector<std::string>& includedUis);
void SearchHeadersForCppFile(const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
std::set<std::string>& absHeaders);
void ParseHeaders(const std::set<std::string>& absHeaders,
const std::map<std::string, std::string>& includedMocs,
std::map<std::string, std::string>& notIncludedMocs);
std::map<std::string, std::string>& notIncludedMocs,
std::vector<std::string>& includedUis);
void ParseForUic(const std::string& fileName,
const std::string& contentsString,
std::vector<std::string>& includedUis);
void ParseForUic(const std::string& fileName,
std::vector<std::string>& includedUis);
void Init();
@ -63,13 +82,24 @@ private:
bool StartsWith(const std::string& str, const std::string& with);
std::string ReadAll(const std::string& filename);
void MergeUicOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);
void MergeRccOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);
std::string QtMajorVersion;
std::string Sources;
std::string RccSources;
std::string SkipMoc;
std::string SkipUic;
std::string Headers;
bool IncludeProjectDirsBefore;
std::string Srcdir;
std::string Builddir;
std::string MocExecutable;
std::string UicExecutable;
std::string RccExecutable;
std::string MocCompileDefinitionsStr;
std::string MocIncludesStr;
std::string MocOptionsStr;
@ -84,10 +114,15 @@ private:
std::list<std::string> MocIncludes;
std::list<std::string> MocDefinitions;
std::vector<std::string> MocOptions;
std::vector<std::string> UicTargetOptions;
std::map<std::string, std::string> UicOptions;
std::map<std::string, std::string> RccOptions;
bool Verbose;
bool ColorOutput;
bool RunMocFailed;
bool RunUicFailed;
bool RunRccFailed;
bool GenerateAll;
bool RelaxedMode;

View File

@ -287,6 +287,17 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
}
this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE);
std::string ext =
cmSystemTools::GetFilenameLastExtension(this->Location.GetName());
if (ext == ".ui")
{
cmMakefile* mf = this->Location.GetMakefile();
if (strcmp(prop, "AUTOUIC_OPTIONS") == 0)
{
mf->AddQtUiFileWithOptions(this);
}
}
}
//----------------------------------------------------------------------------

View File

@ -274,7 +274,11 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("GNUtoMS", 0);
this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
this->SetPropertyDefault("AUTOMOC", 0);
this->SetPropertyDefault("AUTOUIC", 0);
this->SetPropertyDefault("AUTORCC", 0);
this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0);
this->SetPropertyDefault("AUTOUIC_OPTIONS", 0);
this->SetPropertyDefault("AUTORCC_OPTIONS", 0);
this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0);
this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);
this->SetPropertyDefault("WIN32_EXECUTABLE", 0);

View File

@ -13,7 +13,7 @@
#include "cmMakefile.h"
#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmQtAutomoc.h"
#include "cmQtAutoGenerators.h"
#include "cmVersion.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@ -632,12 +632,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
return cmcmd::ExecuteEchoColor(args);
}
else if (args[1] == "cmake_automoc")
else if (args[1] == "cmake_autogen")
{
cmQtAutomoc automoc;
cmQtAutoGenerators autogen;
const char *config = args[3].empty() ? 0 : args[3].c_str();
bool automocSuccess = automoc.Run(args[2].c_str(), config);
return automocSuccess ? 0 : 1;
bool autogenSuccess = autogen.Run(args[2].c_str(), config);
return autogenSuccess ? 0 : 1;
}
#endif

View File

@ -1029,34 +1029,43 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
# On Windows there is no RPATH, so while Qt might be available for building,
# the required dlls may not be in the PATH, so we can't run the executables
# on that platform.
if(WIN32)
set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V)
else()
set(run_autogen_test QtAutogen)
endif()
find_package(Qt5Widgets QUIET NO_MODULE)
if(Qt5Widgets_FOUND)
add_test(Qt5Automoc ${CMAKE_CTEST_COMMAND}
add_test(Qt5Autogen ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/QtAutomoc"
"${CMake_BINARY_DIR}/Tests/Qt5Automoc"
"${CMake_SOURCE_DIR}/Tests/QtAutogen"
"${CMake_BINARY_DIR}/Tests/Qt5Autogen"
${build_generator_args}
--build-project QtAutomoc
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Automoc"
--build-project QtAutogen
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
--force-new-ctest-process
--build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
--test-command ${CMAKE_CTEST_COMMAND} -V
--test-command ${run_autogen_test}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Automoc")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen")
endif()
if(QT4_WORKS AND QT_QTGUI_FOUND)
add_test(Qt4Automoc ${CMAKE_CTEST_COMMAND}
add_test(Qt4Autogen ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/QtAutomoc"
"${CMake_BINARY_DIR}/Tests/Qt4Automoc"
"${CMake_SOURCE_DIR}/Tests/QtAutogen"
"${CMake_BINARY_DIR}/Tests/Qt4Autogen"
${build_generator_args}
--build-project QtAutomoc
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Automoc"
--build-project QtAutogen
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
--force-new-ctest-process
--build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
--test-command ${CMAKE_CTEST_COMMAND} -V
--test-command ${run_autogen_test}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Automoc")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen")
add_test(Qt4Targets ${CMAKE_CTEST_COMMAND}
--build-and-test

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.11)
project(QtAutomoc)
project(QtAutogen)
if (QT_TEST_VERSION STREQUAL 4)
find_package(Qt4 REQUIRED)
@ -35,15 +35,20 @@ add_definitions(-DFOO -DSomeDefine="Barx")
# enable relaxed mode so automoc can handle all the special cases:
set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# create an executable and two library targets, each requiring automoc:
add_library(codeeditorLib STATIC codeeditor.cpp)
add_library(privateSlot OBJECT private_slot.cpp)
add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>)
add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
test.qrc resourcetester.cpp
)
set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
set_target_properties(QtAutogen codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
include(GenerateExportHeader)
# The order is relevant here. B depends on A, and B headers depend on A
@ -59,7 +64,7 @@ set_target_properties(libC PROPERTIES AUTOMOC TRUE)
generate_export_header(libC)
target_link_libraries(libC LINK_PUBLIC libB)
target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} libC)
target_link_libraries(QtAutogen codeeditorLib ${QT_LIBRARIES} libC)
add_library(empty STATIC empty.cpp)
set_target_properties(empty PROPERTIES AUTOMOC TRUE)

View File

@ -49,7 +49,10 @@
#include "calwidget.h"
#include "ui_calwidget.h"
Window::Window()
: ui(new Ui::Window)
{
createPreviewGroupBox();
createGeneralOptionsGroupBox();

View File

@ -52,6 +52,11 @@
class QGroupBox;
class QLabel;
namespace Ui
{
class Window;
}
class Window : public QWidget
{
Q_OBJECT
@ -116,6 +121,8 @@
QCheckBox *firstFridayCheckBox;
QCheckBox *mayFirstCheckBox;
Ui::Window *ui;
};
#endif

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Window</class>
<widget class="QWidget" name="Window">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>90</x>
<y>180</y>
<width>94</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -38,7 +38,8 @@
**
****************************************************************************/
#include <QApplication>
#include <QCoreApplication>
#include <QTimer>
#include "codeeditor.h"
#include "calwidget.h"
@ -49,17 +50,11 @@
#include "xyz.h"
#include "yaf.h"
#include "libC.h"
#include "resourcetester.h"
int main(int argv, char **args)
{
QApplication app(argv, args);
CodeEditor editor;
editor.setWindowTitle(QObject::tr("Code Editor Example"));
editor.show();
Window w;
w.show();
QCoreApplication app(argv, args);
Foo foo;
foo.doFoo();
@ -82,5 +77,9 @@ int main(int argv, char **args)
LibC lc;
lc.foo();
ResourceTester rt;
QTimer::singleShot(0, &rt, SLOT(doTest()));
return app.exec();
}

View File

@ -0,0 +1,21 @@
#include "resourcetester.h"
#include <QDebug>
#include <QApplication>
#include <QFile>
#include <QTimer>
ResourceTester::ResourceTester(QObject *parent)
: QObject(parent)
{
}
void ResourceTester::doTest()
{
if (!QFile::exists(":/CMakeLists.txt"))
qApp->exit(EXIT_FAILURE);
QTimer::singleShot(0, qApp, SLOT(quit()));
}

View File

@ -0,0 +1,17 @@
#ifndef RESOURCE_TESTER_H
#define RESOURCE_TESTER_H
#include <QObject>
class ResourceTester : public QObject
{
Q_OBJECT
public:
explicit ResourceTester(QObject *parent = 0);
private slots:
void doTest();
};
#endif

5
Tests/QtAutogen/test.qrc Normal file
View File

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>CMakeLists.txt</file>
</qresource>
</RCC>