BUG: try to tell the difference between variables with sources and other variables

This commit is contained in:
Bill Hoffman 2002-06-25 09:59:08 -04:00
parent dae99c659d
commit 32353c55e5
1 changed files with 12 additions and 2 deletions

View File

@ -72,13 +72,23 @@ void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
{ {
const char* varValue = const char* varValue =
mf.GetDefinition(temps.c_str()); mf.GetDefinition(temps.c_str());
if (varValue) // if the definition exists
// and it has an extension in it then assume it is a source file
// the problem is that ADD_EXECUTABLE creates a definition with the
// same name as the executable which could be the same name as the
// source file without the extension, so if you do this:
// ADD_EXECUTABLE(foo foo) where foo.cxx is a source file, then
// foo will be varValue will be defined to the path of the executable, but
// not a source list as we expect, so look for a "." in the string to see
// if it is a file or not.
if (varValue
&& strchr(varValue, '.'))
{ {
std::vector<std::string> tval; std::vector<std::string> tval;
tval.push_back(varValue); tval.push_back(varValue);
std::vector<std::string> args; std::vector<std::string> args;
cmSystemTools::ExpandListArguments(tval, args); cmSystemTools::ExpandListArguments(tval, args);
int i; unsigned int i;
for (i = 0; i < args.size(); ++i) for (i = 0; i < args.size(); ++i)
{ {
if (mf.GetSource(args[i].c_str())) if (mf.GetSource(args[i].c_str()))