half checked in changes for CMAKE_ROOT
This commit is contained in:
parent
e093e4a4e0
commit
aa72e182fe
|
@ -126,18 +126,14 @@ int main(int ac, char** av)
|
|||
mf.MakeStartDirectoriesCurrent();
|
||||
cmCacheManager::GetInstance()->LoadCache(&mf);
|
||||
|
||||
// Make sure the internal "CMAKE" cache entry is set.
|
||||
const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue("CMAKE");
|
||||
if(!cacheValue)
|
||||
{
|
||||
// Find our own exectuable.
|
||||
std::string cMakeSelf = cmSystemTools::FindProgram(av[0]);
|
||||
// Save the value in the cache
|
||||
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE",
|
||||
cMakeSelf.c_str(),
|
||||
"Path to CMake executable.",
|
||||
cmCacheManager::INTERNAL);
|
||||
}
|
||||
// Find our own exectuable.
|
||||
std::string cMakeSelf = cmSystemTools::FindProgram(av[0]);
|
||||
// Save the value in the cache
|
||||
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_COMMAND",
|
||||
cMakeSelf.c_str(),
|
||||
"Path to CMake executable.",
|
||||
cmCacheManager::INTERNAL);
|
||||
mf.SetCMakeInstallDirectory(cmSystemTools::FindProgram(av[0]));
|
||||
|
||||
// Transfer the cache into the makefile's definitions.
|
||||
cmCacheManager::GetInstance()->DefineCache(&mf);
|
||||
|
|
|
@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "cmMakefile.h"
|
||||
#include "cmMSProjectGenerator.h"
|
||||
#include "cmCacheManager.h"
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
// this is the command line version of CMakeSetup.
|
||||
// It is called from Visual Studio when a CMakeLists.txt
|
||||
|
@ -90,6 +90,20 @@ int main(int ac, char** av)
|
|||
return -1;
|
||||
}
|
||||
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;
|
||||
SetArgs(makefile, ac, av);
|
||||
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
|
||||
|
@ -105,18 +119,14 @@ int main(int ac, char** av)
|
|||
makefile.MakeStartDirectoriesCurrent();
|
||||
cmCacheManager::GetInstance()->LoadCache(&makefile);
|
||||
|
||||
// Make sure the internal "CMAKE" cache entry is set.
|
||||
const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue("CMAKE");
|
||||
if(!cacheValue)
|
||||
{
|
||||
// Find our own exectuable.
|
||||
std::string cMakeSelf = "\""+cmSystemTools::FindProgram(av[0])+"\"";
|
||||
// Save the value in the cache
|
||||
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE",
|
||||
cMakeSelf.c_str(),
|
||||
"Path to CMake executable.",
|
||||
cmCacheManager::INTERNAL);
|
||||
}
|
||||
// Make sure the internal "CMAKE_COMMAND" cache entry is set.
|
||||
// Find our own exectuable.
|
||||
std::string cMakeSelf = "\""+cmSystemTools::FindProgram(av[0])+"\"";
|
||||
// Save the value in the cache
|
||||
cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_COMMAND",
|
||||
cMakeSelf.c_str(),
|
||||
"Path to CMake executable.",
|
||||
cmCacheManager::INTERNAL);
|
||||
|
||||
cmCacheManager::GetInstance()->DefineCache(&makefile);
|
||||
makefile.ReadListFile(av[1]);
|
||||
|
|
|
@ -66,36 +66,14 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
|||
CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CMakeSetupDialog::IDD, pParent)
|
||||
{
|
||||
CString startPath = _pgmptr;
|
||||
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;
|
||||
m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
|
||||
|
||||
//{{AFX_DATA_INIT(CMakeSetupDialog)
|
||||
m_WhereSource = _T("");
|
||||
m_WhereBuild = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
//}}AFX_DATA_INIT
|
||||
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
||||
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();
|
||||
m_BuildPathChanged = false;
|
||||
}
|
||||
|
@ -209,7 +187,7 @@ HCURSOR CMakeSetupDialog::OnQueryDragIcon()
|
|||
void CMakeSetupDialog::OnBrowseWhereSource()
|
||||
{
|
||||
this->UpdateData();
|
||||
Browse(m_WhereSource, "Enter Path to Insight Source");
|
||||
Browse(m_WhereSource, "Enter Path to Source");
|
||||
this->UpdateData(false);
|
||||
}
|
||||
|
||||
|
@ -241,7 +219,7 @@ bool CMakeSetupDialog::Browse(CString &result, const char *title)
|
|||
void CMakeSetupDialog::OnBrowseWhereBuild()
|
||||
{
|
||||
this->UpdateData();
|
||||
Browse(m_WhereBuild, "Enter Path to Insight Build");
|
||||
Browse(m_WhereBuild, "Enter Path to Build");
|
||||
this->UpdateData(false);
|
||||
}
|
||||
|
||||
|
@ -265,7 +243,6 @@ void CMakeSetupDialog::SaveToRegistry()
|
|||
RegSetValueEx(hKey, _T("WhereBuild"), 0, REG_SZ,
|
||||
(CONST BYTE *)(const char *)m_WhereBuild,
|
||||
m_WhereBuild.GetLength());
|
||||
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
@ -307,9 +284,8 @@ void CMakeSetupDialog::LoadFromRegistry()
|
|||
else
|
||||
{
|
||||
// save some values
|
||||
this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\Insight");
|
||||
this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild",
|
||||
"C:\\Insight");
|
||||
this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\");
|
||||
this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild","C:\\");
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
@ -341,10 +317,10 @@ void CMakeSetupDialog::OnBuildProjects()
|
|||
// current GUI values to the cache
|
||||
this->SaveCacheFromGUI();
|
||||
}
|
||||
// Create a makefile object
|
||||
cmMakefile makefile;
|
||||
// Make sure we are working from the cache on disk
|
||||
this->LoadCacheFromDiskToGUI();
|
||||
// Create a makefile object
|
||||
cmMakefile makefile;
|
||||
makefile.SetMakefileGenerator(new cmMSProjectGenerator);
|
||||
makefile.SetHomeDirectory(m_WhereSource);
|
||||
makefile.SetStartOutputDirectory(m_WhereBuild);
|
||||
|
@ -482,21 +458,26 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI()
|
|||
{
|
||||
cmCacheManager::GetInstance()->LoadCache(m_WhereBuild);
|
||||
|
||||
// Make sure the internal "CMAKE" cache entry is set.
|
||||
const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue("CMAKE");
|
||||
if(!cacheValue)
|
||||
// Find our own exectuable.
|
||||
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)
|
||||
{
|
||||
// Find our own exectuable.
|
||||
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);
|
||||
root = root.substr(0, slashPos);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
|
|||
cMakeLists += "CMakeLists.txt";
|
||||
cMakeLists = cmSystemTools::EscapeSpaces(cMakeLists.c_str());
|
||||
|
||||
std::string command = "${CMAKE} "+cMakeLists;
|
||||
std::string command = "${CMAKE_COMMAND} "+cMakeLists;
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
command += " -DSP";
|
||||
#endif
|
||||
|
|
|
@ -137,7 +137,7 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
|||
makefileIn += m_Makefile->GetStartDirectory();
|
||||
makefileIn += "/";
|
||||
makefileIn += "CMakeLists.txt\"";
|
||||
std::string dsprule = "${CMAKE} ";
|
||||
std::string dsprule = "${CMAKE_COMMAND} ";
|
||||
dsprule += makefileIn;
|
||||
dsprule += " -DSP -H\"";
|
||||
dsprule += m_Makefile->GetHomeDirectory();
|
||||
|
@ -360,16 +360,16 @@ void cmDSPMakefile::WriteDSPEndGroup(std::ostream& fout)
|
|||
|
||||
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");
|
||||
|
||||
if( def)
|
||||
{
|
||||
root = def;
|
||||
root = def;
|
||||
}
|
||||
else
|
||||
{
|
||||
root += "/CMake/Source";
|
||||
root += "/Templates";
|
||||
}
|
||||
|
||||
switch(b)
|
||||
|
|
|
@ -137,7 +137,7 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
|||
makefileIn += m_Makefile->GetStartDirectory();
|
||||
makefileIn += "/";
|
||||
makefileIn += "CMakeLists.txt\"";
|
||||
std::string dsprule = "${CMAKE} ";
|
||||
std::string dsprule = "${CMAKE_COMMAND} ";
|
||||
dsprule += makefileIn;
|
||||
dsprule += " -DSP -H\"";
|
||||
dsprule += m_Makefile->GetHomeDirectory();
|
||||
|
@ -360,16 +360,16 @@ void cmDSPMakefile::WriteDSPEndGroup(std::ostream& fout)
|
|||
|
||||
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");
|
||||
|
||||
if( def)
|
||||
{
|
||||
root = def;
|
||||
root = def;
|
||||
}
|
||||
else
|
||||
{
|
||||
root += "/CMake/Source";
|
||||
root += "/Templates";
|
||||
}
|
||||
|
||||
switch(b)
|
||||
|
|
|
@ -64,6 +64,13 @@ cmMakefile::cmMakefile()
|
|||
this->AddDefaultCommands();
|
||||
this->AddDefaultDefinitions();
|
||||
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()
|
||||
|
@ -854,11 +861,6 @@ void cmMakefile::SetHomeDirectory(const char* dir)
|
|||
m_cmHomeDirectory = dir;
|
||||
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
|
||||
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)
|
||||
|
|
|
@ -755,7 +755,7 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
|
|||
"THREAD_LIBS = @CMAKE_THREAD_LIBS@\n"
|
||||
"\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";
|
||||
|
@ -791,11 +791,11 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
|
|||
"${CMAKE_CXX} ${CMAKE_CXXFLAGS} ${INCLUDE_FLAGS} -c $< -o $@"); this->OutputMakeRule(fout,
|
||||
"Default build rule",
|
||||
"all",
|
||||
"Makefile cmake.depends ${TARGETS} ${SUBDIR_BUILD} ${CMAKE}",
|
||||
"Makefile cmake.depends ${TARGETS} ${SUBDIR_BUILD} ${CMAKE_COMMAND}",
|
||||
0);
|
||||
this->OutputMakeRule(fout,
|
||||
"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",
|
||||
"cd ${CMAKE_BINARY_DIR}/CMake/Source; "
|
||||
"${MAKE} CMakeBuildTargets");
|
||||
|
@ -807,29 +807,29 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
|
|||
this->OutputMakeRule(fout,
|
||||
"Rule to build the Makefile",
|
||||
"Makefile",
|
||||
"${CMAKE} ${CMAKE_MAKEFILE_SOURCES} ",
|
||||
"${CMAKE} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
|
||||
"${CMAKE_COMMAND} ${CMAKE_MAKEFILE_SOURCES} ",
|
||||
"${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
|
||||
"-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} "
|
||||
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
|
||||
this->OutputMakeRule(fout,
|
||||
"Rule to build the cmake.depends",
|
||||
"cmake.depends",
|
||||
"${CMAKE} ${CMAKE_MAKEFILE_SOURCES} ",
|
||||
"${CMAKE} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
|
||||
"${CMAKE_COMMAND} ${CMAKE_MAKEFILE_SOURCES} ",
|
||||
"${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
|
||||
"-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} "
|
||||
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
|
||||
this->OutputMakeRule(fout,
|
||||
"Rule to force the build of cmake.depends",
|
||||
"depend",
|
||||
"${SUBDIR_DEPEND}",
|
||||
"${CMAKE} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
|
||||
"${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE}/CMakeLists.txt "
|
||||
"-S${CMAKE_CURRENT_SOURCE} -O${CMAKE_CURRENT_BINARY} "
|
||||
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
|
||||
this->OutputMakeRule(fout,
|
||||
"Rebuild the cache",
|
||||
"rebuild_cache",
|
||||
"${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} "
|
||||
"-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
|
||||
|
||||
|
|
Loading…
Reference in New Issue