summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-05-24 16:57:33 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-05-24 16:57:33 (GMT)
commit5731bc9d54036b28d4fce428cc218bb207c63411 (patch)
tree39caed87c95dc064689d064469ca5d9b01a7db00 /Source
parentad92f34fea4c565a3f6698c5bc620797be9c64fe (diff)
downloadCMake-5731bc9d54036b28d4fce428cc218bb207c63411.zip
CMake-5731bc9d54036b28d4fce428cc218bb207c63411.tar.gz
CMake-5731bc9d54036b28d4fce428cc218bb207c63411.tar.bz2
ENH: change the syntax of the SET command, fix the combo box for larger strings
Diffstat (limited to 'Source')
-rw-r--r--Source/MFCDialog/CMakeSetup.rc8
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp11
-rw-r--r--Source/cmSetCommand.cxx101
-rw-r--r--Source/cmSetCommand.h9
4 files changed, 66 insertions, 63 deletions
diff --git a/Source/MFCDialog/CMakeSetup.rc b/Source/MFCDialog/CMakeSetup.rc
index 8be968b..4688cb8 100644
--- a/Source/MFCDialog/CMakeSetup.rc
+++ b/Source/MFCDialog/CMakeSetup.rc
@@ -104,10 +104,10 @@ BEGIN
WS_HSCROLL | WS_TABSTOP
CTEXT "Right click on cache entries for additional options",
IDC_STATIC,19,190,333,11
- COMBOBOX IDC_WhereBuild,147,25,133,68,CBS_DROPDOWN | WS_VSCROLL |
- WS_TABSTOP
- COMBOBOX IDC_WhereSource,147,5,133,66,CBS_DROPDOWN | WS_VSCROLL |
- WS_TABSTOP
+ COMBOBOX IDC_WhereBuild,129,26,133,68,CBS_DROPDOWN |
+ CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_WhereSource,127,6,135,66,CBS_DROPDOWN |
+ CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
LTEXT "Static",IDC_CMAKE_VERSION,3,211,70,13,SS_CENTERIMAGE
END
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index c93e652..804496e 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -137,6 +137,8 @@ BOOL CMakeSetupDialog::OnInitDialog()
this->LoadFromRegistry();
// try to load the cmake cache from disk
this->LoadCacheFromDiskToGUI();
+ m_WhereBuildControl.LimitText(2048);
+ m_WhereSourceControl.LimitText(2048);
// Set the version number
char tmp[1024];
sprintf(tmp,"Version %s", cmMakefile::GetVersion());
@@ -435,15 +437,6 @@ void CMakeSetupDialog::OnBuildProjects()
CString makefileIn = m_WhereSource;
makefileIn += "/CMakeLists.txt";
makefile.ReadListFile(makefileIn);
- if(!cmCacheManager::GetInstance()->GetCacheValue("CMAKE_CXX"))
- {
- if(!makefile.GetDefinition("CMAKE_CXX"))
- {
- makefile.AddDefinition("CMAKE_CXX", "VC60");
- }
- cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_CXX", "VC60",
- "Compiler used", cmCacheManager::STRING);
- }
// Generate the project files
makefile.GenerateMakefile();
// Save the cache
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 5760c89..e5869a8 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -48,67 +48,72 @@ bool cmSetCommand::Invoke(std::vector<std::string>& args)
this->SetError("called with incorrect number of arguments");
return false;
}
+ // SET (VAR ) // this is a no-op
if (args.size() == 1)
{
- return true;
+ return true;
}
-// here are the options with the num
-// SET VAR
-// SET VAR value
-// SET VAR CACHE|CACHE_NO_REPLACE
-// SET VAR value CACHE|CACHE_NO_REPLACE
-// SET VAR CACHE|CACHE_NO_REPLACE TYPE
-// SET VAR value CACHE|CACHE_NO_REPLACE TYPE
- const char* type = "STRING"; // set a default type of STRING
- const char* value = "";// set a default value of the empty string
- if(args.size() > 1)
+// here are the options
+// SET (VAR)
+// SET (VAR value )
+// SET (VAR CACHE TYPE "doc String")
+// SET (VAR value CACHE TYPE "doc string")
+
+ const char* variable = args[0].c_str(); // VAR is always first
+ std::string value; // optional
+ bool cache = false; // optional
+ cmCacheManager::CacheEntryType type = cmCacheManager::STRING; // required if cache
+ const char* docstring = 0; // required if cache
+ std::string::size_type cacheStart = 0;
+ if(args.size() == 4)
{
- // always expand the first argument
- m_Makefile->ExpandVariablesInString(args[1]);
- value = args[1].c_str();
+ // SET (VAR CACHE TYPE "doc String")
+ cache = true;
+ cacheStart = 1;
}
- // get the current cache value for the variable
- const char* cacheValue =
- cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
- // assume this will not be cached
- bool cache = false;
- // search the arguments for key words CACHE and CACHE_NO_REPLACE
- for(int i = 1; i < args.size() && !cache; ++i)
+ else if(args.size() == 5)
{
- if(args[i] == "CACHE_NO_REPLACE")
- {
- // if already in cache, ignore entire command
- if(cacheValue)
- {
- return true;
- }
- cache = true;
- }
- if(args[i] == "CACHE")
+ // SET (VAR value CACHE TYPE "doc string")
+ cache = true;
+ value = args[1];
+ cacheStart = 2;
+ }
+ if(cache)
+ {
+ if(args[cacheStart] != "CACHE")
{
- cache = true;
+ std::string error = "Error in arguments to cache, expected CACHE found:";
+ error += args[cacheStart];
+ this->SetError(error.c_str());
+ return false;
}
- // if this is to be cached, find the value and type
- if(cache)
+ type = cmCacheManager::StringToType(args[cacheStart+1].c_str());
+ docstring = args[cacheStart+2].c_str();
+ }
+ // always expand the first argument
+ m_Makefile->ExpandVariablesInString(value);
+ // get the current cache value for the variable
+ const char* cacheValue =
+ cmCacheManager::GetInstance()->GetCacheValue(variable);
+ if(cacheValue)
+ {
+ // if it is not a cached value, or it is a cached
+ // value that is not internal keep the value found
+ // in the cache
+ if(cache && type != cmCacheManager::INTERNAL)
{
- // if this is the
- if(i == 1)
- {
- value = "";
- }
- if(i+1 < args.size())
- {
- type = args[i+1].c_str();
- }
+ return true;
}
}
- m_Makefile->AddDefinition(args[0].c_str(), value);
+ // add the definition
+ m_Makefile->AddDefinition(variable, value.c_str());
+ // if it is meant to be in the cache then define it in the cache
if(cache)
{
- cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- value,
- "Value Computed by CMake",
- cmCacheManager::StringToType(type));
+ cmCacheManager::GetInstance()->AddCacheEntry(variable,
+ value.c_str(),
+ docstring,
+ type);
}
return true;
}
diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h
index 45bccbd..8a97240 100644
--- a/Source/cmSetCommand.h
+++ b/Source/cmSetCommand.h
@@ -91,8 +91,13 @@ public:
virtual const char* GetFullDocumentation()
{
return
- "SET(FOO BAR)\n"
- "Within CMAKE sets FOO to the value BAR. BAR is expanded before FOO is set to it.";
+ "SET(VAR [VALUE] [CACHE TYPE DOCSTRING])\n"
+ "Within CMAKE sets VAR to the value VALUE. VALUE is expanded before VAR "
+ "is set to it. If CACHE is present, then the VAR is put in the cache."
+ " TYPE and DOCSTRING are required. If TYPE is INTERNAL, then the "
+ " VALUE is Always written into the cache, replacing any values "
+ "existing in the cache. If it is not a CACHE VAR, then this always "
+ "writes into the current makefile.";
}
cmTypeMacro(cmSetCommand, cmCommand);