summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorSebastien Barre <sebastien.barre@kitware.com>2001-12-05 15:29:36 -0500
committerSebastien Barre <sebastien.barre@kitware.com>2001-12-05 15:29:36 -0500
commitecca17cfdd016e4ff6ff577824e6f1f44f8027fc (patch)
tree5368f10794d7ea3a9047ea2c03c119d588b07271 /Source
parente273223d6d881b9f9a84243ce7dcef4bbeeeebee (diff)
downloadcmake-ecca17cfdd016e4ff6ff577824e6f1f44f8027fc.tar.gz
Add single quotes feature.
Diffstat (limited to 'Source')
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp27
-rw-r--r--Source/cmCacheManager.cxx51
-rw-r--r--Source/cmNMakeMakefileGenerator.cxx67
3 files changed, 121 insertions, 24 deletions
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 43484b42df..36ca7040be 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -620,7 +620,17 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
i != cache.end(); ++i)
{
const char* key = i->first.c_str();
- const cmCacheManager::CacheEntry& value = i->second;
+ cmCacheManager::CacheEntry value = i->second;
+
+ // if value has trailing space or tab, enclose it in single quotes
+ // to enforce the fact that it has 'invisible' trailing stuff
+ if (value.m_Value.size() &&
+ (value.m_Value[value.m_Value.size() - 1] == ' ' ||
+ value.m_Value[value.m_Value.size() - 1] == '\t'))
+ {
+ value.m_Value = '\'' + value.m_Value + '\'';
+ }
+
if(!m_AdvancedValues)
{
std::string advancedVar = key;
@@ -722,7 +732,20 @@ void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
(const char*)item->m_propName);
if (entry)
{
- entry->m_Value = item->m_curValue;
+ // if value is enclosed in single quotes ('foo') then remove them
+ // they were used to enforce the fact that it had 'invisible'
+ // trailing stuff
+ if (item->m_curValue.GetLength() >= 2 &&
+ item->m_curValue[0] == '\'' &&
+ item->m_curValue[item->m_curValue.GetLength() - 1] == '\'')
+ {
+ entry->m_Value = item->m_curValue.Mid(1,
+ item->m_curValue.GetLength() - 2);
+ }
+ else
+ {
+ entry->m_Value = item->m_curValue;
+ }
}
}
}
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index c3af5e4340..a8ea49ab41 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -127,21 +127,34 @@ bool cmCacheManager::ParseEntry(const char* entry,
cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
// input line is: "key":type=value
cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
+ bool flag = false;
if(regQuoted.find(entry))
{
var = regQuoted.match(1);
type = cmCacheManager::StringToType(regQuoted.match(2).c_str());
value = regQuoted.match(3);
- return true;
+ flag = true;
}
else if (reg.find(entry))
{
var = reg.match(1);
type = cmCacheManager::StringToType(reg.match(2).c_str());
value = reg.match(3);
- return true;
+ flag = true;
}
- return false;
+
+ // if value is enclosed in single quotes ('foo') then remove them
+ // it is used to enclose trailing space or tab
+ if (flag &&
+ value.size() >= 2 &&
+ value[0] == '\'' &&
+ value[value.size() - 1] == '\'')
+ {
+ value = value.substr(1,
+ value.size() - 2);
+ }
+
+ return flag;
}
bool cmCacheManager::LoadCache(const char* path,
@@ -365,8 +378,19 @@ bool cmCacheManager::SaveCache(const char* path)
key = i->first;
}
fout << key.c_str() << ":"
- << cmCacheManagerTypes[t] << "="
- << ce.m_Value << "\n\n";
+ << cmCacheManagerTypes[t] << "=";
+ // if value has trailing space or tab, enclose it in single quotes
+ if (ce.m_Value.size() &&
+ (ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
+ ce.m_Value[ce.m_Value.size() - 1] == '\t'))
+ {
+ fout << '\'' << ce.m_Value << '\'';
+ }
+ else
+ {
+ fout << ce.m_Value;
+ }
+ fout << "\n\n";
}
}
@@ -398,8 +422,19 @@ bool cmCacheManager::SaveCache(const char* path)
key = i->first;
}
fout << key.c_str() << ":"
- << cmCacheManagerTypes[t] << "="
- << ce.m_Value << "\n";
+ << cmCacheManagerTypes[t] << "=";
+ // if value has trailing space or tab, enclose it in single quotes
+ if (ce.m_Value.size() &&
+ (ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
+ ce.m_Value[ce.m_Value.size() - 1] == '\t'))
+ {
+ fout << '\'' << ce.m_Value << '\'';
+ }
+ else
+ {
+ fout << ce.m_Value;
+ }
+ fout << "\n";
}
}
fout << "\n";
@@ -408,7 +443,7 @@ bool cmCacheManager::SaveCache(const char* path)
cacheFile.c_str());
cmSystemTools::RemoveFile(tempFile.c_str());
return true;
-}
+ }
void cmCacheManager::OutputHelpString(std::ofstream& fout,
const std::string& helpString)
diff --git a/Source/cmNMakeMakefileGenerator.cxx b/Source/cmNMakeMakefileGenerator.cxx
index cd545d507b..d91149c960 100644
--- a/Source/cmNMakeMakefileGenerator.cxx
+++ b/Source/cmNMakeMakefileGenerator.cxx
@@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
{
- m_LibraryPathOption = "$(CMAKE_C_LIBPATH_FLAG)";
+ this->SetLibraryPathOption("@CMAKE_C_LIBPATH_FLAG@"); // Use @ here
this->SetObjectFileExtension("$(CMAKE_OBJECT_FILE_SUFFIX)");
this->SetExecutableExtension("$(CMAKE_EXECUTABLE_SUFFIX)");
this->SetLibraryPrefix("");
@@ -151,19 +151,14 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
"CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\n"
"CMAKE_C_FLAGS = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\n"
- "CMAKE_C_OUTPUT_OBJECT_FILE_FLAG = @CMAKE_C_OUTPUT_OBJECT_FILE_FLAG@\n"
- "CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG = @CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG@\n"
"CMAKE_C_LINK_EXECUTABLE_FLAG = @CMAKE_C_LINK_EXECUTABLE_FLAG@\n"
- "CMAKE_C_LIBPATH_FLAG = @CMAKE_C_LIBPATH_FLAG@\n"
"CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"
"CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n"
"CMAKE_LINKER = @CMAKE_LINKER@\n"
"CMAKE_LINKER_FLAGS = @CMAKE_LINKER_FLAGS@ @LINKER_BUILD_FLAGS@\n"
"CMAKE_LINKER_SHARED_LIBRARY_FLAG = @CMAKE_LINKER_SHARED_LIBRARY_FLAG@\n"
- "CMAKE_LINKER_OUTPUT_FILE_FLAG = @CMAKE_LINKER_OUTPUT_FILE_FLAG@\n"
"CMAKE_LIBRARY_MANAGER = @CMAKE_LIBRARY_MANAGER@\n"
"CMAKE_LIBRARY_MANAGER_FLAGS = @CMAKE_LIBRARY_MANAGER_FLAGS@\n"
- "CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG = @CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG@\n"
"CMAKE_OBJECT_FILE_SUFFIX = @CMAKE_OBJECT_FILE_SUFFIX@\n"
"CMAKE_EXECUTABLE_SUFFIX = @CMAKE_EXECUTABLE_SUFFIX@\n"
"CMAKE_STATICLIB_SUFFIX = @CMAKE_STATICLIB_SUFFIX@\n"
@@ -350,7 +345,14 @@ OutputBuildObjectFromSource(std::ostream& fout,
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand +=
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
- compileCommand += " $(CMAKE_C_OUTPUT_OBJECT_FILE_FLAG)";
+
+ // Need to get the definition here because this value might have
+ // trailing space (since it is directly prepended to the filename)
+ std::string output_object_file_flag =
+ m_Makefile->GetDefinition("CMAKE_C_OUTPUT_OBJECT_FILE_FLAG");
+ m_Makefile->ExpandVariablesInString(output_object_file_flag);
+
+ compileCommand += " " + output_object_file_flag;
compileCommand += objectFile;
}
else if (ext == "rc")
@@ -378,7 +380,14 @@ OutputBuildObjectFromSource(std::ostream& fout,
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand +=
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
- compileCommand += " $(CMAKE_C_OUTPUT_OBJECT_FILE_FLAG)";
+
+ // Need to get the definition here because this value might have
+ // trailing space (since it is directly prepended to the filename)
+ std::string output_object_file_flag =
+ m_Makefile->GetDefinition("CMAKE_C_OUTPUT_OBJECT_FILE_FLAG");
+ m_Makefile->ExpandVariablesInString(output_object_file_flag);
+
+ compileCommand += " " + output_object_file_flag;
compileCommand += objectFile;
}
m_QuoteNextCommand = false;
@@ -398,11 +407,20 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
std::string depend = "$(";
depend += name;
depend += "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)";
- std::string command = "$(CMAKE_LINKER) $(CMAKE_LINKER_SHARED_LIBRARY_FLAG) @<<\n\t";
- command += " $(" + std::string(name) + "_SRC_OBJS) $(CMAKE_LINKER_FLAGS) $(CMAKE_LINKER_OUTPUT_FILE_FLAG)";
+
+ // Need to get the definition here because this value might have
+ // trailing space (since it is directly prepended to the filename)
+ std::string linker_output_file_flag =
+ m_Makefile->GetDefinition("CMAKE_LINKER_OUTPUT_FILE_FLAG");
+ m_Makefile->ExpandVariablesInString(linker_output_file_flag);
+
+ std::string command = "$(CMAKE_LINKER) $(CMAKE_LINKER_SHARED_LIBRARY_FLAG) @<<\n\t $(CMAKE_LINKER_FLAGS) " + linker_output_file_flag;
+
std::string dllpath = m_LibraryOutputPath + std::string(name) + m_SharedLibraryExtension;
command += cmSystemTools::EscapeSpaces(dllpath.c_str());
- command += " ";
+
+ command += " $(" + std::string(name) + "_SRC_OBJS) ";
+
std::strstream linklibs;
this->OutputLinkLibraries(linklibs, name, t);
linklibs << std::ends;
@@ -440,7 +458,15 @@ void cmNMakeMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
std::string target = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
std::string depend = "$(";
depend += std::string(name) + "_SRC_OBJS)";
- std::string command = "$(CMAKE_LIBRARY_MANAGER) $(CMAKE_LIBRARY_MANAGER_FLAGS) @<<\n\t $(CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG)";
+
+ // Need to get the definition here because this value might have
+ // trailing space (since it is directly prepended to the filename)
+ std::string library_manager_output_file_flag =
+ m_Makefile->GetDefinition("CMAKE_LIBRARY_MANAGER_OUTPUT_FILE_FLAG");
+ m_Makefile->ExpandVariablesInString(library_manager_output_file_flag);
+
+ std::string command = "$(CMAKE_LIBRARY_MANAGER) $(CMAKE_LIBRARY_MANAGER_FLAGS) @<<\n\t " + library_manager_output_file_flag;
+
std::string libpath = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
command += cmSystemTools::EscapeSpaces(libpath.c_str());
command += " $(";
@@ -468,8 +494,16 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
"$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) ";
command += "$(" + std::string(name) + "_SRC_OBJS) ";
std::string path = m_ExecutableOutputPath + name + m_ExecutableExtension;
- command += " $(CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG)" +
+
+ // Need to get the definition here because this value might have
+ // trailing space (since it is directly prepended to the filename)
+ std::string output_executable_file_flag =
+ m_Makefile->GetDefinition("CMAKE_C_OUTPUT_EXECUTABLE_FILE_FLAG");
+ m_Makefile->ExpandVariablesInString(output_executable_file_flag);
+
+ command += " " + output_executable_file_flag +
cmSystemTools::EscapeSpaces(path.c_str());
+
command += " $(CMAKE_C_LINK_EXECUTABLE_FLAG) ";
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
{
@@ -508,7 +542,12 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
std::string libpath = ShortPath(libDir->c_str());
if(emitted.insert(libpath).second)
{
- linkLibs += m_LibraryPathOption;
+ // Expand content because this value might have
+ // trailing space (since it is directly prepended to the filename)
+ std::string replaceVars = m_LibraryPathOption;
+ m_Makefile->ExpandVariablesInString(replaceVars);
+
+ linkLibs += replaceVars;
cmSystemTools::ConvertToWindowsSlashes(libpath);
linkLibs += libpath;
linkLibs += " ";