half checked in changes for CMAKE_ROOT

This commit is contained in:
Ken Martin 2001-05-17 12:08:46 -04:00
parent e093e4a4e0
commit aa72e182fe
8 changed files with 83 additions and 94 deletions

View File

@ -126,18 +126,14 @@ int main(int ac, char** av)
mf.MakeStartDirectoriesCurrent(); mf.MakeStartDirectoriesCurrent();
cmCacheManager::GetInstance()->LoadCache(&mf); cmCacheManager::GetInstance()->LoadCache(&mf);
// Make sure the internal "CMAKE" cache entry is set. // Find our own exectuable.
const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue("CMAKE"); std::string cMakeSelf = cmSystemTools::FindProgram(av[0]);
if(!cacheValue) // Save the value in the cache
{ cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_COMMAND",
// Find our own exectuable. cMakeSelf.c_str(),
std::string cMakeSelf = cmSystemTools::FindProgram(av[0]); "Path to CMake executable.",
// Save the value in the cache cmCacheManager::INTERNAL);
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE", mf.SetCMakeInstallDirectory(cmSystemTools::FindProgram(av[0]));
cMakeSelf.c_str(),
"Path to CMake executable.",
cmCacheManager::INTERNAL);
}
// Transfer the cache into the makefile's definitions. // Transfer the cache into the makefile's definitions.
cmCacheManager::GetInstance()->DefineCache(&mf); cmCacheManager::GetInstance()->DefineCache(&mf);

View File

@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmMSProjectGenerator.h" #include "cmMSProjectGenerator.h"
#include "cmCacheManager.h" #include "cmCacheManager.h"
#include "windows.h"
// this is the command line version of CMakeSetup. // this is the command line version of CMakeSetup.
// It is called from Visual Studio when a CMakeLists.txt // It is called from Visual Studio when a CMakeLists.txt
@ -90,6 +90,20 @@ int main(int ac, char** av)
return -1; return -1;
} }
std::string arg = av[2]; std::string arg = av[2];
// set the cmake install directory
char fname[1024];
::GetModuleFileName(NULL,fname,1023);
std::string root = cmSystemTools::GetProgramPath(fname);
std::string::size_type slashPos = root.rfind("/");
if(slashPos != std::string::npos)
{
root = root.substr(0, slashPos);
}
cmCacheManager::GetInstance()->AddCacheEntry
("CMAKE_ROOT", root.c_str(),
"Path to CMake installation.", cmCacheManager::INTERNAL);
cmMakefile makefile; cmMakefile makefile;
SetArgs(makefile, ac, av); SetArgs(makefile, ac, av);
cmMSProjectGenerator* pg = new cmMSProjectGenerator; cmMSProjectGenerator* pg = new cmMSProjectGenerator;
@ -105,18 +119,14 @@ int main(int ac, char** av)
makefile.MakeStartDirectoriesCurrent(); makefile.MakeStartDirectoriesCurrent();
cmCacheManager::GetInstance()->LoadCache(&makefile); cmCacheManager::GetInstance()->LoadCache(&makefile);
// Make sure the internal "CMAKE" cache entry is set. // Make sure the internal "CMAKE_COMMAND" cache entry is set.
const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue("CMAKE"); // Find our own exectuable.
if(!cacheValue) std::string cMakeSelf = "\""+cmSystemTools::FindProgram(av[0])+"\"";
{ // Save the value in the cache
// Find our own exectuable. cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_COMMAND",
std::string cMakeSelf = "\""+cmSystemTools::FindProgram(av[0])+"\""; cMakeSelf.c_str(),
// Save the value in the cache "Path to CMake executable.",
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE", cmCacheManager::INTERNAL);
cMakeSelf.c_str(),
"Path to CMake executable.",
cmCacheManager::INTERNAL);
}
cmCacheManager::GetInstance()->DefineCache(&makefile); cmCacheManager::GetInstance()->DefineCache(&makefile);
makefile.ReadListFile(av[1]); makefile.ReadListFile(av[1]);

View File

