diff options
author | Brad King <brad.king@kitware.com> | 2020-04-15 13:44:17 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-04-15 13:44:48 (GMT) |
commit | a67565751f848dfb4fe7a497f3c3e99581805c33 (patch) | |
tree | 1dac16219431fd4c0cda47b1b502ee4cad6518ee | |
parent | 0a6b715c5c25e396916c86e761b54a917c83807a (diff) | |
parent | bc877a7e944d2a83867b4d55073fe3f83bcecc42 (diff) | |
download | CMake-a67565751f848dfb4fe7a497f3c3e99581805c33.zip CMake-a67565751f848dfb4fe7a497f3c3e99581805c33.tar.gz CMake-a67565751f848dfb4fe7a497f3c3e99581805c33.tar.bz2 |
Merge topic 'msbuildUtf8Support'
bc877a7e94 Add support to indicate UTF-8 custom command pipe output encoding
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4587
-rw-r--r-- | Source/cmCustomCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmCustomCommand.h | 7 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 8 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 43 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 18 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 7 | ||||
-rw-r--r-- | Source/cmLocalVisualStudioGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 54 | ||||
-rw-r--r-- | Source/cmMakefile.h | 12 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 13 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 2 |
16 files changed, 127 insertions, 71 deletions
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 0dd8722..149f5e9 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -11,7 +11,8 @@ cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs, std::vector<std::string> depends, cmCustomCommandLines commandLines, cmListFileBacktrace lfbt, const char* comment, - const char* workingDirectory) + const char* workingDirectory, + bool stdPipesUTF8) : Outputs(std::move(outputs)) , Byproducts(std::move(byproducts)) , Depends(std::move(depends)) @@ -20,6 +21,7 @@ cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs, , Comment(comment ? comment : "") , WorkingDirectory(workingDirectory ? workingDirectory : "") , HaveComment(comment != nullptr) + , StdPipesUTF8(stdPipesUTF8) { } diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index d300fa5..aa572ad 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -30,7 +30,8 @@ public: std::vector<std::string> byproducts, std::vector<std::string> depends, cmCustomCommandLines commandLines, cmListFileBacktrace lfbt, - const char* comment, const char* workingDirectory); + const char* comment, const char* workingDirectory, + bool stdPipesUTF8); /** Get the output file produced by the command. */ const std::vector<std::string>& GetOutputs() const; @@ -53,6 +54,9 @@ public: /** Get the comment string for the command. */ const char* GetComment() const; + /** Get a value indicating if the command uses UTF-8 output pipes. */ + bool GetStdPipesUTF8() const { return this->StdPipesUTF8; } + /** Append to the list of command lines. */ void AppendCommands(const cmCustomCommandLines& commandLines); @@ -108,6 +112,7 @@ private: bool EscapeOldStyle = true; bool UsesTerminal = false; bool CommandExpandLists = false; + bool StdPipesUTF8 = false; }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4a6f6fb..035c608 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2545,6 +2545,7 @@ void cmGlobalGenerator::AddGlobalTarget_EditCache( singleLine.push_back("No interactive CMake dialog available."); gti.Message = "No interactive CMake dialog available..."; gti.UsesTerminal = false; + gti.StdPipesUTF8 = true; } gti.CommandLines.push_back(std::move(singleLine)); @@ -2569,6 +2570,7 @@ void cmGlobalGenerator::AddGlobalTarget_RebuildCache( singleLine.push_back("-S$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); gti.CommandLines.push_back(std::move(singleLine)); + gti.StdPipesUTF8 = true; targets.push_back(std::move(gti)); } @@ -2605,6 +2607,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( gti.Name = this->GetInstallTargetName(); gti.Message = "Install the project..."; gti.UsesTerminal = true; + gti.StdPipesUTF8 = true; cmCustomCommandLine singleLine; if (this->GetPreinstallTargetName()) { gti.Depends.emplace_back(this->GetPreinstallTargetName()); @@ -2716,7 +2719,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti, std::vector<std::string> no_depends; // Store the custom command in the target. cmCustomCommand cc(no_outputs, no_byproducts, no_depends, gti.CommandLines, - cmListFileBacktrace(), nullptr, gti.WorkingDir.c_str()); + cmListFileBacktrace(), nullptr, gti.WorkingDir.c_str(), + gti.StdPipesUTF8); cc.SetUsesTerminal(gti.UsesTerminal); target.AddPostBuildCommand(std::move(cc)); if (!gti.Message.empty()) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 70e43b5..a76ab3c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -554,6 +554,7 @@ protected: std::string WorkingDir; bool UsesTerminal = false; bool PerConfig = true; + bool StdPipesUTF8 = false; }; void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index fa0e935..1df76ca 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -142,6 +142,9 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Add a custom rule to re-run CMake if any input files changed. { + // The custom rule runs cmake so set UTF-8 pipes. + bool stdPipesUTF8 = true; + // Collect the input files used to generate all targets in this // project. std::vector<std::string> listFiles; @@ -160,7 +163,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() lg.AddCustomCommandToTarget( CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, no_depends, verifyCommandLines, cmCustomCommandType::PRE_BUILD, - "Checking File Globs", no_working_directory, false); + "Checking File Globs", no_working_directory, stdPipesUTF8); // Ensure ZERO_CHECK always runs in Visual Studio using MSBuild, // otherwise the prebuild command will not be run. @@ -192,7 +195,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() if (cmSourceFile* file = lg.AddCustomCommandToOutput( stamps, no_byproducts, listFiles, no_main_dependency, no_implicit_depends, commandLines, "Checking Build System", - no_working_directory, true, false)) { + no_working_directory, true, false, false, false, "", "", + stdPipesUTF8)) { gt->AddSource(file->ResolveFullPath()); } else { cmSystemTools::Error("Error adding rule for " + stamps[0]); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index d2f9760..b9f4609 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -932,7 +932,7 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( { cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file }); cmCustomCommand command(outputs, empty, empty, commandLines, gt->Target->GetMakefile()->GetBacktrace(), - "Auto build dll exports", "."); + "Auto build dll exports", ".", true); commands.push_back(std::move(command)); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bdc03c7..c7d7133 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1464,6 +1464,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( cmStrCat("$<TARGET_SONAME_FILE:", gtgt->GetName(), '>'); std::string str_link_file = cmStrCat("$<TARGET_LINKER_FILE:", gtgt->GetName(), '>'); + bool stdPipesUTF8 = true; cmCustomCommandLines cmd = cmMakeSingleCommandLine( { cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library", str_file, str_so_file, str_link_file }); @@ -1471,7 +1472,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( cmCustomCommand command( std::vector<std::string>(), std::vector<std::string>(), std::vector<std::string>(), cmd, this->CurrentMakefile->GetBacktrace(), - "Creating symlinks", ""); + "Creating symlinks", "", stdPipesUTF8); postbuild.push_back(std::move(command)); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e6083d3..43de0fc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1089,7 +1089,8 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget( const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists, cmObjectLibraryCommands objLibCommands) + bool command_expand_lists, cmObjectLibraryCommands objLibCommands, + bool stdPipesUTF8) { cmTarget* t = this->Makefile->GetCustomCommandTarget( target, objLibCommands, this->DirectoryBacktrace); @@ -1100,7 +1101,7 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget( detail::AddCustomCommandToTarget( *this, this->DirectoryBacktrace, cmCommandOrigin::Generator, t, byproducts, depends, commandLines, type, comment, workingDir, escapeOldStyle, - uses_terminal, depfile, job_pool, command_expand_lists); + uses_terminal, depfile, job_pool, command_expand_lists, stdPipesUTF8); return t; } @@ -1110,14 +1111,14 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, - const std::string& depfile, const std::string& job_pool) + const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8) { std::vector<std::string> no_byproducts; cmImplicitDependsList no_implicit_depends; return this->AddCustomCommandToOutput( { output }, no_byproducts, depends, main_dependency, no_implicit_depends, commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); + command_expand_lists, depfile, job_pool, stdPipesUTF8); } cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( @@ -1128,7 +1129,7 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { // Make sure there is at least one output. if (outputs.empty()) { @@ -1140,7 +1141,7 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( *this, this->DirectoryBacktrace, cmCommandOrigin::Generator, outputs, byproducts, depends, main_dependency, implicit_depends, commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); + command_expand_lists, depfile, job_pool, stdPipesUTF8); } cmTarget* cmLocalGenerator::AddUtilityCommand( @@ -1149,7 +1150,7 @@ cmTarget* cmLocalGenerator::AddUtilityCommand( const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { cmTarget* target = this->Makefile->AddNewUtilityTarget(utilityName, excludeFromAll); @@ -1163,7 +1164,7 @@ cmTarget* cmLocalGenerator::AddUtilityCommand( *this, this->DirectoryBacktrace, cmCommandOrigin::Generator, target, this->Makefile->GetUtilityOutput(target), workingDir, byproducts, depends, commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists, - job_pool); + job_pool, stdPipesUTF8); return target; } @@ -2648,6 +2649,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) file << "endif()\n"; } + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines = cmMakeSingleCommandLine( { cmSystemTools::GetCMakeCommand(), cmStrCat("-DPDB_PREFIX=", pdb_prefix), "-P", @@ -2666,14 +2668,16 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) if (this->GetGlobalGenerator()->IsVisualStudio()) { this->AddCustomCommandToTarget( target->GetName(), outputs, no_deps, commandLines, - cmCustomCommandType::PRE_BUILD, no_message, - no_current_dir); + cmCustomCommandType::PRE_BUILD, no_message, no_current_dir, + true, false, "", "", false, + cmObjectLibraryCommands::Reject, stdPipesUTF8); } else { cmImplicitDependsList no_implicit_depends; cmSourceFile* copy_rule = this->AddCustomCommandToOutput( outputs, no_byproducts, no_deps, no_main_dependency, no_implicit_depends, commandLines, no_message, - no_current_dir); + no_current_dir, false, true, false, false, "", "", + stdPipesUTF8); if (copy_rule) { target->AddSource(copy_rule->ResolveFullPath()); @@ -3730,7 +3734,7 @@ cmSourceFile* AddCustomCommand( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { cmMakefile* mf = lg.GetMakefile(); @@ -3792,7 +3796,8 @@ cmSourceFile* AddCustomCommand( } std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>( - outputs, byproducts, depends2, commandLines, lfbt, comment, workingDir); + outputs, byproducts, depends2, commandLines, lfbt, comment, workingDir, + stdPipesUTF8); cc->SetEscapeOldStyle(escapeOldStyle); cc->SetEscapeAllowMakeVars(true); cc->SetImplicitDepends(implicit_depends); @@ -3819,7 +3824,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists) + bool command_expand_lists, bool stdPipesUTF8) { cmMakefile* mf = lg.GetMakefile(); @@ -3829,7 +3834,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg, // Add the command to the appropriate build step for the target. std::vector<std::string> no_output; cmCustomCommand cc(no_output, byproducts, depends, commandLines, lfbt, - comment, workingDir); + comment, workingDir, stdPipesUTF8); cc.SetEscapeOldStyle(escapeOldStyle); cc.SetEscapeAllowMakeVars(true); cc.SetUsesTerminal(uses_terminal); @@ -3860,7 +3865,7 @@ cmSourceFile* AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { // Always create the output sources and mark them generated. CreateGeneratedSources(lg, outputs, origin, lfbt); @@ -3869,7 +3874,7 @@ cmSourceFile* AddCustomCommandToOutput( return AddCustomCommand( lg, lfbt, outputs, byproducts, depends, main_dependency, implicit_depends, commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); + command_expand_lists, depfile, job_pool, stdPipesUTF8); } void AppendCustomCommandToOutput(cmLocalGenerator& lg, @@ -3905,7 +3910,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { // Always create the byproduct sources and mark them generated. CreateGeneratedSource(lg, force.Name, origin, lfbt); @@ -3922,7 +3927,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, lg, lfbt, { force.Name }, byproducts, depends, no_main_dependency, no_implicit_depends, commandLines, comment, workingDir, /*replace=*/false, escapeOldStyle, uses_terminal, command_expand_lists, /*depfile=*/"", - job_pool); + job_pool, stdPipesUTF8); if (rule) { lg.GetMakefile()->AddTargetByproducts(target, byproducts); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 71cc63e..5fb9337 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -297,7 +297,8 @@ public: const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", const std::string& job_pool = "", bool command_expand_lists = false, - cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject); + cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject, + bool stdPipesUTF8 = false); /** * Add a custom command to a source file. @@ -308,7 +309,8 @@ public: const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); cmSourceFile* AddCustomCommandToOutput( const std::vector<std::string>& outputs, const std::vector<std::string>& byproducts, @@ -318,7 +320,8 @@ public: const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); /** * Add a utility to the build. A utility target is a command that is run @@ -330,7 +333,8 @@ public: const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false, const std::string& job_pool = ""); + bool command_expand_lists = false, const std::string& job_pool = "", + bool stdPipesUTF8 = false); std::string GetProjectName() const; @@ -548,7 +552,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists); + bool command_expand_lists, bool stdPipesUTF8); cmSourceFile* AddCustomCommandToOutput( cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, @@ -559,7 +563,7 @@ cmSourceFile* AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool); + const std::string& job_pool, bool stdPipesUTF8); void AppendCustomCommandToOutput(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, @@ -576,7 +580,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool); + const std::string& job_pool, bool stdPipesUTF8); } #endif diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9148b27..82bbc61 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -251,14 +251,15 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() std::string argB = cmStrCat("-B", this->GetBinaryDirectory()); std::string stampName = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp"); + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines = cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-file", stampName }); std::string comment = cmStrCat("Building Custom Rule ", makefileIn); const char* no_working_directory = nullptr; - this->AddCustomCommandToOutput(stampName, listFiles, makefileIn, - commandLines, comment.c_str(), - no_working_directory, true, false); + this->AddCustomCommandToOutput( + stampName, listFiles, makefileIn, commandLines, comment.c_str(), + no_working_directory, true, false, false, false, "", "", stdPipesUTF8); if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) { // Finalize the source file path now since we're adding this after // the generator validated all project-named sources. diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 7267976..ebd4f96 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -102,10 +102,12 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, std::vector<std::string> no_output; std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; + bool stdPipesUTF8 = true; cmCustomCommandLines commands = cmMakeSingleCommandLine( { cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir }); pcc.reset(new cmCustomCommand(no_output, no_byproducts, no_depends, commands, - cmListFileBacktrace(), nullptr, nullptr)); + cmListFileBacktrace(), nullptr, nullptr, + stdPipesUTF8)); pcc->SetEscapeOldStyle(false); pcc->SetEscapeAllowMakeVars(true); return pcc; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 15b8b92..85e7df1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1022,7 +1022,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists) + bool command_expand_lists, bool stdPipesUTF8) { cmTarget* t = this->GetCustomCommandTarget( target, cmObjectLibraryCommands::Reject, this->Backtrace); @@ -1040,14 +1040,15 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( cm::optional<std::string> workingStr = MakeOptionalString(workingDir); // Dispatch command creation to allow generator expressions in outputs. - this->AddGeneratorAction([=](cmLocalGenerator& lg, - const cmListFileBacktrace& lfbt) { - BacktraceGuard guard(this->Backtrace, lfbt); - detail::AddCustomCommandToTarget( - lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends, commandLines, - type, GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), - escapeOldStyle, uses_terminal, depfile, job_pool, command_expand_lists); - }); + this->AddGeneratorAction( + [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { + BacktraceGuard guard(this->Backtrace, lfbt); + detail::AddCustomCommandToTarget( + lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends, + commandLines, type, GetCStrOrNull(commentStr), + GetCStrOrNull(workingStr), escapeOldStyle, uses_terminal, depfile, + job_pool, command_expand_lists, stdPipesUTF8); + }); return t; } @@ -1058,14 +1059,14 @@ void cmMakefile::AddCustomCommandToOutput( const char* comment, const char* workingDir, const CommandSourceCallback& callback, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { std::vector<std::string> no_byproducts; cmImplicitDependsList no_implicit_depends; this->AddCustomCommandToOutput( { output }, no_byproducts, depends, main_dependency, no_implicit_depends, commandLines, comment, workingDir, callback, replace, escapeOldStyle, - uses_terminal, command_expand_lists, depfile, job_pool); + uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8); } void cmMakefile::AddCustomCommandToOutput( @@ -1076,7 +1077,7 @@ void cmMakefile::AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, const CommandSourceCallback& callback, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, - const std::string& depfile, const std::string& job_pool) + const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8) { // Make sure there is at least one output. if (outputs.empty()) { @@ -1098,18 +1099,19 @@ void cmMakefile::AddCustomCommandToOutput( cm::optional<std::string> workingStr = MakeOptionalString(workingDir); // Dispatch command creation to allow generator expressions in outputs. - this->AddGeneratorAction([=](cmLocalGenerator& lg, - const cmListFileBacktrace& lfbt) { - BacktraceGuard guard(this->Backtrace, lfbt); - cmSourceFile* sf = detail::AddCustomCommandToOutput( - lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends, - main_dependency, implicit_depends, commandLines, - GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace, - escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool); - if (callback && sf) { - callback(sf); - } - }); + this->AddGeneratorAction( + [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { + BacktraceGuard guard(this->Backtrace, lfbt); + cmSourceFile* sf = detail::AddCustomCommandToOutput( + lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends, + main_dependency, implicit_depends, commandLines, + GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace, + escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool, + stdPipesUTF8); + if (callback && sf) { + callback(sf); + } + }); } void cmMakefile::AddCustomCommandOldStyle( @@ -1225,7 +1227,7 @@ cmTarget* cmMakefile::AddUtilityCommand( const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { cmTarget* target = this->AddNewUtilityTarget(utilityName, excludeFromAll); @@ -1254,7 +1256,7 @@ cmTarget* cmMakefile::AddUtilityCommand( force, GetCStrOrNull(workingStr), byproducts, depends, commandLines, escapeOldStyle, GetCStrOrNull(commentStr), uses_terminal, - command_expand_lists, job_pool); + command_expand_lists, job_pool, stdPipesUTF8); }); return target; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 9a7eff9..04a1f2d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -188,7 +188,8 @@ public: const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", - const std::string& job_pool = "", bool command_expand_lists = false); + const std::string& job_pool = "", bool command_expand_lists = false, + bool stdPipesUTF8 = false); /** * Called for each file with custom command. @@ -205,7 +206,8 @@ public: const char* workingDir, const CommandSourceCallback& callback = nullptr, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); void AddCustomCommandToOutput( const std::vector<std::string>& outputs, const std::vector<std::string>& byproducts, @@ -216,7 +218,8 @@ public: const char* workingDir, const CommandSourceCallback& callback = nullptr, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); void AddCustomCommandOldStyle(const std::string& target, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, @@ -284,7 +287,8 @@ public: const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false, const std::string& job_pool = ""); + bool command_expand_lists = false, const std::string& job_pool = "", + bool stdPipesUTF8 = false); /** * Add a subdirectory to the build. diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index a5af810..87f4656 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1097,6 +1097,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // of fiddling with the include directories std::vector<std::string> configs; this->GlobalGen->GetQtAutoGenConfigs(configs); + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines; for (auto const& config : configs) { commandLines.push_back(cmMakeCommandLine( @@ -1141,7 +1142,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() const std::vector<std::string> no_deps; cmCustomCommand cc(no_output, autogenProvides, no_deps, commandLines, this->Makefile->GetBacktrace(), autogenComment.c_str(), - this->Dir.Work.c_str()); + this->Dir.Work.c_str(), stdPipesUTF8); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); this->GenTarget->Target->AddPreBuildCommand(std::move(cc)); @@ -1211,7 +1212,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() autogenComment.c_str(), this->Dir.Work.c_str(), /*replace=*/false, /*escapeOldStyle=*/false, /*uses_terminal=*/false, - /*command_expand_lists=*/false, this->AutogenTarget.DepFile); + /*command_expand_lists=*/false, this->AutogenTarget.DepFile, "", + stdPipesUTF8); // Alter variables for the autogen target which now merely wraps the // custom command @@ -1282,6 +1284,7 @@ bool cmQtAutoGenInitializer::InitRccTargets() ccDepends.push_back(qrc.QrcFile); ccDepends.push_back(qrc.InfoFile); + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines; if (this->MultiConfig) { // Build for all configurations @@ -1310,7 +1313,8 @@ bool cmQtAutoGenInitializer::InitRccTargets() cmTarget* autoRccTarget = this->LocalGen->AddUtilityCommand( ccName, true, this->Dir.Work.c_str(), ccOutput, ccDepends, - commandLines, false, ccComment.c_str()); + commandLines, false, ccComment.c_str(), false, false, "", + stdPipesUTF8); // Create autogen generator target this->LocalGen->AddGeneratorTarget( @@ -1350,7 +1354,8 @@ bool cmQtAutoGenInitializer::InitRccTargets() this->LocalGen->AddCustomCommandToOutput( ccOutput, ccByproducts, ccDepends, no_main_dependency, no_implicit_depends, commandLines, ccComment.c_str(), - this->Dir.Work.c_str()); + this->Dir.Work.c_str(), false, true, false, false, "", "", + stdPipesUTF8); } // Reconfigure when .qrc file changes this->Makefile->AddCMakeDependFile(qrc.QrcFile); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ec7fe96..c5ed9f9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1404,6 +1404,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild"); this->WriteSource(*spe2, source); spe2->SetHasElements(); + if (command.GetStdPipesUTF8()) { + this->WriteStdOutEncodingUtf8(*spe2); + } } else { Elem e1(e0, "ItemGroup"); Elem e2(e1, "None"); @@ -4048,6 +4051,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent( std::string script; const char* pre = ""; std::string comment; + bool stdPipesUTF8 = false; for (cmCustomCommand const& cc : commands) { cmCustomCommandGenerator ccg(cc, configName, lg); if (!ccg.HasOnlyEmptyCommandLines()) { @@ -4056,11 +4060,16 @@ void cmVisualStudio10TargetGenerator::WriteEvent( script += pre; pre = "\n"; script += lg->ConstructScript(ccg); + + stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8(); } } comment = cmVS10EscapeComment(comment); if (this->ProjectType != csproj) { Elem e2(e1, name); + if (stdPipesUTF8) { + this->WriteStdOutEncodingUtf8(e2); + } e2.Element("Message", comment); e2.Element("Command", script); } else { @@ -4905,3 +4914,8 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( return path; } + +void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1) +{ + e1.Element("StdOutEncoding", "UTF-8"); +} diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index e588de8..4ac5ec0 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -184,6 +184,8 @@ private: Elem& e2, const std::map<std::string, std::string>& tags); std::string GetCSharpSourceLink(cmSourceFile const* source); + void WriteStdOutEncodingUtf8(Elem& e1); + private: friend class cmVS10GeneratorOptions; using Options = cmVS10GeneratorOptions; |