2001-01-11 22:55:47 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: Insight Segmentation & Registration Toolkit
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-01-21 23:30:43 +03:00
|
|
|
Copyright (c) 2002 Insight Consortium. All rights reserved.
|
|
|
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
|
2001-01-11 22:55:47 +03:00
|
|
|
|
2002-01-21 23:30:43 +03:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
2001-01-11 22:55:47 +03:00
|
|
|
|
|
|
|
=========================================================================*/
|
2001-01-05 19:41:20 +03:00
|
|
|
#include "cmMSProjectGenerator.h"
|
2001-06-06 21:48:13 +04:00
|
|
|
#include "cmDSWWriter.h"
|
|
|
|
#include "cmDSPWriter.h"
|
2001-05-18 23:22:17 +04:00
|
|
|
#include "cmCacheManager.h"
|
2001-01-05 19:41:20 +03:00
|
|
|
|
|
|
|
cmMSProjectGenerator::cmMSProjectGenerator()
|
|
|
|
{
|
2001-06-06 21:48:13 +04:00
|
|
|
m_DSWWriter = 0;
|
|
|
|
m_DSPWriter = 0;
|
2001-01-11 22:47:38 +03:00
|
|
|
BuildDSWOn();
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmMSProjectGenerator::GenerateMakefile()
|
|
|
|
{
|
2002-05-22 17:48:33 +04:00
|
|
|
this->EnableLanguage("CXX");
|
2001-01-05 19:41:20 +03:00
|
|
|
if(m_BuildDSW)
|
|
|
|
{
|
2001-06-06 21:48:13 +04:00
|
|
|
delete m_DSWWriter;
|
|
|
|
m_DSWWriter = 0;
|
|
|
|
m_DSWWriter = new cmDSWWriter(m_Makefile);
|
|
|
|
m_DSWWriter->OutputDSWFile();
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-06 21:48:13 +04:00
|
|
|
delete m_DSPWriter;
|
|
|
|
m_DSPWriter = 0;
|
|
|
|
m_DSPWriter = new cmDSPWriter(m_Makefile);
|
|
|
|
m_DSPWriter->OutputDSPFile();
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cmMSProjectGenerator::~cmMSProjectGenerator()
|
|
|
|
{
|
2001-06-06 21:48:13 +04:00
|
|
|
delete m_DSPWriter;
|
|
|
|
delete m_DSWWriter;
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2001-05-18 19:12:21 +04:00
|
|
|
void cmMSProjectGenerator::SetLocal(bool local)
|
|
|
|
{
|
|
|
|
m_BuildDSW = !local;
|
|
|
|
}
|
2001-05-18 23:20:31 +04:00
|
|
|
|
2002-04-03 00:43:23 +04:00
|
|
|
void cmMSProjectGenerator::EnableLanguage(const char*)
|
2001-05-18 23:20:31 +04:00
|
|
|
{
|
|
|
|
// now load the settings
|
2001-08-08 19:54:46 +04:00
|
|
|
if(!m_Makefile->GetDefinition("CMAKE_ROOT"))
|
2001-05-30 23:28:55 +04:00
|
|
|
{
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"CMAKE_ROOT has not been defined, bad GUI or driver program");
|
|
|
|
return;
|
|
|
|
}
|
2002-05-22 17:48:33 +04:00
|
|
|
if(!this->GetLanguageEnabled("CXX"))
|
|
|
|
{
|
|
|
|
std::string fpath =
|
|
|
|
m_Makefile->GetDefinition("CMAKE_ROOT");
|
|
|
|
fpath += "/Templates/CMakeWindowsSystemConfig.cmake";
|
|
|
|
m_Makefile->ReadListFile(NULL,fpath.c_str());
|
|
|
|
this->SetLanguageEnabled("CXX");
|
|
|
|
}
|
2001-05-18 23:20:31 +04:00
|
|
|
}
|
2002-05-22 17:48:33 +04:00
|
|
|
|
2002-08-28 22:51:10 +04:00
|
|
|
int cmMSProjectGenerator::TryCompile(const char *srcdir,
|
|
|
|
const char *bindir,
|
|
|
|
const char *projectName)
|
|
|
|
{
|
|
|
|
// now build the test
|
|
|
|
std::string makeCommand = m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
if(makeCommand.size() == 0)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"Generator cannot find the appropriate make command.");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
|
|
|
|
std::string lowerCaseCommand = makeCommand;
|
|
|
|
cmSystemTools::LowerCase(lowerCaseCommand);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run an executable command and put the stdout in output.
|
|
|
|
*/
|
|
|
|
std::string output;
|
|
|
|
|
|
|
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
|
cmSystemTools::ChangeDirectory(bindir);
|
|
|
|
|
|
|
|
// if there are spaces in the makeCommand, assume a full path
|
|
|
|
// and convert it to a path with no spaces in it as the
|
|
|
|
// RunCommand does not like spaces
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
if(makeCommand.find(' ') != std::string::npos)
|
|
|
|
{
|
|
|
|
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
makeCommand += " ";
|
|
|
|
makeCommand += projectName;
|
|
|
|
makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD";
|
|
|
|
|
|
|
|
if (!cmSystemTools::RunCommand(makeCommand.c_str(), output))
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Generator: execution of msdev failed.");
|
|
|
|
// return to the original directory
|
|
|
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|