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

Merge topic 'autogen_refactor_initialization'

7bb70054 Autogen: Add test for Q_OS_ macros
f3451358 Autogen: For Qt5 pass all implicit include directories to moc
2d6cfe26 Autogen: Split initializer main method
84bdae88 Autogen: Compute variables in Init stage instead of Setup stage
8e0d7027 Autogen: Move info file write code into methods
5776639f Autogen: Pass absolute include path in info file
2e9199b2

 cmLocalGenerator: Respect user requested implicit include directories order
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2230
parents 398ce17f 7bb70054
Pipeline #110734 passed with stage
in 0 seconds
......@@ -960,15 +960,14 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
}
if (!stripImplicitDirs) {
if (!appendAllImplicitDirs) {
// Append only those implicit directories that were requested by the user
for (std::string const& i : implicitDirs) {
if (std::find(userDirs.begin(), userDirs.end(), i) != userDirs.end()) {
dirs.push_back(i);
}
// Append only implicit directories that were requested by the user
for (std::string const& i : implicitDirs) {
if (std::find(userDirs.begin(), userDirs.end(), i) != userDirs.end()) {
dirs.push_back(i);
}
} else {
// Append all implicit directories
}
// Append remaining implicit directories on demand
if (appendAllImplicitDirs) {
for (std::string const& i : implicitDirs) {
if (std::find(dirs.begin(), dirs.end(), i) == dirs.end()) {
dirs.push_back(i);
......
This diff is collapsed.
......@@ -12,6 +12,7 @@
#include <vector>
class cmGeneratorTarget;
class cmTarget;
/// @brief Initializes the QtAutoGen generators
class cmQtAutoGenInitializer : public cmQtAutoGen
......@@ -38,6 +39,7 @@ public:
std::string PathChecksum;
std::string InfoFile;
std::string SettingsFile;
std::map<std::string, std::string> ConfigSettingsFile;
std::string RccFile;
bool Generated;
bool Unique;
......@@ -54,8 +56,16 @@ public:
bool SetupCustomTargets();
private:
bool SetupCustomTargetsMoc();
bool SetupCustomTargetsUic();
bool InitMoc();
bool InitUic();
bool InitRcc();
bool InitScanFiles();
bool InitAutogenTarget();
bool InitRccTargets();
bool SetupWriteAutogenInfo();
bool SetupWriteRccInfo();
void AddGeneratedSource(std::string const& filename, GeneratorT genType);
......@@ -72,7 +82,7 @@ private:
private:
cmGeneratorTarget* Target;
bool MultiConfig;
bool MultiConfig = false;
// Qt
std::string QtVersionMajor;
std::string QtVersionMinor;
......@@ -86,17 +96,28 @@ private:
std::string AutogenFolder;
std::string AutogenInfoFile;
std::string AutogenSettingsFile;
std::map<std::string, std::string> AutogenConfigSettingsFile;
std::set<std::string> AutogenDependFiles;
std::set<cmTarget*> AutogenDependTargets;
// Directories
std::string DirInfo;
std::string DirBuild;
std::string DirWork;
// Sources
std::vector<std::string> Headers;
std::vector<std::string> Sources;
std::string DirInclude;
std::map<std::string, std::string> DirConfigInclude;
// Moc and UIC
struct
{
// Sources
std::vector<std::string> Headers;
std::vector<std::string> Sources;
std::vector<std::string> HeadersGenerated;
std::vector<std::string> SourcesGenerated;
} MocUic;
// Moc
struct
{
bool Enabled;
bool Enabled = false;
std::string Executable;
std::string PredefsCmd;
std::set<std::string> Skip;
......@@ -104,11 +125,12 @@ private:
std::map<std::string, std::string> ConfigIncludes;
std::string Defines;
std::map<std::string, std::string> ConfigDefines;
std::string MocsCompilation;
} Moc;
// Uic
struct
{
bool Enabled;
bool Enabled = false;
std::string Executable;
std::set<std::string> Skip;
std::vector<std::string> SearchPaths;
......@@ -120,7 +142,7 @@ private:
// Rcc
struct
{
bool Enabled;
bool Enabled = false;
std::string Executable;
std::vector<std::string> ListOptions;
std::vector<Qrc> Qrcs;
......
......@@ -1247,14 +1247,11 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
return false;
}
// include directory
{
std::string dirRel = InfoGetConfig("AM_INCLUDE_DIR");
if (dirRel.empty()) {
Log().ErrorFile(GeneratorT::GEN, InfoFile(),
"Autogen include directory missing");
return false;
}
Base_.AutogenIncludeDir = Base_.AbsoluteBuildPath(dirRel);
Base_.AutogenIncludeDir = InfoGetConfig("AM_INCLUDE_DIR");
if (Base_.AutogenIncludeDir.empty()) {
Log().ErrorFile(GeneratorT::GEN, InfoFile(),
"Autogen include directory missing");
return false;
}
// - Files
......
......@@ -141,9 +141,7 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile)
// Compute rcc output file name
if (IsMultiConfig()) {
RccFileOutput_ = AutogenBuildDir_;
RccFileOutput_ += '/';
RccFileOutput_ += IncludeDir_;
RccFileOutput_ = IncludeDir_;
RccFileOutput_ += '/';
RccFileOutput_ += MultiConfigOutput();
} else {
......
......@@ -23,6 +23,9 @@ endif()
if(QT_TEST_ALLOW_QT_MACROS)
ADD_AUTOGEN_TEST(MocCMP0071)
endif()
if(NOT QT_TEST_VERSION STREQUAL 4)
ADD_AUTOGEN_TEST(MocOsMacros mocOsMacros)
endif()
ADD_AUTOGEN_TEST(UicInclude uicInclude)
ADD_AUTOGEN_TEST(UicInterface QtAutoUicInterface)
ADD_AUTOGEN_TEST(ObjectLibrary someProgram)
......
cmake_minimum_required(VERSION 3.11)
project(MocOsMacros)
include("../AutogenTest.cmake")
# Tests if moc processes the macro Q_OS_MAC
set(CMAKE_AUTOMOC True)
add_executable(mocOsMacros
main.cpp
TestClass.cpp
TestClass.hpp
)
target_link_libraries(mocOsMacros PRIVATE ${QT_QTCORE_TARGET})
message ( "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" )
#include "TestClass.hpp"
#include <iostream>
// -- Mac
#ifndef Q_OS_MAC
void TestClass::MacNotDef()
{
std::cout << "MacNotDef\n";
}
#else
void TestClass::MacNotDefElse()
{
std::cout << "MacNotDefElse\n";
}
#endif
#ifdef Q_OS_MAC
void TestClass::MacDef()
{
std::cout << "MacDef\n";
}
#else
void TestClass::MacDefElse()
{
std::cout << "MacDefElse\n";
}
#endif
// -- Unix
#ifndef Q_OS_UNIX
void TestClass::UnixNotDef()
{
std::cout << "UnixNotDef\n";
}
#else
void TestClass::UnixNotDefElse()
{
std::cout << "UnixNotDefElse\n";
}
#endif
#ifdef Q_OS_UNIX
void TestClass::UnixDef()
{
std::cout << "UnixDef\n";
}
#else
void TestClass::UnixDefElse()
{
std::cout << "UnixDefElse\n";
}
#endif
// -- Windows
#ifndef Q_OS_WIN
void TestClass::WindowsNotDef()
{
std::cout << "WindowsNotDef\n";
}
#else
void TestClass::WindowsNotDefElse()
{
std::cout << "WindowsNotDefElse\n";
}
#endif
#ifdef Q_OS_WIN
void TestClass::WindowsDef()
{
std::cout << "WindowsDef\n";
}
#else
void TestClass::WindowsDefElse()
{
std::cout << "WindowsDefElse\n";
}
#endif
#ifndef TestClass_hpp
#define TestClass_hpp
#include <QObject>
#include <QtGlobal>
class TestClass : public QObject
{
Q_OBJECT
public Q_SLOTS:
// -- Mac
#ifndef Q_OS_MAC
void MacNotDef();
#else
void MacNotDefElse();
#endif
#ifdef Q_OS_MAC
void MacDef();
#else
void MacDefElse();
#endif
// -- Unix
#ifndef Q_OS_UNIX
void UnixNotDef();
#else
void UnixNotDefElse();
#endif
#ifdef Q_OS_UNIX
void UnixDef();
#else
void UnixDefElse();
#endif
// -- Windows
#ifndef Q_OS_WIN
void WindowsNotDef();
#else
void WindowsNotDefElse();
#endif
#ifdef Q_OS_WIN
void WindowsDef();
#else
void WindowsDefElse();
#endif
};
#endif /* TestClass_hpp */
#include "TestClass.hpp"
#include <QtGlobal>
int main()
{
TestClass a;
#ifdef Q_OS_MAC
a.MacNotDefElse();
a.MacDef();
#else
a.MacNotDef();
a.MacDefElse();
#endif
#ifdef Q_OS_UNIX
a.UnixNotDefElse();
a.UnixDef();
#else
a.UnixNotDef();
a.UnixDefElse();
#endif
#ifdef Q_OS_WIN
a.WindowsNotDefElse();
a.WindowsDef();
#else
a.WindowsNotDef();
a.WindowsDefElse();
#endif
return 0;
}
Markdown is supported
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