[cmake-commits] king committed cmGlobalVisualStudio8Generator.cxx
1.22 1.23 cmLocalVisualStudio7Generator.cxx 1.200 1.201
cmake-commits at cmake.org
cmake-commits at cmake.org
Fri Nov 9 12:05:05 EST 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv22824
Modified Files:
cmGlobalVisualStudio8Generator.cxx
cmLocalVisualStudio7Generator.cxx
Log Message:
ENH: Converted vcproj file generation to use cmGeneratedFileStream for atomic replacement. Replaced the vcproj.cmake copy of the file with a simple vcproj.stamp timestamp file to preserve previous rerun-without-reload behavior.
Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- cmLocalVisualStudio7Generator.cxx 17 Sep 2007 19:59:50 -0000 1.200
+++ cmLocalVisualStudio7Generator.cxx 9 Nov 2007 17:05:03 -0000 1.201
@@ -24,6 +24,8 @@
#include "cmCacheManager.h"
#include "cmake.h"
+#include "cmGeneratedFileStream.h"
+
#include <cmsys/System.h>
#include <ctype.h> // for isspace
@@ -152,25 +154,35 @@
fname += "/";
fname += lname;
fname += ".vcproj";
- // save the name of the real dsp file
- std::string realVCProj = fname;
- fname += ".cmake";
- std::ofstream fout(fname.c_str());
- if(!fout)
- {
- cmSystemTools::Error("Error Writing ", fname.c_str());
- }
+
+ // Generate the project file and replace it atomically with
+ // copy-if-different. We use a separate timestamp so that the IDE
+ // does not reload project files unnecessarily.
+ {
+ cmGeneratedFileStream fout(fname.c_str());
+ fout.SetCopyIfDifferent(true);
this->WriteVCProjFile(fout,lname,target);
- fout.close();
- // if the dsp file has changed, then write it.
- cmSystemTools::CopyFileIfDifferent(fname.c_str(), realVCProj.c_str());
+ }
+
+ // Touch a timestamp file used to determine when the project file is
+ // out of date.
+ std::string stampName;
+ stampName = this->Makefile->GetStartOutputDirectory();
+ stampName += cmake::GetCMakeFilesDirectory();
+ cmSystemTools::MakeDirectory(stampName.c_str());
+ stampName += "/";
+ stampName += lname;
+ stampName += ".vcproj.stamp";
+ std::ofstream stamp(stampName.c_str());
+ stamp << "# CMake timestamp for " << lname << ".vcproj" << std::endl;
}
void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt)
{
- std::string dspname = tgt.GetName();
- dspname += ".vcproj.cmake";
+ std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
+ stampName += tgt.GetName();
+ stampName += ".vcproj.stamp";
const char* dsprule =
this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine;
@@ -213,7 +225,7 @@
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
const char* no_working_directory = 0;
- this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles,
+ this->Makefile->AddCustomCommandToOutput(stampName.c_str(), listFiles,
makefileIn.c_str(), commandLines,
comment.c_str(),
no_working_directory, true);
@@ -959,10 +971,6 @@
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
- // trace the visual studio dependencies
- std::string name = libName;
- name += ".vcproj.cmake";
-
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
Index: cmGlobalVisualStudio8Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmGlobalVisualStudio8Generator.cxx 22 Oct 2007 16:48:39 -0000 1.22
+++ cmGlobalVisualStudio8Generator.cxx 9 Nov 2007 17:05:03 -0000 1.23
@@ -146,20 +146,21 @@
// target.
const char* no_main_dependency = 0;
const char* no_working_directory = 0;
+ std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
+ stampName += CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.stamp";
mf->AddCustomCommandToOutput(
- CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.cmake", listFiles,
+ stampName.c_str(), listFiles,
no_main_dependency, commandLines, "Checking Build System",
no_working_directory, true);
- if(cmSourceFile* file = mf->GetSource(CMAKE_CHECK_BUILD_SYSTEM_TARGET
- ".vcproj.cmake.rule"))
+ std::string ruleName = stampName;
+ ruleName += ".rule";
+ if(cmSourceFile* file = mf->GetSource(ruleName.c_str()))
{
tgt->AddSourceFile(file);
}
else
{
- cmSystemTools::Error("Error adding rule for "
- CMAKE_CHECK_BUILD_SYSTEM_TARGET
- ".vcproj.cmake");
+ cmSystemTools::Error("Error adding rule for ", stampName.c_str());
}
}
}
More information about the Cmake-commits
mailing list