Merge topic 'makefile-assign-escape-octothorpe'
fbf7a929
Makefile: Handle '#' in COMPILE_OPTIONS (#15070)
This commit is contained in:
commit
3353657919
|
@ -361,9 +361,13 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
|||
for(std::set<std::string>::const_iterator l = languages.begin();
|
||||
l != languages.end(); ++l)
|
||||
{
|
||||
*this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n";
|
||||
*this->FlagFileStream << *l << "_DEFINES = " << this->GetDefines(*l) <<
|
||||
"\n\n";
|
||||
std::string flags = this->GetFlags(*l);
|
||||
std::string defines = this->GetDefines(*l);
|
||||
// Escape comment characters so they do not terminate assignment.
|
||||
cmSystemTools::ReplaceString(flags, "#", "\\#");
|
||||
cmSystemTools::ReplaceString(defines, "#", "\\#");
|
||||
*this->FlagFileStream << *l << "_FLAGS = " << flags << "\n\n";
|
||||
*this->FlagFileStream << *l << "_DEFINES = " << defines << "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,12 @@ set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS
|
|||
${cxx_tests}
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland")
|
||||
set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS
|
||||
"-DTEST_OCTOTHORPE=\"#\""
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(CompileOptions testlib)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
int main()
|
||||
{
|
||||
return (strcmp(NEEDS_ESCAPE, "E$CAPE") == 0
|
||||
#ifdef TEST_OCTOTHORPE
|
||||
&& strcmp(TEST_OCTOTHORPE, "#") == 0
|
||||
#endif
|
||||
&& strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0
|
||||
&& strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == 0
|
||||
&& TEST_C_COMPILER_VERSION_EQUALITY == 1
|
||||
|
|
Loading…
Reference in New Issue