Commit fcbe435c authored by Brad King's avatar Brad King 💬 Committed by Kitware Robot
Browse files

Merge topic 'Qt-auto-generators'

9c87d9cc Add automatic rcc invocation for Qt.
84218e18 Add automatic uic invocation for Qt.
94a0ca60 Record which files are skipped by automoc.
18fb7588 Run the main executable created in the autogen tests.
e485ba12 Rename the QtAutomoc tests to QtAutogen.
7ce65c3c Add extra checks for the AUTOMOC target property.
32771fc7 Update output messages for generic use.
f371ab58 Rename RunAutomoc to RunAutogen.
85b3d6e7 Extract an SetupAutoMocTarget method.
ca124a15 Rename the AutomocInfo.cmake file to be more generic.
a342c9ff Move some makefile definitions up away from moc-specific code.
98632eff Add the AUTOGEN_TARGETS_FOLDER and obsolete AUTOMOC_TARGETS_FOLDER.
63378baa Rename some variables to reflect broader scope.
97f1aa39 Rename method to reflect generic use.
4abb1115 Rename local variable to reflect generic use.
03878c9a Move variable set to where it is used.
...
parents 16df2456 9c87d9cc
......@@ -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
......
......@@ -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
......
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.
......@@ -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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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@)
......@@ -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
......
......@@ -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
}
......
......@@ -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
......
......@@ -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)
......
......@@ -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;
};
//----------------------------------------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment