summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/.gitattributes31
-rw-r--r--Source/CMakeLists.txt5
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/OSXScriptLauncher.cxx1
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx10
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx45
-rw-r--r--Source/CPack/cmCPackGenerator.cxx4
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx14
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h2
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx25
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx5
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx11
-rw-r--r--Source/CTest/cmCTestRunTest.cxx19
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx13
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx70
-rw-r--r--Source/CursesDialog/form/.gitattributes1
-rw-r--r--Source/bindexplib.cxx3
-rw-r--r--Source/cmCTest.cxx2
-rw-r--r--Source/cmDepends.cxx14
-rw-r--r--Source/cmFindLibraryCommand.cxx92
-rw-r--r--Source/cmGeneratorTarget.cxx28
-rw-r--r--Source/cmGeneratorTarget.h4
-rw-r--r--Source/cmGlobalGenerator.cxx9
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx161
-rw-r--r--Source/cmGlobalXCodeGenerator.h3
-rw-r--r--Source/cmListFileCache.cxx7
-rw-r--r--Source/cmListFileLexer.c8
-rw-r--r--Source/cmListFileLexer.h1
-rw-r--r--Source/cmLocalGenerator.cxx11
-rw-r--r--Source/cmMakefile.cxx17
-rw-r--r--Source/cmMakefile.h10
-rw-r--r--Source/cmNinjaTargetGenerator.cxx7
-rw-r--r--Source/cmOrderDirectories.cxx22
-rw-r--r--Source/cmOrderDirectories.h2
-rw-r--r--Source/cmQtAutoGeneratorCommon.cxx215
-rw-r--r--Source/cmQtAutoGeneratorCommon.h34
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx503
-rw-r--r--Source/cmQtAutoGenerators.cxx951
-rw-r--r--Source/cmQtAutoGenerators.h23
-rw-r--r--Source/cmSourceFile.h1
-rw-r--r--Source/cmStateSnapshot.cxx2
-rw-r--r--Source/cmTarget.cxx3
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx94
-rw-r--r--Source/cmWorkingDirectory.cxx24
-rw-r--r--Source/cmWorkingDirectory.h25
-rw-r--r--Source/cmXCodeScheme.cxx227
-rw-r--r--Source/cmXCodeScheme.h50
-rw-r--r--Source/cmXMLWriter.cxx11
-rw-r--r--Source/cmXMLWriter.h3
-rw-r--r--Source/cmake.cxx30
50 files changed, 1791 insertions, 1064 deletions
diff --git a/Source/.gitattributes b/Source/.gitattributes
index dbd6382..1cec8a3 100644
--- a/Source/.gitattributes
+++ b/Source/.gitattributes
@@ -1,10 +1,21 @@
-# Preserve indentation style in generated code.
-cmCommandArgumentLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
-cmCommandArgumentLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
-cmDependsJavaLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
-cmDependsJavaLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
-cmExprLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
-cmExprLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
-cmFortranLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
-cmFortranLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
-cmListFileLexer.c whitespace=-tab-in-indent,-indent-with-non-tab
+/cmCommandArgumentLexer.cxx generated
+/cmCommandArgumentLexer.h generated
+/cmCommandArgumentParser.cxx generated
+/cmCommandArgumentParserTokens.h generated
+/cmDependsJavaLexer.cxx generated
+/cmDependsJavaLexer.h generated
+/cmDependsJavaParser.cxx generated
+/cmDependsJavaParserTokens.h generated
+/cmExprLexer.cxx generated
+/cmExprLexer.h generated
+/cmExprParser.cxx generated
+/cmExprParserTokens.h generated
+/cmFortranLexer.cxx generated
+/cmFortranLexer.h generated
+/cmFortranParser.cxx generated
+/cmFortranParserTokens.h generated
+/cmListFileLexer.c generated
+
+# Do not format third-party sources.
+/bindexplib.* -format.clang-format
+/kwsys/** -format.clang-format
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 3b49f72..59920f8 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -344,6 +344,8 @@ set(SRCS
cmPropertyDefinitionMap.h
cmPropertyMap.cxx
cmPropertyMap.h
+ cmQtAutoGeneratorCommon.cxx
+ cmQtAutoGeneratorCommon.h
cmQtAutoGeneratorInitializer.cxx
cmQtAutoGeneratorInitializer.h
cmQtAutoGenerators.cxx
@@ -381,6 +383,8 @@ set(SRCS
cmVariableWatch.h
cmVersion.cxx
cmVersion.h
+ cmWorkingDirectory.cxx
+ cmWorkingDirectory.h
cmXMLParser.cxx
cmXMLParser.h
cmXMLSafe.cxx
@@ -639,6 +643,7 @@ if(APPLE)
set(SRCS ${SRCS}
cmXCodeObject.cxx
cmXCode21Object.cxx
+ cmXCodeScheme.cxx
cmGlobalXCodeGenerator.cxx
cmGlobalXCodeGenerator.h
cmLocalXCodeGenerator.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 0dc9dad..dcc6ab9 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 8)
-set(CMake_VERSION_PATCH 20170223)
+set(CMake_VERSION_PATCH 20170308)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index b159e64..aeabde9 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -20,7 +20,6 @@
int main(int argc, char* argv[])
{
// if ( cmsys::SystemTools::FileExists(
- std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory();
cmsys::ofstream ofs("/tmp/output.txt");
CFStringRef fileName;
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 9d9cd66..cc01b0c 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -7,6 +7,7 @@
#include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <map>
#include <ostream>
@@ -37,9 +38,8 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
// Add the files of this component to the archive
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
localToplevel += "/" + component->Name;
- std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
// Change to local toplevel
- cmSystemTools::ChangeDirectory(localToplevel);
+ cmWorkingDirectory workdir(localToplevel);
std::string filePrefix;
if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
@@ -64,8 +64,6 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
return 0;
}
}
- // Go back to previous dir
- cmSystemTools::ChangeDirectory(dir);
return 1;
}
@@ -227,8 +225,7 @@ int cmCPackArchiveGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package.
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
std::vector<std::string>::const_iterator fileIt;
- std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(toplevel);
+ cmWorkingDirectory workdir(toplevel);
for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
// Get the relative path to the file
std::string rp =
@@ -241,7 +238,6 @@ int cmCPackArchiveGenerator::PackageFiles()
return 0;
}
}
- cmSystemTools::ChangeDirectory(dir);
// The destructor of cmArchiveWrite will close and finish the write
return 1;
}
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index fd67df9..ec5fc88 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -390,6 +390,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
bool remount_image =
!cpack_package_icon.empty() || !cpack_dmg_ds_store_setup_script.empty();
+ std::string temp_image_format = "UDZO";
+
// Create 1 MB dummy padding file in staging area when we need to remount
// image, so we have enough space for storing changes ...
if (remount_image) {
@@ -401,6 +403,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
return 0;
}
+ temp_image_format = "UDRW";
}
// Create a temporary read-write disk image ...
@@ -413,7 +416,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
temp_image_command << " -ov";
temp_image_command << " -srcfolder \"" << staging.str() << "\"";
temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\"";
- temp_image_command << " -format UDRW";
+ temp_image_command << " -format " << temp_image_format;
temp_image_command << " \"" << temp_image << "\"";
if (!this->RunCommand(temp_image_command)) {
@@ -632,29 +635,33 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
return 0;
}
- // convert to UDCO
- std::string temp_udco = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- temp_udco += "/temp-udco.dmg";
+ if (temp_image_format != "UDZO") {
+ temp_image_format = "UDZO";
+ // convert to UDZO to enable unflatten/flatten
+ std::string temp_udzo = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+ temp_udzo += "/temp-udzo.dmg";
- std::ostringstream udco_image_command;
- udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
- udco_image_command << " convert \"" << temp_image << "\"";
- udco_image_command << " -format UDCO";
- udco_image_command << " -ov -o \"" << temp_udco << "\"";
+ std::ostringstream udco_image_command;
+ udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
+ udco_image_command << " convert \"" << temp_image << "\"";
+ udco_image_command << " -format UDZO";
+ udco_image_command << " -ov -o \"" << temp_udzo << "\"";
- if (!this->RunCommand(udco_image_command, &error)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error converting to UDCO dmg for adding SLA."
- << std::endl
- << error << std::endl);
- return 0;
+ if (!this->RunCommand(udco_image_command, &error)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error converting to UDCO dmg for adding SLA."
+ << std::endl
+ << error << std::endl);
+ return 0;
+ }
+ temp_image = temp_udzo;
}
// unflatten dmg
std::ostringstream unflatten_command;
unflatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
unflatten_command << " unflatten ";
- unflatten_command << "\"" << temp_udco << "\"";
+ unflatten_command << "\"" << temp_image << "\"";
if (!this->RunCommand(unflatten_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -673,7 +680,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
}
embed_sla_command << " \"" << sla_r << "\"";
embed_sla_command << " -a -o ";
- embed_sla_command << "\"" << temp_udco << "\"";
+ embed_sla_command << "\"" << temp_image << "\"";
if (!this->RunCommand(embed_sla_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding SLA." << std::endl
@@ -686,7 +693,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::ostringstream flatten_command;
flatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
flatten_command << " flatten ";
- flatten_command << "\"" << temp_udco << "\"";
+ flatten_command << "\"" << temp_image << "\"";
if (!this->RunCommand(flatten_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -695,8 +702,6 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
<< std::endl);
return 0;
}
-
- temp_image = temp_udco;
}
// Create the final compressed read-only disk image ...
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index e1a4a2a..f6ea8cf 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -16,6 +16,7 @@
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmStateSnapshot.h"
+#include "cmWorkingDirectory.h"
#include "cmXMLSafe.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h"
@@ -383,7 +384,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
goToDir += "/" + subdir;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
<< std::endl);
- cmSystemTools::ChangeDirectory(goToDir);
+ cmWorkingDirectory workdir(goToDir);
for (symlinkedIt = symlinkedFiles.begin();
symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
@@ -408,7 +409,6 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir
<< std::endl);
- cmSystemTools::ChangeDirectory(curDir);
}
}
}
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 6780a0e..6f81429 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -6,6 +6,7 @@
#include "cmCTestTestHandler.h"
#include "cmGlobalGenerator.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmake.h"
#include <cmsys/Process.h>
@@ -42,7 +43,7 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
std::ostringstream& out,
std::string& cmakeOutString,
- std::string& cwd, cmake* cm)
+ cmake* cm)
{
unsigned int k;
std::vector<std::string> args;
@@ -85,8 +86,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
if (outstring) {
*outstring = out.str();
} else {
@@ -99,8 +98,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
if (outstring) {
*outstring = out.str();
} else {
@@ -199,13 +196,12 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
double clock_start = cmSystemTools::GetTime();
// make sure the binary dir is there
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
out << "Internal cmake changing into directory: " << this->BinaryDir
<< std::endl;
if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
}
- cmSystemTools::ChangeDirectory(this->BinaryDir);
+ cmWorkingDirectory workdir(this->BinaryDir);
if (this->BuildNoCMake) {
// Make the generator available for the Build call below.
@@ -217,7 +213,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cm.LoadCache(this->BinaryDir);
} else {
// do the cmake step, no timeout here since it is not a sub process
- if (this->RunCMake(outstring, out, cmakeOutString, cwd, &cm)) {
+ if (this->RunCMake(outstring, out, cmakeOutString, &cm)) {
return 1;
}
}
@@ -304,8 +300,6 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
} else {
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
}
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
return 1;
}
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index 5885738..af082a3 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -46,7 +46,7 @@ protected:
///! Run CMake and build a test and then run it as a single test.
int RunCMakeAndTest(std::string* output);
int RunCMake(std::string* outstring, std::ostringstream& out,
- std::string& cmakeOutString, std::string& cwd, cmake* cm);
+ std::string& cmakeOutString, cmake* cm);
std::string Output;
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 989c096..120c5d9 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -12,6 +12,7 @@
#include "cmParseJacocoCoverage.h"
#include "cmParsePHPCoverage.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
#include "cmake.h"
@@ -969,9 +970,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
- std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::MakeDirectory(tempDir.c_str());
- cmSystemTools::ChangeDirectory(tempDir);
+ cmWorkingDirectory workdir(tempDir);
int gcovStyle = 0;
@@ -1294,7 +1294,6 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
}
- cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
@@ -1340,7 +1339,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
return 0;
}
std::string testingDir = this->CTest->GetBinaryDir();
- std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
std::set<std::string> missingFiles;
@@ -1362,7 +1360,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
std::string fileDir = cmSystemTools::GetFilenamePath(*it);
- cmSystemTools::ChangeDirectory(fileDir);
+ cmWorkingDirectory workdir(fileDir);
std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " ";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1552,7 +1550,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
}
}
- cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
@@ -1591,13 +1588,8 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is
// used while compiling.
gl.RecurseThroughSymlinksOff();
- std::string prevBinaryDir;
std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory");
- if (cmSystemTools::ChangeDirectory(buildDir)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error changing directory to "
- << buildDir << std::endl);
- return false;
- }
+ cmWorkingDirectory workdir(buildDir);
// Run profmerge to merge all *.dyn files into dpi files
if (!cmSystemTools::RunSingleCommand("profmerge")) {
@@ -1605,11 +1597,9 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
return false;
}
- prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory();
-
// DPI file should appear in build directory
std::string daGlob;
- daGlob = prevBinaryDir;
+ daGlob = buildDir;
daGlob += "/*.dpi";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" looking for dpi files in: " << daGlob << std::endl,
@@ -1646,11 +1636,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
- std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::MakeDirectory(tempDir.c_str());
- cmSystemTools::ChangeDirectory(tempDir);
-
- cmSystemTools::ChangeDirectory(currentDirectory);
std::vector<std::string>::iterator fileIt;
int file_count = 0;
@@ -1737,7 +1723,6 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
}
++file_count;
}
- cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 2a67d47..c99e450 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -6,6 +6,7 @@
#include "cmCTestGenericHandler.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmake.h"
#include <sstream>
@@ -216,8 +217,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
}
}
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(
+ cmWorkingDirectory workdir(
this->CTest->GetCTestConfiguration("BuildDirectory"));
int res = handler->ProcessHandler();
if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) {
@@ -243,7 +243,6 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
returnString);
}
- cmSystemTools::ChangeDirectory(current_dir);
return true;
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index c1724ab..ff465ab 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -7,6 +7,7 @@
#include "cmCTestScriptHandler.h"
#include "cmCTestTestHandler.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <algorithm>
#include <cmsys/FStream.hxx>
@@ -138,8 +139,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
}
}
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->Properties[test]->Directory);
+ cmWorkingDirectory workdir(this->Properties[test]->Directory);
// Lock the resources we'll be using
this->LockResources(test);
@@ -166,7 +166,6 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
this->Failed->push_back(this->Properties[test]->Name);
delete testRun;
}
- cmSystemTools::ChangeDirectory(current_dir);
}
void cmCTestMultiProcessHandler::LockResources(int index)
@@ -683,9 +682,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
count++;
cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
- // push working dir
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(p.Directory);
+ cmWorkingDirectory workdir(p.Directory);
cmCTestRunTest testRun(this->TestHandler);
testRun.SetIndex(p.Index);
@@ -724,8 +721,6 @@ void cmCTestMultiProcessHandler::PrintTestList()
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, p.Name << std::endl,
this->Quiet);
- // pop working dir
- cmSystemTools::ChangeDirectory(current_dir);
}
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index ac1644f..f148f30 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -7,6 +7,7 @@
#include "cmCTestTestHandler.h"
#include "cmProcess.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <cmConfigure.h>
#include <cm_curl.h>
@@ -270,14 +271,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
*this->TestHandler->LogFile << "Test time = " << buf << std::endl;
}
- // Set the working directory to the tests directory
- std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->TestProperties->Directory);
-
- this->DartProcessing();
-
- // restore working directory
- cmSystemTools::ChangeDirectory(oldpath);
+ // Set the working directory to the tests directory to process Dart files.
+ {
+ cmWorkingDirectory workdir(this->TestProperties->Directory);
+ this->DartProcessing();
+ }
// if this is doing MemCheck then all the output needs to be put into
// Output since that is what is parsed by cmCTestMemCheckHandler
@@ -356,11 +354,8 @@ bool cmCTestRunTest::StartAgain()
}
this->RunAgain = false; // reset
// change to tests directory
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->TestProperties->Directory);
+ cmWorkingDirectory workdir(this->TestProperties->Directory);
this->StartTest(this->TotalNumberOfTests);
- // change back
- cmSystemTools::ChangeDirectory(current_dir);
return true;
}
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 5e5119d..cc399b0 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -19,6 +19,7 @@
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmThirdParty.h"
+#include "cmWorkingDirectory.h"
#include "cmXMLParser.h"
#include "cmake.h"
@@ -1519,7 +1520,6 @@ int cmCTestSubmitHandler::ProcessHandler()
#endif
} else if (dropMethod == "scp") {
std::string url;
- std::string oldWorkingDirectory;
if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
}
@@ -1528,19 +1528,16 @@ int cmCTestSubmitHandler::ProcessHandler()
// change to the build directory so that we can uses a relative path
// on windows since scp dosn't support "c:" a drive in the path
- oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(buildDirectory);
+ cmWorkingDirectory workdir(buildDirectory);
if (!this->SubmitUsingSCP(this->CTest->GetCTestConfiguration("ScpCommand"),
"Testing/" + this->CTest->GetCurrentTag(), files,
prefix, url)) {
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when submitting via SCP" << std::endl);
ofs << " Problems when submitting via SCP" << std::endl;
return -1;
}
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
@@ -1550,22 +1547,18 @@ int cmCTestSubmitHandler::ProcessHandler()
// change to the build directory so that we can uses a relative path
// on windows since scp dosn't support "c:" a drive in the path
- std::string oldWorkingDirectory =
- cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(buildDirectory);
+ cmWorkingDirectory workdir(buildDirectory);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Change directory: " << buildDirectory << std::endl,
this->Quiet);
if (!this->SubmitUsingCP("Testing/" + this->CTest->GetCurrentTag(), files,
prefix, location)) {
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when submitting via CP" << std::endl);
ofs << " Problems when submitting via cp" << std::endl;
return -1;
}
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 6175e50..9d22065 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -27,6 +27,7 @@
#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
#include "cm_auto_ptr.hxx"
#include "cm_utf8.h"
@@ -86,22 +87,24 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
// No subdirectory? So what...
continue;
}
- cmSystemTools::ChangeDirectory(fname);
- const char* testFilename;
- if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
- // does the CTestTestfile.cmake exist ?
- testFilename = "CTestTestfile.cmake";
- } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
- // does the DartTestfile.txt exist ?
- testFilename = "DartTestfile.txt";
- } else {
- // No CTestTestfile? Who cares...
- continue;
+ bool readit = false;
+ {
+ cmWorkingDirectory workdir(fname);
+ const char* testFilename;
+ if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
+ // does the CTestTestfile.cmake exist ?
+ testFilename = "CTestTestfile.cmake";
+ } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
+ // does the DartTestfile.txt exist ?
+ testFilename = "DartTestfile.txt";
+ } else {
+ // No CTestTestfile? Who cares...
+ continue;
+ }
+ fname += "/";
+ fname += testFilename;
+ readit = this->Makefile->ReadDependentFile(fname.c_str());
}
- fname += "/";
- fname += testFilename;
- bool readit = this->Makefile->ReadDependentFile(fname.c_str());
- cmSystemTools::ChangeDirectory(cwd);
if (!readit) {
std::string m = "Could not find include file: ";
m += fname;
@@ -109,7 +112,6 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
}
- cmSystemTools::ChangeDirectory(cwd);
return true;
}
@@ -149,9 +151,7 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
return false;
}
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(cwd);
- std::string fname = cwd;
+ std::string fname = cmSystemTools::GetCurrentWorkingDirectory();
fname += "/";
fname += args[0];
@@ -159,23 +159,23 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
// No subdirectory? So what...
return true;
}
- cmSystemTools::ChangeDirectory(fname);
- const char* testFilename;
- if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
- // does the CTestTestfile.cmake exist ?
- testFilename = "CTestTestfile.cmake";
- } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
- // does the DartTestfile.txt exist ?
- testFilename = "DartTestfile.txt";
- } else {
- // No CTestTestfile? Who cares...
- cmSystemTools::ChangeDirectory(cwd);
- return true;
+ bool readit = false;
+ {
+ const char* testFilename;
+ if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
+ // does the CTestTestfile.cmake exist ?
+ testFilename = "CTestTestfile.cmake";
+ } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
+ // does the DartTestfile.txt exist ?
+ testFilename = "DartTestfile.txt";
+ } else {
+ // No CTestTestfile? Who cares...
+ return true;
+ }
+ fname += "/";
+ fname += testFilename;
+ readit = this->Makefile->ReadDependentFile(fname.c_str());
}
- fname += "/";
- fname += testFilename;
- bool readit = this->Makefile->ReadDependentFile(fname.c_str());
- cmSystemTools::ChangeDirectory(cwd);
if (!readit) {
std::string m = "Could not find include file: ";
m += fname;
diff --git a/Source/CursesDialog/form/.gitattributes b/Source/CursesDialog/form/.gitattributes
new file mode 100644
index 0000000..62d728c
--- /dev/null
+++ b/Source/CursesDialog/form/.gitattributes
@@ -0,0 +1 @@
+* -format.clang-format
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx
index eded883..e41850a 100644
--- a/Source/bindexplib.cxx
+++ b/Source/bindexplib.cxx
@@ -308,7 +308,8 @@ public:
this->DataSymbols.insert(symbol);
} else {
if ( pSymbolTable->Type ||
- !(SectChar & IMAGE_SCN_MEM_READ)) {
+ !(SectChar & IMAGE_SCN_MEM_READ) ||
+ (SectChar & IMAGE_SCN_MEM_EXECUTE)) {
this->Symbols.insert(symbol);
} else {
// printf(" strange symbol: %s \n",symbol.c_str());
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 559275e..e6e50e9 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1122,7 +1122,6 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
if (log) {
*log << "* Run internal CTest" << std::endl;
}
- std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv;
if (modifyEnv) {
@@ -1137,7 +1136,6 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
if (log && output) {
*log << *output;
}
- cmSystemTools::ChangeDirectory(oldpath);
if (output) {
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
"Internal cmCTest object used to run test." << std::endl
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index c189419..b8c76b9 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -7,6 +7,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <cmsys/FStream.hxx>
#include <sstream>
@@ -75,13 +76,7 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
std::map<std::string, DependencyVector>& validDeps)
{
// Dependency checks must be done in proper working directory.
- std::string oldcwd = ".";
- if (this->CompileDirectory != ".") {
- // Get the CWD but do not call CollapseFullPath because
- // we only need it to cd back, and the form does not matter
- oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false);
- cmSystemTools::ChangeDirectory(this->CompileDirectory);
- }
+ cmWorkingDirectory workdir(this->CompileDirectory);
// Check whether dependencies must be regenerated.
bool okay = true;
@@ -93,11 +88,6 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
okay = false;
}
- // Restore working directory.
- if (oldcwd != ".") {
- cmSystemTools::ChangeDirectory(oldcwd);
- }
-
return okay;
}
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 2feedf3..69f9078 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -43,20 +43,22 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn,
return true;
}
- if (this->Makefile->GetState()->GetGlobalPropertyAsBool(
- "FIND_LIBRARY_USE_LIB32_PATHS")) {
- // add special 32 bit paths if this is a 32 bit compile.
- if (this->Makefile->PlatformIs32Bit()) {
- this->AddArchitecturePaths("32");
- }
+ // add custom lib<qual> paths instead of using fixed lib32 or lib64
+ if (const char* customLib = this->Makefile->GetDefinition(
+ "CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX")) {
+ this->AddArchitecturePaths(customLib);
}
-
- if (this->Makefile->GetState()->GetGlobalPropertyAsBool(
- "FIND_LIBRARY_USE_LIB64_PATHS")) {
- // add special 64 bit paths if this is a 64 bit compile.
- if (this->Makefile->PlatformIs64Bit()) {
- this->AddArchitecturePaths("64");
- }
+ // add special 32 bit paths if this is a 32 bit compile.
+ else if (this->Makefile->PlatformIs32Bit() &&
+ this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ "FIND_LIBRARY_USE_LIB32_PATHS")) {
+ this->AddArchitecturePaths("32");
+ }
+ // add special 64 bit paths if this is a 64 bit compile.
+ else if (this->Makefile->PlatformIs64Bit() &&
+ this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ "FIND_LIBRARY_USE_LIB64_PATHS")) {
+ this->AddArchitecturePaths("64");
}
std::string library = this->FindLibrary();
@@ -84,36 +86,68 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
}
}
+static bool cmLibDirsLinked(std::string const& l, std::string const& r)
+{
+ // Compare the real paths of the two directories.
+ // Since our caller only changed the trailing component of each
+ // directory, the real paths can be the same only if at least one of
+ // the trailing components is a symlink. Use this as an optimization
+ // to avoid excessive realpath calls.
+ return (cmSystemTools::FileIsSymlink(l) ||
+ cmSystemTools::FileIsSymlink(r)) &&
+ cmSystemTools::GetRealPath(l) == cmSystemTools::GetRealPath(r);
+}
+
void cmFindLibraryCommand::AddArchitecturePath(
std::string const& dir, std::string::size_type start_pos, const char* suffix,
bool fresh)
{
std::string::size_type pos = dir.find("lib/", start_pos);
+
if (pos != std::string::npos) {
- std::string cur_dir = dir.substr(0, pos + 3);
-
- // Follow "lib<suffix>".
- std::string next_dir = cur_dir + suffix;
- if (cmSystemTools::FileIsDirectory(next_dir)) {
- next_dir += dir.substr(pos + 3);
- std::string::size_type next_pos = pos + 3 + strlen(suffix) + 1;
- this->AddArchitecturePath(next_dir, next_pos, suffix);
+ // Check for "lib".
+ std::string lib = dir.substr(0, pos + 3);
+ bool use_lib = cmSystemTools::FileIsDirectory(lib);
+
+ // Check for "lib<suffix>" and use it first.
+ std::string libX = lib + suffix;
+ bool use_libX = cmSystemTools::FileIsDirectory(libX);
+
+ // Avoid copies of the same directory due to symlinks.
+ if (use_libX && use_lib && cmLibDirsLinked(libX, lib)) {
+ use_libX = false;
+ }
+
+ if (use_libX) {
+ libX += dir.substr(pos + 3);
+ std::string::size_type libX_pos = pos + 3 + strlen(suffix) + 1;
+ this->AddArchitecturePath(libX, libX_pos, suffix);
}
- // Follow "lib".
- if (cmSystemTools::FileIsDirectory(cur_dir)) {
+ if (use_lib) {
this->AddArchitecturePath(dir, pos + 3 + 1, suffix, false);
}
}
+
if (fresh) {
- // Check for <dir><suffix>/.
- std::string cur_dir = dir + suffix + "/";
- if (cmSystemTools::FileIsDirectory(cur_dir)) {
- this->SearchPaths.push_back(cur_dir);
+ // Check for the original unchanged path.
+ bool use_dir = cmSystemTools::FileIsDirectory(dir);
+
+ // Check for <dir><suffix>/ and use it first.
+ std::string dirX = dir + suffix;
+ bool use_dirX = cmSystemTools::FileIsDirectory(dirX);
+
+ // Avoid copies of the same directory due to symlinks.
+ if (use_dirX && use_dir && cmLibDirsLinked(dirX, dir)) {
+ use_dirX = false;
+ }
+
+ if (use_dirX) {
+ dirX += "/";
+ this->SearchPaths.push_back(dirX);
}
- // Now add the original unchanged path
- if (cmSystemTools::FileIsDirectory(dir)) {
+ if (use_dir) {
this->SearchPaths.push_back(dir);
}
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 8512b99..47d685d 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -711,12 +711,18 @@ void cmGeneratorTarget::GetExternalObjects(
IMPLEMENT_VISIT(ExternalObjects);
}
-void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
+void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& headers,
const std::string& config) const
{
- ResxData data;
- IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
- srcs = data.ExpectedResxHeaders;
+ HeadersCacheType::const_iterator it = this->ResxHeadersCache.find(config);
+ if (it == this->ResxHeadersCache.end()) {
+ ResxData data;
+ IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+ it = this->ResxHeadersCache
+ .insert(std::make_pair(config, data.ExpectedResxHeaders))
+ .first;
+ }
+ headers = it->second;
}
void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile const*>& srcs,
@@ -748,9 +754,15 @@ void cmGeneratorTarget::GetCertificates(std::vector<cmSourceFile const*>& data,
void cmGeneratorTarget::GetExpectedXamlHeaders(std::set<std::string>& headers,
const std::string& config) const
{
- XamlData data;
- IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
- headers = data.ExpectedXamlHeaders;
+ HeadersCacheType::const_iterator it = this->XamlHeadersCache.find(config);
+ if (it == this->XamlHeadersCache.end()) {
+ XamlData data;
+ IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
+ it = this->XamlHeadersCache
+ .insert(std::make_pair(config, data.ExpectedXamlHeaders))
+ .first;
+ }
+ headers = it->second;
}
void cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs,
@@ -1147,7 +1159,7 @@ std::string cmGeneratorTarget::GetCompilePDBPath(
{
std::string dir = this->GetCompilePDBDirectory(config);
std::string name = this->GetCompilePDBName(config);
- if (dir.empty() && !name.empty()) {
+ if (dir.empty() && !name.empty() && this->HaveWellDefinedOutputFiles()) {
dir = this->GetPDBDirectory(config);
}
if (!dir.empty()) {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 689fbda..e72e0a6 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -739,6 +739,10 @@ private:
bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
std::string& out) const;
+ typedef std::map<std::string, std::set<std::string> > HeadersCacheType;
+ mutable HeadersCacheType ResxHeadersCache;
+ mutable HeadersCacheType XamlHeadersCache;
+
public:
const std::vector<const cmGeneratorTarget*>& GetLinkImplementationClosure(
const std::string& config) const;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b6b7d9e..1f5e624 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -42,6 +42,7 @@
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
#include "cmVersion.h"
+#include "cmWorkingDirectory.h"
#include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -1763,8 +1764,7 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
/**
* Run an executable command and put the stdout in output.
*/
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir);
+ cmWorkingDirectory workdir(bindir);
output += "Change Dir: ";
output += bindir;
output += "\n";
@@ -1804,8 +1804,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
output += *outputPtr;
output += "\nGenerator: execution of make clean failed.\n";
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
return 1;
}
output += *outputPtr;
@@ -1828,8 +1826,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
output += "\nGenerator: execution of make failed. Make command was: " +
makeCommandStr + "\n";
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
return 1;
}
output += *outputPtr;
@@ -1842,7 +1838,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
retVal = 1;
}
- cmSystemTools::ChangeDirectory(cwd);
return retVal;
}
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 8627cf2..b023d5c 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -28,6 +28,7 @@
#include "cmTarget.h"
#include "cmXCode21Object.h"
#include "cmXCodeObject.h"
+#include "cmXCodeScheme.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h"
@@ -423,14 +424,12 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// Add XCODE depend helper
std::string dir = root->GetCurrentBinaryDirectory();
cmCustomCommandLine makeHelper;
- if (this->XcodeVersion < 50) {
- makeHelper.push_back("make");
- makeHelper.push_back("-C");
- makeHelper.push_back(dir);
- makeHelper.push_back("-f");
- makeHelper.push_back(this->CurrentXCodeHackMakefile);
- makeHelper.push_back(""); // placeholder, see below
- }
+ makeHelper.push_back("make");
+ makeHelper.push_back("-C");
+ makeHelper.push_back(dir);
+ makeHelper.push_back("-f");
+ makeHelper.push_back(this->CurrentXCodeHackMakefile);
+ makeHelper.push_back(""); // placeholder, see below
// Add ZERO_CHECK
bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION");
@@ -475,13 +474,12 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// run the depend check makefile as a post build rule
// this will make sure that when the next target is built
// things are up-to-date
- if (!makeHelper.empty() &&
- (target->GetType() == cmStateEnums::EXECUTABLE ||
- // Nope - no post-build for OBJECT_LIRBRARY
- // target->GetType() == cmStateEnums::OBJECT_LIBRARY ||
- target->GetType() == cmStateEnums::STATIC_LIBRARY ||
- target->GetType() == cmStateEnums::SHARED_LIBRARY ||
- target->GetType() == cmStateEnums::MODULE_LIBRARY)) {
+ if (target->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ (this->XcodeVersion < 50 &&
+ (target->GetType() == cmStateEnums::EXECUTABLE ||
+ target->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ target->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ target->GetType() == cmStateEnums::MODULE_LIBRARY))) {
makeHelper[makeHelper.size() - 1] = // fill placeholder
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
cmCustomCommandLines commandLines;
@@ -489,7 +487,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
std::vector<std::string> no_byproducts;
lg->GetMakefile()->AddCustomCommandToTarget(
target->GetName(), no_byproducts, no_depends, commandLines,
- cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str());
+ cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true,
+ false, "", false, cmMakefile::AcceptObjectLibraryCommands);
}
if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
@@ -3129,10 +3128,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
cmXCodeObject* t = *i;
this->AddDependAndLinkInformation(t);
}
- if (this->XcodeVersion < 50) {
- // now create xcode depend hack makefile
- this->CreateXCodeDependHackTarget(targets);
- }
+ this->CreateXCodeDependHackTarget(targets);
// now add all targets to the root object
cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
@@ -3183,29 +3179,9 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
"default:\n"
"\techo \"Do not invoke directly\"\n"
"\n";
- makefileStream
- << "# For each target create a dummy rule "
- "so the target does not have to exist\n";
/* clang-format on */
- std::set<std::string> emitted;
- for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
- i != targets.end(); ++i) {
- cmXCodeObject* target = *i;
- std::map<std::string, cmXCodeObject::StringVec> const& deplibs =
- target->GetDependLibraries();
- for (std::map<std::string, cmXCodeObject::StringVec>::const_iterator ci =
- deplibs.begin();
- ci != deplibs.end(); ++ci) {
- for (cmXCodeObject::StringVec::const_iterator d = ci->second.begin();
- d != ci->second.end(); ++d) {
- if (emitted.insert(*d).second) {
- makefileStream << this->ConvertToRelativeForMake(d->c_str())
- << ":\n";
- }
- }
- }
- }
- makefileStream << "\n\n";
+
+ std::set<std::string> dummyRules;
// Write rules to help Xcode relink things at the right time.
/* clang-format off */
@@ -3224,8 +3200,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
cmGeneratorTarget* gt = target->GetTarget();
if (gt->GetType() == cmStateEnums::EXECUTABLE ||
- // Nope - no post-build for OBJECT_LIRBRARY
- // gt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ gt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
gt->GetType() == cmStateEnums::STATIC_LIBRARY ||
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
@@ -3235,6 +3210,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
}
if (gt->GetType() == cmStateEnums::EXECUTABLE ||
+ gt->GetType() == cmStateEnums::STATIC_LIBRARY ||
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
std::string tfull = gt->GetFullPath(configName);
@@ -3252,6 +3228,15 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
}
}
+ std::vector<cmGeneratorTarget*> objlibs;
+ gt->GetObjectLibrariesCMP0026(objlibs);
+ for (std::vector<cmGeneratorTarget*>::const_iterator it =
+ objlibs.begin();
+ it != objlibs.end(); ++it) {
+ makefileStream << this->PostBuildMakeTarget((*it)->GetName(), *ct)
+ << ": " << trel << "\n";
+ }
+
// Create a rule for this target.
makefileStream << trel << ":";
@@ -3262,10 +3247,28 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
std::vector<std::string> const& deplibs = x->second;
for (std::vector<std::string>::const_iterator d = deplibs.begin();
d != deplibs.end(); ++d) {
- makefileStream << "\\\n\t"
- << this->ConvertToRelativeForMake(d->c_str());
+ std::string file = this->ConvertToRelativeForMake(d->c_str());
+ makefileStream << "\\\n\t" << file;
+ dummyRules.insert(file);
}
}
+
+ for (std::vector<cmGeneratorTarget*>::const_iterator it =
+ objlibs.begin();
+ it != objlibs.end(); ++it) {
+
+ const std::string objLibName = (*it)->GetName();
+ std::string d = this->GetObjectsNormalDirectory(this->CurrentProject,
+ configName, *it);
+ d += "lib";
+ d += objLibName;
+ d += ".a";
+
+ std::string dependency = this->ConvertToRelativeForMake(d.c_str());
+ makefileStream << "\\\n\t" << dependency;
+ dummyRules.insert(dependency);
+ }
+
// Write the action to remove the target if it is out of date.
makefileStream << "\n";
makefileStream << "\t/bin/rm -f "
@@ -3293,6 +3296,14 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
}
}
}
+
+ makefileStream << "\n\n"
+ << "# For each target create a dummy rule"
+ << "so the target does not have to exist\n";
+ for (std::set<std::string>::const_iterator it = dummyRules.begin();
+ it != dummyRules.end(); ++it) {
+ makefileStream << *it << ":\n";
+ }
}
void cmGlobalXCodeGenerator::OutputXCodeProject(
@@ -3327,6 +3338,16 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
return;
}
this->WriteXCodePBXProj(fout, root, generators);
+
+ // Since the lowest available Xcode version for testing was 7.0,
+ // I'm setting this as a limit then
+ if (this->GetCMakeInstance()->GetState()->GetGlobalPropertyAsBool(
+ "XCODE_GENERATE_SCHEME") &&
+ this->XcodeVersion >= 70) {
+ this->OutputXCodeSharedSchemes(xcodeDir);
+ this->OutputXCodeWorkspaceSettings(xcodeDir);
+ }
+
this->ClearXCodeObjects();
// Since this call may have created new cache entries, save the cache:
@@ -3335,6 +3356,54 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
root->GetBinaryDirectory());
}
+void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
+ const std::string& xcProjDir)
+{
+ for (std::vector<cmXCodeObject*>::const_iterator i =
+ this->XCodeObjects.begin();
+ i != this->XCodeObjects.end(); ++i) {
+ cmXCodeObject* obj = *i;
+ if (obj->GetType() == cmXCodeObject::OBJECT &&
+ (obj->GetIsA() == cmXCodeObject::PBXNativeTarget ||
+ obj->GetIsA() == cmXCodeObject::PBXAggregateTarget)) {
+ cmXCodeScheme schm(obj, this->CurrentConfigurationTypes,
+ this->XcodeVersion);
+ schm.WriteXCodeSharedScheme(xcProjDir,
+ this->RelativeToSource(xcProjDir.c_str()));
+ }
+ }
+}
+
+void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings(
+ const std::string& xcProjDir)
+{
+ std::string xcodeSharedDataDir = xcProjDir;
+ xcodeSharedDataDir += "/project.xcworkspace/xcshareddata";
+ cmSystemTools::MakeDirectory(xcodeSharedDataDir);
+
+ std::string workspaceSettingsFile = xcodeSharedDataDir;
+ workspaceSettingsFile += "/WorkspaceSettings.xcsettings";
+
+ cmGeneratedFileStream fout(workspaceSettingsFile.c_str());
+ fout.SetCopyIfDifferent(true);
+ if (!fout) {
+ return;
+ }
+
+ cmXMLWriter xout(fout);
+ xout.StartDocument();
+ xout.Doctype("plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\""
+ "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"");
+ xout.StartElement("plist");
+ xout.Attribute("version", "1.0");
+ xout.StartElement("dict");
+ xout.Element("key", "IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded");
+ xout.Element("false");
+ xout.EndElement(); // dict
+ xout.EndElement(); // plist
+ xout.EndDocument();
+}
+
void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
cmLocalGenerator*,
std::vector<cmLocalGenerator*>&)
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 1aaf9c7..9eacdef 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -165,6 +165,9 @@ private:
std::vector<cmLocalGenerator*>& generators);
void OutputXCodeProject(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
+ // Write shared scheme files for all the native targets
+ void OutputXCodeSharedSchemes(const std::string& xcProjDir);
+ void OutputXCodeWorkspaceSettings(const std::string& xcProjDir);
void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string& fullpath,
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index b1cd889..23b666e 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -80,6 +80,13 @@ bool cmListFileParser::ParseFile()
return false;
}
+ if (bom == cmListFileLexer_BOM_Broken) {
+ cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
+ this->IssueFileOpenError("Error while reading Byte-Order-Mark. "
+ "File not seekable?");
+ return false;
+ }
+
// Verify the Byte-Order-Mark, if any.
if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) {
cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c
index 56559f6..44d0894 100644
--- a/Source/cmListFileLexer.c
+++ b/Source/cmListFileLexer.c
@@ -2559,11 +2559,15 @@ static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
return cmListFileLexer_BOM_UTF32LE;
}
- fsetpos(f, &p);
+ if (fsetpos(f, &p) != 0) {
+ return cmListFileLexer_BOM_Broken;
+ }
return cmListFileLexer_BOM_UTF16LE;
}
}
- rewind(f);
+ if (fseek(f, 0, SEEK_SET) != 0) {
+ return cmListFileLexer_BOM_Broken;
+ }
return cmListFileLexer_BOM_None;
}
diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h
index c9fb6da..f243010a 100644
--- a/Source/cmListFileLexer.h
+++ b/Source/cmListFileLexer.h
@@ -32,6 +32,7 @@ struct cmListFileLexer_Token_s
enum cmListFileLexer_BOM_e
{
cmListFileLexer_BOM_None,
+ cmListFileLexer_BOM_Broken,
cmListFileLexer_BOM_UTF8,
cmListFileLexer_BOM_UTF16BE,
cmListFileLexer_BOM_UTF16LE,
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 07d712c..82bf0b9 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -213,14 +213,7 @@ void cmLocalGenerator::TraceDependencies()
void cmLocalGenerator::GenerateTestFiles()
{
- std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
- file += "/";
- file += "CTestTestfile.cmake";
-
if (!this->Makefile->IsOn("CMAKE_TESTING_ENABLED")) {
- if (cmSystemTools::FileExists(file)) {
- cmSystemTools::RemoveFile(file);
- }
return;
}
@@ -229,6 +222,10 @@ void cmLocalGenerator::GenerateTestFiles()
const std::string& config =
this->Makefile->GetConfigurations(configurationTypes, false);
+ std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
+ file += "/";
+ file += "CTestTestfile.cmake";
+
cmGeneratedFileStream fout(file.c_str());
fout.SetCopyIfDifferent(true);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index b3d7a04..204fd8f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -36,6 +36,7 @@
#include "cmTest.h"
#include "cmTestGenerator.h" // IWYU pragma: keep
#include "cmVersion.h"
+#include "cmWorkingDirectory.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h"
@@ -684,7 +685,8 @@ void cmMakefile::AddCustomCommandToTarget(
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
const char* comment, const char* workingDir, bool escapeOldStyle,
- bool uses_terminal, const std::string& depfile, bool command_expand_lists)
+ bool uses_terminal, const std::string& depfile, bool command_expand_lists,
+ ObjectLibraryCommands objLibraryCommands)
{
// Find the target to which to add the custom command.
cmTargets::iterator ti = this->Targets.find(target);
@@ -724,7 +726,8 @@ void cmMakefile::AddCustomCommandToTarget(
return;
}
- if (ti->second.GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ if (objLibraryCommands == RejectObjectLibraryCommands &&
+ ti->second.GetType() == cmStateEnums::OBJECT_LIBRARY) {
std::ostringstream e;
e << "Target \"" << target
<< "\" is an OBJECT library "
@@ -3145,8 +3148,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// change to the tests directory and run cmake
// use the cmake object instead of calling cmake
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir);
+ cmWorkingDirectory workdir(bindir);
// make sure the same generator is used
// use this program as the cmake to be run, it should not
@@ -3160,8 +3162,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this->GetGlobalGenerator()->GetName() +
"' could not be created.");
cmSystemTools::SetFatalErrorOccured();
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3225,8 +3225,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this->IssueMessage(cmake::FATAL_ERROR,
"Failed to configure test project build system.");
cmSystemTools::SetFatalErrorOccured();
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3235,8 +3233,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this->IssueMessage(cmake::FATAL_ERROR,
"Failed to generate test project build system.");
cmSystemTools::SetFatalErrorOccured();
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3245,7 +3241,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
int ret = this->GetGlobalGenerator()->TryCompile(
srcdir, bindir, projectName, targetName, fast, output, this);
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return ret;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 9d9e90a..4d5ce98 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -119,6 +119,13 @@ public:
*/
void FinalPass();
+ /** How to handle custom commands for object libraries */
+ enum ObjectLibraryCommands
+ {
+ RejectObjectLibraryCommands,
+ AcceptObjectLibraryCommands
+ };
+
/** Add a custom command to the build. */
void AddCustomCommandToTarget(
const std::string& target, const std::vector<std::string>& byproducts,
@@ -126,7 +133,8 @@ public:
const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
const char* comment, const char* workingDir, bool escapeOldStyle = true,
bool uses_terminal = false, const std::string& depfile = "",
- bool command_expand_lists = false);
+ bool command_expand_lists = false,
+ ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands);
cmSourceFile* AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& byproducts,
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index f096416..b1f26e4 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -385,7 +385,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.CMTargetType =
cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType());
vars.Language = lang.c_str();
- vars.Source = "$IN_ABS";
+ vars.Source = "$in";
vars.Object = "$out";
vars.Defines = "$DEFINES";
vars.Includes = "$INCLUDES";
@@ -773,7 +773,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
cmSourceFile const* source, bool writeOrderDependsTargetForTarget)
{
std::string const language = source->GetLanguage();
- std::string const sourceFileName = this->GetSourceFilePath(source);
+ std::string const sourceFileName =
+ language == "RC" ? source->GetFullPath() : this->GetSourceFilePath(source);
std::string const objectDir =
this->ConvertToNinjaPath(this->GeneratorTarget->GetSupportDirectory());
std::string const objectFileName =
@@ -782,8 +783,6 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
cmSystemTools::GetFilenamePath(objectFileName);
cmNinjaVars vars;
- vars["IN_ABS"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- source->GetFullPath(), cmOutputConverter::SHELL);
vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
vars["DEFINES"] = this->ComputeDefines(source, language);
vars["INCLUDES"] = this->GetIncludes(language);
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 7744a5a..d48eb53 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -287,8 +287,7 @@ void cmOrderDirectories::AddRuntimeLibrary(std::string const& fullPath,
}
}
- if (this->ImplicitDirectories.find(dir) !=
- this->ImplicitDirectories.end()) {
+ if (this->IsImplicitDirectory(dir)) {
this->ImplicitDirEntries.push_back(
new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
return;
@@ -316,8 +315,7 @@ void cmOrderDirectories::AddLinkLibrary(std::string const& fullPath)
// Implicit link directories need special handling.
if (!this->ImplicitDirectories.empty()) {
std::string dir = cmSystemTools::GetFilenamePath(fullPath);
- if (this->ImplicitDirectories.find(dir) !=
- this->ImplicitDirectories.end()) {
+ if (this->IsImplicitDirectory(dir)) {
this->ImplicitDirEntries.push_back(
new cmOrderDirectoriesConstraintLibrary(this, fullPath));
return;
@@ -347,7 +345,18 @@ void cmOrderDirectories::AddLanguageDirectories(
void cmOrderDirectories::SetImplicitDirectories(
std::set<std::string> const& implicitDirs)
{
- this->ImplicitDirectories = implicitDirs;
+ this->ImplicitDirectories.clear();
+ for (std::set<std::string>::const_iterator i = implicitDirs.begin();
+ i != implicitDirs.end(); ++i) {
+ this->ImplicitDirectories.insert(this->GetRealPath(*i));
+ }
+}
+
+bool cmOrderDirectories::IsImplicitDirectory(std::string const& dir)
+{
+ std::string const& real = this->GetRealPath(dir);
+ return this->ImplicitDirectories.find(real) !=
+ this->ImplicitDirectories.end();
}
void cmOrderDirectories::SetLinkExtensionInfo(
@@ -394,8 +403,7 @@ void cmOrderDirectories::AddOriginalDirectories(
for (std::vector<std::string>::const_iterator di = dirs.begin();
di != dirs.end(); ++di) {
// We never explicitly specify implicit link directories.
- if (this->ImplicitDirectories.find(*di) !=
- this->ImplicitDirectories.end()) {
+ if (this->IsImplicitDirectory(*di)) {
continue;
}
diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 90a67e7..d9e0126 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -82,6 +82,8 @@ private:
// Compare directories after resolving symlinks.
bool IsSameDirectory(std::string const& l, std::string const& r);
+ bool IsImplicitDirectory(std::string const& dir);
+
std::string const& GetRealPath(std::string const& dir);
std::map<std::string, std::string> RealPaths;
diff --git a/Source/cmQtAutoGeneratorCommon.cxx b/Source/cmQtAutoGeneratorCommon.cxx
new file mode 100644
index 0000000..dcd61a3
--- /dev/null
+++ b/Source/cmQtAutoGeneratorCommon.cxx
@@ -0,0 +1,215 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoGeneratorCommon.h"
+#include "cmAlgorithms.h"
+#include "cmSystemTools.h"
+
+#include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
+
+#include <sstream>
+
+// - Static functions
+
+static std::string utilStripCR(std::string const& line)
+{
+ // Strip CR characters rcc may have printed (possibly more than one!).
+ std::string::size_type cr = line.find('\r');
+ if (cr != line.npos) {
+ return line.substr(0, cr);
+ }
+ return line;
+}
+
+/// @brief Reads the resource files list from from a .qrc file - Qt4 version
+/// @return True if the .qrc file was successfully parsed
+static bool RccListInputsQt4(const std::string& fileName,
+ std::vector<std::string>& files,
+ std::string* errorMessage)
+{
+ bool allGood = true;
+ // Read qrc file content into string
+ std::string qrcContents;
+ {
+ cmsys::ifstream ifs(fileName.c_str());
+ if (ifs) {
+ std::ostringstream osst;
+ osst << ifs.rdbuf();
+ qrcContents = osst.str();
+ } else {
+ if (errorMessage != CM_NULLPTR) {
+ std::ostringstream ost;
+ ost << "AutoRcc: Error: Rcc file not readable:\n"
+ << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n";
+ *errorMessage = ost.str();
+ }
+ allGood = false;
+ }
+ }
+ if (allGood) {
+ // qrc file directory
+ std::string qrcDir(cmsys::SystemTools::GetFilenamePath(fileName));
+ if (!qrcDir.empty()) {
+ qrcDir += '/';
+ }
+
+ cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
+ cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
+
+ size_t offset = 0;
+ while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
+ std::string qrcEntry = fileMatchRegex.match(1);
+ offset += qrcEntry.size();
+ {
+ fileReplaceRegex.find(qrcEntry);
+ std::string tag = fileReplaceRegex.match(1);
+ qrcEntry = qrcEntry.substr(tag.size());
+ }
+ if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
+ qrcEntry = qrcDir + qrcEntry;
+ }
+ files.push_back(qrcEntry);
+ }
+ }
+ return allGood;
+}
+
+/// @brief Reads the resource files list from from a .qrc file - Qt5 version
+/// @return True if the .qrc file was successfully parsed
+static bool RccListInputsQt5(const std::string& rccCommand,
+ const std::string& fileName,
+ std::vector<std::string>& files,
+ std::string* errorMessage)
+{
+ if (rccCommand.empty()) {
+ cmSystemTools::Error("AutoRcc: Error: rcc executable not available\n");
+ return false;
+ }
+
+ // Read rcc features
+ bool hasDashDashList = false;
+ {
+ std::vector<std::string> command;
+ command.push_back(rccCommand);
+ command.push_back("--help");
+ std::string rccStdOut;
+ std::string rccStdErr;
+ int retVal = 0;
+ bool result =
+ cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
+ CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
+ if (result && retVal == 0 &&
+ rccStdOut.find("--list") != std::string::npos) {
+ hasDashDashList = true;
+ }
+ }
+
+ // Run rcc list command
+ bool result = false;
+ int retVal = 0;
+ std::string rccStdOut;
+ std::string rccStdErr;
+ {
+ std::vector<std::string> command;
+ command.push_back(rccCommand);
+ command.push_back(hasDashDashList ? "--list" : "-list");
+ command.push_back(fileName);
+ result =
+ cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
+ CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
+ }
+ if (!result || retVal) {
+ if (errorMessage != CM_NULLPTR) {
+ std::ostringstream ost;
+ ost << "AutoRcc: Error: Rcc list process for " << fileName
+ << " failed:\n"
+ << rccStdOut << "\n"
+ << rccStdErr << "\n";
+ *errorMessage = ost.str();
+ }
+ return false;
+ }
+
+ // Parse rcc std output
+ {
+ std::istringstream ostr(rccStdOut);
+ std::string oline;
+ while (std::getline(ostr, oline)) {
+ oline = utilStripCR(oline);
+ if (!oline.empty()) {
+ files.push_back(oline);
+ }
+ }
+ }
+ // Parse rcc error output
+ {
+ std::istringstream estr(rccStdErr);
+ std::string eline;
+ while (std::getline(estr, eline)) {
+ eline = utilStripCR(eline);
+ if (cmHasLiteralPrefix(eline, "RCC: Error in")) {
+ static std::string searchString = "Cannot find file '";
+
+ std::string::size_type pos = eline.find(searchString);
+ if (pos == std::string::npos) {
+ if (errorMessage != CM_NULLPTR) {
+ std::ostringstream ost;
+ ost << "AutoRcc: Error: Rcc lists unparsable output:\n"
+ << cmQtAutoGeneratorCommon::Quoted(eline) << "\n";
+ *errorMessage = ost.str();
+ }
+ return false;
+ }
+ pos += searchString.length();
+ std::string::size_type sz = eline.size() - pos - 1;
+ files.push_back(eline.substr(pos, sz));
+ }
+ }
+ }
+
+ return true;
+}
+
+// - Class definitions
+
+const char* cmQtAutoGeneratorCommon::listSep = "@LSEP@";
+
+std::string cmQtAutoGeneratorCommon::Quoted(const std::string& text)
+{
+ static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",
+ "\b", "\\b", "\f", "\\f", "\n", "\\n",
+ "\r", "\\r", "\t", "\\t", "\v", "\\v" };
+
+ std::string res = text;
+ for (const char* const* it = cmArrayBegin(rep); it != cmArrayEnd(rep);
+ it += 2) {
+ cmSystemTools::ReplaceString(res, *it, *(it + 1));
+ }
+ res = '"' + res;
+ res += '"';
+ return res;
+}
+
+bool cmQtAutoGeneratorCommon::RccListInputs(const std::string& qtMajorVersion,
+ const std::string& rccCommand,
+ const std::string& fileName,
+ std::vector<std::string>& files,
+ std::string* errorMessage)
+{
+ bool allGood = false;
+ if (cmsys::SystemTools::FileExists(fileName.c_str())) {
+ if (qtMajorVersion == "4") {
+ allGood = RccListInputsQt4(fileName, files, errorMessage);
+ } else {
+ allGood = RccListInputsQt5(rccCommand, fileName, files, errorMessage);
+ }
+ } else {
+ if (errorMessage != CM_NULLPTR) {
+ std::ostringstream ost;
+ ost << "AutoRcc: Error: Rcc file does not exist:\n"
+ << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n";
+ *errorMessage = ost.str();
+ }
+ }
+ return allGood;
+}
diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h
new file mode 100644
index 0000000..ee97b71
--- /dev/null
+++ b/Source/cmQtAutoGeneratorCommon.h
@@ -0,0 +1,34 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmQtAutoGeneratorCommon_h
+#define cmQtAutoGeneratorCommon_h
+
+#include <cmConfigure.h> // IWYU pragma: keep
+#include <string>
+#include <vector>
+
+class cmGeneratorTarget;
+class cmLocalGenerator;
+
+class cmQtAutoGeneratorCommon
+{
+ // - Types and statics
+public:
+ static const char* listSep;
+
+public:
+ /// @brief Returns a the string escaped and enclosed in quotes
+ ///
+ static std::string Quoted(const std::string& text);
+
+ /// @brief Reads the resource files list from from a .qrc file
+ /// @arg fileName Must be the absolute path of the .qrc file
+ /// @return True if the rcc file was successfully parsed
+ static bool RccListInputs(const std::string& qtMajorVersion,
+ const std::string& rccCommand,
+ const std::string& fileName,
+ std::vector<std::string>& files,
+ std::string* errorMessage = CM_NULLPTR);
+};
+
+#endif
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 52112ff..94cc981 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -1,6 +1,7 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQtAutoGeneratorInitializer.h"
+#include "cmQtAutoGeneratorCommon.h"
#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
@@ -44,14 +45,9 @@ static void utilCopyTargetProperty(cmTarget* destinationTarget,
}
}
-static std::string utilStripCR(std::string const& line)
+inline static bool PropertyEnabled(cmSourceFile* sourceFile, const char* key)
{
- // Strip CR characters rcc may have printed (possibly more than one!).
- std::string::size_type cr = line.find('\r');
- if (cr != line.npos) {
- return line.substr(0, cr);
- }
- return line;
+ return cmSystemTools::IsOn(sourceFile->GetPropertyForUser(key));
}
static std::string GetSafeProperty(cmGeneratorTarget const* target,
@@ -138,21 +134,17 @@ static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
}
-static void SetupSourceFiles(cmGeneratorTarget const* target,
+static void AcquireScanFiles(cmGeneratorTarget const* target,
std::vector<std::string>& mocUicSources,
std::vector<std::string>& mocUicHeaders,
std::vector<std::string>& mocSkipList,
std::vector<std::string>& uicSkipList)
{
- cmMakefile* makefile = target->Target->GetMakefile();
-
- std::vector<cmSourceFile*> srcFiles;
- target->GetConfigCommonSourceFiles(srcFiles);
-
const bool mocTarget = target->GetPropertyAsBool("AUTOMOC");
const bool uicTarget = target->GetPropertyAsBool("AUTOUIC");
- cmFilePathChecksum fpathCheckSum(makefile);
+ std::vector<cmSourceFile*> srcFiles;
+ target->GetConfigCommonSourceFiles(srcFiles);
for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
fileIt != srcFiles.end(); ++fileIt) {
cmSourceFile* sf = *fileIt;
@@ -163,18 +155,12 @@ static void SetupSourceFiles(cmGeneratorTarget const* target,
!(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
continue;
}
- if (cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
- continue;
- }
const std::string absFile =
cmsys::SystemTools::GetRealPath(sf->GetFullPath());
// Skip flags
- const bool skipAll =
- cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN"));
- const bool mocSkip =
- skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
- const bool uicSkip =
- skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"));
+ const bool skipAll = PropertyEnabled(sf, "SKIP_AUTOGEN");
+ const bool mocSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOMOC");
+ const bool uicSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOUIC");
// Add file name to skip lists.
// Do this even when the file is not added to the sources/headers lists
// because the file name may be extracted from an other file when
@@ -218,6 +204,8 @@ static void MocSetupAutoTarget(
AddDefinitionEscaped(makefile, "_moc_relaxed_mode",
makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE"
: "FALSE");
+ AddDefinitionEscaped(makefile, "_moc_depend_filters",
+ GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS"));
// Moc includes and compile definitions
{
@@ -304,6 +292,19 @@ static void UicSetupAutoTarget(
AddDefinitionEscaped(makefile, "_uic_skip", uicSkipList);
+ // Uic search paths
+ {
+ std::vector<std::string> uicSearchPaths;
+ cmSystemTools::ExpandListArgument(
+ GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"), uicSearchPaths);
+ const std::string srcDir = makefile->GetCurrentSourceDirectory();
+ for (std::vector<std::string>::iterator it = uicSearchPaths.begin();
+ it != uicSearchPaths.end(); ++it) {
+ *it = cmSystemTools::CollapseFullPath(*it, srcDir);
+ }
+ AddDefinitionEscaped(makefile, "_uic_search_paths", uicSearchPaths);
+ }
+
// Uic target options
{
std::string _uic_opts;
@@ -346,7 +347,8 @@ static void UicSetupAutoTarget(
uiFileFiles.push_back(absFile);
{
std::string opts = sf->GetProperty("AUTOUIC_OPTIONS");
- cmSystemTools::ReplaceString(opts, ";", "@list_sep@");
+ cmSystemTools::ReplaceString(opts, ";",
+ cmQtAutoGeneratorCommon::listSep);
uiFileOptions.push_back(opts);
}
}
@@ -454,146 +456,12 @@ static void RccMergeOptions(std::vector<std::string>& opts,
opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
}
-/// @brief Reads the resource files list from from a .qrc file - Qt5 version
-/// @return True if the .qrc file was successfully parsed
-static bool RccListInputsQt5(cmSourceFile* sf, cmGeneratorTarget const* target,
- std::vector<std::string>& depends)
-{
- const std::string rccCommand = RccGetExecutable(target, "5");
- if (rccCommand.empty()) {
- cmSystemTools::Error("AUTOGEN: error: rcc executable not available\n");
- return false;
- }
-
- bool hasDashDashList = false;
- // Read rcc features
- {
- std::vector<std::string> command;
- command.push_back(rccCommand);
- command.push_back("--help");
- std::string rccStdOut;
- std::string rccStdErr;
- int retVal = 0;
- bool result =
- cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
- CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
- if (result && retVal == 0 &&
- rccStdOut.find("--list") != std::string::npos) {
- hasDashDashList = true;
- }
- }
- // Run rcc list command
- std::vector<std::string> command;
- command.push_back(rccCommand);
- command.push_back(hasDashDashList ? "--list" : "-list");
-
- std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath());
- command.push_back(absFile);
-
- std::string rccStdOut;
- std::string rccStdErr;
- int retVal = 0;
- bool result =
- cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
- CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
- if (!result || retVal) {
- std::ostringstream err;
- err << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath()
- << " failed:\n"
- << rccStdOut << "\n"
- << rccStdErr << std::endl;
- cmSystemTools::Error(err.str().c_str());
- return false;
- }
-
- // Parse rcc list output
- {
- std::istringstream ostr(rccStdOut);
- std::string oline;
- while (std::getline(ostr, oline)) {
- oline = utilStripCR(oline);
- if (!oline.empty()) {
- depends.push_back(oline);
- }
- }
- }
-
- {
- std::istringstream estr(rccStdErr);
- std::string eline;
- while (std::getline(estr, eline)) {
- eline = utilStripCR(eline);
- if (cmHasLiteralPrefix(eline, "RCC: Error in")) {
- static std::string searchString = "Cannot find file '";
-
- std::string::size_type pos = eline.find(searchString);
- if (pos == std::string::npos) {
- std::ostringstream err;
- err << "AUTOGEN: error: Rcc lists unparsable output " << eline
- << std::endl;
- cmSystemTools::Error(err.str().c_str());
- return false;
- }
- pos += searchString.length();
- std::string::size_type sz = eline.size() - pos - 1;
- depends.push_back(eline.substr(pos, sz));
- }
- }
- }
-
- return true;
-}
-
-/// @brief Reads the resource files list from from a .qrc file - Qt4 version
-/// @return True if the .qrc file was successfully parsed
-static bool RccListInputsQt4(cmSourceFile* sf,
- std::vector<std::string>& depends)
-{
- // Read file into string
- std::string qrcContents;
- {
- std::ostringstream stream;
- stream << cmsys::ifstream(sf->GetFullPath().c_str()).rdbuf();
- qrcContents = stream.str();
- }
-
- cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
- cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
-
- size_t offset = 0;
- while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
- std::string qrcEntry = fileMatchRegex.match(1);
- offset += qrcEntry.size();
- {
- fileReplaceRegex.find(qrcEntry);
- std::string tag = fileReplaceRegex.match(1);
- qrcEntry = qrcEntry.substr(tag.size());
- }
- if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
- qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry;
- }
- depends.push_back(qrcEntry);
- }
- return true;
-}
-
-/// @brief Reads the resource files list from from a .qrc file
-/// @return True if the rcc file was successfully parsed
-static bool RccListInputs(const std::string& qtMajorVersion, cmSourceFile* sf,
- cmGeneratorTarget const* target,
- std::vector<std::string>& depends)
-{
- if (qtMajorVersion == "5") {
- return RccListInputsQt5(sf, target, depends);
- }
- return RccListInputsQt4(sf, depends);
-}
-
static void RccSetupAutoTarget(cmGeneratorTarget const* target,
const std::string& qtMajorVersion)
{
cmMakefile* makefile = target->Target->GetMakefile();
const bool qtMajorVersion5 = (qtMajorVersion == "5");
+ const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
std::vector<std::string> _rcc_files;
std::vector<std::string> _rcc_inputs;
std::vector<std::string> rccFileFiles;
@@ -608,53 +476,54 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
fileIt != srcFiles.end(); ++fileIt) {
cmSourceFile* sf = *fileIt;
- if (sf->GetExtension() == "qrc") {
- const bool skip =
- cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) ||
- cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"));
- if (!skip) {
- const std::string absFile =
- cmsys::SystemTools::GetRealPath(sf->GetFullPath());
- // qrc file
- _rcc_files.push_back(absFile);
- // qrc file entries
- {
- std::string entriesList;
- if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
- std::vector<std::string> depends;
- if (RccListInputs(qtMajorVersion, sf, target, depends)) {
- entriesList = cmJoin(depends, "@list_sep@");
- } else {
- return;
- }
+ if ((sf->GetExtension() == "qrc") &&
+ !PropertyEnabled(sf, "SKIP_AUTOGEN") &&
+ !PropertyEnabled(sf, "SKIP_AUTORCC")) {
+ const std::string absFile =
+ cmsys::SystemTools::GetRealPath(sf->GetFullPath());
+ // qrc file
+ _rcc_files.push_back(absFile);
+ // qrc file entries
+ {
+ std::string entriesList = "{";
+ // Read input file list only for non generated .qrc files.
+ if (!PropertyEnabled(sf, "GENERATED")) {
+ std::string error;
+ std::vector<std::string> files;
+ if (cmQtAutoGeneratorCommon::RccListInputs(
+ qtMajorVersion, rccCommand, absFile, files, &error)) {
+ entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep);
+ } else {
+ cmSystemTools::Error(error.c_str());
}
- _rcc_inputs.push_back(entriesList);
}
- // rcc options for this qrc file
- {
- // Merged target and file options
- std::vector<std::string> rccOptions(rccOptionsTarget);
- if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) {
- std::vector<std::string> optsVec;
- cmSystemTools::ExpandListArgument(prop, optsVec);
- RccMergeOptions(rccOptions, optsVec, qtMajorVersion5);
- }
- // Only store non empty options lists
- if (!rccOptions.empty()) {
- rccFileFiles.push_back(absFile);
- rccFileOptions.push_back(cmJoin(rccOptions, "@list_sep@"));
- }
+ entriesList += "}";
+ _rcc_inputs.push_back(entriesList);
+ }
+ // rcc options for this qrc file
+ {
+ // Merged target and file options
+ std::vector<std::string> rccOptions(rccOptionsTarget);
+ if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) {
+ std::vector<std::string> optsVec;
+ cmSystemTools::ExpandListArgument(prop, optsVec);
+ RccMergeOptions(rccOptions, optsVec, qtMajorVersion5);
+ }
+ // Only store non empty options lists
+ if (!rccOptions.empty()) {
+ rccFileFiles.push_back(absFile);
+ rccFileOptions.push_back(
+ cmJoin(rccOptions, cmQtAutoGeneratorCommon::listSep));
}
}
}
}
+ AddDefinitionEscaped(makefile, "_qt_rcc_executable", rccCommand);
AddDefinitionEscaped(makefile, "_rcc_files", _rcc_files);
AddDefinitionEscaped(makefile, "_rcc_inputs", _rcc_inputs);
AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles);
AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions);
- AddDefinitionEscaped(makefile, "_qt_rcc_executable",
- RccGetExecutable(target, qtMajorVersion));
}
void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
@@ -676,12 +545,17 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
cmMakefile* makefile = target->Target->GetMakefile();
// Create a custom target for running generators at buildtime
+ const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
+ const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
+ const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
const std::string autogenTargetName = GetAutogenTargetName(target);
const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
const std::string workingDirectory =
cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
const std::string qtMajorVersion = GetQtMajorVersion(target);
- std::vector<std::string> autogenOutputFiles;
+ const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
+ std::vector<std::string> autogenDepends;
+ std::vector<std::string> autogenProvides;
// Remove old settings on cleanup
{
@@ -691,32 +565,6 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
false);
}
- // Create autogen target build directory and add it to the clean files
- cmSystemTools::MakeDirectory(autogenBuildDir);
- makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
- autogenBuildDir.c_str(), false);
-
- if (target->GetPropertyAsBool("AUTOMOC") ||
- target->GetPropertyAsBool("AUTOUIC")) {
- // Create autogen target includes directory and
- // add it to the origin target INCLUDE_DIRECTORIES
- const std::string incsDir = autogenBuildDir + "include";
- cmSystemTools::MakeDirectory(incsDir);
- target->AddIncludeDirectory(incsDir, true);
- }
-
- if (target->GetPropertyAsBool("AUTOMOC")) {
- // Register moc compilation file as generated
- autogenOutputFiles.push_back(autogenBuildDir + "moc_compilation.cpp");
- }
-
- // Initialize autogen target dependencies
- std::vector<std::string> depends;
- if (const char* autogenDepends =
- target->GetProperty("AUTOGEN_TARGET_DEPENDS")) {
- cmSystemTools::ExpandListArgument(autogenDepends, depends);
- }
-
// Compose command lines
cmCustomCommandLines commandLines;
{
@@ -733,13 +581,13 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
std::string autogenComment;
{
std::vector<std::string> toolNames;
- if (target->GetPropertyAsBool("AUTOMOC")) {
+ if (mocEnabled) {
toolNames.push_back("MOC");
}
- if (target->GetPropertyAsBool("AUTOUIC")) {
+ if (uicEnabled) {
toolNames.push_back("UIC");
}
- if (target->GetPropertyAsBool("AUTORCC")) {
+ if (rccEnabled) {
toolNames.push_back("RCC");
}
@@ -755,6 +603,24 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
autogenComment = "Automatic " + tools + " for target " + target->GetName();
}
+ // Create autogen target build directory and add it to the clean files
+ cmSystemTools::MakeDirectory(autogenBuildDir);
+ makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
+ autogenBuildDir.c_str(), false);
+
+ // Create autogen target includes directory and
+ // add it to the origin target INCLUDE_DIRECTORIES
+ if (mocEnabled || uicEnabled) {
+ const std::string incsDir = autogenBuildDir + "include";
+ cmSystemTools::MakeDirectory(incsDir);
+ target->AddIncludeDirectory(incsDir, true);
+ }
+
+ // Register moc compilation file as generated
+ if (mocEnabled) {
+ autogenProvides.push_back(autogenBuildDir + "moc_compilation.cpp");
+ }
+
#if defined(_WIN32) && !defined(__CYGWIN__)
bool usePRE_BUILD = false;
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
@@ -766,65 +632,100 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
// This also works around a VS 11 bug that may skip updating the target:
// https://connect.microsoft.com/VisualStudio/feedback/details/769495
usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7;
- if (usePRE_BUILD) {
- // If the autogen target depends on an other target
- // don't use PRE_BUILD
- for (std::vector<std::string>::iterator it = depends.begin();
- it != depends.end(); ++it) {
- if (!makefile->FindTargetToUse(it->c_str())) {
- usePRE_BUILD = false;
- break;
- }
- }
- }
}
#endif
- if (target->GetPropertyAsBool("AUTORCC")) {
+ // Initialize autogen target dependencies
+ if (const char* deps = target->GetProperty("AUTOGEN_TARGET_DEPENDS")) {
+ cmSystemTools::ExpandListArgument(deps, autogenDepends);
+ }
+ // Add link library targets to the autogen dependencies
+ {
+ const cmTarget::LinkLibraryVectorType& libVec =
+ target->Target->GetOriginalLinkLibraries();
+ for (cmTarget::LinkLibraryVectorType::const_iterator it = libVec.begin();
+ it != libVec.end(); ++it) {
+ const std::string& libName = it->first;
+ if (makefile->FindTargetToUse(libName) != CM_NULLPTR) {
+ autogenDepends.push_back(libName);
+ }
+ }
+ }
+ {
cmFilePathChecksum fpathCheckSum(makefile);
+ // Iterate over all source files
std::vector<cmSourceFile*> srcFiles;
target->GetConfigCommonSourceFiles(srcFiles);
for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
fileIt != srcFiles.end(); ++fileIt) {
cmSourceFile* sf = *fileIt;
- if (sf->GetExtension() == "qrc" &&
- !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) &&
- !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) {
- {
+ if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) {
+ const std::string ext = sf->GetExtension();
+ // Add generated file that will be scanned by moc or uic to
+ // the dependencies
+ if (mocEnabled || uicEnabled) {
+ const cmSystemTools::FileFormat fileType =
+ cmSystemTools::GetFileFormat(ext.c_str());
+ if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
+ (fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
+ if (PropertyEnabled(sf, "GENERATED")) {
+ if ((mocEnabled && !PropertyEnabled(sf, "SKIP_AUTOMOC")) ||
+ (uicEnabled && !PropertyEnabled(sf, "SKIP_AUTOUIC"))) {
+ autogenDepends.push_back(
+ cmsys::SystemTools::GetRealPath(sf->GetFullPath()));
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // Cannot use PRE_BUILD with generated files
+ usePRE_BUILD = false;
+#endif
+ }
+ }
+ }
+ }
+ // Process rcc enabled files
+ if (rccEnabled && (ext == "qrc") &&
+ !PropertyEnabled(sf, "SKIP_AUTORCC")) {
const std::string absFile =
cmsys::SystemTools::GetRealPath(sf->GetFullPath());
- // Run cmake again when .qrc file changes
- makefile->AddCMakeDependFile(absFile);
-
- std::string rccOutputFile = autogenBuildDir;
- rccOutputFile += fpathCheckSum.getPart(absFile);
- rccOutputFile += "/qrc_";
- rccOutputFile +=
- cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
- rccOutputFile += ".cpp";
-
- // Add rcc output file to origin target sources
- cmSourceFile* gf = makefile->GetOrCreateSource(rccOutputFile, true);
- gf->SetProperty("SKIP_AUTOGEN", "On");
- target->AddSource(rccOutputFile);
- // Register rcc output file as generated
- autogenOutputFiles.push_back(rccOutputFile);
- }
- if (lg->GetGlobalGenerator()->GetName() == "Ninja"
-#if defined(_WIN32) && !defined(__CYGWIN__)
- || usePRE_BUILD
-#endif
- ) {
- if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
- RccListInputs(qtMajorVersion, sf, target, depends);
+ // Compose rcc output file name
+ {
+ std::string rccOut = autogenBuildDir;
+ rccOut += fpathCheckSum.getPart(absFile);
+ rccOut += "/qrc_";
+ rccOut +=
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
+ rccOut += ".cpp";
+
+ // Register rcc output file as generated
+ autogenProvides.push_back(rccOut);
+
+ // Add rcc output file to origin target sources
+ cmSourceFile* gf = makefile->GetOrCreateSource(rccOut, true);
+ gf->SetProperty("SKIP_AUTOGEN", "On");
+ target->AddSource(rccOut);
+ }
+
+ if (PropertyEnabled(sf, "GENERATED")) {
+ // Add generated qrc file to the dependencies
+ autogenDepends.push_back(absFile);
+ } else {
+ // Run cmake again when .qrc file changes
+ makefile->AddCMakeDependFile(absFile);
+
+ // Add the qrc input files to the dependencies
+ std::string error;
+ if (!cmQtAutoGeneratorCommon::RccListInputs(
+ qtMajorVersion, rccCommand, absFile, autogenDepends,
+ &error)) {
+ cmSystemTools::Error(error.c_str());
+ }
+ }
#if defined(_WIN32) && !defined(__CYGWIN__)
- // Cannot use PRE_BUILD because the resource files themselves
- // may not be sources within the target so VS may not know the
- // target needs to re-build at all.
- usePRE_BUILD = false;
+ // Cannot use PRE_BUILD because the resource files themselves
+ // may not be sources within the target so VS may not know the
+ // target needs to re-build at all.
+ usePRE_BUILD = false;
#endif
- }
}
}
}
@@ -832,12 +733,21 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
#if defined(_WIN32) && !defined(__CYGWIN__)
if (usePRE_BUILD) {
+ // If the autogen target depends on an other target don't use PRE_BUILD
+ for (std::vector<std::string>::iterator it = autogenDepends.begin();
+ it != autogenDepends.end(); ++it) {
+ if (makefile->FindTargetToUse(*it) != CM_NULLPTR) {
+ usePRE_BUILD = false;
+ break;
+ }
+ }
+ }
+ if (usePRE_BUILD) {
// Add the pre-build command directly to bypass the OBJECT_LIBRARY
// rejection in cmMakefile::AddCustomCommandToTarget because we know
// PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
std::vector<std::string> no_output;
- std::vector<std::string> no_byproducts;
- cmCustomCommand cc(makefile, no_output, no_byproducts, depends,
+ cmCustomCommand cc(makefile, no_output, autogenProvides, autogenDepends,
commandLines, autogenComment.c_str(),
workingDirectory.c_str());
cc.SetEscapeOldStyle(false);
@@ -848,7 +758,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
{
cmTarget* autogenTarget = makefile->AddUtilityCommand(
autogenTargetName, true, workingDirectory.c_str(),
- /*byproducts=*/autogenOutputFiles, depends, commandLines, false,
+ /*byproducts=*/autogenProvides, autogenDepends, commandLines, false,
autogenComment.c_str());
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
@@ -885,38 +795,37 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
std::map<std::string, std::string> configMocDefines;
std::map<std::string, std::string> configUicOptions;
{
- // create a custom target for running generators at buildtime:
+ const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
+ const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
+ const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
const std::string autogenTargetName = GetAutogenTargetName(target);
const std::string qtMajorVersion = GetQtMajorVersion(target);
- AddDefinitionEscaped(makefile, "_autogen_target_name", autogenTargetName);
- AddDefinitionEscaped(makefile, "_origin_target_name", target->GetName());
- AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);
-
std::vector<std::string> _sources;
std::vector<std::string> _headers;
- std::vector<std::string> mocSkipList;
- std::vector<std::string> uicSkipList;
- if (target->GetPropertyAsBool("AUTOMOC") ||
- target->GetPropertyAsBool("AUTOUIC") ||
- target->GetPropertyAsBool("AUTORCC")) {
- SetupSourceFiles(target, _sources, _headers, mocSkipList, uicSkipList);
+ if (mocEnabled || uicEnabled || rccEnabled) {
+ std::vector<std::string> mocSkipList;
+ std::vector<std::string> uicSkipList;
+ AcquireScanFiles(target, _sources, _headers, mocSkipList, uicSkipList);
+ if (mocEnabled) {
+ MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion,
+ mocSkipList, configMocIncludes, configMocDefines);
+ }
+ if (uicEnabled) {
+ UicSetupAutoTarget(target, qtMajorVersion, uicSkipList,
+ configUicOptions);
+ }
+ if (rccEnabled) {
+ RccSetupAutoTarget(target, qtMajorVersion);
+ }
}
+
+ AddDefinitionEscaped(makefile, "_autogen_target_name", autogenTargetName);
+ AddDefinitionEscaped(makefile, "_origin_target_name", target->GetName());
+ AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);
AddDefinitionEscaped(makefile, "_sources", _sources);
AddDefinitionEscaped(makefile, "_headers", _headers);
-
- if (target->GetPropertyAsBool("AUTOMOC")) {
- MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion,
- mocSkipList, configMocIncludes, configMocDefines);
- }
- if (target->GetPropertyAsBool("AUTOUIC")) {
- UicSetupAutoTarget(target, qtMajorVersion, uicSkipList,
- configUicOptions);
- }
- if (target->GetPropertyAsBool("AUTORCC")) {
- RccSetupAutoTarget(target, qtMajorVersion);
- }
}
// Generate config file
@@ -957,7 +866,7 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
it = configMocDefines.begin(),
end = configMocDefines.end();
it != end; ++it) {
- infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << " "
+ infoFile << "set(AM_MOC_DEFINITIONS_" << it->first << " "
<< it->second << ")\n";
}
}
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index d51efb4..246dd8d 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1,6 +1,7 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQtAutoGenerators.h"
+#include "cmQtAutoGeneratorCommon.h"
#include <algorithm>
#include <assert.h>
@@ -36,20 +37,43 @@ static const char* SettingsKeyRcc = "AM_RCC_OLD_SETTINGS";
// -- Static functions
-static std::string GetConfigDefinition(cmMakefile* makefile,
- const std::string& key,
- const std::string& config)
+inline static std::string Quoted(const std::string& text)
{
- std::string keyConf = key;
- if (!config.empty()) {
- keyConf += "_";
- keyConf += config;
+ return cmQtAutoGeneratorCommon::Quoted(text);
+}
+
+static void InfoGet(cmMakefile* makefile, const char* key, std::string& value)
+{
+ value = makefile->GetSafeDefinition(key);
+}
+
+static void InfoGet(cmMakefile* makefile, const char* key, bool& value)
+{
+ value = makefile->IsOn(key);
+}
+
+static void InfoGet(cmMakefile* makefile, const char* key,
+ std::vector<std::string>& list)
+{
+ cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition(key), list);
+}
+
+static void InfoGet(cmMakefile* makefile, const char* key,
+ const std::string& config, std::vector<std::string>& list)
+{
+ const char* valueConf = CM_NULLPTR;
+ {
+ std::string keyConf = key;
+ if (!config.empty()) {
+ keyConf += "_";
+ keyConf += config;
+ }
+ valueConf = makefile->GetDefinition(keyConf);
}
- const char* valueConf = makefile->GetDefinition(keyConf);
- if (valueConf != CM_NULLPTR) {
- return valueConf;
+ if (valueConf == CM_NULLPTR) {
+ valueConf = makefile->GetSafeDefinition(key);
}
- return makefile->GetSafeDefinition(key);
+ cmSystemTools::ExpandListArgument(valueConf, list);
}
static std::string SettingsFile(const std::string& targetDirectory)
@@ -75,6 +99,15 @@ static void SettingWrite(std::ostream& ostr, const char* key,
}
}
+std::string subDirPrefix(const std::string& fileName)
+{
+ std::string res(cmsys::SystemTools::GetFilenamePath(fileName));
+ if (!res.empty()) {
+ res += '/';
+ }
+ return res;
+}
+
static bool FileNameIsUnique(const std::string& filePath,
const std::map<std::string, std::string>& fileMap)
{
@@ -92,13 +125,19 @@ static bool FileNameIsUnique(const std::string& filePath,
return true;
}
-static std::string ReadAll(const std::string& filename)
+static bool ReadAll(std::string& content, const std::string& filename)
{
- cmsys::ifstream file(filename.c_str());
- std::ostringstream stream;
- stream << file.rdbuf();
- file.close();
- return stream.str();
+ bool success = false;
+ {
+ cmsys::ifstream ifs(filename.c_str());
+ if (ifs) {
+ std::ostringstream osst;
+ osst << ifs.rdbuf();
+ content = osst.str();
+ success = true;
+ }
+ }
+ return success;
}
/**
@@ -132,7 +171,7 @@ static std::string JoinOptionsMap(
for (std::map<std::string, std::string>::const_iterator it = opts.begin();
it != opts.end(); ++it) {
if (it != opts.begin()) {
- result += "@list_sep@";
+ result += cmQtAutoGeneratorCommon::listSep;
}
result += it->first;
result += "===";
@@ -244,23 +283,46 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, snapshot));
gg.SetCurrentMakefile(mf.get());
- if (!this->ReadAutogenInfoFile(mf.get(), targetDirectory, config)) {
- return false;
- }
- // Read old settings
- this->SettingsFileRead(mf.get(), targetDirectory);
- // Init and run
- this->Init(mf.get());
- if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") {
- if (!this->RunAutogen()) {
- return false;
+ bool success = false;
+ if (this->ReadAutogenInfoFile(mf.get(), targetDirectory, config)) {
+ // Read old settings
+ this->SettingsFileRead(mf.get(), targetDirectory);
+ // Init and run
+ this->Init(mf.get());
+ if (this->RunAutogen()) {
+ // Write current settings
+ if (this->SettingsFileWrite(targetDirectory)) {
+ success = true;
+ }
}
}
- // Write latest settings
- if (!this->SettingsFileWrite(targetDirectory)) {
- return false;
+ return success;
+}
+
+bool cmQtAutoGenerators::MocDependFilterPush(const std::string& key,
+ const std::string& regExp)
+{
+ bool success = false;
+ if (!key.empty()) {
+ if (!regExp.empty()) {
+ MocDependFilter filter;
+ filter.key = key;
+ if (filter.regExp.compile(regExp)) {
+ this->MocDependFilters.push_back(filter);
+ success = true;
+ } else {
+ this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Compiling "
+ "regular expression failed.\nKey: " +
+ Quoted(key) + "\nExp.: " + Quoted(regExp));
+ }
+ } else {
+ this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Regular "
+ "expression is empty");
+ }
+ } else {
+ this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Key is empty");
}
- return true;
+ return success;
}
bool cmQtAutoGenerators::ReadAutogenInfoFile(
@@ -272,136 +334,156 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
filename += "/AutogenInfo.cmake";
if (!makefile->ReadListFile(filename.c_str())) {
- std::ostringstream err;
- err << "AutoGen: error processing file: " << filename << std::endl;
- this->LogError(err.str());
+ this->LogError("AutoGen: Error processing file: " + filename);
return false;
}
// - Target names
- this->OriginTargetName =
- makefile->GetSafeDefinition("AM_ORIGIN_TARGET_NAME");
- this->AutogenTargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
-
- // - Directories
- this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
- this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR");
- this->CurrentSourceDir =
- makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR");
- this->CurrentBinaryDir =
- makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR");
+ InfoGet(makefile, "AM_TARGET_NAME", this->AutogenTargetName);
+ InfoGet(makefile, "AM_ORIGIN_TARGET_NAME", this->OriginTargetName);
+
+ // - Files and directories
+ InfoGet(makefile, "AM_CMAKE_SOURCE_DIR", this->ProjectSourceDir);
+ InfoGet(makefile, "AM_CMAKE_BINARY_DIR", this->ProjectBinaryDir);
+ InfoGet(makefile, "AM_CMAKE_CURRENT_SOURCE_DIR", this->CurrentSourceDir);
+ InfoGet(makefile, "AM_CMAKE_CURRENT_BINARY_DIR", this->CurrentBinaryDir);
+ InfoGet(makefile, "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE",
+ this->IncludeProjectDirsBefore);
+ InfoGet(makefile, "AM_SOURCES", this->Sources);
+ InfoGet(makefile, "AM_HEADERS", this->Headers);
// - Qt environment
- this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR");
- if (this->QtMajorVersion == "") {
- this->QtMajorVersion =
- makefile->GetSafeDefinition("AM_Qt5Core_VERSION_MAJOR");
+ InfoGet(makefile, "AM_QT_VERSION_MAJOR", this->QtMajorVersion);
+ if (this->QtMajorVersion.empty()) {
+ InfoGet(makefile, "AM_Qt5Core_VERSION_MAJOR", this->QtMajorVersion);
+ }
+ InfoGet(makefile, "AM_QT_MOC_EXECUTABLE", this->MocExecutable);
+ InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable);
+ InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable);
+ // Check Qt version
+ if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) {
+ this->LogError("AutoGen: Error: Unsupported Qt version: " +
+ Quoted(this->QtMajorVersion));
+ return false;
}
- this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE");
- this->UicExecutable = makefile->GetSafeDefinition("AM_QT_UIC_EXECUTABLE");
- this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE");
-
- // - File Lists
- cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_SOURCES"),
- this->Sources);
- cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_HEADERS"),
- this->Headers);
// - Moc
- cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_MOC_SKIP"),
- this->MocSkipList);
- cmSystemTools::ExpandListArgument(
- GetConfigDefinition(makefile, "AM_MOC_COMPILE_DEFINITIONS", config),
- this->MocDefinitions);
- cmSystemTools::ExpandListArgument(
- GetConfigDefinition(makefile, "AM_MOC_INCLUDES", config),
- this->MocIncludePaths);
- cmSystemTools::ExpandListArgument(
- makefile->GetSafeDefinition("AM_MOC_OPTIONS"), this->MocOptions);
+ if (this->MocEnabled()) {
+ InfoGet(makefile, "AM_MOC_SKIP", this->MocSkipList);
+ InfoGet(makefile, "AM_MOC_DEFINITIONS", config, this->MocDefinitions);
+ InfoGet(makefile, "AM_MOC_INCLUDES", config, this->MocIncludePaths);
+ InfoGet(makefile, "AM_MOC_OPTIONS", this->MocOptions);
+ InfoGet(makefile, "AM_MOC_RELAXED_MODE", this->MocRelaxedMode);
+ {
+ std::vector<std::string> mocDependFilters;
+ InfoGet(makefile, "AM_MOC_DEPEND_FILTERS", mocDependFilters);
+ // Insert Q_PLUGIN_METADATA dependency filter
+ if (this->QtMajorVersion != "4") {
+ this->MocDependFilterPush("Q_PLUGIN_METADATA",
+ "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\("
+ "[^\\)]*FILE[ \t]*\"([^\"]+)\"");
+ }
+ // Insert user defined dependency filters
+ if ((mocDependFilters.size() % 2) == 0) {
+ for (std::vector<std::string>::const_iterator dit =
+ mocDependFilters.begin();
+ dit != mocDependFilters.end(); dit += 2) {
+ if (!this->MocDependFilterPush(*dit, *(dit + 1))) {
+ return false;
+ }
+ }
+ } else {
+ this->LogError(
+ "AutoMoc: Error: AUTOMOC_DEPEND_FILTERS list size is not "
+ "a multiple of 2 in:\n" +
+ Quoted(filename));
+ return false;
+ }
+ }
+ }
// - Uic
- cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_UIC_SKIP"),
- this->UicSkipList);
- cmSystemTools::ExpandListArgument(
- GetConfigDefinition(makefile, "AM_UIC_TARGET_OPTIONS", config),
- this->UicTargetOptions);
- {
- std::vector<std::string> uicFilesVec;
- std::vector<std::string> uicOptionsVec;
- cmSystemTools::ExpandListArgument(
- makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"), uicFilesVec);
- cmSystemTools::ExpandListArgument(
- makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"), uicOptionsVec);
- if (uicFilesVec.size() != uicOptionsVec.size()) {
- std::ostringstream err;
- err << "AutoGen: Error: Uic files/options lists size missmatch in: "
- << filename << std::endl;
- this->LogError(err.str());
- return false;
- }
- for (std::vector<std::string>::iterator fileIt = uicFilesVec.begin(),
- optionIt = uicOptionsVec.begin();
- fileIt != uicFilesVec.end(); ++fileIt, ++optionIt) {
- cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
- this->UicOptions[*fileIt] = *optionIt;
+ if (this->UicEnabled()) {
+ InfoGet(makefile, "AM_UIC_SKIP", this->UicSkipList);
+ InfoGet(makefile, "AM_UIC_SEARCH_PATHS", this->UicSearchPaths);
+ InfoGet(makefile, "AM_UIC_TARGET_OPTIONS", config, this->UicTargetOptions);
+ {
+ std::vector<std::string> uicFilesVec;
+ std::vector<std::string> uicOptionsVec;
+ InfoGet(makefile, "AM_UIC_OPTIONS_FILES", uicFilesVec);
+ InfoGet(makefile, "AM_UIC_OPTIONS_OPTIONS", uicOptionsVec);
+ // Compare list sizes
+ if (uicFilesVec.size() == uicOptionsVec.size()) {
+ for (std::vector<std::string>::iterator
+ fileIt = uicFilesVec.begin(),
+ optionIt = uicOptionsVec.begin();
+ fileIt != uicFilesVec.end(); ++fileIt, ++optionIt) {
+ cmSystemTools::ReplaceString(*optionIt,
+ cmQtAutoGeneratorCommon::listSep, ";");
+ this->UicOptions[*fileIt] = *optionIt;
+ }
+ } else {
+ this->LogError(
+ "AutoGen: Error: Uic files/options lists size missmatch in:\n" +
+ Quoted(filename));
+ return false;
+ }
}
}
// - Rcc
- cmSystemTools::ExpandListArgument(
- makefile->GetSafeDefinition("AM_RCC_SOURCES"), this->RccSources);
- {
- std::vector<std::string> rccFilesVec;
- std::vector<std::string> rccOptionsVec;
- cmSystemTools::ExpandListArgument(
- makefile->GetSafeDefinition("AM_RCC_OPTIONS_FILES"), rccFilesVec);
- cmSystemTools::ExpandListArgument(
- makefile->GetSafeDefinition("AM_RCC_OPTIONS_OPTIONS"), rccOptionsVec);
- if (rccFilesVec.size() != rccOptionsVec.size()) {
- std::ostringstream err;
- err << "AutoGen: Error: RCC files/options lists size missmatch in: "
- << filename << std::endl;
- this->LogError(err.str());
- return false;
- }
- for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(),
- optionIt = rccOptionsVec.begin();
- fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) {
- cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
- this->RccOptions[*fileIt] = *optionIt;
- }
- }
- {
- std::vector<std::string> rccInputLists;
- cmSystemTools::ExpandListArgument(
- makefile->GetSafeDefinition("AM_RCC_INPUTS"), rccInputLists);
-
- // qrc files in the end of the list may have been empty
- if (rccInputLists.size() < this->RccSources.size()) {
- rccInputLists.resize(this->RccSources.size());
- }
- if (this->RccSources.size() != rccInputLists.size()) {
- std::ostringstream err;
- err << "AutoGen: Error: RCC sources/inputs lists size missmatch in: "
- << filename << std::endl;
- this->LogError(err.str());
- return false;
+ if (this->RccEnabled()) {
+ InfoGet(makefile, "AM_RCC_SOURCES", this->RccSources);
+ // File options
+ {
+ std::vector<std::string> rccFilesVec;
+ std::vector<std::string> rccOptionsVec;
+ InfoGet(makefile, "AM_RCC_OPTIONS_FILES", rccFilesVec);
+ InfoGet(makefile, "AM_RCC_OPTIONS_OPTIONS", rccOptionsVec);
+ if (rccFilesVec.size() == rccOptionsVec.size()) {
+ for (std::vector<std::string>::iterator
+ fileIt = rccFilesVec.begin(),
+ optionIt = rccOptionsVec.begin();
+ fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) {
+ // Replace item separator
+ cmSystemTools::ReplaceString(*optionIt,
+ cmQtAutoGeneratorCommon::listSep, ";");
+ this->RccOptions[*fileIt] = *optionIt;
+ }
+ } else {
+ this->LogError(
+ "AutoGen: Error: RCC files/options lists size missmatch in:\n" +
+ Quoted(filename));
+ return false;
+ }
}
- for (std::vector<std::string>::iterator fileIt = this->RccSources.begin(),
- inputIt = rccInputLists.begin();
- fileIt != this->RccSources.end(); ++fileIt, ++inputIt) {
- cmSystemTools::ReplaceString(*inputIt, "@list_sep@", ";");
- std::vector<std::string> rccInputFiles;
- cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
- this->RccInputs[*fileIt] = rccInputFiles;
+ // File lists
+ {
+ std::vector<std::string> rccInputLists;
+ InfoGet(makefile, "AM_RCC_INPUTS", rccInputLists);
+ if (this->RccSources.size() == rccInputLists.size()) {
+ for (std::vector<std::string>::iterator
+ fileIt = this->RccSources.begin(),
+ inputIt = rccInputLists.begin();
+ fileIt != this->RccSources.end(); ++fileIt, ++inputIt) {
+ // Remove braces
+ *inputIt = inputIt->substr(1, inputIt->size() - 2);
+ // Replace item separator
+ cmSystemTools::ReplaceString(*inputIt,
+ cmQtAutoGeneratorCommon::listSep, ";");
+ std::vector<std::string> rccInputFiles;
+ cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
+ this->RccInputs[*fileIt] = rccInputFiles;
+ }
+ } else {
+ this->LogError(
+ "AutoGen: Error: RCC sources/inputs lists size missmatch in:\n" +
+ Quoted(filename));
+ return false;
+ }
}
}
- // - Flags
- this->IncludeProjectDirsBefore =
- makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE");
- this->MocRelaxedMode = makefile->IsOn("AM_MOC_RELAXED_MODE");
-
return true;
}
@@ -480,12 +562,8 @@ bool cmQtAutoGenerators::SettingsFileWrite(const std::string& targetDirectory)
success = false;
// Remove old settings file to trigger full rebuild on next run
cmSystemTools::RemoveFile(filename);
- {
- std::ostringstream err;
- err << "AutoGen: Error: Writing old settings file failed: "
- << filename;
- this->LogError(err.str());
- }
+ this->LogError("AutoGen: Error: Writing old settings file failed: " +
+ filename);
}
}
return success;
@@ -564,16 +642,6 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile)
this->MocIncludes.push_back(*it);
}
}
-
- // Insert MocDependFilter for Q_PLUGIN_METADATA
- if (QtMajorVersion != "4") {
- MocDependFilter filter;
- filter.key = "Q_PLUGIN_METADATA";
- filter.regExp.compile("[\n][ \t]*"
- "Q_PLUGIN_METADATA[ \t]*\\("
- "[^\\)]*FILE[ \t]*\"([^\"]+)\"");
- this->MocDependFilters.push_back(filter);
- }
}
bool cmQtAutoGenerators::RunAutogen()
@@ -620,8 +688,10 @@ bool cmQtAutoGenerators::RunAutogen()
uicHeaderFiles.insert(headerName);
}
}
- this->ParseHeaders(mocHeaderFiles, uicHeaderFiles, mocsIncluded,
- mocsNotIncluded, mocDepends, uisIncluded);
+ if (!this->ParseHeaders(mocHeaderFiles, uicHeaderFiles, mocsIncluded,
+ mocsNotIncluded, mocDepends, uisIncluded)) {
+ return false;
+ };
// Generate files
if (!this->MocGenerateAll(mocsIncluded, mocsNotIncluded, mocDepends)) {
@@ -673,24 +743,24 @@ void cmQtAutoGenerators::MocFindDepends(
// regular expression check
if (contentText.find(filter.key) != std::string::npos) {
// Run regular expression check loop
+ const std::string sourcePath = subDirPrefix(absFilename);
const char* contentChars = contentText.c_str();
while (filter.regExp.find(contentChars)) {
// Evaluate match
const std::string match = filter.regExp.match(1);
if (!match.empty()) {
// Find the dependency file
- const std::string incFile =
- this->FindIncludedFile(absFilename, match);
- if (!incFile.empty()) {
+ std::string incFile;
+ if (this->MocFindIncludedFile(incFile, sourcePath, match)) {
mocDepends[absFilename].insert(incFile);
if (this->Verbose) {
- this->LogInfo("AutoMoc: Found dependency:\n \"" + absFilename +
- "\"\n \"" + incFile + "\"");
+ this->LogInfo("AutoMoc: Found dependency:\n " +
+ Quoted(absFilename) + "\n " + Quoted(incFile));
}
} else {
- this->LogWarning("AutoMoc: Warning: \"" + absFilename + "\"\n" +
- "Could not find dependency file \"" + match +
- "\"");
+ this->LogWarning("AutoMoc: Warning: " + Quoted(absFilename) +
+ "\n" + "Could not find dependency file " +
+ Quoted(match));
}
}
contentChars += filter.regExp.end();
@@ -737,23 +807,29 @@ bool cmQtAutoGenerators::ParseSourceFile(
std::map<std::string, std::set<std::string> >& mocDepends,
std::map<std::string, std::vector<std::string> >& uisIncluded, bool relaxed)
{
- bool success = true;
- const std::string contentText = ReadAll(absFilename);
- if (contentText.empty()) {
- std::ostringstream ost;
- ost << "AutoGen: Warning: " << absFilename << "\n"
- << "The file is empty\n";
- this->LogWarning(ost.str());
- } else {
- // Parse source contents for MOC
- if (success && !this->MocSkip(absFilename)) {
- success = this->MocParseSourceContent(absFilename, contentText,
- mocsIncluded, mocDepends, relaxed);
- }
- // Parse source contents for UIC
- if (success && !this->UicSkip(absFilename)) {
- this->UicParseContent(absFilename, contentText, uisIncluded);
+ std::string contentText;
+ bool success = ReadAll(contentText, absFilename);
+ if (success) {
+ if (!contentText.empty()) {
+ // Parse source contents for MOC
+ if (success && !this->MocSkip(absFilename)) {
+ success = this->MocParseSourceContent(
+ absFilename, contentText, mocsIncluded, mocDepends, relaxed);
+ }
+ // Parse source contents for UIC
+ if (success && !this->UicSkip(absFilename)) {
+ this->UicParseContent(absFilename, contentText, uisIncluded);
+ }
+ } else {
+ std::ostringstream ost;
+ ost << "AutoGen: Warning: The file is empty:\n"
+ << Quoted(absFilename) << "\n";
+ this->LogWarning(ost.str());
}
+ } else {
+ std::ostringstream ost;
+ ost << "AutoGen: Error: Could not read file:\n" << Quoted(absFilename);
+ this->LogError(ost.str());
}
return success;
}
@@ -769,12 +845,7 @@ void cmQtAutoGenerators::UicParseContent(
const char* contentChars = contentText.c_str();
if (strstr(contentChars, "ui_") != CM_NULLPTR) {
while (this->RegExpUicInclude.find(contentChars)) {
- const std::string currentUi = this->RegExpUicInclude.match(1);
- const std::string basename =
- cmsys::SystemTools::GetFilenameWithoutLastExtension(currentUi);
- // basename should be the part of the ui filename used for
- // finding the correct header, so we need to remove the ui_ part
- uisIncluded[absFilename].push_back(basename.substr(3));
+ uisIncluded[absFilename].push_back(this->RegExpUicInclude.match(1));
contentChars += this->RegExpUicInclude.end();
}
}
@@ -792,8 +863,7 @@ bool cmQtAutoGenerators::MocParseSourceContent(
this->LogInfo("AutoMoc: Checking " + absFilename);
}
- const std::string scannedFileAbsPath =
- cmsys::SystemTools::GetFilenamePath(absFilename) + '/';
+ const std::string scannedFileAbsPath = subDirPrefix(absFilename);
const std::string scannedFileBasename =
cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
@@ -812,13 +882,9 @@ bool cmQtAutoGenerators::MocParseSourceContent(
while (this->RegExpMocInclude.find(contentChars)) {
const std::string incString = this->RegExpMocInclude.match(1);
// Basename of the moc include
+ const std::string incSubDir(subDirPrefix(incString));
const std::string incBasename =
cmsys::SystemTools::GetFilenameWithoutLastExtension(incString);
- std::string incSubDir;
- if (incString.find_first_of('/') != std::string::npos) {
- incSubDir = cmsys::SystemTools::GetFilenamePath(incString);
- incSubDir += '/';
- }
// If the moc include is of the moc_foo.cpp style we expect
// the Q_OBJECT class declaration in a header file.
@@ -830,7 +896,7 @@ bool cmQtAutoGenerators::MocParseSourceContent(
// Remove the moc_ part
const std::string incRealBasename = incBasename.substr(4);
const std::string headerToMoc =
- this->FindMocHeader(scannedFileAbsPath, incRealBasename, incSubDir);
+ this->MocFindHeader(scannedFileAbsPath, incSubDir + incRealBasename);
if (!headerToMoc.empty()) {
// Register moc job
mocsIncluded[headerToMoc] = incString;
@@ -843,9 +909,11 @@ bool cmQtAutoGenerators::MocParseSourceContent(
} else {
std::ostringstream ost;
ost << "AutoMoc: Error: " << absFilename << "\n"
- << "The file includes the moc file \"" << incString
- << "\", but could not find header \"" << incRealBasename << '{'
- << JoinExts(this->HeaderExtensions) << "}\"\n";
+ << "The file includes the moc file " << Quoted(incString)
+ << ", but could not find header "
+ << Quoted(incRealBasename + "{" +
+ JoinExts(this->HeaderExtensions) + "}");
+ ;
this->LogError(ost.str());
return false;
}
@@ -861,38 +929,39 @@ bool cmQtAutoGenerators::MocParseSourceContent(
} else {
// In relaxed mode try to find a header instead but issue a warning
const std::string headerToMoc =
- this->FindMocHeader(scannedFileAbsPath, incBasename, incSubDir);
+ this->MocFindHeader(scannedFileAbsPath, incSubDir + incBasename);
if (!headerToMoc.empty()) {
// This is for KDE4 compatibility:
fileToMoc = headerToMoc;
if (!requiresMoc && (incBasename == scannedFileBasename)) {
std::ostringstream ost;
- ost << "AutoMoc: Warning: " << absFilename << "\n"
- << "The file includes the moc file \"" << incString << "\""
+ ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
+ << "The file includes the moc file " << Quoted(incString)
<< ", but does not contain a Q_OBJECT or Q_GADGET macro.\n"
- << "Running moc on \"" << headerToMoc << "\"!\n"
- << "Include \"moc_" << incBasename
- << ".cpp\" for a compatibility with "
- "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n";
+ << "Running moc on " << Quoted(headerToMoc) << "!\n"
+ << "Include " << Quoted("moc_" + incBasename + ".cpp")
+ << " for a compatibility with strict mode (see "
+ "CMAKE_AUTOMOC_RELAXED_MODE).\n";
this->LogWarning(ost.str());
} else {
std::ostringstream ost;
- ost << "AutoMoc: Warning: " << absFilename << "\n"
- << "The file includes the moc file \"" << incString
- << "\" instead of \"moc_" << incBasename << ".cpp\".\n"
- << "Running moc on \"" << headerToMoc << "\"!\n"
- << "Include \"moc_" << incBasename
- << ".cpp\" for compatibility with "
- "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n";
+ ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
+ << "The file includes the moc file " << Quoted(incString)
+ << " instead of " << Quoted("moc_" + incBasename + ".cpp")
+ << ".\n"
+ << "Running moc on " << Quoted(headerToMoc) << "!\n"
+ << "Include " << Quoted("moc_" + incBasename + ".cpp")
+ << " for compatibility with strict mode (see "
+ "CMAKE_AUTOMOC_RELAXED_MODE).\n";
this->LogWarning(ost.str());
}
} else {
std::ostringstream ost;
- ost << "AutoMoc: Error: " << absFilename << "\n"
- << "The file includes the moc file \"" << incString
- << "\", which seems to be the moc file from a different "
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
+ << "The file includes the moc file " << Quoted(incString)
+ << ". which seems to be the moc file from a different "
"source file. CMake also could not find a matching "
- "header.\n";
+ "header.";
this->LogError(ost.str());
return false;
}
@@ -906,21 +975,21 @@ bool cmQtAutoGenerators::MocParseSourceContent(
// Accept but issue a warning if moc isn't required
if (!requiresMoc) {
std::ostringstream ost;
- ost << "AutoMoc: Error: " << absFilename << "\n"
- << "The file includes the moc file \"" << incString << "\""
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
+ << "The file includes the moc file " << Quoted(incString)
<< ", but does not contain a Q_OBJECT or Q_GADGET "
- "macro.\n";
+ "macro.";
this->LogWarning(ost.str());
}
} else {
// Don't allow FOO.moc include other than self in strict mode
std::ostringstream ost;
- ost << "AutoMoc: Error: " << absFilename << "\n"
- << "The file includes the moc file \"" << incString
- << "\", which seems to be the moc file from a different "
- "source file. This is not supported. Include \""
- << scannedFileBasename
- << ".moc\" to run moc on this source file.\n";
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
+ << "The file includes the moc file " << Quoted(incString)
+ << ", which seems to be the moc file from a different "
+ "source file. This is not supported. Include "
+ << Quoted(scannedFileBasename + ".moc")
+ << " to run moc on this source file.";
this->LogError(ost.str());
return false;
}
@@ -943,15 +1012,15 @@ bool cmQtAutoGenerators::MocParseSourceContent(
if (relaxed && !ownMocUnderscoreInclude.empty()) {
// This is for KDE4 compatibility:
std::ostringstream ost;
- ost << "AutoMoc: Warning: " << absFilename << "\n"
+ ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
<< "The file contains a " << macroName
<< " macro, but does not include "
- << "\"" << scannedFileBasename << ".moc\", but instead includes "
- << "\"" << ownMocUnderscoreInclude << "\".\n"
- << "Running moc on \"" << absFilename << "\"!\n"
- << "Better include \"" << scannedFileBasename
- << ".moc\" for compatibility with "
- "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n";
+ << Quoted(scannedFileBasename + ".moc") << ", but instead includes "
+ << Quoted(ownMocUnderscoreInclude) << ".\n"
+ << "Running moc on " << Quoted(absFilename) << "!\n"
+ << "Better include " << Quoted(scannedFileBasename + ".moc")
+ << " for compatibility with strict mode (see "
+ "CMAKE_AUTOMOC_RELAXED_MODE).";
this->LogWarning(ost.str());
// Use scanned source file instead of scanned header file as moc source
@@ -962,10 +1031,12 @@ bool cmQtAutoGenerators::MocParseSourceContent(
} else {
// Otherwise always error out since it will not compile:
std::ostringstream ost;
- ost << "AutoMoc: Error: " << absFilename << "\n"
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
<< "The file contains a " << macroName
<< " macro, but does not include "
- << "\"" << scannedFileBasename << ".moc\"!\n";
+ << Quoted(scannedFileBasename + ".moc") << "!\n"
+ << "Consider adding the include or enabling SKIP_AUTOMOC for this "
+ "file.";
this->LogError(ost.str());
return false;
}
@@ -997,8 +1068,7 @@ void cmQtAutoGenerators::SearchHeadersForSourceFile(
{
std::string basepaths[2];
{
- std::string bpath = cmsys::SystemTools::GetFilenamePath(absFilename);
- bpath += '/';
+ std::string bpath = subDirPrefix(absFilename);
bpath += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
// search for default header files and private header files
basepaths[0] = bpath;
@@ -1022,7 +1092,7 @@ void cmQtAutoGenerators::SearchHeadersForSourceFile(
}
}
-void cmQtAutoGenerators::ParseHeaders(
+bool cmQtAutoGenerators::ParseHeaders(
const std::set<std::string>& mocHeaderFiles,
const std::set<std::string>& uicHeaderFiles,
const std::map<std::string, std::string>& mocsIncluded,
@@ -1030,6 +1100,7 @@ void cmQtAutoGenerators::ParseHeaders(
std::map<std::string, std::set<std::string> >& mocDepends,
std::map<std::string, std::vector<std::string> >& uisIncluded)
{
+ bool success = true;
// Merged header files list to read files only once
std::set<std::string> headerFiles;
headerFiles.insert(mocHeaderFiles.begin(), mocHeaderFiles.end());
@@ -1038,20 +1109,28 @@ void cmQtAutoGenerators::ParseHeaders(
for (std::set<std::string>::const_iterator hIt = headerFiles.begin();
hIt != headerFiles.end(); ++hIt) {
const std::string& headerName = *hIt;
- const std::string contentText = ReadAll(headerName);
-
- // Parse header content for MOC
- if ((mocHeaderFiles.find(headerName) != mocHeaderFiles.end()) &&
- (mocsIncluded.find(headerName) == mocsIncluded.end())) {
- this->MocParseHeaderContent(headerName, contentText, mocsNotIncluded,
- mocDepends);
- }
-
- // Parse header content for UIC
- if (uicHeaderFiles.find(headerName) != uicHeaderFiles.end()) {
- this->UicParseContent(headerName, contentText, uisIncluded);
+ std::string contentText;
+ if (ReadAll(contentText, headerName)) {
+ // Parse header content for MOC
+ if ((mocHeaderFiles.find(headerName) != mocHeaderFiles.end()) &&
+ (mocsIncluded.find(headerName) == mocsIncluded.end())) {
+ this->MocParseHeaderContent(headerName, contentText, mocsNotIncluded,
+ mocDepends);
+ }
+ // Parse header content for UIC
+ if (uicHeaderFiles.find(headerName) != uicHeaderFiles.end()) {
+ this->UicParseContent(headerName, contentText, uisIncluded);
+ }
+ } else {
+ std::ostringstream ost;
+ ost << "AutoGen: Error: Could not read header file:\n"
+ << Quoted(headerName);
+ this->LogError(ost.str());
+ success = false;
+ break;
}
}
+ return success;
}
bool cmQtAutoGenerators::MocGenerateAll(
@@ -1134,8 +1213,12 @@ bool cmQtAutoGenerators::MocGenerateAll(
// Check if the content of moc_compilation.cpp changed
{
- const std::string oldContents = ReadAll(this->MocCppFilenameAbs);
- mocCompChanged = (oldContents != automocSource);
+ std::string oldContents;
+ if (ReadAll(oldContents, this->MocCppFilenameAbs)) {
+ mocCompChanged = (oldContents != automocSource);
+ } else {
+ mocCompChanged = true;
+ }
}
bool success = true;
@@ -1150,13 +1233,13 @@ bool cmQtAutoGenerators::MocGenerateAll(
outfile.open(this->MocCppFilenameAbs.c_str(), std::ios::trunc);
if (!outfile) {
success = false;
- this->LogError("AutoMoc: error opening " + this->MocCppFilenameAbs);
+ this->LogError("AutoMoc: Error opening " + this->MocCppFilenameAbs);
} else {
outfile << automocSource;
// Check for write errors
if (!outfile.good()) {
success = false;
- this->LogError("AutoMoc: error writing " + this->MocCppFilenameAbs);
+ this->LogError("AutoMoc: Error writing " + this->MocCppFilenameAbs);
}
}
}
@@ -1176,14 +1259,14 @@ bool cmQtAutoGenerators::MocGenerateAll(
*/
bool cmQtAutoGenerators::MocGenerateFile(
const std::string& sourceFile, const std::string& mocFileName,
- const std::string& subDirPrefix,
+ const std::string& subDir,
const std::map<std::string, std::set<std::string> >& mocDepends)
{
bool mocGenerated = false;
bool generateMoc = this->GenerateAllMoc;
const std::string mocFileRel =
- this->AutogenBuildSubDir + subDirPrefix + mocFileName;
+ this->AutogenBuildSubDir + subDir + mocFileName;
const std::string mocFileAbs = this->CurrentBinaryDir + mocFileRel;
if (!generateMoc) {
@@ -1229,32 +1312,23 @@ bool cmQtAutoGenerators::MocGenerateFile(
cmd.push_back(mocFileAbs);
cmd.push_back(sourceFile);
- // Log moc command
- if (this->Verbose) {
- this->LogCommand(cmd);
- }
-
// Execute moc command
- bool res = false;
- int retVal = 0;
std::string output;
- res = cmSystemTools::RunSingleCommand(cmd, &output, &output, &retVal);
-
- if (!res || (retVal != 0)) {
+ if (this->RunCommand(cmd, output)) {
+ // Success
+ mocGenerated = true;
+ } else {
// Command failed
{
std::ostringstream ost;
ost << "AutoMoc: Error: moc process failed for\n";
- ost << "\"" << mocFileRel << "\"\n";
+ ost << Quoted(mocFileRel) << "\n";
ost << "AutoMoc: Command:\n" << cmJoin(cmd, " ") << "\n";
ost << "AutoMoc: Command output:\n" << output << "\n";
this->LogError(ost.str());
}
cmSystemTools::RemoveFile(mocFileAbs);
this->RunMocFailed = true;
- } else {
- // Success
- mocGenerated = true;
}
} else {
// Parent directory creation failed
@@ -1264,6 +1338,36 @@ bool cmQtAutoGenerators::MocGenerateFile(
return mocGenerated;
}
+bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile,
+ const std::string& sourceFile,
+ const std::string& includeString)
+{
+ bool success = false;
+ // Search in vicinity of the source
+ {
+ std::string testPath = subDirPrefix(sourceFile);
+ testPath += includeString;
+ if (cmsys::SystemTools::FileExists(testPath.c_str())) {
+ absFile = cmsys::SystemTools::GetRealPath(testPath);
+ success = true;
+ }
+ }
+ // Search in include directories
+ if (!success) {
+ for (std::vector<std::string>::const_iterator iit =
+ this->UicSearchPaths.begin();
+ iit != this->UicSearchPaths.end(); ++iit) {
+ const std::string fullPath = ((*iit) + '/' + includeString);
+ if (cmsys::SystemTools::FileExists(fullPath.c_str())) {
+ absFile = cmsys::SystemTools::GetRealPath(fullPath);
+ success = true;
+ break;
+ }
+ }
+ }
+ return success;
+}
+
bool cmQtAutoGenerators::UicGenerateAll(
const std::map<std::string, std::vector<std::string> >& uisIncluded)
{
@@ -1272,46 +1376,57 @@ bool cmQtAutoGenerators::UicGenerateAll(
}
// single map with input / output names
- std::map<std::string, std::map<std::string, std::string> > uiGenMap;
- std::map<std::string, std::string> testMap;
- for (std::map<std::string, std::vector<std::string> >::const_iterator it =
- uisIncluded.begin();
- it != uisIncluded.end(); ++it) {
- // source file path
- std::string sourcePath = cmsys::SystemTools::GetFilenamePath(it->first);
- sourcePath += '/';
- // insert new map for source file an use new reference
- uiGenMap[it->first] = std::map<std::string, std::string>();
- std::map<std::string, std::string>& sourceMap = uiGenMap[it->first];
- for (std::vector<std::string>::const_iterator sit = it->second.begin();
- sit != it->second.end(); ++sit) {
- const std::string& uiFileName = *sit;
- const std::string uiInputFile = sourcePath + uiFileName + ".ui";
- const std::string uiOutputFile = "ui_" + uiFileName + ".h";
- sourceMap[uiInputFile] = uiOutputFile;
- testMap[uiInputFile] = uiOutputFile;
- }
- }
-
- // look for name collisions
+ std::map<std::string, std::map<std::string, std::string> > sourceGenMap;
{
- std::multimap<std::string, std::string> collisions;
- if (this->NameCollisionTest(testMap, collisions)) {
- std::ostringstream ost;
- ost << "AutoUic: Error: The same ui_NAME.h file will be generated "
- "from different sources.\n"
- "To avoid this error rename the source files.\n";
- this->LogErrorNameCollision(ost.str(), collisions);
- return false;
+ // Collision lookup map
+ std::map<std::string, std::string> testMap;
+ // Compile maps
+ for (std::map<std::string, std::vector<std::string> >::const_iterator sit =
+ uisIncluded.begin();
+ sit != uisIncluded.end(); ++sit) {
+ const std::string& source(sit->first);
+ const std::vector<std::string>& sourceIncs(sit->second);
+ // insert new source/destination map
+ std::map<std::string, std::string>& uiGenMap = sourceGenMap[source];
+ for (std::vector<std::string>::const_iterator uit = sourceIncs.begin();
+ uit != sourceIncs.end(); ++uit) {
+ // Remove ui_ from the begin filename by substr()
+ const std::string uiBasePath = subDirPrefix(*uit);
+ const std::string uiBaseName =
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(*uit).substr(3);
+ const std::string searchFileName = uiBasePath + uiBaseName + ".ui";
+ std::string uiInputFile;
+ if (UicFindIncludedFile(uiInputFile, source, searchFileName)) {
+ std::string uiOutputFile = uiBasePath + "ui_" + uiBaseName + ".h";
+ cmSystemTools::ReplaceString(uiOutputFile, "..", "__");
+ uiGenMap[uiInputFile] = uiOutputFile;
+ testMap[uiInputFile] = uiOutputFile;
+ } else {
+ this->LogError("AutoUic: Error: " + Quoted(sit->first) +
+ "\nCould not find " + Quoted(searchFileName));
+ return false;
+ }
+ }
+ }
+ // look for name collisions
+ {
+ std::multimap<std::string, std::string> collisions;
+ if (this->NameCollisionTest(testMap, collisions)) {
+ std::ostringstream ost;
+ ost << "AutoUic: Error: The same ui_NAME.h file will be generated "
+ "from different sources.\n"
+ "To avoid this error rename the source files.\n";
+ this->LogErrorNameCollision(ost.str(), collisions);
+ return false;
+ }
}
}
- testMap.clear();
// generate ui files
for (std::map<std::string,
std::map<std::string, std::string> >::const_iterator it =
- uiGenMap.begin();
- it != uiGenMap.end(); ++it) {
+ sourceGenMap.begin();
+ it != sourceGenMap.end(); ++it) {
for (std::map<std::string, std::string>::const_iterator sit =
it->second.begin();
sit != it->second.end(); ++sit) {
@@ -1354,47 +1469,37 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName,
std::vector<std::string> cmd;
cmd.push_back(this->UicExecutable);
{
- std::vector<std::string> opts = this->UicTargetOptions;
+ std::vector<std::string> allOpts = this->UicTargetOptions;
std::map<std::string, std::string>::const_iterator optionIt =
this->UicOptions.find(uiInputFile);
if (optionIt != this->UicOptions.end()) {
std::vector<std::string> fileOpts;
cmSystemTools::ExpandListArgument(optionIt->second, fileOpts);
- UicMergeOptions(opts, fileOpts, (this->QtMajorVersion == "5"));
+ UicMergeOptions(allOpts, fileOpts, (this->QtMajorVersion == "5"));
}
- cmd.insert(cmd.end(), opts.begin(), opts.end());
+ cmd.insert(cmd.end(), allOpts.begin(), allOpts.end());
}
cmd.push_back("-o");
cmd.push_back(uicFileAbs);
cmd.push_back(uiInputFile);
- // Log command
- if (this->Verbose) {
- this->LogCommand(cmd);
- }
-
- // Execute command
- bool res = false;
- int retVal = 0;
std::string output;
- res = cmSystemTools::RunSingleCommand(cmd, &output, &output, &retVal);
-
- if (!res || (retVal != 0)) {
+ if (this->RunCommand(cmd, output)) {
+ // Success
+ uicGenerated = true;
+ } else {
// Command failed
{
std::ostringstream ost;
ost << "AutoUic: Error: uic process failed for\n";
- ost << "\"" << uicFileRel << "\" needed by\n";
- ost << "\"" << realName << "\"\n";
+ ost << Quoted(uicFileRel) << " needed by\n";
+ ost << Quoted(realName) << "\n";
ost << "AutoUic: Command:\n" << cmJoin(cmd, " ") << "\n";
ost << "AutoUic: Command output:\n" << output << "\n";
this->LogError(ost.str());
}
cmSystemTools::RemoveFile(uicFileAbs);
this->RunUicFailed = true;
- } else {
- // Success
- uicGenerated = true;
}
} else {
// Parent directory creation failed
@@ -1464,13 +1569,30 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
// Test if the resources list file is newer than build file
generateRcc = FileAbsentOrOlder(rccBuildFile, rccInputFile);
if (!generateRcc) {
- // Test if any resource file is newer than the build file
- const std::vector<std::string>& files = this->RccInputs[rccInputFile];
- for (std::vector<std::string>::const_iterator it = files.begin();
- it != files.end(); ++it) {
- if (FileAbsentOrOlder(rccBuildFile, *it)) {
- generateRcc = true;
- break;
+ // Acquire input file list
+ std::vector<std::string> readFiles;
+ const std::vector<std::string>* files = &this->RccInputs[rccInputFile];
+ if (files->empty()) {
+ // Read input file list from qrc file
+ std::string error;
+ if (cmQtAutoGeneratorCommon::RccListInputs(
+ this->QtMajorVersion, this->RccExecutable, rccInputFile,
+ readFiles, &error)) {
+ files = &readFiles;
+ } else {
+ files = CM_NULLPTR;
+ this->LogError(error);
+ this->RunRccFailed = true;
+ }
+ }
+ // Test if any input file is newer than the build file
+ if (files != CM_NULLPTR) {
+ for (std::vector<std::string>::const_iterator it = files->begin();
+ it != files->end(); ++it) {
+ if (FileAbsentOrOlder(rccBuildFile, *it)) {
+ generateRcc = true;
+ break;
+ }
}
}
}
@@ -1508,31 +1630,22 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
cmd.push_back(rccBuildFile);
cmd.push_back(rccInputFile);
- // Log command
- if (this->Verbose) {
- this->LogCommand(cmd);
- }
-
- // Execute command
- bool res = false;
- int retVal = 0;
std::string output;
- res = cmSystemTools::RunSingleCommand(cmd, &output, &output, &retVal);
- if (!res || (retVal != 0)) {
+ if (this->RunCommand(cmd, output)) {
+ // Success
+ rccGenerated = true;
+ } else {
// Command failed
{
std::ostringstream ost;
ost << "AutoRcc: Error: rcc process failed for\n";
- ost << "\"" << rccOutputFile << "\"\n";
+ ost << Quoted(rccOutputFile) << "\n";
ost << "AutoRcc: Command:\n" << cmJoin(cmd, " ") << "\n";
ost << "AutoRcc: Command output:\n" << output << "\n";
this->LogError(ost.str());
}
cmSystemTools::RemoveFile(rccBuildFile);
this->RunRccFailed = true;
- } else {
- // Success
- rccGenerated = true;
}
} else {
// Parent directory creation failed
@@ -1610,7 +1723,18 @@ void cmQtAutoGenerators::LogError(const std::string& message) const
void cmQtAutoGenerators::LogCommand(
const std::vector<std::string>& command) const
{
- this->LogInfo(cmJoin(command, " "));
+ std::vector<std::string> cmdEscaped;
+ typedef std::vector<std::string>::const_iterator Iter;
+ for (Iter cit = command.begin(); cit != command.end(); ++cit) {
+ const std::string cesc = Quoted(*cit);
+ if ((cesc.size() > (cit->size() + 2)) ||
+ (cesc.find(' ') != std::string::npos)) {
+ cmdEscaped.push_back(cesc);
+ } else {
+ cmdEscaped.push_back(*cit);
+ }
+ }
+ this->LogInfo(cmJoin(cmdEscaped, " "));
}
/**
@@ -1660,6 +1784,41 @@ std::string cmQtAutoGenerators::ChecksumedPath(const std::string& sourceFile,
}
/**
+ * @brief Generates the parent directory of the given file on demand
+ * @return True on success
+ */
+bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) const
+{
+ bool success = true;
+ const std::string dirName = cmSystemTools::GetFilenamePath(filename);
+ if (!dirName.empty()) {
+ success = cmsys::SystemTools::MakeDirectory(dirName);
+ if (!success) {
+ this->LogError("AutoGen: Error: Directory creation failed: " + dirName);
+ }
+ }
+ return success;
+}
+
+/**
+ * @brief Runs a command and returns true on success
+ * @return True on success
+ */
+bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command,
+ std::string& output) const
+{
+ // Log command
+ if (this->Verbose) {
+ this->LogCommand(command);
+ }
+ // Execute command
+ int retVal = 0;
+ bool res =
+ cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
+ return (res && (retVal == 0));
+}
+
+/**
* @brief Tries to find the header file to the given file base path by
* appending different header extensions
* @return True on success
@@ -1681,39 +1840,22 @@ bool cmQtAutoGenerators::FindHeader(std::string& header,
return false;
}
-bool cmQtAutoGenerators::FindHeaderGlobal(
- std::string& header, const std::string& testBasePath) const
-{
- for (std::vector<std::string>::const_iterator iit =
- this->MocIncludePaths.begin();
- iit != this->MocIncludePaths.end(); ++iit) {
- const std::string fullPath = ((*iit) + '/' + testBasePath);
- if (FindHeader(header, fullPath)) {
- return true;
- }
- }
- return false;
-}
-
-std::string cmQtAutoGenerators::FindMocHeader(const std::string& basePath,
- const std::string& baseName,
- const std::string& subDir) const
+std::string cmQtAutoGenerators::MocFindHeader(
+ const std::string& sourcePath, const std::string& includeBase) const
{
std::string header;
- do {
- if (!subDir.empty()) {
- if (this->FindHeader(header, basePath + subDir + baseName)) {
+ // Search in vicinity of the source
+ if (!this->FindHeader(header, sourcePath + includeBase)) {
+ // Search in include directories
+ for (std::vector<std::string>::const_iterator iit =
+ this->MocIncludePaths.begin();
+ iit != this->MocIncludePaths.end(); ++iit) {
+ const std::string fullPath = ((*iit) + '/' + includeBase);
+ if (FindHeader(header, fullPath)) {
break;
}
}
- if (this->FindHeader(header, basePath + baseName)) {
- break;
- }
- // Try include directories
- if (this->FindHeaderGlobal(header, subDir + baseName)) {
- break;
- }
- } while (false);
+ }
// Sanitize
if (!header.empty()) {
header = cmsys::SystemTools::GetRealPath(header);
@@ -1721,54 +1863,31 @@ std::string cmQtAutoGenerators::FindMocHeader(const std::string& basePath,
return header;
}
-std::string cmQtAutoGenerators::FindIncludedFile(
- const std::string& sourceFile, const std::string& includeString) const
+bool cmQtAutoGenerators::MocFindIncludedFile(
+ std::string& absFile, const std::string& sourcePath,
+ const std::string& includeString) const
{
+ bool success = false;
// Search in vicinity of the source
{
- std::string testPath = cmSystemTools::GetFilenamePath(sourceFile);
- testPath += '/';
+ std::string testPath = sourcePath;
testPath += includeString;
if (cmsys::SystemTools::FileExists(testPath.c_str())) {
- return cmsys::SystemTools::GetRealPath(testPath);
+ absFile = cmsys::SystemTools::GetRealPath(testPath);
+ success = true;
}
}
- // Search globally
- return FindInIncludeDirectories(includeString);
-}
-
-/**
- * @brief Tries to find a file in the include directories
- * @return True on success
- */
-std::string cmQtAutoGenerators::FindInIncludeDirectories(
- const std::string& includeString) const
-{
- std::string res;
- for (std::vector<std::string>::const_iterator iit =
- this->MocIncludePaths.begin();
- iit != this->MocIncludePaths.end(); ++iit) {
- const std::string fullPath = ((*iit) + '/' + includeString);
- if (cmsys::SystemTools::FileExists(fullPath.c_str())) {
- res = cmsys::SystemTools::GetRealPath(fullPath);
- break;
- }
- }
- return res;
-}
-
-/**
- * @brief Generates the parent directory of the given file on demand
- * @return True on success
- */
-bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) const
-{
- bool success = true;
- const std::string dirName = cmSystemTools::GetFilenamePath(filename);
- if (!dirName.empty()) {
- success = cmsys::SystemTools::MakeDirectory(dirName);
- if (!success) {
- this->LogError("AutoGen: Directory creation failed: " + dirName);
+ // Search in include directories
+ if (!success) {
+ for (std::vector<std::string>::const_iterator iit =
+ this->MocIncludePaths.begin();
+ iit != this->MocIncludePaths.end(); ++iit) {
+ const std::string fullPath = ((*iit) + '/' + includeString);
+ if (cmsys::SystemTools::FileExists(fullPath.c_str())) {
+ absFile = cmsys::SystemTools::GetRealPath(fullPath);
+ success = true;
+ break;
+ }
}
}
return success;
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index c20b83c..ee046de 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -33,6 +33,7 @@ private:
typedef std::pair<std::string, cmsys::RegularExpression> MacroFilter;
// - Configuration
+ bool MocDependFilterPush(const std::string& key, const std::string& regExp);
bool ReadAutogenInfoFile(cmMakefile* makefile,
const std::string& targetDirectory,
const std::string& config);
@@ -77,7 +78,7 @@ private:
std::set<std::string>& mocHeaderFiles,
std::set<std::string>& uicHeaderFiles) const;
- void ParseHeaders(
+ bool ParseHeaders(
const std::set<std::string>& mocHeaderFiles,
const std::set<std::string>& uicHeaderFiles,
const std::map<std::string, std::string>& mocsIncluded,
@@ -106,10 +107,12 @@ private:
const std::map<std::string, std::set<std::string> >& mocDepends);
bool MocGenerateFile(
const std::string& sourceFile, const std::string& mocFileName,
- const std::string& subDirPrefix,
+ const std::string& subDir,
const std::map<std::string, std::set<std::string> >& mocDepends);
// - Uic file generation
+ bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile,
+ const std::string& includeString);
bool UicGenerateAll(
const std::map<std::string, std::vector<std::string> >& includedUis);
bool UicGenerateFile(const std::string& realName,
@@ -139,16 +142,15 @@ 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 FindHeader(std::string& header, const std::string& testBasePath) const;
- bool FindHeaderGlobal(std::string& header,
- const std::string& testBasePath) const;
- std::string FindMocHeader(const std::string& basePath,
- const std::string& baseName,
- const std::string& subDir) const;
- std::string FindIncludedFile(const std::string& sourceFile,
- const std::string& includeString) const;
- std::string FindInIncludeDirectories(const std::string& includeString) const;
+
+ std::string MocFindHeader(const std::string& sourcePath,
+ const std::string& includeBase) const;
+ bool MocFindIncludedFile(std::string& absFile, const std::string& sourceFile,
+ const std::string& includeString) const;
// - Target names
std::string OriginTargetName;
@@ -184,6 +186,7 @@ private:
std::vector<std::string> UicSkipList;
std::vector<std::string> UicTargetOptions;
std::map<std::string, std::string> UicOptions;
+ std::vector<std::string> UicSearchPaths;
// - Rcc
std::vector<std::string> RccSources;
std::map<std::string, std::string> RccOptions;
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index b193f65..bbcc300 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -86,6 +86,7 @@ public:
// Get the properties
cmPropertyMap& GetProperties() { return this->Properties; }
+ const cmPropertyMap& GetProperties() const { return this->Properties; }
/**
* Check whether the given source file location could refer to this
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index 80e494b..d2c9d73 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -308,7 +308,7 @@ void cmStateSnapshot::SetDefaultDefinitions()
this->SetDefinition("CMAKE_HOST_UNIX", "1");
struct utsname uts_name;
- if (uname(&uts_name) == 0) {
+ if (uname(&uts_name) >= 0) {
this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", uts_name.sysname);
}
#endif
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ad3d604..e3c7b63 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -230,6 +230,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
this->SetPropertyDefault("INSTALL_NAME_DIR", CM_NULLPTR);
this->SetPropertyDefault("INSTALL_RPATH", "");
this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF");
+ this->SetPropertyDefault("INTERPROCEDURAL_OPTIMIZATION", CM_NULLPTR);
this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF");
this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF");
this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", CM_NULLPTR);
@@ -245,8 +246,10 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
this->SetPropertyDefault("AUTOMOC", CM_NULLPTR);
this->SetPropertyDefault("AUTOUIC", CM_NULLPTR);
this->SetPropertyDefault("AUTORCC", CM_NULLPTR);
+ this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", CM_NULLPTR);
this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", CM_NULLPTR);
this->SetPropertyDefault("AUTOUIC_OPTIONS", CM_NULLPTR);
+ this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", CM_NULLPTR);
this->SetPropertyDefault("AUTORCC_OPTIONS", CM_NULLPTR);
this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", CM_NULLPTR);
this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", CM_NULLPTR);
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index e3853ed..fbf7447 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -131,6 +131,7 @@ void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
}
stream->fill(' ');
stream->width(indentLevel * 2);
+ (*stream) << ""; // applies indentation
(*stream) << "<" << tag << " Condition=\"";
(*stream) << "'$(Configuration)|$(Platform)'=='";
(*stream) << config << "|" << this->Platform;
@@ -706,20 +707,40 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
if (const char* g = (*oi)->GetProperty("VS_RESOURCE_GENERATOR")) {
generator = g;
}
- this->WriteString("<Generator>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(generator)
- << "</Generator>\n";
- if (designerResource.find(srcDir) == 0) {
- designerResource = designerResource.substr(srcDir.length() + 1);
- } else if (designerResource.find(binDir) == 0) {
- designerResource = designerResource.substr(binDir.length() + 1);
- } else {
- designerResource =
- cmsys::SystemTools::GetFilenameName(designerResource);
+ if (!generator.empty()) {
+ this->WriteString("<Generator>", 3);
+ (*this->BuildFileStream) << cmVS10EscapeXML(generator)
+ << "</Generator>\n";
+ if (designerResource.find(srcDir) == 0) {
+ designerResource = designerResource.substr(srcDir.length() + 1);
+ } else if (designerResource.find(binDir) == 0) {
+ designerResource = designerResource.substr(binDir.length() + 1);
+ } else {
+ designerResource =
+ cmsys::SystemTools::GetFilenameName(designerResource);
+ }
+ this->ConvertToWindowsSlash(designerResource);
+ this->WriteString("<LastGenOutput>", 3);
+ (*this->BuildFileStream) << designerResource
+ << "</LastGenOutput>\n";
+ }
+ }
+ const cmPropertyMap& props = (*oi)->GetProperties();
+ for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
+ ++p) {
+ static const std::string propNamePrefix = "VS_CSHARP_";
+ if (p->first.find(propNamePrefix.c_str()) == 0) {
+ std::string tagName = p->first.substr(propNamePrefix.length());
+ if (!tagName.empty()) {
+ std::string value = props.GetPropertyValue(p->first);
+ if (!value.empty()) {
+ this->WriteString("<", 3);
+ (*this->BuildFileStream) << tagName << ">";
+ (*this->BuildFileStream) << cmVS10EscapeXML(value);
+ (*this->BuildFileStream) << "</" << tagName << ">\n";
+ }
+ }
}
- this->ConvertToWindowsSlash(designerResource);
- this->WriteString("<LastGenOutput>", 3);
- (*this->BuildFileStream) << designerResource << "</LastGenOutput>\n";
}
}
@@ -1968,42 +1989,21 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
sourceFileTags["Link"] = link;
}
}
- // check if file is a generated .Designer.cs or .xaml.cs file
- // to add additional necessary tags
- const std::string fileExtension =
- cmsys::SystemTools::GetFilenameExtension(f);
- if (fileExtension == ".Designer.cs" || fileExtension == ".xaml.cs") {
- f = f.substr(0, f.length() - fileExtension.length());
- if (sourceFileTags.find("Link") == sourceFileTags.end() &&
- !this->InSourceBuild) {
- // add link fallback
- sourceFileTags["Link"] =
- cmsys::SystemTools::GetFilenameName(f) + fileExtension;
- }
- std::vector<std::string> extensions;
- extensions.push_back(".resx");
- extensions.push_back(".settings");
- extensions.push_back(".xaml");
- extensions.push_back(".cs");
- std::string dependencyExtension;
- for (std::vector<std::string>::iterator i = extensions.begin();
- i != extensions.end(); ++i) {
- if (cmsys::SystemTools::FileExists(f + *i)) {
- dependencyExtension = *i;
- // There should never be more than one match. Otherwise
- // one cannot tell on which match the file depends.
- break;
+ const cmPropertyMap& props = sf.GetProperties();
+ for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
+ ++p) {
+ static const std::string propNamePrefix = "VS_CSHARP_";
+ if (p->first.find(propNamePrefix.c_str()) == 0) {
+ std::string tagName = p->first.substr(propNamePrefix.length());
+ if (!tagName.empty()) {
+ const std::string val = props.GetPropertyValue(p->first);
+ if (!val.empty()) {
+ sourceFileTags[tagName] = val;
+ } else {
+ sourceFileTags.erase(tagName);
+ }
}
}
- if (dependencyExtension == ".resx") {
- sourceFileTags["DesignTime"] = "True";
- sourceFileTags["AutoGen"] = "True";
- } else if (dependencyExtension == ".settings") {
- sourceFileTags["DesignTimeSharedInput"] = "True";
- sourceFileTags["AutoGen"] = "True";
- }
- sourceFileTags["DependentUpon"] =
- cmsys::SystemTools::GetFilenameName(f) + dependencyExtension;
}
// write source file specific tags
if (!sourceFileTags.empty()) {
diff --git a/Source/cmWorkingDirectory.cxx b/Source/cmWorkingDirectory.cxx
new file mode 100644
index 0000000..99c9ba8
--- /dev/null
+++ b/Source/cmWorkingDirectory.cxx
@@ -0,0 +1,24 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmWorkingDirectory.h"
+
+#include "cmSystemTools.h"
+
+cmWorkingDirectory::cmWorkingDirectory(std::string const& newdir)
+{
+ this->OldDir = cmSystemTools::GetCurrentWorkingDirectory();
+ cmSystemTools::ChangeDirectory(newdir);
+}
+
+cmWorkingDirectory::~cmWorkingDirectory()
+{
+ this->Pop();
+}
+
+void cmWorkingDirectory::Pop()
+{
+ if (!this->OldDir.empty()) {
+ cmSystemTools::ChangeDirectory(this->OldDir);
+ this->OldDir.clear();
+ }
+}
diff --git a/Source/cmWorkingDirectory.h b/Source/cmWorkingDirectory.h
new file mode 100644
index 0000000..af0fd44
--- /dev/null
+++ b/Source/cmWorkingDirectory.h
@@ -0,0 +1,25 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmWorkingDirectory_h
+#define cmWorkingDirectory_h
+
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <string>
+
+/** \class cmWorkingDirectory
+ * \brief An RAII class to manipulate the working directory.
+ */
+class cmWorkingDirectory
+{
+public:
+ cmWorkingDirectory(std::string const& newdir);
+ ~cmWorkingDirectory();
+
+ void Pop();
+
+private:
+ std::string OldDir;
+};
+
+#endif
diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx
new file mode 100644
index 0000000..5c22531
--- /dev/null
+++ b/Source/cmXCodeScheme.cxx
@@ -0,0 +1,227 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmXCodeScheme.h"
+
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+
+#include "cmGeneratedFileStream.h"
+#include "cmGeneratorTarget.h"
+#include "cmXMLSafe.h"
+
+cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj,
+ const std::vector<std::string>& configList,
+ unsigned int xcVersion)
+ : Target(xcObj)
+ , TargetName(xcObj->GetTarget()->GetName())
+ , BuildableName(xcObj->GetTarget()->GetFullName())
+ , TargetId(xcObj->GetId())
+ , ConfigList(configList)
+ , XcodeVersion(xcVersion)
+{
+}
+
+void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir,
+ const std::string& container)
+{
+ // Create shared scheme sub-directory tree
+ //
+ std::string xcodeSchemeDir = xcProjDir;
+ xcodeSchemeDir += "/xcshareddata/xcschemes";
+ cmSystemTools::MakeDirectory(xcodeSchemeDir.c_str());
+
+ std::string xcodeSchemeFile = xcodeSchemeDir;
+ xcodeSchemeFile += "/";
+ xcodeSchemeFile += this->TargetName;
+ xcodeSchemeFile += ".xcscheme";
+
+ cmGeneratedFileStream fout(xcodeSchemeFile.c_str());
+ fout.SetCopyIfDifferent(true);
+ if (!fout) {
+ return;
+ }
+
+ WriteXCodeXCScheme(fout, container);
+}
+
+void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout,
+ const std::string& container)
+{
+ cmXMLWriter xout(fout);
+ xout.SetIndentationElement(std::string(3, ' '));
+ xout.StartDocument();
+
+ xout.StartElement("Scheme");
+ xout.BreakAttributes();
+ xout.Attribute("LastUpgradeVersion", WriteVersionString());
+ xout.Attribute("version", "1.3");
+
+ WriteBuildAction(xout, container);
+ WriteTestAction(xout, FindConfiguration("Debug"));
+ WriteLaunchAction(xout, FindConfiguration("Debug"), container);
+ WriteProfileAction(xout, FindConfiguration("Release"));
+ WriteAnalyzeAction(xout, FindConfiguration("Debug"));
+ WriteArchiveAction(xout, FindConfiguration("Release"));
+
+ xout.EndElement();
+}
+
+void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout,
+ const std::string& container)
+{
+ xout.StartElement("BuildAction");
+ xout.BreakAttributes();
+ xout.Attribute("parallelizeBuildables", "YES");
+ xout.Attribute("buildImplicitDependencies", "YES");
+
+ xout.StartElement("BuildActionEntries");
+ xout.StartElement("BuildActionEntry");
+ xout.BreakAttributes();
+ xout.Attribute("buildForTesting", "YES");
+ xout.Attribute("buildForRunning", "YES");
+ xout.Attribute("buildForProfiling", "YES");
+ xout.Attribute("buildForArchiving", "YES");
+ xout.Attribute("buildForAnalyzing", "YES");
+
+ xout.StartElement("BuildableReference");
+ xout.BreakAttributes();
+ xout.Attribute("BuildableIdentifier", "primary");
+ xout.Attribute("BlueprintIdentifier", this->TargetId);
+ xout.Attribute("BuildableName", this->BuildableName);
+ xout.Attribute("BlueprintName", this->TargetName);
+ xout.Attribute("ReferencedContainer", "container:" + container);
+ xout.EndElement();
+
+ xout.EndElement(); // BuildActionEntry
+ xout.EndElement(); // BuildActionEntries
+ xout.EndElement(); // BuildAction
+}
+
+void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout,
+ std::string configuration)
+{
+ xout.StartElement("TestAction");
+ xout.BreakAttributes();
+ xout.Attribute("buildConfiguration", configuration);
+ xout.Attribute("selectedDebuggerIdentifier",
+ "Xcode.DebuggerFoundation.Debugger.LLDB");
+ xout.Attribute("selectedLauncherIdentifier",
+ "Xcode.DebuggerFoundation.Launcher.LLDB");
+ xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES");
+
+ xout.StartElement("Testables");
+ xout.EndElement();
+
+ xout.StartElement("AdditionalOptions");
+ xout.EndElement();
+
+ xout.EndElement(); // TestAction
+}
+
+void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
+ std::string configuration,
+ const std::string& container)
+{
+ xout.StartElement("LaunchAction");
+ xout.BreakAttributes();
+ xout.Attribute("buildConfiguration", configuration);
+ xout.Attribute("selectedDebuggerIdentifier",
+ "Xcode.DebuggerFoundation.Debugger.LLDB");
+ xout.Attribute("selectedLauncherIdentifier",
+ "Xcode.DebuggerFoundation.Launcher.LLDB");
+ xout.Attribute("launchStyle", "0");
+ xout.Attribute("useCustomWorkingDirectory", "NO");
+ xout.Attribute("ignoresPersistentStateOnLaunch", "NO");
+ xout.Attribute("debugDocumentVersioning", "YES");
+ xout.Attribute("debugServiceExtension", "internal");
+ xout.Attribute("allowLocationSimulation", "YES");
+
+ if (IsExecutable(this->Target)) {
+ xout.StartElement("BuildableProductRunnable");
+ xout.BreakAttributes();
+ xout.Attribute("runnableDebuggingMode", "0");
+
+ } else {
+ xout.StartElement("MacroExpansion");
+ }
+
+ xout.StartElement("BuildableReference");
+ xout.BreakAttributes();
+ xout.Attribute("BuildableIdentifier", "primary");
+ xout.Attribute("BlueprintIdentifier", this->TargetId);
+ xout.Attribute("BuildableName", this->BuildableName);
+ xout.Attribute("BlueprintName", this->TargetName);
+ xout.Attribute("ReferencedContainer", "container:" + container);
+ xout.EndElement();
+
+ xout.EndElement(); // MacroExpansion
+
+ xout.StartElement("AdditionalOptions");
+ xout.EndElement();
+
+ xout.EndElement(); // LaunchAction
+}
+
+void cmXCodeScheme::WriteProfileAction(cmXMLWriter& xout,
+ std::string configuration)
+{
+ xout.StartElement("ProfileAction");
+ xout.BreakAttributes();
+ xout.Attribute("buildConfiguration", configuration);
+ xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES");
+ xout.Attribute("savedToolIdentifier", "");
+ xout.Attribute("useCustomWorkingDirectory", "NO");
+ xout.Attribute("debugDocumentVersioning", "YES");
+ xout.EndElement();
+}
+
+void cmXCodeScheme::WriteAnalyzeAction(cmXMLWriter& xout,
+ std::string configuration)
+{
+ xout.StartElement("AnalyzeAction");
+ xout.BreakAttributes();
+ xout.Attribute("buildConfiguration", configuration);
+ xout.EndElement();
+}
+
+void cmXCodeScheme::WriteArchiveAction(cmXMLWriter& xout,
+ std::string configuration)
+{
+ xout.StartElement("ArchiveAction");
+ xout.BreakAttributes();
+ xout.Attribute("buildConfiguration", configuration);
+ xout.Attribute("revealArchiveInOrganizer", "YES");
+ xout.EndElement();
+}
+
+std::string cmXCodeScheme::WriteVersionString()
+{
+ std::ostringstream v;
+ v << std::setfill('0') << std::setw(4) << this->XcodeVersion * 10;
+ return v.str();
+}
+
+std::string cmXCodeScheme::FindConfiguration(const std::string& name)
+{
+ // Try to find the desired configuration by name,
+ // and if it's not found return first from the list
+ //
+ if (std::find(this->ConfigList.begin(), this->ConfigList.end(), name) ==
+ this->ConfigList.end() &&
+ this->ConfigList.size() > 0)
+ return this->ConfigList[0];
+
+ return name;
+}
+
+bool cmXCodeScheme::IsExecutable(const cmXCodeObject* target)
+{
+ cmGeneratorTarget* gt = target->GetTarget();
+ if (!gt) {
+ cmSystemTools::Error("Error no target on xobject\n");
+ return false;
+ }
+
+ return gt->GetType() == cmStateEnums::EXECUTABLE;
+}
diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h
new file mode 100644
index 0000000..0a8e737
--- /dev/null
+++ b/Source/cmXCodeScheme.h
@@ -0,0 +1,50 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmXCodeScheme_h
+#define cmXCodeScheme_h
+
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include "cmGlobalXCodeGenerator.h"
+#include "cmSystemTools.h"
+#include "cmXCodeObject.h"
+#include "cmXMLWriter.h"
+
+/** \class cmXCodeScheme
+ * \brief Write shared schemes for native targets in Xcode project.
+ */
+class cmXCodeScheme
+{
+public:
+ cmXCodeScheme(cmXCodeObject* xcObj,
+ const std::vector<std::string>& configList,
+ unsigned int xcVersion);
+
+ void WriteXCodeSharedScheme(const std::string& xcProjDir,
+ const std::string& container);
+
+private:
+ const cmXCodeObject* const Target;
+ const std::string& TargetName;
+ const std::string BuildableName;
+ const std::string& TargetId;
+ const std::vector<std::string>& ConfigList;
+ const unsigned int XcodeVersion;
+
+ void WriteXCodeXCScheme(std::ostream& fout, const std::string& container);
+
+ void WriteBuildAction(cmXMLWriter& xout, const std::string& container);
+ void WriteTestAction(cmXMLWriter& xout, std::string configuration);
+ void WriteLaunchAction(cmXMLWriter& xout, std::string configuration,
+ const std::string& container);
+ void WriteProfileAction(cmXMLWriter& xout, std::string configuration);
+ void WriteAnalyzeAction(cmXMLWriter& xout, std::string configuration);
+ void WriteArchiveAction(cmXMLWriter& xout, std::string configuration);
+
+ std::string WriteVersionString();
+ std::string FindConfiguration(const std::string& name);
+
+ static bool IsExecutable(const cmXCodeObject* target);
+};
+
+#endif
diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx
index 2f50fe9..541cb3d 100644
--- a/Source/cmXMLWriter.cxx
+++ b/Source/cmXMLWriter.cxx
@@ -7,6 +7,7 @@
cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level)
: Output(output)
+ , IndentationElement(1, '\t')
, Level(level)
, ElementOpen(false)
, BreakAttrib(false)
@@ -100,10 +101,18 @@ void cmXMLWriter::FragmentFile(const char* fname)
this->Output << fin.rdbuf();
}
+void cmXMLWriter::SetIndentationElement(std::string const& element)
+{
+ this->IndentationElement = element;
+}
+
void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent)
{
if (condition) {
- this->Output << '\n' << std::string(indent + this->Level, '\t');
+ this->Output << '\n';
+ for (std::size_t i = 0; i < indent + this->Level; ++i) {
+ this->Output << this->IndentationElement;
+ }
}
}
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index 904f73b..6d1e6b4 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -60,6 +60,8 @@ public:
void FragmentFile(const char* fname);
+ void SetIndentationElement(std::string const& element);
+
private:
cmXMLWriter(const cmXMLWriter&);
cmXMLWriter& operator=(const cmXMLWriter&);
@@ -107,6 +109,7 @@ private:
private:
std::ostream& Output;
std::stack<std::string, std::vector<std::string> > Elements;
+ std::string IndentationElement;
std::size_t Level;
bool ElementOpen;
bool BreakAttrib;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index b2384cd..3af3be6 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -23,6 +23,7 @@
#include "cmTargetLinkLibraryType.h"
#include "cmUtils.hxx"
#include "cmVersionConfig.h"
+#include "cmWorkingDirectory.h"
#include "cm_auto_ptr.hxx"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -2199,24 +2200,23 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
resultFile += "/__cmake_systeminformation/results.txt";
}
- // now run cmake on the CMakeLists file
- cmSystemTools::ChangeDirectory(destPath);
- std::vector<std::string> args2;
- args2.push_back(args[0]);
- args2.push_back(destPath);
- std::string resultArg = "-DRESULT_FILE=";
- resultArg += resultFile;
- args2.push_back(resultArg);
- int res = this->Run(args2, false);
+ {
+ // now run cmake on the CMakeLists file
+ cmWorkingDirectory workdir(destPath);
+ std::vector<std::string> args2;
+ args2.push_back(args[0]);
+ args2.push_back(destPath);
+ std::string resultArg = "-DRESULT_FILE=";
+ resultArg += resultFile;
+ args2.push_back(resultArg);
+ int res = this->Run(args2, false);
- if (res != 0) {
- std::cerr << "Error: --system-information failed on internal CMake!\n";
- return res;
+ if (res != 0) {
+ std::cerr << "Error: --system-information failed on internal CMake!\n";
+ return res;
+ }
}
- // change back to the original directory
- cmSystemTools::ChangeDirectory(cwd);
-
// echo results to stdout if needed
if (writeToStdout) {
FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r");