diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackProductBuildGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/Checks/cm_cxx14_check.cmake | 2 | ||||
-rw-r--r-- | Source/Checks/cm_cxx14_check.cpp | 5 | ||||
-rw-r--r-- | Source/Checks/cm_cxx17_check.cmake | 2 | ||||
-rw-r--r-- | Source/Checks/cm_cxx17_check.cpp | 4 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 14 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 49 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 9 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 25 | ||||
-rw-r--r-- | Source/cmWriteFileCommand.cxx | 14 | ||||
-rw-r--r-- | Source/cmXCodeScheme.cxx | 167 | ||||
-rw-r--r-- | Source/cmXCodeScheme.h | 10 |
14 files changed, 264 insertions, 45 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a7e64fc..d8f56f6 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 12) -set(CMake_VERSION_PATCH 20180731) +set(CMake_VERSION_PATCH 20180809) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index 4ca0fa8..76b3275 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -144,10 +144,10 @@ bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command) tmpFile += "/ProductBuildOutput.log"; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl); - std::string output, error_output; + std::string output; int retVal = 1; bool res = cmSystemTools::RunSingleCommand( - command.c_str(), &output, &error_output, &retVal, nullptr, + command.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl); if (!res || retVal) { diff --git a/Source/Checks/cm_cxx14_check.cmake b/Source/Checks/cm_cxx14_check.cmake index a78ba35..38606b9 100644 --- a/Source/Checks/cm_cxx14_check.cmake +++ b/Source/Checks/cm_cxx14_check.cmake @@ -1,5 +1,5 @@ set(CMake_CXX14_BROKEN 0) -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|PGI") if(NOT CMAKE_CXX14_STANDARD_COMPILE_OPTION) set(CMake_CXX14_WORKS 0) endif() diff --git a/Source/Checks/cm_cxx14_check.cpp b/Source/Checks/cm_cxx14_check.cpp index f5806a9..9369ba2 100644 --- a/Source/Checks/cm_cxx14_check.cpp +++ b/Source/Checks/cm_cxx14_check.cpp @@ -1,5 +1,8 @@ #include <cstdio> +#include <memory> + int main() { - return 0; + std::unique_ptr<int> u(new int(0)); + return *u; } diff --git a/Source/Checks/cm_cxx17_check.cmake b/Source/Checks/cm_cxx17_check.cmake index 83d3971..4da2fd7 100644 --- a/Source/Checks/cm_cxx17_check.cmake +++ b/Source/Checks/cm_cxx17_check.cmake @@ -1,5 +1,5 @@ set(CMake_CXX17_BROKEN 0) -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|PGI") if(NOT CMAKE_CXX17_STANDARD_COMPILE_OPTION) set(CMake_CXX17_WORKS 0) endif() diff --git a/Source/Checks/cm_cxx17_check.cpp b/Source/Checks/cm_cxx17_check.cpp index 2cbf1d5..4e89184 100644 --- a/Source/Checks/cm_cxx17_check.cpp +++ b/Source/Checks/cm_cxx17_check.cpp @@ -1,7 +1,9 @@ #include <cstdio> +#include <memory> #include <unordered_map> int main() { - return 0; + std::unique_ptr<int> u(new int(0)); + return *u; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4c288f5..402ceb2 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -208,16 +208,20 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, cmSystemTools::MakeDirectory(dir); mode_t mode = 0; + bool writable = false; // Set permissions to writable if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) { - cmSystemTools::SetPermissions(fileName.c_str(), #if defined(_MSC_VER) || defined(__MINGW32__) - mode | S_IWRITE + writable = mode & S_IWRITE; + mode_t newMode = mode | S_IWRITE; #else - mode | S_IWUSR | S_IWGRP + writable = mode & S_IWUSR; + mode_t newMode = mode | S_IWUSR | S_IWGRP; #endif - ); + if (!writable) { + cmSystemTools::SetPermissions(fileName.c_str(), newMode); + } } // If GetPermissions fails, pretend like it is ok. File open will fail if // the file is not writable @@ -242,7 +246,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, return false; } file.close(); - if (mode) { + if (mode && !writable) { cmSystemTools::SetPermissions(fileName.c_str(), mode); } return true; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 63bbf04..58821c2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1313,16 +1313,10 @@ bool cmGlobalGenerator::Compute() // so create the map from project name to vector of local generators this->FillProjectMap(); -#ifdef CMAKE_BUILD_WITH_CMAKE - // Iterate through all targets and set up automoc for those which have - // the AUTOMOC, AUTOUIC or AUTORCC property set - auto autogenInits = this->CreateQtAutoGenInitializers(); - for (auto& autoGen : autogenInits) { - if (!autoGen->InitCustomTargets()) { - return false; - } + // Iterate through all targets and set up AUTOMOC, AUTOUIC and AUTORCC + if (!this->QtAutoGen()) { + return false; } -#endif // Add generator specific helper commands for (cmLocalGenerator* localGen : this->LocalGenerators) { @@ -1341,16 +1335,6 @@ bool cmGlobalGenerator::Compute() } } -#ifdef CMAKE_BUILD_WITH_CMAKE - for (auto& autoGen : autogenInits) { - if (!autoGen->SetupCustomTargets()) { - return false; - } - autoGen.reset(nullptr); - } - autogenInits.clear(); -#endif - for (cmLocalGenerator* localGen : this->LocalGenerators) { cmMakefile* mf = localGen->GetMakefile(); for (cmInstallGenerator* g : mf->GetInstallGenerators()) { @@ -1480,12 +1464,11 @@ bool cmGlobalGenerator::ComputeTargetDepends() return true; } -std::vector<std::unique_ptr<cmQtAutoGenInitializer>> -cmGlobalGenerator::CreateQtAutoGenInitializers() +bool cmGlobalGenerator::QtAutoGen() { +#ifdef CMAKE_BUILD_WITH_CMAKE std::vector<std::unique_ptr<cmQtAutoGenInitializer>> autogenInits; -#ifdef CMAKE_BUILD_WITH_CMAKE for (cmLocalGenerator* localGen : this->LocalGenerators) { const std::vector<cmGeneratorTarget*>& targets = localGen->GetGeneratorTargets(); @@ -1519,12 +1502,30 @@ cmGlobalGenerator::CreateQtAutoGenInitializers() continue; } - autogenInits.emplace_back(new cmQtAutoGenInitializer( + autogenInits.emplace_back(cm::make_unique<cmQtAutoGenInitializer>( target, mocEnabled, uicEnabled, rccEnabled, qtVersionMajor)); } } + + if (!autogenInits.empty()) { + // Initialize custom targets + for (auto& autoGen : autogenInits) { + if (!autoGen->InitCustomTargets()) { + return false; + } + } + + // Setup custom targets + for (auto& autoGen : autogenInits) { + if (!autoGen->SetupCustomTargets()) { + return false; + } + autoGen.reset(nullptr); + } + } #endif - return autogenInits; + + return true; } cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer( diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index a50cc3b..1ed070e 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -33,7 +33,6 @@ class cmLinkLineComputer; class cmLocalGenerator; class cmMakefile; class cmOutputConverter; -class cmQtAutoGenInitializer; class cmSourceFile; class cmStateDirectory; class cmake; @@ -354,6 +353,8 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() const { return false; } + virtual bool IsXcode() const { return false; } + /** Return true if we know the exact location of object files. If false, store the reason in the given string. This is meaningful only after EnableLanguage has been called. */ @@ -441,9 +442,9 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; - // Qt auto generators - std::vector<std::unique_ptr<cmQtAutoGenInitializer>> - CreateQtAutoGenInitializers(); + /// @brief Qt AUTOMOC/UIC/RCC target generation + /// @return true on success + bool QtAutoGen(); std::string SelectMakeProgram(const std::string& makeProgram, const std::string& makeDefault = "") const; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index f7bca13..62f7030 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -96,6 +96,8 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ bool IsMultiConfig() const override; + bool IsXcode() const override { return true; } + bool HasKnownObjectFileLocation(std::string* reason) const override; bool IsIPOSupported() const override { return true; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 803a0a9..380ac88 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -278,6 +278,31 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("LINK_SEARCH_START_STATIC", nullptr); this->SetPropertyDefault("LINK_SEARCH_END_STATIC", nullptr); this->SetPropertyDefault("FOLDER", nullptr); +#ifdef __APPLE__ + if (this->GetGlobalGenerator()->IsXcode()) { + this->SetPropertyDefault("XCODE_SCHEME_ADDRESS_SANITIZER", nullptr); + this->SetPropertyDefault( + "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_THREAD_SANITIZER", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_THREAD_SANITIZER_STOP", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER", + nullptr); + this->SetPropertyDefault( + "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER", + nullptr); + this->SetPropertyDefault("XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP", + nullptr); + this->SetPropertyDefault("XCODE_SCHEME_MALLOC_SCRIBBLE", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_MALLOC_GUARD_EDGES", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_GUARD_MALLOC", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_ZOMBIE_OBJECTS", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_MALLOC_STACK", nullptr); + this->SetPropertyDefault("XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE", + nullptr); + this->SetPropertyDefault("XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS", nullptr); + } +#endif } // Collect the set of configuration types. diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index d3d2db0..c504ef4 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -45,16 +45,20 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args, cmSystemTools::MakeDirectory(dir); mode_t mode = 0; + bool writable = false; // Set permissions to writable if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) { - cmSystemTools::SetPermissions(fileName.c_str(), #if defined(_MSC_VER) || defined(__MINGW32__) - mode | S_IWRITE + writable = mode & S_IWRITE; + mode_t newMode = mode | S_IWRITE; #else - mode | S_IWUSR | S_IWGRP + writable = mode & S_IWUSR; + mode_t newMode = mode | S_IWUSR | S_IWGRP; #endif - ); + if (!writable) { + cmSystemTools::SetPermissions(fileName.c_str(), newMode); + } } // If GetPermissions fails, pretend like it is ok. File open will fail if // the file is not writable @@ -69,7 +73,7 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args, } file << message << std::endl; file.close(); - if (mode) { + if (mode && !writable) { cmSystemTools::SetPermissions(fileName.c_str(), mode); } diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index f1dce64..58cb9c9 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -143,6 +143,41 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, xout.Attribute("debugServiceExtension", "internal"); xout.Attribute("allowLocationSimulation", "YES"); + // Diagnostics tab begin + + bool useAddressSanitizer = WriteLaunchActionAttribute( + xout, "enableAddressSanitizer", + "XCODE_SCHEME_ADDRESS_SANITIZER"); // not allowed with + // enableThreadSanitizer=YES + WriteLaunchActionAttribute( + xout, "enableASanStackUseAfterReturn", + "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN"); + + bool useThreadSanitizer = false; + if (!useAddressSanitizer) { + useThreadSanitizer = WriteLaunchActionAttribute( + xout, "enableThreadSanitizer", + "XCODE_SCHEME_THREAD_SANITIZER"); // not allowed with + // enableAddressSanitizer=YES + } + + WriteLaunchActionAttribute(xout, "stopOnEveryThreadSanitizerIssue", + "XCODE_SCHEME_THREAD_SANITIZER_STOP"); + + WriteLaunchActionAttribute(xout, "enableUBSanitizer", + "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER"); + WriteLaunchActionAttribute( + xout, "stopOnEveryUBSanitizerIssue", + "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP"); + + WriteLaunchActionAttribute( + xout, "disableMainThreadChecker", + "XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER"); // negative enabled! + WriteLaunchActionAttribute(xout, "stopOnEveryMainThreadCheckerIssue", + "XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP"); + + // Diagnostics tab end + if (IsExecutable(this->Target)) { xout.StartElement("BuildableProductRunnable"); xout.BreakAttributes(); @@ -156,12 +191,144 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, xout.EndElement(); // MacroExpansion + // Info tab begin + + if (const char* exe = + this->Target->GetTarget()->GetProperty("XCODE_SCHEME_EXECUTABLE")) { + + xout.StartElement("PathRunnable"); + xout.BreakAttributes(); + + xout.Attribute("runnableDebuggingMode", "0"); + xout.Attribute("FilePath", exe); + + xout.EndElement(); // PathRunnable + } + + // Info tab end + + // Arguments tab begin + + if (const char* argList = + this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ARGUMENTS")) { + std::vector<std::string> arguments; + cmSystemTools::ExpandListArgument(argList, arguments); + if (!arguments.empty()) { + xout.StartElement("CommandLineArguments"); + + for (auto argument : arguments) { + xout.StartElement("CommandLineArgument"); + xout.BreakAttributes(); + + xout.Attribute("argument", argument); + xout.Attribute("isEnabled", "YES"); + + xout.EndElement(); // CommandLineArgument + } + + xout.EndElement(); // CommandLineArguments + } + } + + if (const char* envList = + this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ENVIRONMENT")) { + std::vector<std::string> envs; + cmSystemTools::ExpandListArgument(envList, envs); + if (!envs.empty()) { + xout.StartElement("EnvironmentVariables"); + + for (auto env : envs) { + + xout.StartElement("EnvironmentVariable"); + xout.BreakAttributes(); + + std::string envValue; + const auto p = env.find_first_of('='); + if (p != std::string::npos) { + envValue = env.substr(p + 1); + env.resize(p); + } + + xout.Attribute("key", env); + xout.Attribute("value", envValue); + xout.Attribute("isEnabled", "YES"); + + xout.EndElement(); // EnvironmentVariable + } + + xout.EndElement(); // EnvironmentVariables + } + } + + // Arguments tab end + xout.StartElement("AdditionalOptions"); + + if (!useThreadSanitizer) { + WriteLaunchActionAdditionalOption(xout, "MallocScribble", "", + "XCODE_SCHEME_MALLOC_SCRIBBLE"); + } + + if (!useThreadSanitizer && !useAddressSanitizer) { + WriteLaunchActionAdditionalOption(xout, "MallocGuardEdges", "", + "XCODE_SCHEME_MALLOC_GUARD_EDGES"); + } + + if (!useThreadSanitizer && !useAddressSanitizer) { + WriteLaunchActionAdditionalOption(xout, "DYLD_INSERT_LIBRARIES", + "/usr/lib/libgmalloc.dylib", + "XCODE_SCHEME_GUARD_MALLOC"); + } + + WriteLaunchActionAdditionalOption(xout, "NSZombieEnabled", "YES", + "XCODE_SCHEME_ZOMBIE_OBJECTS"); + + if (!useThreadSanitizer && !useAddressSanitizer) { + WriteLaunchActionAdditionalOption(xout, "MallocStackLogging", "", + "XCODE_SCHEME_MALLOC_STACK"); + } + + WriteLaunchActionAdditionalOption(xout, "DYLD_PRINT_APIS", "", + "XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE"); + + WriteLaunchActionAdditionalOption(xout, "DYLD_PRINT_LIBRARIES", "", + "XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS"); + xout.EndElement(); xout.EndElement(); // LaunchAction } +bool cmXCodeScheme::WriteLaunchActionAttribute(cmXMLWriter& xout, + const std::string& attrName, + const std::string& varName) +{ + if (Target->GetTarget()->GetPropertyAsBool(varName)) { + xout.Attribute(attrName.c_str(), "YES"); + return true; + } + return false; +} + +bool cmXCodeScheme::WriteLaunchActionAdditionalOption( + cmXMLWriter& xout, const std::string& key, const std::string& value, + const std::string& varName) +{ + if (Target->GetTarget()->GetPropertyAsBool(varName)) { + xout.StartElement("AdditionalOption"); + xout.BreakAttributes(); + + xout.Attribute("key", key); + xout.Attribute("value", value); + xout.Attribute("isEnabled", "YES"); + + xout.EndElement(); // AdditionalOption + + return true; + } + return false; +} + void cmXCodeScheme::WriteProfileAction(cmXMLWriter& xout, const std::string& configuration) { diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index e5e501a..96c76e6 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -41,6 +41,16 @@ private: const std::string& container); void WriteLaunchAction(cmXMLWriter& xout, const std::string& configuration, const std::string& container); + + bool WriteLaunchActionAttribute(cmXMLWriter& xout, + const std::string& attrName, + const std::string& varName); + + bool WriteLaunchActionAdditionalOption(cmXMLWriter& xout, + const std::string& attrName, + const std::string& value, + const std::string& varName); + void WriteProfileAction(cmXMLWriter& xout, const std::string& configuration); void WriteAnalyzeAction(cmXMLWriter& xout, const std::string& configuration); void WriteArchiveAction(cmXMLWriter& xout, const std::string& configuration); |