BUG: Fixed support for external object files built by custom commands. Also added a test to keep it working.

This commit is contained in:
Brad King 2005-11-17 13:49:10 -05:00
parent 6ce463dab3
commit 70b4e1051e
3 changed files with 40 additions and 3 deletions

View File

@ -398,6 +398,13 @@ cmLocalUnixMakefileGenerator3
// This is an external object file. Just add it.
external_objects.push_back((*source)->GetFullPath());
}
else
{
// We only get here if a source file is not an external object
// and has an extension that is listed as an ignored file type
// for this language. No message or diagnosis should be
// given.
}
}
}
@ -1283,6 +1290,14 @@ cmLocalUnixMakefileGenerator3
// Add a dependency on the rule file itself.
this->AppendRuleDepend(depends, ruleFileName);
for(std::vector<std::string>::const_iterator obj = external_objects.begin();
obj != external_objects.end(); ++obj)
{
depends.push_back(*obj);
}
// from here up is the same for exe or lib
// Get the name of the executable to generate.
std::string targetName;
std::string targetNameReal;
@ -1602,14 +1617,14 @@ cmLocalUnixMakefileGenerator3
// Add a dependency on the rule file itself.
this->AppendRuleDepend(depends, ruleFileName);
// from here up is the same for exe or lib
for(std::vector<std::string>::const_iterator obj = external_objects.begin();
obj != external_objects.end(); ++obj)
{
depends.push_back(*obj);
}
// from here up is the same for exe or lib
// Get the language to use for linking this library.
const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());

View File

@ -70,6 +70,10 @@ void cmSourceFile::SetName(const char* name, const char* dir,
this->SetProperty("HEADER_FILE_ONLY","0");
}
m_FullPath = hname;
// Mark this as an external object file if it has the proper
// extension. THIS CODE IS DUPLICATED IN THE OTHER SetName METHOD.
// THESE METHODS SHOULD BE MERGED.
if ( m_SourceExtension == "obj" || m_SourceExtension == "o" ||
m_SourceExtension == "lo" )
{
@ -141,6 +145,15 @@ void cmSourceFile::SetName(const char* name, const char* dir, const char *ext,
m_FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir);
cmSystemTools::ConvertToUnixSlashes(m_FullPath);
m_SourceExtension = ext;
// Mark this as an external object file if it has the proper
// extension. THIS CODE IS DUPLICATED IN THE OTHER SetName METHOD.
// THESE METHODS SHOULD BE MERGED.
if ( m_SourceExtension == "obj" || m_SourceExtension == "o" ||
m_SourceExtension == "lo" )
{
this->SetProperty("EXTERNAL_OBJECT", "1");
}
return;
}

View File

@ -41,5 +41,14 @@ ELSE(EXTERNAL_OBJECT)
MESSAGE(FATAL_ERROR "Could not find ${EXTERNAL_OBJECT_NAME}.")
ENDIF(EXTERNAL_OBJECT)
# Test creation of external objects by custom commands.
SET(CUSTOM_OBJECT
${CMAKE_CURRENT_BINARY_DIR}/custom_object${CMAKE_C_OUTPUT_EXTENSION})
ADD_CUSTOM_COMMAND(
OUTPUT ${CUSTOM_OBJECT}
COMMAND ${CMAKE_COMMAND} -E copy ${EXTERNAL_OBJECT} ${CUSTOM_OBJECT}
DEPENDS ${EXTERNAL_OBJECT}
)
# Build an executable using the external object file.
ADD_EXECUTABLE(executable executable.cxx ${EXTERNAL_OBJECT})
ADD_EXECUTABLE(executable executable.cxx ${CUSTOM_OBJECT})