@ -66,36 +66,14 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/) CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/)
: CDialog(CMakeSetupDialog::IDD, pParent) : CDialog(CMakeSetupDialog::IDD, pParent)
{ {
CString startPath = _pgmptr; m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
startPath.Replace('\\', '_');
startPath.Replace(':', '_');
startPath.Replace(".EXE", "");
startPath.Replace(".exe", "");
m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\";
// _pgmptr should be the directory from which cmake was run from
// use it as the unique key for the dialog
m_RegistryKey += startPath;
//{{AFX_DATA_INIT(CMakeSetupDialog) //{{AFX_DATA_INIT(CMakeSetupDialog)
m_WhereSource = _T(""); m_WhereSource = _T("");
m_WhereBuild = _T(""); m_WhereBuild = _T("");
//}}AFX_DATA_INIT //}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// Guess the initial source directory based on the location
// of this program, it should be in CMake/Source/
startPath = _pgmptr;
int removePos = startPath.Find("\\CMake\\Source");
if(removePos == -1)
{
removePos = startPath.Find("/CMake/Source");
}
if(removePos != -1)
{
startPath = startPath.Left(removePos);
}
m_WhereSource = startPath;
m_WhereBuild = startPath;
this->LoadFromRegistry(); this->LoadFromRegistry();
m_BuildPathChanged = false; m_BuildPathChanged = false;
} }
@ -209,7 +187,7 @@ HCURSOR CMakeSetupDialog::OnQueryDragIcon()
void CMakeSetupDialog::OnBrowseWhereSource() void CMakeSetupDialog::OnBrowseWhereSource()
{ {
this->UpdateData(); this->UpdateData();
Browse(m_WhereSource, "Enter Path to Insight Source"); Browse(m_WhereSource, "Enter Path to Source");
this->UpdateData(false); this->UpdateData(false);
} }
@ -241,7 +219,7 @@ bool CMakeSetupDialog::Browse(CString &result, const char *title)
void CMakeSetupDialog::OnBrowseWhereBuild() void CMakeSetupDialog::OnBrowseWhereBuild()
{ {
this->UpdateData(); this->UpdateData();
Browse(m_WhereBuild, "Enter Path to Insight Build"); Browse(m_WhereBuild, "Enter Path to Build");
this->UpdateData(false); this->UpdateData(false);
} }
@ -265,7 +243,6 @@ void CMakeSetupDialog::SaveToRegistry()
RegSetValueEx(hKey, _T("WhereBuild"), 0, REG_SZ, RegSetValueEx(hKey, _T("WhereBuild"), 0, REG_SZ,
(CONST BYTE *)(const char *)m_WhereBuild, (CONST BYTE *)(const char *)m_WhereBuild,
m_WhereBuild.GetLength()); m_WhereBuild.GetLength());
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
@ -307,9 +284,8 @@ void CMakeSetupDialog::LoadFromRegistry()
else else
{ {
// save some values // save some values
this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\Insight"); this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\");
this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild", this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild","C:\\");
"C:\\Insight");
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
@ -341,10 +317,10 @@ void CMakeSetupDialog::OnBuildProjects()
// current GUI values to the cache // current GUI values to the cache
this->SaveCacheFromGUI(); this->SaveCacheFromGUI();
} }
// Create a makefile object
cmMakefile makefile;
// Make sure we are working from the cache on disk // Make sure we are working from the cache on disk
this->LoadCacheFromDiskToGUI(); this->LoadCacheFromDiskToGUI();
// Create a makefile object
cmMakefile makefile;
makefile.SetMakefileGenerator(new cmMSProjectGenerator); makefile.SetMakefileGenerator(new cmMSProjectGenerator);
makefile.SetHomeDirectory(m_WhereSource); makefile.SetHomeDirectory(m_WhereSource);
makefile.SetStartOutputDirectory(m_WhereBuild); makefile.SetStartOutputDirectory(m_WhereBuild);
@ -482,21 +458,26 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI()
{ {
cmCacheManager::GetInstance()->LoadCache(m_WhereBuild); cmCacheManager::GetInstance()->LoadCache(m_WhereBuild);
// Make sure the internal "CMAKE" cache entry is set. // Find our own exectuable.
const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue("CMAKE"); char fname[1024];
if(!cacheValue) ::GetModuleFileName(NULL,fname,1023);
std::string root = cmSystemTools::GetProgramPath(fname);
std::string::size_type slashPos = root.rfind("/");
if(slashPos != std::string::npos)
{ {
// Find our own exectuable. root = root.substr(0, slashPos);
std::string cMakeCMD = "\""+cmSystemTools::GetProgramPath(_pgmptr);
cMakeCMD += "/CMakeSetupCMD.exe\"";
// Save the value in the cache
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE",
cMakeCMD.c_str(),
"Path to CMake executable.",
cmCacheManager::INTERNAL);
} }
cmCacheManager::GetInstance()->AddCacheEntry
("CMAKE_ROOT", root.c_str(),
"Path to CMake installation.", cmCacheManager::INTERNAL);
std::string cMakeCMD = "\""+cmSystemTools::GetProgramPath(fname);
cMakeCMD += "/CMakeSetupCMD.exe\"";
// Save the value in the cache
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_COMMAND",
cMakeCMD.c_str(),
"Path to CMake executable.",
cmCacheManager::INTERNAL);
this->FillCacheGUIFromCacheManager(); this->FillCacheGUIFromCacheManager();
} }
} }

