Hi,

I enclosed patch to support correct quoting for Watcom linker.
Single quote quoting is necessary also for target name, library names and 
libraries search path.
This patch fix it.

Regards

Jiri
>From 5bde9fa6aefe7560a07b188e522ef5305a8a6b20 Mon Sep 17 00:00:00 2001
From: Jiri Malak <malak.j...@gmail.com>
Date: Fri, 4 Apr 2014 23:06:13 +0200
Subject: [PATCH] Use single quote for all file/path items in Watcom linker
 command

Watcom Linker use single quote if necessary for quoting target name, libraries 
names and libraries search path.
Object names were already fixed.
---
 Modules/Platform/Windows-wcl386.cmake          |  4 +--
 Source/cmLocalGenerator.cxx                    | 34 ++++++++++++++++----------
 Source/cmLocalGenerator.h                      | 10 +++++---
 Source/cmMakefileExecutableTargetGenerator.cxx | 13 +++++++---
 Source/cmMakefileLibraryTargetGenerator.cxx    | 12 +++++++--
 Source/cmMakefileTargetGenerator.cxx           |  6 +++--
 Source/cmMakefileTargetGenerator.h             |  3 ++-
 Source/cmNinjaNormalTargetGenerator.cxx        |  8 +++++-
 Source/cmake.cxx                               |  2 +-
 9 files changed, 63 insertions(+), 29 deletions(-)

diff --git a/Modules/Platform/Windows-wcl386.cmake 
b/Modules/Platform/Windows-wcl386.cmake
index 72a5929..ac410de 100644
--- a/Modules/Platform/Windows-wcl386.cmake
+++ b/Modules/Platform/Windows-wcl386.cmake
@@ -51,7 +51,7 @@ set(CMAKE_C_CREATE_IMPORT_LIBRARY
 set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
 
 set(CMAKE_C_LINK_EXECUTABLE
-    "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name 
'<TARGET_UNQUOTED>' <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> 
${CMAKE_END_TEMP_FILE}")
+    "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> 
<LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
 
 
 set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE})
@@ -73,7 +73,7 @@ set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
     "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> 
-d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ 
<SOURCE>${CMAKE_END_TEMP_FILE}")
 
 set(CMAKE_CXX_CREATE_SHARED_LIBRARY
- "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' 
<LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> 
${CMAKE_END_TEMP_FILE}")
+ "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> 
<LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> 
${CMAKE_END_TEMP_FILE}")
 string(REPLACE " option implib=<TARGET_IMPLIB>" ""
   CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
 
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1e65a02..feb839f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -689,6 +689,7 @@ void cmLocalGenerator::AddBuildTargetRule(const 
std::string& llang,
   std::string createRule = "CMAKE_";
   createRule += llang;
   createRule += target.GetCreateRuleVariable();
+  bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
   std::string targetName = target.Target->GetFullName();
   // Executable :
   // Shared Library:
@@ -700,7 +701,7 @@ void cmLocalGenerator::AddBuildTargetRule(const 
std::string& llang,
   std::string flags; // should be set
   std::string linkFlags; // should be set
   this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
-                       &target);
+                       &target, useWatcomQuote);
   linkLibs = frameworkPath + linkPath + linkLibs;
   cmLocalGenerator::RuleVariables vars;
   vars.Language = llang.c_str();
@@ -1611,7 +1612,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& 
linkLibs,
                                  std::string& linkFlags,
                                  std::string& frameworkPath,
                                  std::string& linkPath,
-                                 cmGeneratorTarget* target)
+                                 cmGeneratorTarget* target,
+                                 bool useWatcomQuote)
 {
   std::string buildType =
     this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
@@ -1675,7 +1677,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& 
linkLibs,
           }
         }
       this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *target, false, false);
+                                *target, false, false, useWatcomQuote);
       }
       break;
     case cmTarget::EXECUTABLE:
@@ -1700,7 +1702,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& 
linkLibs,
         }
       this->AddLanguageFlags(flags, linkLanguage, buildType);
       this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *target, false, false);
