Add single quotes feature.
This commit is contained in:
parent
e273223d6d
commit
ecca17cfdd
|
@ -620,7 +620,17 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
||||||
i != cache.end(); ++i)
|
i != cache.end(); ++i)
|
||||||
{
|
{
|
||||||
const char* key = i->first.c_str();
|
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)
|
if(!m_AdvancedValues)
|
||||||
{
|
{
|
||||||
std::string advancedVar = key;
|
std::string advancedVar = key;
|
||||||
|
@ -721,10 +731,23 @@ void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
|
||||||
cmCacheManager::GetInstance()->GetCacheEntry(
|
cmCacheManager::GetInstance()->GetCacheEntry(
|
||||||
(const char*)item->m_propName);
|
(const char*)item->m_propName);
|
||||||
if (entry)
|
if (entry)
|
||||||
|
{
|
||||||
|
// 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;
|
entry->m_Value = item->m_curValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,21 +127,34 @@ bool cmCacheManager::ParseEntry(const char* entry,
|
||||||
cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
|
cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
|
||||||
// input line is: "key":type=value
|
// input line is: "key":type=value
|
||||||
cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
|
cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
|
||||||
|
bool flag = false;
|
||||||
if(regQuoted.find(entry))
|
if(regQuoted.find(entry))
|
||||||
{
|
{
|
||||||
var = regQuoted.match(1);
|
var = regQuoted.match(1);
|
||||||
type = cmCacheManager::StringToType(regQuoted.match(2).c_str());
|
type = cmCacheManager::StringToType(regQuoted.match(2).c_str());
|
||||||
value = regQuoted.match(3);
|
value = regQuoted.match(3);
|
||||||
return true;
|
flag = true;
|
||||||
}
|
}
|
||||||
else if (reg.find(entry))
|
else if (reg.find(entry))
|
||||||
{
|
{
|
||||||
var = reg.match(1);
|
var = reg.match(1);
|
||||||
type = cmCacheManager::StringToType(reg.match(2).c_str());
|
type = cmCacheManager::StringToType(reg.match(2).c_str());
|
||||||
value = reg.match(3);
|
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,
|
bool cmCacheManager::LoadCache(const char* path,
|
||||||
|
@ -365,8 +378,19 @@ bool cmCacheManager::SaveCache(const char* path)
|
||||||
key = i->first;
|
key = i->first;
|
||||||
}
|
}
|
||||||
fout << key.c_str() << ":"
|
fout << key.c_str() << ":"
|
||||||
<< cmCacheManagerTypes[t] << "="
|
<< cmCacheManagerTypes[t] << "=";
|
||||||
<< ce.m_Value << "\n\n";
|
// 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;
|
key = i->first;
|
||||||
}
|
}
|
||||||
fout << key.c_str() << ":"
|
fout << key.c_str() << ":"
|
||||||
<< cmCacheManagerTypes[t] << "="
|
<< cmCacheManagerTypes[t] << "=";
|
||||||
<< ce.m_Value << "\n";
|
// 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";
|
fout << "\n";
|
||||||
|
@ -408,7 +443,7 @@ bool cmCacheManager::SaveCache(const char* path)
|
||||||
cacheFile.c_str());
|
cacheFile.c_str());
|
||||||
cmSystemTools::RemoveFile(tempFile.c_str());
|
cmSystemTools::RemoveFile(tempFile.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCacheManager::OutputHelpString(std::ofstream& fout,
|
void cmCacheManager::OutputHelpString(std::ofstream& fout,
|
||||||
const std::string& helpString)
|
const std::string& helpString)
|
||||||
|
|
|
@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
|
cmNMakeMakefileGenerator::cmNMakeMakefileGenerator()
|
||||||
{
|
{
|
||||||
m_LibraryPathOption = "$(CMAKE_C_LIBPATH_FLAG)";
|
this->SetLibraryPathOption("@CMAKE_C_LIBPATH_FLAG@"); // Use @ here
|
||||||
this->SetObjectFileExtension("$(CMAKE_OBJECT_FILE_SUFFIX)");
|
this->SetObjectFileExtension("$(CMAKE_OBJECT_FILE_SUFFIX)");
|
||||||
this->SetExecutableExtension("$(CMAKE_EXECUTABLE_SUFFIX)");
|
this->SetExecutableExtension("$(CMAKE_EXECUTABLE_SUFFIX)");
|
||||||
this->SetLibraryPrefix("");
|
this->SetLibraryPrefix("");
|
||||||
|
@ -151,19 +151,14 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
|
||||||
"CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\n"
|
"CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\n"
|
||||||
"CMAKE_C_FLAGS = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\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_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_FLAGS = @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"
|
||||||
"CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n"
|
"CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n"
|
||||||
"CMAKE_LINKER = @CMAKE_LINKER@\n"
|
"CMAKE_LINKER = @CMAKE_LINKER@\n"
|
||||||
"CMAKE_LINKER_FLAGS = @CMAKE_LINKER_FLAGS@ @LINKER_BUILD_FLAGS@\n"
|
"CMAKE_LINKER_FLAGS = @CMAKE_LINKER_FLAGS@ @LINKER_BUILD_FLAGS@\n"
|
||||||
"CMAKE_LINKER_SHARED_LIBRARY_FLAG = @CMAKE_LINKER_SHARED_LIBRARY_FLAG@\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 = @CMAKE_LIBRARY_MANAGER@\n"
|
||||||
"CMAKE_LIBRARY_MANAGER_FLAGS = @CMAKE_LIBRARY_MANAGER_FLAGS@\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_OBJECT_FILE_SUFFIX = @CMAKE_OBJECT_FILE_SUFFIX@\n"
|
||||||
"CMAKE_EXECUTABLE_SUFFIX = @CMAKE_EXECUTABLE_SUFFIX@\n"
|
"CMAKE_EXECUTABLE_SUFFIX = @CMAKE_EXECUTABLE_SUFFIX@\n"
|
||||||
"CMAKE_STATICLIB_SUFFIX = @CMAKE_STATICLIB_SUFFIX@\n"
|
"CMAKE_STATICLIB_SUFFIX = @CMAKE_STATICLIB_SUFFIX@\n"
|
||||||
|
@ -350,7 +345,14 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
||||||
compileCommand += "$(INCLUDE_FLAGS) -c ";
|
compileCommand += "$(INCLUDE_FLAGS) -c ";
|
||||||
compileCommand +=
|
compileCommand +=
|
||||||
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
|
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;
|
compileCommand += objectFile;
|
||||||
}
|
}
|
||||||
else if (ext == "rc")
|
else if (ext == "rc")
|
||||||
|
@ -378,7 +380,14 @@ OutputBuildObjectFromSource(std::ostream& fout,
|
||||||
compileCommand += "$(INCLUDE_FLAGS) -c ";
|
compileCommand += "$(INCLUDE_FLAGS) -c ";
|
||||||
compileCommand +=
|
compileCommand +=
|
||||||
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
|
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;
|
compileCommand += objectFile;
|
||||||
}
|
}
|
||||||
m_QuoteNextCommand = false;
|
m_QuoteNextCommand = false;
|
||||||
|
@ -398,11 +407,20 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
|
||||||
std::string depend = "$(";
|
std::string depend = "$(";
|
||||||
depend += name;
|
depend += name;
|
||||||
depend += "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)";
|
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;
|
std::string dllpath = m_LibraryOutputPath + std::string(name) + m_SharedLibraryExtension;
|
||||||
command += cmSystemTools::EscapeSpaces(dllpath.c_str());
|
command += cmSystemTools::EscapeSpaces(dllpath.c_str());
|
||||||
command += " ";
|
|
||||||
|
command += " $(" + std::string(name) + "_SRC_OBJS) ";
|
||||||
|
|
||||||
std::strstream linklibs;
|
std::strstream linklibs;
|
||||||
this->OutputLinkLibraries(linklibs, name, t);
|
this->OutputLinkLibraries(linklibs, name, t);
|
||||||
linklibs << std::ends;
|
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 target = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
|
||||||
std::string depend = "$(";
|
std::string depend = "$(";
|
||||||
depend += std::string(name) + "_SRC_OBJS)";
|
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;
|
std::string libpath = m_LibraryOutputPath + std::string(name) + m_StaticLibraryExtension;
|
||||||
command += cmSystemTools::EscapeSpaces(libpath.c_str());
|
command += cmSystemTools::EscapeSpaces(libpath.c_str());
|
||||||
command += " $(";
|
command += " $(";
|
||||||
|
@ -468,8 +494,16 @@ void cmNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout,
|
||||||
"$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) ";
|
"$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) ";
|
||||||
command += "$(" + std::string(name) + "_SRC_OBJS) ";
|
command += "$(" + std::string(name) + "_SRC_OBJS) ";
|
||||||
std::string path = m_ExecutableOutputPath + name + m_ExecutableExtension;
|
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());
|
cmSystemTools::EscapeSpaces(path.c_str());
|
||||||
|
|
||||||
command += " $(CMAKE_C_LINK_EXECUTABLE_FLAG) ";
|
command += " $(CMAKE_C_LINK_EXECUTABLE_FLAG) ";
|
||||||
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
|
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
|
||||||
{
|
{
|
||||||
|
@ -508,7 +542,12 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||||
std::string libpath = ShortPath(libDir->c_str());
|
std::string libpath = ShortPath(libDir->c_str());
|
||||||
if(emitted.insert(libpath).second)
|
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);
|
cmSystemTools::ConvertToWindowsSlashes(libpath);
|
||||||
linkLibs += libpath;
|
linkLibs += libpath;
|
||||||
linkLibs += " ";
|
linkLibs += " ";
|
||||||
|
|
Loading…
Reference in New Issue