ENH: fix java and add OBJECT_DIR support
This commit is contained in:
parent
0f8603acc2
commit
5ecfd3d4d3
|
@ -15,14 +15,14 @@ ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
|
||||||
# this is a place holder if java needed flags for javac they would go here.
|
# this is a place holder if java needed flags for javac they would go here.
|
||||||
IF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY)
|
IF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY)
|
||||||
SET(CMAKE_Java_CREATE_STATIC_LIBRARY
|
SET(CMAKE_Java_CREATE_STATIC_LIBRARY
|
||||||
"<CMAKE_Java_ARCHIVE> -cf <TARGET> *.class")
|
"<CMAKE_Java_ARCHIVE> -cf <TARGET> -C <OBJECT_DIR> .")
|
||||||
# should be this <OBJECTS> but compling a java file can create more than one .class file
|
# should be this <OBJECTS> but compling a java file can create more than one .class file
|
||||||
# so for now get all of them
|
# so for now get all of them
|
||||||
ENDIF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY)
|
ENDIF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY)
|
||||||
# compile a Java file into an object file
|
# compile a Java file into an object file
|
||||||
IF(NOT CMAKE_Java_COMPILE_OBJECT)
|
IF(NOT CMAKE_Java_COMPILE_OBJECT)
|
||||||
SET(CMAKE_Java_COMPILE_OBJECT
|
SET(CMAKE_Java_COMPILE_OBJECT
|
||||||
"<CMAKE_Java_COMPILER> <FLAGS> <SOURCE> -d <CMAKE_CURRENT_BINARY_DIR>")
|
"<CMAKE_Java_COMPILER> <FLAGS> <SOURCE> -d <OBJECT_DIR>")
|
||||||
ENDIF(NOT CMAKE_Java_COMPILE_OBJECT)
|
ENDIF(NOT CMAKE_Java_COMPILE_OBJECT)
|
||||||
|
|
||||||
# set java include flag option and the separator for multiple include paths
|
# set java include flag option and the separator for multiple include paths
|
||||||
|
|
|
@ -457,6 +457,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
||||||
cmSourceFile& source,
|
cmSourceFile& source,
|
||||||
cmTarget& )
|
cmTarget& )
|
||||||
{
|
{
|
||||||
|
std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
|
||||||
std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
|
std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
|
||||||
std::string sourceFile =
|
std::string sourceFile =
|
||||||
this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
|
this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
|
||||||
|
@ -481,6 +482,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
||||||
vars.Language = lang;
|
vars.Language = lang;
|
||||||
vars.Source = sourceFile.c_str();
|
vars.Source = sourceFile.c_str();
|
||||||
vars.Object = objectFile.c_str();
|
vars.Object = objectFile.c_str();
|
||||||
|
vars.ObjectDir = objectDir.c_str();
|
||||||
vars.Flags = flags.c_str();
|
vars.Flags = flags.c_str();
|
||||||
for(std::vector<std::string>::iterator i = commands.begin();
|
for(std::vector<std::string>::iterator i = commands.begin();
|
||||||
i != commands.end(); ++i)
|
i != commands.end(); ++i)
|
||||||
|
@ -568,6 +570,10 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
|
||||||
cmLocalGenerator::RuleVariables vars;
|
cmLocalGenerator::RuleVariables vars;
|
||||||
vars.Language = llang;
|
vars.Language = llang;
|
||||||
vars.Objects = objs.c_str();
|
vars.Objects = objs.c_str();
|
||||||
|
std::string objdir = "CMakeFiles/";
|
||||||
|
objdir += targetName;
|
||||||
|
objdir += ".dir";
|
||||||
|
vars.ObjectDir = objdir.c_str();
|
||||||
vars.Target = targetName.c_str();
|
vars.Target = targetName.c_str();
|
||||||
vars.LinkLibraries = linkLibs.c_str();
|
vars.LinkLibraries = linkLibs.c_str();
|
||||||
vars.Flags = flags.c_str();
|
vars.Flags = flags.c_str();
|
||||||
|
@ -583,7 +589,6 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
|
||||||
{
|
{
|
||||||
// Expand the full command line string.
|
// Expand the full command line string.
|
||||||
this->ExpandRuleVariables(*i, vars);
|
this->ExpandRuleVariables(*i, vars);
|
||||||
|
|
||||||
// Parse the string to get the custom command line.
|
// Parse the string to get the custom command line.
|
||||||
cmCustomCommandLine commandLine;
|
cmCustomCommandLine commandLine;
|
||||||
std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
|
std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
|
||||||
|
@ -710,6 +715,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
|
||||||
return replaceValues.Object;
|
return replaceValues.Object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(replaceValues.ObjectDir)
|
||||||
|
{
|
||||||
|
if(variable == "OBJECT_DIR")
|
||||||
|
{
|
||||||
|
return replaceValues.ObjectDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(replaceValues.Objects)
|
if(replaceValues.Objects)
|
||||||
{
|
{
|
||||||
if(variable == "OBJECTS")
|
if(variable == "OBJECTS")
|
||||||
|
|
|
@ -185,6 +185,7 @@ public:
|
||||||
this->LinkLibraries= 0;
|
this->LinkLibraries= 0;
|
||||||
this->Source= 0;
|
this->Source= 0;
|
||||||
this->Object= 0;
|
this->Object= 0;
|
||||||
|
this->ObjectDir= 0;
|
||||||
this->Flags= 0;
|
this->Flags= 0;
|
||||||
this->ObjectsQuoted= 0;
|
this->ObjectsQuoted= 0;
|
||||||
this->TargetSOName= 0;
|
this->TargetSOName= 0;
|
||||||
|
@ -197,6 +198,7 @@ public:
|
||||||
const char* LinkLibraries;
|
const char* LinkLibraries;
|
||||||
const char* Source;
|
const char* Source;
|
||||||
const char* Object;
|
const char* Object;
|
||||||
|
const char* ObjectDir;
|
||||||
const char* Flags;
|
const char* Flags;
|
||||||
const char* ObjectsQuoted;
|
const char* ObjectsQuoted;
|
||||||
const char* TargetSOName;
|
const char* TargetSOName;
|
||||||
|
|
|
@ -404,6 +404,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
||||||
cmLocalGenerator::RuleVariables vars;
|
cmLocalGenerator::RuleVariables vars;
|
||||||
vars.Language = linkLanguage;
|
vars.Language = linkLanguage;
|
||||||
vars.Objects = buildObjs.c_str();
|
vars.Objects = buildObjs.c_str();
|
||||||
|
std::string objdir = "CMakeFiles/";
|
||||||
|
objdir += this->Target->GetName();
|
||||||
|
objdir += ".dir";
|
||||||
|
vars.ObjectDir = objdir.c_str();
|
||||||
vars.Target = targetOutPathReal.c_str();
|
vars.Target = targetOutPathReal.c_str();
|
||||||
std::string linkString = linklibs.str();
|
std::string linkString = linklibs.str();
|
||||||
vars.LinkLibraries = linkString.c_str();
|
vars.LinkLibraries = linkString.c_str();
|
||||||
|
|
|
@ -389,6 +389,12 @@ cmMakefileTargetGenerator
|
||||||
vars.Language = lang;
|
vars.Language = lang;
|
||||||
vars.Source = sourceFile.c_str();
|
vars.Source = sourceFile.c_str();
|
||||||
vars.Object = relativeObj.c_str();
|
vars.Object = relativeObj.c_str();
|
||||||
|
std::string objdir = this->LocalGenerator->GetHomeRelativeOutputPath();
|
||||||
|
objdir = this->Convert(objdir.c_str(),
|
||||||
|
cmLocalGenerator::START_OUTPUT,
|
||||||
|
cmLocalGenerator::SHELL);
|
||||||
|
std::string objectDir = cmSystemTools::GetFilenamePath(obj);
|
||||||
|
vars.ObjectDir = objectDir.c_str();
|
||||||
vars.Flags = flags.c_str();
|
vars.Flags = flags.c_str();
|
||||||
|
|
||||||
// Expand placeholders in the commands.
|
// Expand placeholders in the commands.
|
||||||
|
|
Loading…
Reference in New Issue