diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 72a5929571..ac410de1ba 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 '' file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name file {} ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) @@ -73,7 +73,7 @@ set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ -fo -pl -cc++ ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_CREATE_SHARED_LIBRARY - "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' option implib= file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name option implib= file {} ${CMAKE_END_TEMP_FILE}") string(REPLACE " option implib=" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1e65a0210a..8e56d2f599 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 8f30149840..8090b344f2 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,8 @@ 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 +371,8 @@ public: std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target); + cmGeneratorTarget* target, + bool useWatcomQuote); virtual void ComputeObjectFilenames( std::map& mapping, @@ -383,7 +385,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 701d5a0691..fc52cccf3b 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 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 754f62f3f0..7ac025687d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -458,8 +458,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->Target); } - bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); - // Determine whether a link script will be used. bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); @@ -541,6 +539,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Expand the rule variables. std::vector 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 +548,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 +588,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 f940ac4d20..d4723adb37 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& makefile_depends) + std::vector& 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 ff946605d4..9fac5746f4 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& makefile_depends); + std::vector& 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 1d0336a265..c86561728c 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 2cf636c3d3..71ea3f51f9 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -600,7 +600,7 @@ bool cmake::FindPackage(const std::vector& 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() );