summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-11-13 23:23:45 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-11-13 23:23:45 (GMT)
commitdc839f80f01dd547e1685a252f218aac0f0e769b (patch)
tree0ffdeece08e5a109acc6dfe9e6421960fb6e31c9 /Source
parent6220a187ba1e500442ce05efc16a3c0f016ed5cd (diff)
downloadCMake-dc839f80f01dd547e1685a252f218aac0f0e769b.zip
CMake-dc839f80f01dd547e1685a252f218aac0f0e769b.tar.gz
CMake-dc839f80f01dd547e1685a252f218aac0f0e769b.tar.bz2
start work on nmake generator
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLib.dsp4
-rw-r--r--Source/CMakeLists.txt1
-rw-r--r--Source/cmNMakeMakefileGenerator.cxx117
-rw-r--r--Source/cmNMakeMakefileGenerator.h77
-rw-r--r--Source/cmUnixMakefileGenerator.cxx47
-rw-r--r--Source/cmUnixMakefileGenerator.h5
6 files changed, 239 insertions, 12 deletions
diff --git a/Source/CMakeLib.dsp b/Source/CMakeLib.dsp
index 215ccf9..f2e63cc 100644
--- a/Source/CMakeLib.dsp
+++ b/Source/CMakeLib.dsp
@@ -91,6 +91,10 @@ SOURCE=.\cmake.cxx
# End Source File
# Begin Source File
+SOURCE=.\cmNMakeMakefileGenerator.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\cmBorlandMakefileGenerator.cpp
# End Source File
# Begin Source File
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 92c7119..ad340db 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -38,6 +38,7 @@ ADD_DEFINITIONS(-DCMAKE_BUILD_WITH_CMAKE)
IF (WIN32)
SOURCE_FILES(SRCS cmDSWWriter.cxx cmDSPWriter.cxx cmMSProjectGenerator.cxx)
SOURCE_FILES(SRCS cmBorlandMakefileGenerator.cpp)
+ SOURCE_FILES(SRCS cmNMakeMakefileGenerator.cxx)
IF(NOT UNIX)
IF( CMAKE_CXX_COMPILER MATCHES Borland )
ELSE (CMAKE_CXX_COMPILER MATCHES Borland )
diff --git a/Source/cmNMakeMakefileGenerator.cxx b/Source/cmNMakeMakefileGenerator.cxx
new file mode 100644
index 0000000..8a25dde
--- /dev/null
+++ b/Source/cmNMakeMakefileGenerator.cxx
@@ -0,0 +1,117 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+Copyright (c) 2001 Insight Consortium
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * The name of the Insight Consortium, nor the names of any consortium members,
+ nor of any contributors, may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ * Modified source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+#include "cmNMakeMakefileGenerator.h"
+#include "cmMakefile.h"
+#include "cmStandardIncludes.h"
+#include "cmSystemTools.h"
+#include "cmSourceFile.h"
+#include "cmMakeDepend.h"
+#include "cmCacheManager.h"
+#include "cmGeneratedFileStream.h"
+
+cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
+{
+}
+
+cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator()
+{
+}
+
+void cmNMakeMakefileGenerator::ComputeSystemInfo()
+{
+}
+
+void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
+{
+ fout << "# NMake Makefile generated by cmake\n";
+ const char* variables =
+ "# general varibles used in the makefile\n"
+ "\n"
+ "# Path to cmake\n"
+ "CMAKE_COMMAND = ${CMAKE_COMMAND}\n";
+ std::string replaceVars = variables;
+ m_Makefile->ExpandVariablesInString(replaceVars);
+ fout << replaceVars.c_str();
+ fout << "CMAKE_CURRENT_SOURCE = " << m_Makefile->GetStartDirectory()
+ << "\n";
+ fout << "CMAKE_CURRENT_BINARY = " << m_Makefile->GetStartOutputDirectory()
+ << "\n";
+ fout << "CMAKE_SOURCE_DIR = " << m_Makefile->GetHomeDirectory() << "\n";
+ fout << "CMAKE_BINARY_DIR = " << m_Makefile->GetHomeOutputDirectory()
+ << "\n";
+ // Output Include paths
+ fout << "INCLUDE_FLAGS = ";
+ std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
+ std::vector<std::string>::iterator i;
+ fout << "-I" << m_Makefile->GetStartDirectory() << " ";
+ for(i = includes.begin(); i != includes.end(); ++i)
+ {
+ std::string include = *i;
+ // Don't output a -I for the standard include path "/usr/include".
+ // This can cause problems with certain standard library
+ // implementations because the wrong headers may be found first.
+ if(include != "/usr/include")
+ {
+ fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()).c_str() << " ";
+ }
+ }
+ fout << m_Makefile->GetDefineFlags();
+ fout << "\n\n";
+}
+
+
+void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
+ const char* directory,
+ const char* target1,
+ const char* target2)
+{
+ if(target1)
+ {
+ fout << "\tif not exist " << directory << " "
+ << "$(MAKE) rebuild_cache\n"
+ << "\tcd \".\\" << directory << "\"\n"
+ << "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
+ }
+ if(target2)
+ {
+ fout << "\t$(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
+ }
+}
diff --git a/Source/cmNMakeMakefileGenerator.h b/Source/cmNMakeMakefileGenerator.h
new file mode 100644
index 0000000..1c92eb9
--- /dev/null
+++ b/Source/cmNMakeMakefileGenerator.h
@@ -0,0 +1,77 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+Copyright (c) 2001 Insight Consortium
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * The name of the Insight Consortium, nor the names of any consortium members,
+ nor of any contributors, may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ * Modified source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+#ifndef cmNMakeMakefileGenerator_h
+#define cmNMakeMakefileGenerator_h
+
+#include "cmUnixMakefileGenerator.h"
+
+/** \class cmNMakeMakefileGenerator
+ * \brief Write an NMake makefile.
+ *
+ * cmNMakeMakefileGenerator produces a Unix makefile from its
+ * member m_Makefile.
+ */
+class cmNMakeMakefileGenerator : public cmUnixMakefileGenerator
+{
+public:
+ ///! Set cache only and recurse to false by default.
+ cmNMakeMakefileGenerator();
+
+ virtual ~cmNMakeMakefileGenerator();
+
+ ///! Get the name for the generator.
+ virtual const char* GetName() {return "NMake Makefiles";}
+
+ ///! virtual copy constructor
+ virtual cmMakefileGenerator* CreateObject()
+ { return new cmNMakeMakefileGenerator;}
+
+ ///! figure out about the current system information
+ virtual void ComputeSystemInfo();
+protected:
+ virtual void OutputMakeVariables(std::ostream&);
+ virtual void BuildInSubDirectory(std::ostream& fout,
+ const char* directory,
+ const char* target1,
+ const char* target2);
+};
+
+#endif
diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx
index 59bf908..94f8662 100644
--- a/Source/cmUnixMakefileGenerator.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -204,6 +204,10 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
return;
}
fout << "# CMAKE generated Makefile, DO NOT EDIT!\n"
+ << "# Generated by \"" << this->GetName() << "\""
+ << " Generator, CMake Version "
+ << cmMakefile::GetMajorVersion() << "."
+ << cmMakefile::GetMinorVersion() << "\n"
<< "# Generated from the following files:\n# "
<< m_Makefile->GetHomeOutputDirectory() << "/CMakeCache.txt\n";
std::vector<std::string> lfiles = m_Makefile->GetListFiles();
@@ -256,6 +260,12 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
}
this->OutputObjectDepends(dependout);
}
+ else
+ {
+ std::cout << "skipping depends\n";
+ }
+ std::cout << "hello\n";
+
this->OutputCustomRules(fout);
this->OutputMakeRules(fout);
this->OutputInstallRules(fout);
@@ -839,6 +849,27 @@ inline std::string FixDirectoryName(const char* dir)
return s;
}
+
+void cmUnixMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
+ const char* directory,
+ const char* target1,
+ const char* target2)
+{
+ if(target1)
+ {
+ fout << "\t@if test ! -d " << directory
+ << "; then $(MAKE) rebuild_cache; fi\n"
+ "\tcd " << directory
+ << "; $(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
+ }
+ if(target2)
+ {
+ fout << "\t@cd " << directory
+ << "; $(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
+ }
+}
+
+
void
cmUnixMakefileGenerator::
OutputSubDirectoryVars(std::ostream& fout,
@@ -881,17 +912,8 @@ OutputSubDirectoryVars(std::ostream& fout,
fout << " " << target << "_" << fixed_d.c_str();
}
fout << "\n";
- if(target1)
- {
- fout << "\t@if test ! -d " << SubDirectories[i].c_str() << "; then $(MAKE) rebuild_cache; fi\n"
- "\tcd " << SubDirectories[i].c_str()
- << "; $(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
- }
- if(target2)
- {
- fout << "\t@cd " << SubDirectories[i].c_str()
- << "; $(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
- }
+ this->BuildInSubDirectory(fout, SubDirectories[i].c_str(),
+ target1, target2);
}
fout << "\n\n";
}
@@ -1080,7 +1102,8 @@ void cmUnixMakefileGenerator::RecursiveGenerateCacheOnly()
{
mf->AddDefinition("RUN_CONFIGURE", true);
}
- cmUnixMakefileGenerator* gen = new cmUnixMakefileGenerator;
+ cmUnixMakefileGenerator* gen =
+ static_cast<cmUnixMakefileGenerator*>(this->CreateObject());
gen->SetCacheOnlyOn();
gen->SetRecurseOff();
mf->SetMakefileGenerator(gen);
diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h
index 56f0ffe..00fb976 100644
--- a/Source/cmUnixMakefileGenerator.h
+++ b/Source/cmUnixMakefileGenerator.h
@@ -131,6 +131,11 @@ protected:
const char* extraCompileFlags,
bool sharedTarget);
+ virtual void BuildInSubDirectory(std::ostream& fout,
+ const char* directory,
+ const char* target1,
+ const char* target2);
+
virtual void OutputSubDirectoryVars(std::ostream& fout,
const char* var,
const char* target,