+                                *target, false, false, useWatcomQuote);
       if(cmSystemTools::IsOn
          (this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
         {
@@ -1759,9 +1761,8 @@ std::string 
cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
                                                      OutputFormat format)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  // Work-ardound command line parsing limitations in MSVC 6.0 and
-  // Watcom.
-  if(this->Makefile->IsOn("MSVC60") || this->Makefile->IsOn("WATCOM"))
+  // Work-ardound command line parsing limitations in MSVC 6.0
+  if(this->Makefile->IsOn("MSVC60"))
     {
     // Search for the last space.
     std::string::size_type pos = lib.rfind(' ');
@@ -1798,9 +1799,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& 
linkLibraries,
                                            std::string& linkPath,
                                            cmGeneratorTarget &tgt,
                                            bool relink,
-                                           bool forResponseFile)
+                                           bool forResponseFile,
+                                           bool useWatcomQuote)
 {
-  OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
+  OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
+                             ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
   bool escapeAllowMakeVars = !forResponseFile;
   cmOStringStream fout;
   const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
@@ -2594,7 +2597,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const 
std::string& source,
     {
     result = cmSystemTools::ConvertToOutputPath(result.c_str());
     }
-  else if( output == SHELL)
+  else if(output == SHELL || output == WATCOMQUOTE)
     {
         // For the MSYS shell convert drive letters to posix paths, so
     // that c:/some/path becomes /c/some/path.  This is needed to
@@ -2616,11 +2619,11 @@ std::string 
cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
         pos++;
         }
       }
-    result = this->EscapeForShell(result, true, false);
+    result = this->EscapeForShell(result, true, false, (output == 
WATCOMQUOTE));
     }
   else if(output == RESPONSE)
     {
-    result = this->EscapeForShell(result, false, false);
+    result = this->EscapeForShell(result, false, false, false);
     }
   return result;
 }
@@ -3247,7 +3250,8 @@ static bool cmLocalGeneratorIsShellOperator(const 
std::string& str)
 //----------------------------------------------------------------------------
 std::string cmLocalGenerator::EscapeForShell(const std::string& str,
                                              bool makeVars,
-                                             bool forEcho)
+                                             bool forEcho,
+                                             bool useWatcomQuote)
 {
   // Do not escape shell operators.
   if(cmLocalGeneratorIsShellOperator(str))
@@ -3273,6 +3277,10 @@ std::string cmLocalGenerator::EscapeForShell(const 
std::string& str,
     {
     flags |= cmsysSystem_Shell_Flag_EchoWindows;
     }
+  if(useWatcomQuote)
+    {
+    flags |= cmsysSystem_Shell_Flag_WatcomQuote;
+    }
   if(this->WatcomWMake)
     {
     flags |= cmsysSystem_Shell_Flag_WatcomWMake;
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 8f30149..8c2c56b 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -106,7 +106,7 @@ public:
    * path setting
    */
   enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT };
-  enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, RESPONSE };
+  enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, WATCOMQUOTE, RESPONSE };
   std::string ConvertToOutputFormat(const std::string& source,
                                     OutputFormat output);
   std::string Convert(const std::string& remote, RelativeRoot local,
@@ -288,7 +288,7 @@ public:
       escapes for the special case of passing to the native echo
       command.  */
   std::string EscapeForShell(const std::string& str, bool makeVars = false,
-                             bool forEcho = false);
+                             bool forEcho = false, bool useWatcomQuote = 
false);
 
   /** Backwards-compatibility version of EscapeForShell.  */
   std::string EscapeForShellOldStyle(const std::string& str);
@@ -370,7 +370,8 @@ public:
                       std::string& linkFlags,
                       std::string& frameworkPath,
                       std::string& linkPath,
-                      cmGeneratorTarget* target);
+                      cmGeneratorTarget* target,
+                      bool useWatcomQuote);
 
   virtual void ComputeObjectFilenames(
                         std::map<cmSourceFile const*, std::string>& mapping,
@@ -383,7 +384,8 @@ protected:
                                    std::string& linkPath,
                                    cmGeneratorTarget &,
                                    bool relink,
-                                   bool forResponseFile);
+                                   bool forResponseFile,
+                                   bool useWatcomQuote);
 
   // Expand rule variables in CMake of the type found in language rules
   void ExpandRuleVariables(std::string& string,
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx 
b/Source/cmMakefileExecutableTargetGenerator.cxx
index 701d5a0..fc52ccc 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -290,7 +290,6 @@ void 
cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   linkRuleVar += linkLanguage;
   linkRuleVar += "_LINK_EXECUTABLE";
   std::string linkRule = this->GetLinkRule(linkRuleVar);
-  bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
   std::vector<std::string> commands1;
   cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
   if(this->Target->IsExecutableWithExports())
@@ -333,12 +332,15 @@ void 
cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
 
   // Expand the rule variables.
   {
+  bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
+
   // Set path conversion for link script shells.
   this->LocalGenerator->SetLinkScriptShell(useLinkScript);
 
   // Collect up flags to link in needed libraries.
   std::string linkLibs;
-  this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends);
+  this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
+                       useWatcomQuote);
 
   // Construct object file lists that may be needed to expand the
   // rule.
