summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx19
-rw-r--r--Source/cmSourceFile.cxx13
-rw-r--r--Tests/ExternalOBJ/CMakeLists.txt11
3 files changed, 40 insertions, 3 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 54f063b..c89c587 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -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());
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 595e234..8e71afd 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -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;
}
diff --git a/Tests/ExternalOBJ/CMakeLists.txt b/Tests/ExternalOBJ/CMakeLists.txt
index 7607f69..cf95dc5 100644
--- a/Tests/ExternalOBJ/CMakeLists.txt
+++ b/Tests/ExternalOBJ/CMakeLists.txt
@@ -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})