BUG: Fixed support for external object files built by custom commands. Also added a test to keep it working.
This commit is contained in:
parent
6ce463dab3
commit
70b4e1051e
@ -398,6 +398,13 @@ cmLocalUnixMakefileGenerator3
|
|||||||
// This is an external object file. Just add it.
|
// This is an external object file. Just add it.
|
||||||
external_objects.push_back((*source)->GetFullPath());
|
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.
|
// Add a dependency on the rule file itself.
|
||||||
this->AppendRuleDepend(depends, ruleFileName);
|
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.
|
// Get the name of the executable to generate.
|
||||||
std::string targetName;
|
std::string targetName;
|
||||||
std::string targetNameReal;
|
std::string targetNameReal;
|
||||||
@ -1602,14 +1617,14 @@ cmLocalUnixMakefileGenerator3
|
|||||||
// Add a dependency on the rule file itself.
|
// Add a dependency on the rule file itself.
|
||||||
this->AppendRuleDepend(depends, ruleFileName);
|
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();
|
for(std::vector<std::string>::const_iterator obj = external_objects.begin();
|
||||||
obj != external_objects.end(); ++obj)
|
obj != external_objects.end(); ++obj)
|
||||||
{
|
{
|
||||||
depends.push_back(*obj);
|
depends.push_back(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from here up is the same for exe or lib
|
||||||
|
|
||||||
// Get the language to use for linking this library.
|
// Get the language to use for linking this library.
|
||||||
const char* linkLanguage =
|
const char* linkLanguage =
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||||
|
@ -70,6 +70,10 @@ void cmSourceFile::SetName(const char* name, const char* dir,
|
|||||||
this->SetProperty("HEADER_FILE_ONLY","0");
|
this->SetProperty("HEADER_FILE_ONLY","0");
|
||||||
}
|
}
|
||||||
m_FullPath = hname;
|
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" ||
|
if ( m_SourceExtension == "obj" || m_SourceExtension == "o" ||
|
||||||
m_SourceExtension == "lo" )
|
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);
|
m_FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir);
|
||||||
cmSystemTools::ConvertToUnixSlashes(m_FullPath);
|
cmSystemTools::ConvertToUnixSlashes(m_FullPath);
|
||||||
m_SourceExtension = ext;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,5 +41,14 @@ ELSE(EXTERNAL_OBJECT)
|
|||||||
MESSAGE(FATAL_ERROR "Could not find ${EXTERNAL_OBJECT_NAME}.")
|
MESSAGE(FATAL_ERROR "Could not find ${EXTERNAL_OBJECT_NAME}.")
|
||||||
ENDIF(EXTERNAL_OBJECT)
|
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.
|
# Build an executable using the external object file.
|
||||||
ADD_EXECUTABLE(executable executable.cxx ${EXTERNAL_OBJECT})
|
ADD_EXECUTABLE(executable executable.cxx ${CUSTOM_OBJECT})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user