@@ -357,7 +359,12 @@ void 
cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
   vars.ObjectDir = objectDir.c_str();
-  vars.Target = targetOutPathReal.c_str();
+  cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
+    cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
+  std::string target = this->Convert(targetFullPathReal,
+                                     cmLocalGenerator::START_OUTPUT,
+                                     output);
+  vars.Target = target.c_str();
   vars.TargetPDB = targetOutPathPDB.c_str();
 
   // Setup the target version.
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx 
b/Source/cmMakefileLibraryTargetGenerator.cxx
index 754f62f..71c6b07 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -541,6 +541,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   // Expand the rule variables.
   std::vector<std::string> real_link_commands;
   {
+  bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
+
   // Set path conversion for link script shells.
   this->LocalGenerator->SetLinkScriptShell(useLinkScript);
 
@@ -548,7 +550,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::string linkLibs;
   if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
     {
-    this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends);
+    this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
+                         useWatcomQuote);
     }
 
   // Construct object file lists that may be needed to expand the
@@ -587,7 +590,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
   vars.ObjectDir = objectDir.c_str();
-  vars.Target = targetOutPathReal.c_str();
+  cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
+    cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
+  std::string target = this->Convert(targetFullPathReal,
+                                     cmLocalGenerator::START_OUTPUT,
+                                     output);
+  vars.Target = target.c_str();
   vars.LinkLibraries = linkLibs.c_str();
   vars.ObjectsQuoted = buildObjs.c_str();
   if (this->Target->HasSOName(this->ConfigName))
diff --git a/Source/cmMakefileTargetGenerator.cxx 
b/Source/cmMakefileTargetGenerator.cxx
index f940ac4..d4723ad 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1826,14 +1826,16 @@ void
 cmMakefileTargetGenerator
 ::CreateLinkLibs(std::string& linkLibs, bool relink,
                  bool useResponseFile,
-                 std::vector<std::string>& makefile_depends)
+                 std::vector<std::string>& makefile_depends,
+                 bool useWatcomQuote)
 {
   std::string frameworkPath;
   std::string linkPath;
   this->LocalGenerator
     ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
                           *this->GeneratorTarget, relink,
-                          useResponseFile);
+                          useResponseFile,
+                          useWatcomQuote);
   linkLibs = frameworkPath + linkPath + linkLibs;
 
   if(useResponseFile)
diff --git a/Source/cmMakefileTargetGenerator.h 
b/Source/cmMakefileTargetGenerator.h
index ff94660..9fac574 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -168,7 +168,8 @@ protected:
   /** Create list of flags for link libraries. */
   void CreateLinkLibs(std::string& linkLibs, bool relink,
                       bool useResponseFile,
-                      std::vector<std::string>& makefile_depends);
+                      std::vector<std::string>& makefile_depends,
+                      bool useWatcomQuote);
 
   /** Create lists of object files for linking and cleaning.  */
   void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx 
b/Source/cmNinjaNormalTargetGenerator.cxx
index 1d0336a..c865617 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -439,12 +439,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   std::string frameworkPath;
   std::string linkPath;
   cmGeneratorTarget* gtarget = this->GetGeneratorTarget();
+
+  std::string createRule = "CMAKE_";
+  createRule += this->TargetLinkLanguage;
+  createRule += gtarget->GetCreateRuleVariable();
+  bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
   this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
                                             vars["FLAGS"],
                                             vars["LINK_FLAGS"],
                                             frameworkPath,
                                             linkPath,
-                                            gtarget);
+                                            gtarget,
+                                            useWatcomQuote);
 
   this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars);
 
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 2cf636c..71ea3f5 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -600,7 +600,7 @@ bool cmake::FindPackage(const std::vector<std::string>& 
args)
     gg->CreateGeneratorTargets(mf);
     cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
     lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
-                       gtgt);
+                       gtgt, false);
     linkLibs = frameworkPath + linkPath + linkLibs;
 
     printf("%s\n", linkLibs.c_str() );
-- 
1.8.1.msysgit.1
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to