[Cmake-commits] CMake branch, next, updated. v3.8.0-769-g98c4dd1
Kitware Robot
kwrobot at kitware.com
Fri Apr 14 09:45:03 EDT 2017
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 98c4dd19b693c874ab468ff8db704bd10090cc99 (commit)
via 24196b1edad20edc86d8b76c9b42c0ad9e5f359a (commit)
via 09dbe388b2ed30dae266e99f0185728e6f40f53b (commit)
from 14094834a07dc2333de19e76379bcb9256cded7d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=98c4dd19b693c874ab468ff8db704bd10090cc99
commit 98c4dd19b693c874ab468ff8db704bd10090cc99
Merge: 1409483 24196b1
Author: Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Fri Apr 14 13:36:35 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Apr 14 09:36:39 2017 -0400
Stage topic 'master'
Topic-id: 23520
Topic-url: https://gitlab.kitware.com/cmake/cmake/merge_requests/671
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=24196b1edad20edc86d8b76c9b42c0ad9e5f359a
commit 24196b1edad20edc86d8b76c9b42c0ad9e5f359a
Author: Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Apr 13 18:13:07 2017 +0200
Commit: Aleix Pol <aleixpol at kde.org>
CommitDate: Thu Apr 13 21:25:27 2017 +0200
Autogen: Include moc_predefs.h by absolute path
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index e6177ee..8563823 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -581,6 +581,12 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile)
this->MocCppFilenameAbs = this->CurrentBinaryDir + this->MocCppFilenameRel;
+ // Moc predefs file
+ if (!this->MocPredefsCmd.empty()) {
+ this->MocPredefsFileRel = this->AutogenBuildSubDir + "moc_predefs.h";
+ this->MocPredefsFileAbs = this->CurrentBinaryDir + this->MocPredefsFileRel;
+ }
+
// Init file path checksum generator
fpathCheckSum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir,
this->ProjectSourceDir,
@@ -1146,13 +1152,12 @@ bool cmQtAutoGenerators::MocGenerateAll(
// Generate moc_predefs
if (!this->MocPredefsCmd.empty()) {
- const std::string mocPredefsFile =
- this->AutogenBuildSubDir + "moc_predefs.h";
- if (!this->MakeParentDirectory(mocPredefsFile)) {
- this->LogError("AutoMoc: Error creating directory for" + mocPredefsFile);
+ if (!this->MakeParentDirectory(this->MocPredefsFileAbs)) {
+ this->LogError("AutoMoc: Error creating directory for " +
+ this->MocPredefsFileRel);
return false;
}
- this->LogBold("Generating " + mocPredefsFile);
+ this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel);
std::vector<std::string> cmd = this->MocPredefsCmd;
cmd.insert(cmd.end(), this->MocIncludes.cbegin(),
@@ -1171,16 +1176,16 @@ bool cmQtAutoGenerators::MocGenerateAll(
// actually write the file
cmsys::ofstream outfile;
- outfile.open(mocPredefsFile.c_str(), std::ios::trunc);
+ outfile.open(this->MocPredefsFileAbs.c_str(), std::ios::trunc);
if (!outfile) {
moc_predefsGenerated = false;
- this->LogError("AutoMoc: Error opening " + mocPredefsFile);
+ this->LogError("AutoMoc: Error opening " + this->MocPredefsFileRel);
} else {
outfile << output;
// Check for write errors
if (!outfile.good()) {
moc_predefsGenerated = false;
- this->LogError("AutoMoc: Error writing " + mocPredefsFile);
+ this->LogError("AutoMoc: Error writing " + this->MocPredefsFileRel);
}
}
@@ -1351,9 +1356,9 @@ bool cmQtAutoGenerators::MocGenerateFile(
cmd.push_back("-D" + (*it));
}
cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
- if (!this->MocPredefsCmd.empty()) {
+ if (!this->MocPredefsFileAbs.empty()) {
cmd.push_back("--include");
- cmd.push_back(this->AutogenBuildSubDir + "moc_predefs.h");
+ cmd.push_back(this->MocPredefsFileAbs);
}
#ifdef _WIN32
cmd.push_back("-DWIN32");
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index cc8b029..cb6f45a 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -176,6 +176,8 @@ private:
// - Moc
std::string MocCppFilenameRel;
std::string MocCppFilenameAbs;
+ std::string MocPredefsFileRel;
+ std::string MocPredefsFileAbs;
std::vector<std::string> MocSkipList;
std::vector<std::string> MocIncludePaths;
std::vector<std::string> MocIncludes;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=09dbe388b2ed30dae266e99f0185728e6f40f53b
commit 09dbe388b2ed30dae266e99f0185728e6f40f53b
Author: Aleix Pol <aleixpol at kde.org>
AuthorDate: Thu Apr 6 04:14:35 2017 +0200
Commit: Aleix Pol <aleixpol at kde.org>
CommitDate: Thu Apr 13 15:55:59 2017 +0200
Fix automoc in some set ups
Qt is relying on whoever calls moc to include a file with the predefined
values that will be used by the compiler, otherwise moc takes wrong
paths and weird things happen.
Instead, generate an include file and feed it to all mocs to make sure
it's generating correct code.
Fixes: 16640
diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in
index fcecb6c..5e945bc 100644
--- a/Modules/AutogenInfo.cmake.in
+++ b/Modules/AutogenInfo.cmake.in
@@ -21,6 +21,7 @@ set(AM_MOC_INCLUDES @_moc_incs@)
set(AM_MOC_OPTIONS @_moc_options@)
set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@)
set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@)
+set(AM_MOC_PREDEFS_CMD @_moc_predefs_cmd@)
# UIC settings
set(AM_UIC_SKIP @_uic_skip@)
set(AM_UIC_TARGET_OPTIONS @_uic_target_options@)
diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake
index 02968b4..513e62a 100644
--- a/Modules/Compiler/Intel.cmake
+++ b/Modules/Compiler/Intel.cmake
@@ -22,5 +22,7 @@ else()
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
+
+ set(CMAKE_GENERATE_${lang}_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
endmacro()
endif()
diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake
index 6878254..939c08e 100644
--- a/Modules/Platform/Linux-GNU.cmake
+++ b/Modules/Platform/Linux-GNU.cmake
@@ -12,4 +12,5 @@ macro(__linux_compiler_gnu lang)
# We pass this for historical reasons. Projects may have
# executables that use dlopen but do not set ENABLE_EXPORTS.
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
+ set(CMAKE_GENERATE_${lang}_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
endmacro()
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index d69794c..07fcb2f 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -96,6 +96,36 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target)
return qtMajorVersion;
}
+static std::string GetQtMinorVersion(cmGeneratorTarget const* target)
+{
+ cmMakefile* makefile = target->Target->GetMakefile();
+ std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR");
+ if (qtMajorVersion.empty()) {
+ qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR");
+ }
+ const char* targetQtVersion =
+ target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", "");
+ if (targetQtVersion != CM_NULLPTR) {
+ qtMajorVersion = targetQtVersion;
+ }
+ return qtMajorVersion;
+}
+
+static bool QtVersionGreaterOrEqual(const std::string& major,
+ const std::string& minor,
+ unsigned long requestMajor,
+ unsigned long requestMinor)
+{
+ unsigned long majorUL(0);
+ unsigned long minorUL(0);
+ if (cmSystemTools::StringToULong(major.c_str(), &majorUL) &&
+ cmSystemTools::StringToULong(minor.c_str(), &minorUL)) {
+ return (majorUL > requestMajor) ||
+ (majorUL == requestMajor && minorUL >= requestMinor);
+ }
+ return false;
+}
+
static void GetCompileDefinitionsAndDirectories(
cmGeneratorTarget const* target, const std::string& config,
std::string& incs, std::string& defs)
@@ -258,6 +288,12 @@ static void MocSetupAutoTarget(
AddDefinitionEscaped(makefile, "_moc_depend_filters",
GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS"));
+ if (QtVersionGreaterOrEqual(qtMajorVersion, GetQtMinorVersion(target), 5,
+ 8)) {
+ AddDefinitionEscaped(
+ makefile, "_moc_predefs_cmd",
+ makefile->GetSafeDefinition("CMAKE_GENERATE_CXX_PREDEFINES_COMMAND"));
+ }
// Moc includes and compile definitions
{
std::string _moc_incs;
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 246dd8d..e6177ee 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -360,6 +360,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
InfoGet(makefile, "AM_QT_MOC_EXECUTABLE", this->MocExecutable);
InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable);
InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable);
+
+ InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd);
// Check Qt version
if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) {
this->LogError("AutoGen: Error: Unsupported Qt version: " +
@@ -1142,6 +1144,50 @@ bool cmQtAutoGenerators::MocGenerateAll(
return true;
}
+ // Generate moc_predefs
+ if (!this->MocPredefsCmd.empty()) {
+ const std::string mocPredefsFile =
+ this->AutogenBuildSubDir + "moc_predefs.h";
+ if (!this->MakeParentDirectory(mocPredefsFile)) {
+ this->LogError("AutoMoc: Error creating directory for" + mocPredefsFile);
+ return false;
+ }
+ this->LogBold("Generating " + mocPredefsFile);
+
+ std::vector<std::string> cmd = this->MocPredefsCmd;
+ cmd.insert(cmd.end(), this->MocIncludes.cbegin(),
+ this->MocIncludes.cend());
+ for (std::vector<std::string>::const_iterator it =
+ this->MocDefinitions.cbegin();
+ it != this->MocDefinitions.cend(); ++it) {
+ cmd.push_back("-D" + (*it));
+ }
+ cmd.insert(cmd.end(), this->MocOptions.cbegin(), this->MocOptions.cend());
+
+ std::string output;
+ bool moc_predefsGenerated = this->RunCommand(cmd, output, false);
+ if (!moc_predefsGenerated)
+ return false;
+
+ // actually write the file
+ cmsys::ofstream outfile;
+ outfile.open(mocPredefsFile.c_str(), std::ios::trunc);
+ if (!outfile) {
+ moc_predefsGenerated = false;
+ this->LogError("AutoMoc: Error opening " + mocPredefsFile);
+ } else {
+ outfile << output;
+ // Check for write errors
+ if (!outfile.good()) {
+ moc_predefsGenerated = false;
+ this->LogError("AutoMoc: Error writing " + mocPredefsFile);
+ }
+ }
+
+ if (!moc_predefsGenerated)
+ return false;
+ }
+
bool mocCompFileGenerated = false;
bool mocCompChanged = false;
@@ -1305,6 +1351,10 @@ bool cmQtAutoGenerators::MocGenerateFile(
cmd.push_back("-D" + (*it));
}
cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
+ if (!this->MocPredefsCmd.empty()) {
+ cmd.push_back("--include");
+ cmd.push_back(this->AutogenBuildSubDir + "moc_predefs.h");
+ }
#ifdef _WIN32
cmd.push_back("-DWIN32");
#endif
@@ -1805,7 +1855,7 @@ bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) const
* @return True on success
*/
bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command,
- std::string& output) const
+ std::string& output, bool verbose) const
{
// Log command
if (this->Verbose) {
@@ -1813,8 +1863,9 @@ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command,
}
// Execute command
int retVal = 0;
- bool res =
- cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
+ bool res = cmSystemTools::RunSingleCommand(
+ command, &output, &output, &retVal, CM_NULLPTR,
+ verbose ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE);
return (res && (retVal == 0));
}
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index ee046de..cc8b029 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -142,8 +142,8 @@ private:
const char* basePrefix,
const char* baseSuffix) const;
bool MakeParentDirectory(const std::string& filename) const;
- bool RunCommand(const std::vector<std::string>& command,
- std::string& output) const;
+ bool RunCommand(const std::vector<std::string>& command, std::string& output,
+ bool verbose = true) const;
bool FindHeader(std::string& header, const std::string& testBasePath) const;
@@ -197,6 +197,8 @@ private:
MacroFilter MacroFilters[2];
cmsys::RegularExpression RegExpMocInclude;
cmsys::RegularExpression RegExpUicInclude;
+ // - moc_predefs
+ std::vector<std::string> MocPredefsCmd;
// - Flags
bool IncludeProjectDirsBefore;
bool Verbose;
-----------------------------------------------------------------------
Summary of changes:
Modules/AutogenInfo.cmake.in | 1 +
Modules/Compiler/Intel.cmake | 2 +
Modules/Platform/Linux-GNU.cmake | 1 +
Source/cmQtAutoGeneratorInitializer.cxx | 36 ++++++++++++++++++
Source/cmQtAutoGenerators.cxx | 62 +++++++++++++++++++++++++++++--
Source/cmQtAutoGenerators.h | 8 +++-
6 files changed, 105 insertions(+), 5 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list