View File

@ -78,7 +78,7 @@ bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
cMakeLists += "CMakeLists.txt"; cMakeLists += "CMakeLists.txt";
cMakeLists = cmSystemTools::EscapeSpaces(cMakeLists.c_str()); cMakeLists = cmSystemTools::EscapeSpaces(cMakeLists.c_str());
std::string command = "${CMAKE} "+cMakeLists; std::string command = "${CMAKE_COMMAND} "+cMakeLists;
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
command += " -DSP"; command += " -DSP";
#endif #endif

View File

@ -137,7 +137,7 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
makefileIn += m_Makefile->GetStartDirectory(); makefileIn += m_Makefile->GetStartDirectory();
makefileIn += "/"; makefileIn += "/";
makefileIn += "CMakeLists.txt\""; makefileIn += "CMakeLists.txt\"";
std::string dsprule = "${CMAKE} "; std::string dsprule = "${CMAKE_COMMAND} ";
dsprule += makefileIn; dsprule += makefileIn;
dsprule += " -DSP -H\""; dsprule += " -DSP -H\"";
dsprule += m_Makefile->GetHomeDirectory(); dsprule += m_Makefile->GetHomeDirectory();
@ -360,18 +360,18 @@ void cmDSPMakefile::WriteDSPEndGroup(std::ostream& fout)
void cmDSPMakefile::SetBuildType(BuildType b, const char *libName) void cmDSPMakefile::SetBuildType(BuildType b, const char *libName)
{ {
std::string root= m_Makefile->GetHomeDirectory(); std::string root= cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT");
const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
if( def) if( def)
{ {
root = def; root = def;
} }
else else
{ {
root += "/CMake/Source"; root += "/Templates";
} }
switch(b) switch(b)
{ {
case STATIC_LIBRARY: case STATIC_LIBRARY:

View File

@ -137,7 +137,7 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
makefileIn += m_Makefile->GetStartDirectory(); makefileIn += m_Makefile->GetStartDirectory();
makefileIn += "/"; makefileIn += "/";
makefileIn += "CMakeLists.txt\""; makefileIn += "CMakeLists.txt\"";
std::string dsprule = "${CMAKE} "; std::string dsprule = "${CMAKE_COMMAND} ";
dsprule += makefileIn; dsprule += makefileIn;
dsprule += " -DSP -H\""; dsprule += " -DSP -H\"";
dsprule += m_Makefile->GetHomeDirectory(); dsprule += m_Makefile->GetHomeDirectory();
@ -360,18 +360,18 @@ void cmDSPMakefile::WriteDSPEndGroup(std::ostream& fout)
void cmDSPMakefile::SetBuildType(BuildType b, const char *libName) void cmDSPMakefile::SetBuildType(BuildType b, const char *libName)
{ {
std::string root= m_Makefile->GetHomeDirectory(); std::string root= cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT");
const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
if( def) if( def)
{ {
root = def; root = def;
} }
else else
{ {
root += "/CMake/Source"; root += "/Templates";
} }
switch(b) switch(b)
{ {
case STATIC_LIBRARY: case STATIC_LIBRARY:

View File

@ -64,6 +64,13 @@ cmMakefile::cmMakefile()
this->AddDefaultCommands(); this->AddDefaultCommands();
this->AddDefaultDefinitions(); this->AddDefaultDefinitions();
cmCacheManager::GetInstance()->DefineCache(this); cmCacheManager::GetInstance()->DefineCache(this);
#if defined(_WIN32) && !defined(__CYGWIN__)
const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue("CMAKE_ROOT");
std::string fpath = cacheValue;
fpath += "/Templates/CMakeWindowsSystemConfig.cmake";
this->ReadListFile(NULL,fpath.c_str());
#endif
} }
void cmMakefile::AddDefaultCommands() void cmMakefile::AddDefaultCommands()
@ -854,11 +861,6 @@ void cmMakefile::SetHomeDirectory(const char* dir)
m_cmHomeDirectory = dir; m_cmHomeDirectory = dir;
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory); cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
this->AddDefinition("CMAKE_SOURCE_DIR", this->GetHomeDirectory()); this->AddDefinition("CMAKE_SOURCE_DIR", this->GetHomeDirectory());
#if defined(_WIN32) && !defined(__CYGWIN__)
std::string fpath = dir;
fpath += "/CMake/CMakeWindowsSystemConfig.cmake";
this->ReadListFile(NULL,fpath.c_str());
#endif
} }
void cmMakefile::SetHomeOutputDirectory(const char* lib) void cmMakefile::SetHomeOutputDirectory(const char* lib)

View File

@ -755,7 +755,7 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
"THREAD_LIBS = @CMAKE_THREAD_LIBS@\n" "THREAD_LIBS = @CMAKE_THREAD_LIBS@\n"
"\n" "\n"
"# set up the path to the rulesgen program\n" "# set up the path to the rulesgen program\n"
"CMAKE = ${CMAKE_BINARY_DIR}/CMake/Source/CMakeBuildTargets\n" "CMAKE_COMMAND = ${CMAKE_BINARY_DIR}/CMake/Source/CMakeBuildTargets\n"
"\n" "\n"
"\n" "\n"
"\n"; "\n";
@ -791,11 +791,11 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
"${CMAKE_CXX} ${CMAKE_CXXFLAGS} ${INCLUDE_FLAGS} -c $< -o $@"); this->OutputMakeRule(fout, "${CMAKE_CXX} ${CMAKE_CXXFLAGS} ${INCLUDE_FLAGS} -c $< -o $@"); this->OutputMakeRule(fout,
"Default build rule", "Default build rule",
"all", "all",
"Makefile cmake.depends ${TARGETS} ${SUBDIR_BUILD} ${CMAKE}", "Makefile cmake.depends ${TARGETS} ${SUBDIR_BUILD} ${CMAKE_COMMAND}",
0); 0);
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
"rule to build cmake from source", "rule to build cmake from source",
"${CMAKE}", "${CMAKE_SOURCE_DIR}/CMake/Source/*.cxx " "${CMAKE_COMMAND}", "${CMAKE_SOURCE_DIR}/CMake/Source/*.cxx "
"${CMAKE_SOURCE_DIR}/CMake/Source/*.h", "${CMAKE_SOURCE_DIR}/CMake/Source/*.h",
"cd ${CMAKE_BINARY_DIR}/CMake/Source; " "cd ${CMAKE_BINARY_DIR}/CMake/Source; "
"${MAKE} CMakeBuildTargets"); "${MAKE} CMakeBuildTargets");
@ -807,29 +807,29 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
"Rule to build the Makefile", "Rule to build the Makefile",
"Makefile", "Makefile",
"${CMAKE} ${CMAKE_MAKEFILE_SOURCES} ", "${CMAKE_COMMAND} ${CMAKE_MAKEFILE_SOURCES} ",
"${CMAKE} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt " "${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
"-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} " "-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} "
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}"); "-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
"Rule to build the cmake.depends", "Rule to build the cmake.depends",
"cmake.depends", "cmake.depends",
"${CMAKE} ${CMAKE_MAKEFILE_SOURCES} ", "${CMAKE_COMMAND} ${CMAKE_MAKEFILE_SOURCES} ",
"${CMAKE} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt " "${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
"-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} " "-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} "
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}"); "-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
"Rule to force the build of cmake.depends", "Rule to force the build of cmake.depends",
"depend", "depend",
"${SUBDIR_DEPEND}", "${SUBDIR_DEPEND}",
"${CMAKE} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt " "${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
"-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} " "-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} "
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}"); "-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
"Rebuild the cache", "Rebuild the cache",
"rebuild_cache", "rebuild_cache",
"${CMAKE_BINARY_DIR}/CMakeCache.txt", "${CMAKE_BINARY_DIR}/CMakeCache.txt",
"${CMAKE} ${CMAKE_SOURCE_DIR}/CMakeLists.txt " "${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}/CMakeLists.txt "
"-MakeCache -S${CMAKE_SOURCE_DIR} -O${CMAKE_BINARY_DIR} " "-MakeCache -S${CMAKE_SOURCE_DIR} -O${CMAKE_BINARY_DIR} "
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}"); "-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");