FIX: stupid pb fixed (close to being medieval'ed by The Ken)
[cmake.git] / Source / cmNMakeMakefileGenerator.cxx
blobef4b9a31ac8f7ffdc0dda3cdde7304df619597ae
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmNMakeMakefileGenerator.cxx,v $
5 Language: C++
6 Date: $Date: 2002-07-31 17:45:07 $
7 Version: $Revision: 1.55 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmNMakeMakefileGenerator.h"
18 #include "cmMakefile.h"
19 #include "cmStandardIncludes.h"
20 #include "cmSystemTools.h"
21 #include "cmSourceFile.h"
22 #include "cmMakeDepend.h"
23 #include "cmCacheManager.h"
24 #include "cmGeneratedFileStream.h"
25 #include "windows.h"
28 cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
30 this->SetLibraryPathOption("@CMAKE_C_LIBPATH_FLAG@"); // Use @ here
31 this->SetObjectFileExtension("$(CMAKE_OBJECT_FILE_SUFFIX)");
32 this->SetExecutableExtension("$(CMAKE_EXECUTABLE_SUFFIX)");
33 this->SetLibraryPrefix("");
34 this->SetStaticLibraryExtension("$(CMAKE_STATICLIB_SUFFIX)");
35 this->SetSharedLibraryExtension("$(CMAKE_SHLIB_SUFFIX)");
38 cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator()
42 // convert to windows short paths if there are spaces
43 // in path
44 std::string cmNMakeMakefileGenerator::ShortPath(const char* path)
46 std::string ret = path;
47 // if there are no spaces in path, then just
48 // call ConvertToOutputPath
49 if(ret.find(' ') == std::string::npos)
51 return this->ConvertToOutputPath(path);
54 // if there are spaces then call GetShortPathName to get rid of them
55 if(!cmSystemTools::GetShortPath(path, ret))
57 // if GetShortPathName failed for some reason use
58 // ConvertToOutputPath instead which will at least escape the spaces
59 ret = this->ConvertToOutputPath(path);
60 return ret;
62 ret = this->ConvertToOutputPath(ret.c_str());
63 return ret;
67 // convert a command to a short path if it has spaces
68 // this separates the arguments from the command and puts
69 // them back together
70 std::string cmNMakeMakefileGenerator::ShortPathCommand(const char* command)
72 if (!command)
74 return "";
76 if(!strchr(command, ' '))
78 return command;
80 cmRegularExpression reg("^\"([^\"]*)\"(.*)");
81 if(reg.find(command))
83 std::string c = reg.match(1);
84 cmRegularExpression removeIntDir("(.*)(/|\\\\)\\$\\(IntDir\\)(.*)");
85 if(removeIntDir.find(c))
87 c = removeIntDir.match(1) + removeIntDir.match(3);
89 std::string unixPath = c;
90 // since the command may already be a windows path, convert it
91 // to unix so we can use SplitProgramPath on it.
92 cmSystemTools::ConvertToUnixSlashes(unixPath);
93 std::string path, file;
94 cmSystemTools::SplitProgramPath(unixPath.c_str(), path, file);
95 // do a short path on the directory, because ShortPath will
96 // not work for files that do not exist
97 path = this->ShortPath(path.c_str());
98 // now put the two back together
99 path += "\\";
100 path += file;
101 std::string ret = path;
102 std::string args = reg.match(2);
103 ret += args;
104 return ret;
106 return command;
110 void cmNMakeMakefileGenerator::EnableLanguage(const char*)
112 // now load the settings
113 if(!m_Makefile->GetDefinition("CMAKE_ROOT"))
115 cmSystemTools::Error(
116 "CMAKE_ROOT has not been defined, bad GUI or driver program");
117 return;
119 if(!this->GetLanguageEnabled("CXX"))
121 std::string fpath =
122 m_Makefile->GetDefinition("CMAKE_ROOT");
123 fpath += "/Templates/CMakeNMakeWindowsSystemConfig.cmake";
124 m_Makefile->ReadListFile(NULL,fpath.c_str());
125 this->SetLanguageEnabled("CXX");
131 void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
133 fout << "# NMake Makefile generated by cmake\n";
134 const char* variables =
135 "# general variables used in the makefile\n"
136 "\n"
137 "# Path to cmake\n"
138 "MAKESILENT = /nologo\n"
139 "CMAKE_STANDARD_WINDOWS_LIBRARIES = @CMAKE_STANDARD_WINDOWS_LIBRARIES@\n"
140 "CMAKE_C_FLAGS = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\n"
141 "CMAKE_C_LINK_EXECUTABLE_FLAG = @CMAKE_C_LINK_EXECUTABLE_FLAG@\n"
142 "CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"
143 "CMAKE_LINKER_FLAGS = @CMAKE_LINKER_FLAGS@ @LINKER_BUILD_FLAGS@\n"
144 "CMAKE_LINKER_SHARED_LIBRARY_FLAG = @CMAKE_LINKER_SHARED_LIBRARY_FLAG@\n"
145 "CMAKE_LIBRARY_MANAGER_FLAGS = @CMAKE_LIBRARY_MANAGER_FLAGS@\n"
146 "CMAKE_OBJECT_FILE_SUFFIX = @CMAKE_OBJECT_FILE_SUFFIX@\n"
147 "CMAKE_EXECUTABLE_SUFFIX = @CMAKE_EXECUTABLE_SUFFIX@\n"
148 "CMAKE_STATICLIB_SUFFIX = @CMAKE_STATICLIB_SUFFIX@\n"
149 "CMAKE_SHLIB_SUFFIX = @CMAKE_SHLIB_SUFFIX@\n"
150 "!IF \"$(OS)\" == \"Windows_NT\"\n"
151 "NULL=\n"
152 "!ELSE \n"
153 "NULL=nul\n"
154 "!ENDIF \n";
156 std::string buildType = "CMAKE_CXX_FLAGS_";
157 buildType += m_Makefile->GetDefinition("CMAKE_BUILD_TYPE");
158 buildType = cmSystemTools::UpperCase(buildType);
159 m_Makefile->AddDefinition("BUILD_FLAGS",
160 m_Makefile->GetDefinition(
161 buildType.c_str()));
163 buildType = "CMAKE_LINKER_FLAGS_";
164 buildType += m_Makefile->GetDefinition("CMAKE_BUILD_TYPE");
165 buildType = cmSystemTools::UpperCase(buildType);
166 m_Makefile->AddDefinition("LINKER_BUILD_FLAGS",
167 m_Makefile->GetDefinition(
168 buildType.c_str()));
170 std::string replaceVars = variables;
171 m_Makefile->ExpandVariablesInString(replaceVars);
172 fout << replaceVars.c_str();
173 std::string ccompiler = m_Makefile->GetDefinition("CMAKE_C_COMPILER");
174 fout << "CMAKE_C_COMPILER = "
175 << this->ShortPath(ccompiler.c_str()) << "\n";
177 std::string cxxcompiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER");
178 fout << "CMAKE_CXX_COMPILER = "
179 << this->ShortPath(cxxcompiler.c_str()) << "\n";
181 std::string linker = m_Makefile->GetDefinition("CMAKE_LINKER");
182 fout << "CMAKE_LINKER = " <<
183 this->ShortPath(linker.c_str()) << "\n";
185 std::string lib_manager = m_Makefile->GetDefinition("CMAKE_LIBRARY_MANAGER");
186 fout << "CMAKE_LIBRARY_MANAGER = "
187 << this->ShortPath(lib_manager.c_str()) << "\n";
189 std::string cmakecommand = m_Makefile->GetDefinition("CMAKE_COMMAND");
190 fout << "CMAKE_COMMAND = "
191 << this->ShortPath(cmakecommand.c_str()) << "\n";
192 fout << "RM = " << this->ShortPath(cmakecommand.c_str()) << " -E remove -f\n";
194 if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
196 fout << "CMAKE_EDIT_COMMAND = "
197 << this->ShortPath(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
198 << "\n";
201 fout << "CMAKE_CURRENT_SOURCE = "
202 << this->ShortPath(m_Makefile->GetStartDirectory() )
203 << "\n";
204 fout << "CMAKE_CURRENT_BINARY = "
205 << this->ShortPath(m_Makefile->GetStartOutputDirectory())
206 << "\n";
207 fout << "CMAKE_SOURCE_DIR = "
208 << this->ShortPath(m_Makefile->GetHomeDirectory()) << "\n";
209 fout << "CMAKE_BINARY_DIR = "
210 << this->ShortPath(m_Makefile->GetHomeOutputDirectory() )
211 << "\n";
213 // Output Include paths
214 fout << "INCLUDE_FLAGS = ";
215 std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
216 std::vector<std::string>::iterator i;
217 fout << "-I" <<
218 this->ConvertToOutputPath(m_Makefile->GetStartDirectory()) << " ";
219 for(i = includes.begin(); i != includes.end(); ++i)
221 std::string include = *i;
222 // Don't output a -I for the standard include path "/usr/include".
223 // This can cause problems with certain standard library
224 // implementations because the wrong headers may be found first.
225 fout << "-I" << this->ConvertToOutputPath(i->c_str()).c_str() << " ";
228 fout << m_Makefile->GetDefineFlags();
229 fout << "\n\n";
233 void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
234 const char* directory,
235 const char* target1,
236 const char* target2,
237 bool silent)
239 if(target1)
241 std::string dir = this->ConvertToOutputPath(directory);
242 fout << "\tif not exist \"" << dir << "\\$(NULL)\""
243 << " "
244 << "$(MAKE) $(MAKESILENT) rebuild_cache\n";
245 if (!silent)
247 fout << "\techo " << directory << ": building " << target1 << "\n";
249 fout << "\tcd " << dir << "\n"
250 << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) " << target1 << "\n";
252 if(target2)
254 if (!silent)
256 fout << "\techo " << directory << ": building " << target2 << "\n";
258 fout << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) " << target2 << "\n";
260 std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
261 fout << "\tcd " << this->ConvertToOutputPath(currentDir.c_str()) << "\n\n";
267 // This needs to be overriden because nmake requires commands to be quoted
268 // if the are full paths to the executable????
270 void cmNMakeMakefileGenerator::OutputMakeRule(std::ostream& fout,
271 const char* comment,
272 const char* target,
273 const char* depends,
274 const char* command,
275 const char* command2,
276 const char* command3,
277 const char* command4)
279 std::string short_command;
280 if (command)
282 short_command = ShortPathCommand(command);
283 command = short_command.c_str();
286 std::string short_command2;
287 if (command2)
289 short_command2 = ShortPathCommand(command2);
290 command2 = short_command2.c_str();
293 std::string short_command3;
294 if (command3)
296 short_command3 = ShortPathCommand(command3);
297 command3 = short_command3.c_str();
300 std::string short_command4;
301 if (command4)
303 short_command4 = ShortPathCommand(command4);
304 command4 = short_command4.c_str();
307 cmUnixMakefileGenerator::OutputMakeRule(fout,
308 comment,
309 target,
310 depends,
311 command,
312 command2,
313 command3,
314 command4);
315 return;
318 void
319 cmNMakeMakefileGenerator::
320 OutputBuildObjectFromSource(std::ostream& fout,
321 const char* shortName,
322 const cmSourceFile& source,
323 const char* extraCompileFlags,
324 bool shared)
326 // Header files shouldn't have build rules.
327 if(source.IsAHeaderFileOnly())
328 return;
330 std::string comment = "Build ";
331 std::string objectFile = std::string(shortName) +
332 this->GetOutputExtension(source.GetSourceExtension().c_str());
334 comment += objectFile + " From ";
335 comment += source.GetFullPath();
336 std::string compileCommand;
337 std::string ext = source.GetSourceExtension();
338 if(ext == "c" )
340 compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_C_FLAGS) ";
341 compileCommand += extraCompileFlags;
342 if(shared)
344 compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
346 compileCommand += "$(INCLUDE_FLAGS) -c ";
347 compileCommand +=
348 this->ConvertToOutputPath(source.GetFullPath().c_str());
350 // Need to get the definition here because this value might have
351 // trailing space (since it is directly prepended to the filename)
352 std::string output_object_file_flag =
353 m_Makefile->GetDefinition("CMAKE_C_OUTPUT_OBJECT_FILE_FLAG");
354 m_Makefile->ExpandVariablesInString(output_object_file_flag);
356 compileCommand += " " + output_object_file_flag;
357 compileCommand += objectFile;
359 else if (ext == "rc")
361 compileCommand = "$(RC) /fo\"";
362 compileCommand += objectFile;
363 compileCommand += "\" ";
364 compileCommand +=
365 this->ConvertToOutputPath(source.GetFullPath().c_str());
367 else if (ext == "def")
369 // no rule to output for this one
370 return;
372 // assume c++ if not c rc or def
373 else
376 compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) ";
377 compileCommand += extraCompileFlags;
378 if(shared)
380 compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
382 compileCommand += "$(INCLUDE_FLAGS) -c ";
383 compileCommand +=
384 this->ConvertToOutputPath(source.GetFullPath().c_str());
386 // Need to get the definition here because this value might have
387 // trailing space (since it is directly prepended to the filename)
388 std::string output_object_file_flag =
389 m_Makefile->GetDefinition("CMAKE_C_OUTPUT_OBJECT_FILE_FLAG");
390 m_Makefile->ExpandVariablesInString(output_object_file_flag);
392 compileCommand += " " + output_object_file_flag;
393 compileCommand += objectFile;
396 this->OutputMakeRule(fout,
397 comment.c_str(),
398 objectFile.c_str(),
399 this->ConvertToOutputPath(
400 source.GetFullPath().c_str()).c_str(),
401 compileCommand.c_str());
404 void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
405 const char* name,
406 const cmTarget &t)
408 std::string target = m_LibraryOutputPath + name + m_SharedLibraryExtension;
409 std::string depend = "$(";
410 depend += this->CreateMakeVariable(name, "_SRC_OBJS");
411 depend += ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
413 // Need to get the definition here because this value might have
414 // trailing space (since it is directly prepended to the filename)
415 std::string linker_output_file_flag =
416 m_Makefile->GetDefinition("CMAKE_LINKER_OUTPUT_FILE_FLAG");
417 m_Makefile->ExpandVariablesInString(linker_output_file_flag);
419 std::string command = "$(CMAKE_LINKER) $(CMAKE_LINKER_SHARED_LIBRARY_FLAG)";
421 bool hide_param = m_Makefile->IsOn("CMAKE_LINKER_HIDE_PARAMETERS");
422 if (hide_param)
424 command += " @<<\n\t";
427 command += " $(CMAKE_LINKER_FLAGS) " + linker_output_file_flag;
429 std::string dllpath = m_LibraryOutputPath + std::string(name) + m_SharedLibraryExtension;
430 command += this->ConvertToOutputPath(dllpath.c_str());
432 command += " $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
434 cmStringStream linklibs;
435 this->OutputLinkLibraries(linklibs, name, t);
436 command += linklibs.str();
438 const std::vector<cmSourceFile*>& sources = t.GetSourceFiles();
439 for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
440 i != sources.end(); ++i)
442 if((*i)->GetSourceExtension() == "def")
444 command += "/DEF:";
445 command += (*i)->GetFullPath();
449 command += "\n";
450 if (hide_param)
452 command += "<<\n";
455 std::string customCommands = this->CreateTargetRules(t, name);
456 const char* cc = 0;
457 if(customCommands.size() > 0)
459 cc = customCommands.c_str();
461 this->OutputMakeRule(fout, "rules for a shared library",
462 target.c_str(),
463 depend.c_str(),
464 command.c_str(), cc);
467 void cmNMakeMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
468 const char* name,
469 const cmTarget &target)
471 this->OutputSharedLibraryRule(fout, name, target);
474 void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
475 const char* name,
476 const cmTarget &t)
478 std::string target = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
479 std::string depend = "$(";
480 depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
482 // Need to get the definition here because this value might have
483 // trailing space (since it is directly prepended to the filename)
484 std::string library_manager_output_file_flag =
485 m_Makefile->GetDefinition("CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG");
486 m_Makefile->ExpandVariablesInString(library_manager_output_file_flag);
488 std::string command = "$(CMAKE_LIBRARY_MANAGER) $(CMAKE_LIBRARY_MANAGER_FLAGS) @<<\n\t " + library_manager_output_file_flag;
490 std::string libpath = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
491 command += this->ConvertToOutputPath(libpath.c_str());
493 command += " $(";
494 command += this->CreateMakeVariable(name, "_SRC_OBJS") + ")";
495 command += "\n<<\n";
497 std::string comment = "rule to build static library: ";
498 comment += name;
500 std::string customCommands = this->CreateTargetRules(t, name);
501 const char* cc = 0;
502 if(customCommands.size() > 0)
504 cc = customCommands.c_str();
506 this->OutputMakeRule(fout,
507 comment.c_str(),
508 target.c_str(),
509 depend.c_str(),
510 command.c_str(), cc);
513 void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
514 const char* name,
515 const cmTarget &t)
517 std::string target = m_ExecutableOutputPath + name;
518 target += m_ExecutableExtension;
519 std::string depend = "$(";
520 depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" +
521 this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
522 std::string command =
523 "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) ";
524 command += "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
525 std::string path = m_ExecutableOutputPath + name + m_ExecutableExtension;
527 // Need to get the definition here because this value might have
528 // trailing space (since it is directly prepended to the filename)
529 std::string output_executable_file_flag =
530 m_Makefile->GetDefinition("CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG");
531 m_Makefile->ExpandVariablesInString(output_executable_file_flag);
533 command += " " + output_executable_file_flag +
534 this->ConvertToOutputPath(path.c_str());
536 command += " $(CMAKE_C_LINK_EXECUTABLE_FLAG) $(CMAKE_LINKER_FLAGS) ";
537 if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
539 command += " /subsystem:windows ";
542 cmStringStream linklibs;
543 this->OutputLinkLibraries(linklibs, 0, t);
544 command += linklibs.str();
546 std::string comment = "rule to build executable: ";
547 comment += name;
549 std::string customCommands = this->CreateTargetRules(t, name);
550 const char* cc = 0;
551 if(customCommands.size() > 0)
553 cc = customCommands.c_str();
555 this->OutputMakeRule(fout,
556 comment.c_str(),
557 target.c_str(),
558 depend.c_str(),
559 command.c_str(), cc);
563 void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
564 const char* targetLibrary,
565 const cmTarget &tgt)
567 // Try to emit each search path once
568 std::set<std::string> emitted;
570 // Embed runtime search paths if possible and if required.
571 // collect all the flags needed for linking libraries
572 // Do not try if there is no library path option (it is set to -L or
573 // -LIBPATH for some linker, but some others do not even support link
574 // search path).
575 std::string linkLibs;
577 // Expand content because this value might have
578 // trailing space (since it is directly prepended to the filename)
579 std::string lib_path_opt = m_LibraryPathOption;
580 m_Makefile->ExpandVariablesInString(lib_path_opt);
582 if (lib_path_opt.size())
584 const std::vector<std::string>& libdirs = tgt.GetLinkDirectories();
585 for(std::vector<std::string>::const_iterator libDir = libdirs.begin();
586 libDir != libdirs.end(); ++libDir)
588 std::string libpath = ShortPath(libDir->c_str());
589 if(emitted.insert(libpath).second)
591 linkLibs += lib_path_opt;
592 this->ConvertToOutputPath(libpath.c_str());
593 linkLibs += libpath;
594 linkLibs += " ";
599 std::string librariesLinked;
600 const cmTarget::LinkLibraries& libs = tgt.GetLinkLibraries();
601 for(cmTarget::LinkLibraries::const_iterator lib = libs.begin();
602 lib != libs.end(); ++lib)
604 // Don't link the library against itself!
605 if(targetLibrary && (lib->first == targetLibrary)) continue;
607 // ** should fix this later, it should check to see if this is
608 // a debug build and add the library
609 // don't look at debug libraries
610 // if (lib->second == cmTarget::DEBUG) continue;
611 // skip zero size library entries, this may happen
612 // if a variable expands to nothing.
613 if (lib->first.size() == 0) continue;
614 if(emitted.insert(lib->first).second)
616 std::string regexp = ".*\\";
617 regexp += m_Makefile->GetDefinition("CMAKE_STATICLIB_SUFFIX");
618 regexp += "$";
619 cmRegularExpression reg(regexp.c_str());
620 // if it ends in .lib, then it is a full path and should
621 // be escaped, and does not need .lib added
622 if(reg.find(lib->first))
624 librariesLinked += ShortPath(lib->first.c_str());
625 librariesLinked += " ";
627 else
629 librariesLinked += m_LibraryLinkOption;
630 librariesLinked += lib->first;
631 librariesLinked += m_StaticLibraryExtension + " ";
635 linkLibs += librariesLinked;
636 fout << linkLibs;
637 fout << "$(CMAKE_STANDARD_WINDOWS_LIBRARIES) ";
641 std::string cmNMakeMakefileGenerator::GetOutputExtension(const char* s)
643 std::string sourceExtension = s;
644 if(sourceExtension == "def")
646 return "";
648 if(sourceExtension == "ico" || sourceExtension == "rc2")
650 return "";
652 if(sourceExtension == "rc")
654 return ".res";
656 return m_ObjectFileExtension;
660 void cmNMakeMakefileGenerator::OutputIncludeMakefile(std::ostream& fout,
661 const char* file)
663 fout << "!include " << file << "\n";
666 bool cmNMakeMakefileGenerator::SamePath(const char* path1, const char* path2)
668 // first check to see if they are the same anyway
669 if (strcmp(path1, path2) == 0)
671 return true;
673 // next short path and lower case both of them for the compare
674 return
675 cmSystemTools::LowerCase(ShortPath(path1)) ==
676 cmSystemTools::LowerCase(ShortPath(path2));
679 void cmNMakeMakefileGenerator::OutputBuildTargetInDir(std::ostream& fout,
680 const char* path,
681 const char* library,
682 const char* fullpath,
683 const char* libOutPath)
685 const char* makeTarget = library;
686 std::string currentDir =
687 this->ConvertToOutputPath(m_Makefile->GetCurrentOutputDirectory());
688 std::string wpath = this->ConvertToOutputPath(path);
689 std::string wfullpath = this->ConvertToOutputPath(fullpath);
690 if(libOutPath && strcmp( libOutPath, "" ) != 0)
692 makeTarget = wfullpath.c_str();
694 fout << wfullpath
695 << ":\n\tcd " << wpath << "\n"
696 << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends\n"
697 << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends\n"
698 << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends\n"
699 << "\t$(MAKE) $(MAKESILENT) " << makeTarget
700 << "\n\tcd " << currentDir << "\n";
704 std::string cmNMakeMakefileGenerator::ConvertToOutputPath(const char* s)
706 return cmSystemTools::ConvertToOutputPath(s);
710 std::string cmNMakeMakefileGenerator::CreateMakeVariable(const char* s, const char* s2)
712 std::string ret= std::string(s) + std::string(s2);
713 cmSystemTools::ReplaceString(ret, "-", "_");
714 return ret;
717 std::string cmNMakeMakefileGenerator::LowerCasePath(const char* path)
719 return cmSystemTools::LowerCase(path);