ENH: fix build c stuff with c and c++ with c++
This commit is contained in:
parent
8268d16bbb
commit
1794836ee3
|
@ -262,6 +262,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
|
|||
{"EnableEnhancedInstructionSet", "arch:SSE", "Use sse instructions", "1"},
|
||||
{"FavorSizeOrSpeed", "Ot", "Favor fast code", "1"},
|
||||
{"FavorSizeOrSpeed", "Os", "Favor small code", "2"},
|
||||
{"CompileAs", "TC", "Compile as c code", "1"},
|
||||
{"CompileAs", "TP", "Compile as c++ code", "2"},
|
||||
{"Optimization", "Od", "Non Debug", "0"},
|
||||
{"Optimization", "O1", "Min Size", "1"},
|
||||
{"Optimization", "O2", "Max Speed", "2"},
|
||||
|
@ -395,6 +397,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
flags += " ";
|
||||
flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
||||
}
|
||||
// set the correct language
|
||||
if(strcmp(linkLanguage, "C") == 0)
|
||||
{
|
||||
flags += " /TC ";
|
||||
}
|
||||
if(strcmp(linkLanguage, "CXX") == 0)
|
||||
{
|
||||
flags += " /TP ";
|
||||
}
|
||||
std::cerr << flags << "\n";
|
||||
}
|
||||
|
||||
// Add the target-specific flags.
|
||||
|
@ -1035,10 +1047,21 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
|
|||
}
|
||||
const char* lang =
|
||||
this->GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
|
||||
if(lang && strcmp(lang, "CXX") == 0)
|
||||
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||
// if the source file does not match the linker language
|
||||
// then force c or c++
|
||||
if(linkLanguage && lang && strcmp(lang, linkLanguage) != 0)
|
||||
{
|
||||
// force a C++ file type
|
||||
compileFlags += " /TP ";
|
||||
if(strcmp(lang, "CXX") == 0)
|
||||
{
|
||||
// force a C++ file type
|
||||
compileFlags += " /TP ";
|
||||
}
|
||||
else if(strcmp(lang, "C") == 0)
|
||||
{
|
||||
// force to c
|
||||
compileFlags += " /TC ";
|
||||
}
|
||||
}
|
||||
// Check for extra object-file dependencies.
|
||||
const char* deps = (*sf)->GetProperty("OBJECT_DEPENDS");
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
int main ()
|
||||
{
|
||||
int class = 0;
|
||||
if ( LibC1Func() != 2.0 )
|
||||
{
|
||||
printf("Problem with libc1\n");
|
||||
|
@ -17,6 +18,6 @@ int main ()
|
|||
printf("Problem with libc2\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Foo: %s\n", foo);
|
||||
printf("Foo: %s %d\n", foo, class);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue