ENH: add working directory support
This commit is contained in:
parent
6fe45fe9c3
commit
347c5f4b46
|
@ -115,6 +115,17 @@ IF(NOT CMAKE_Fortran_LINK_EXECUTABLE)
|
|||
ENDIF(NOT CMAKE_Fortran_LINK_EXECUTABLE)
|
||||
|
||||
|
||||
IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||
SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG_INIT}" CACHE STRING
|
||||
"Flags used by the compiler during debug builds.")
|
||||
SET (CMAKE_Fortran_FLAGS_MINSIZEREL "${CMAKE_Fortran_FLAGS_MINSIZEREL_INIT}" CACHE STRING
|
||||
"Flags used by the compiler during release minsize builds.")
|
||||
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE_INIT}" CACHE STRING
|
||||
"Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).")
|
||||
SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
|
||||
"Flags used by the compiler during Release with Debug Info builds.")
|
||||
|
||||
ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
CMAKE_Fortran_FLAGS
|
||||
|
|
|
@ -365,7 +365,19 @@ IF(BUILD_TESTING)
|
|||
--build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin"
|
||||
--test-command CustomCommand
|
||||
)
|
||||
|
||||
IF(FALSE)
|
||||
ADD_TEST(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory"
|
||||
"${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory"
|
||||
--build-two-config
|
||||
--build-generator ${CMAKE_TEST_GENERATOR}
|
||||
--build-project TestWorkingDir
|
||||
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
|
||||
--build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory"
|
||||
--test-command working
|
||||
)
|
||||
ENDIF(FALSE)
|
||||
ADD_TEST(FindPackageTest ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindPackageTest"
|
||||
|
|
|
@ -31,7 +31,8 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string source, target, comment, output, main_dependency;
|
||||
std::string source, target, comment, output, main_dependency,
|
||||
working;
|
||||
std::vector<std::string> depends, outputs;
|
||||
|
||||
// Accumulate one command line at a time.
|
||||
|
@ -51,6 +52,7 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
|||
doing_output,
|
||||
doing_outputs,
|
||||
doing_comment,
|
||||
doing_working_directory,
|
||||
doing_nothing
|
||||
};
|
||||
|
||||
|
@ -107,6 +109,10 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
|||
{
|
||||
doing = doing_output;
|
||||
}
|
||||
else if (copy == "WORKING_DIRECTORY")
|
||||
{
|
||||
doing = doing_working_directory;
|
||||
}
|
||||
else if (copy == "MAIN_DEPENDENCY")
|
||||
{
|
||||
doing = doing_main_dependency;
|
||||
|
@ -141,6 +147,9 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
|||
|
||||
switch (doing)
|
||||
{
|
||||
case doing_working_directory:
|
||||
working = copy;
|
||||
break;
|
||||
case doing_source:
|
||||
source = copy;
|
||||
break;
|
||||
|
@ -210,14 +219,15 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
|||
std::vector<std::string> no_depends;
|
||||
m_Makefile->AddCustomCommandToTarget(target.c_str(), no_depends,
|
||||
commandLines, cctype,
|
||||
comment.c_str());
|
||||
comment.c_str(), working.c_str());
|
||||
}
|
||||
else if(target.empty())
|
||||
{
|
||||
// Target is empty, use the output.
|
||||
m_Makefile->AddCustomCommandToOutput(output.c_str(), depends,
|
||||
main_dependency.c_str(),
|
||||
commandLines, comment.c_str());
|
||||
commandLines, comment.c_str(),
|
||||
working.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
" [COMMAND command2 [ARGS] [args2...] ...]\n"
|
||||
" [MAIN_DEPENDENCY depend]\n"
|
||||
" [DEPENDS [depends...]]\n"
|
||||
" [WORKING_DIRECTORY dir]\n"
|
||||
" [COMMENT comment])\n"
|
||||
"This defines a new command that can be executed during the build "
|
||||
"process. Note that MAIN_DEPENDENCY is completely optional and is "
|
||||
|
@ -89,6 +90,7 @@ public:
|
|||
" PRE_BUILD | PRE_LINK | POST_BUILD\n"
|
||||
" COMMAND command1 [ARGS] [args1...]\n"
|
||||
" [COMMAND command2 [ARGS] [args2...] ...]\n"
|
||||
" [WORKING_DIRECTORY dir]\n"
|
||||
" [COMMENT comment])\n"
|
||||
"This defines a new command that will be associated with "
|
||||
"building the specified target. When the command will "
|
||||
|
@ -98,7 +100,9 @@ public:
|
|||
" POST_BUILD - run after the target has been built\n"
|
||||
"Note that the PRE_BUILD option is only supported on Visual "
|
||||
"Studio 7 or later. For all other generators PRE_BUILD "
|
||||
"will be treated as PRE_LINK.";
|
||||
"will be treated as PRE_LINK."
|
||||
"If WORKING_DIRECTORY is specified the command a cd \"dir\" is "
|
||||
"done prior to running the command.";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
|
||||
|
|
|
@ -33,11 +33,13 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
|
|||
|
||||
// Accumulate dependencies.
|
||||
std::vector<std::string> depends;
|
||||
std::string working_directory;
|
||||
|
||||
// Keep track of parser state.
|
||||
enum tdoing {
|
||||
doing_command,
|
||||
doing_depends
|
||||
doing_depends,
|
||||
doing_working_directory
|
||||
};
|
||||
tdoing doing = doing_command;
|
||||
|
||||
|
@ -62,6 +64,10 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
|
|||
{
|
||||
doing = doing_depends;
|
||||
}
|
||||
if(copy == "WORKING_DIRECTORY")
|
||||
{
|
||||
doing = doing_working_directory;
|
||||
}
|
||||
else if(copy == "COMMAND")
|
||||
{
|
||||
doing = doing_command;
|
||||
|
@ -77,6 +83,9 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
|
|||
{
|
||||
switch (doing)
|
||||
{
|
||||
case doing_working_directory:
|
||||
working_directory = copy;
|
||||
break;
|
||||
case doing_command:
|
||||
currentLine.push_back(copy);
|
||||
break;
|
||||
|
@ -109,7 +118,8 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
|
|||
|
||||
// Add the utility target to the makefile.
|
||||
const char* no_output = 0;
|
||||
m_Makefile->AddUtilityCommand(args[0].c_str(), all, no_output, depends,
|
||||
m_Makefile->AddUtilityCommand(args[0].c_str(), all, no_output,
|
||||
working_directory.c_str(), depends,
|
||||
commandLines);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
" ADD_CUSTOM_TARGET(Name [ALL] [command1 [args1...]]\n"
|
||||
" [COMMAND command2 [args2...] ...]\n"
|
||||
" [DEPENDS depend depend depend ... ])\n"
|
||||
" [WORKING_DIRECTORY dir]\n"
|
||||
"Adds a target with the given name that executes the given commands "
|
||||
"every time the target is built. If the ALL option is specified "
|
||||
"it indicates that this target should be added to the default build "
|
||||
|
@ -73,7 +74,9 @@ public:
|
|||
"The command and arguments are optional. If not specified, "
|
||||
"it will create an empty target. The ADD_DEPENDENCIES command can be "
|
||||
"used in conjunction with this command to drive custom target "
|
||||
"generation. The command cannot be called ALL.";
|
||||
"generation. The command cannot be called ALL. "
|
||||
"If WORKING_DIRECTORY is set, then the command will be run in that "
|
||||
"directory.";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmAddCustomTargetCommand, cmCommand);
|
||||
|
|
|
@ -240,7 +240,7 @@ void CCONV cmAddUtilityCommand(void *arg, const char* utilityName,
|
|||
|
||||
// Pass the call to the makefile instance.
|
||||
mf->AddUtilityCommand(utilityName, (all ? true : false),
|
||||
output, depends2, commandLines);
|
||||
output, 0, depends2, commandLines);
|
||||
}
|
||||
void CCONV cmAddCustomCommand(void *arg, const char* source,
|
||||
const char* command,
|
||||
|
@ -319,8 +319,9 @@ void CCONV cmAddCustomCommandToOutput(void *arg, const char* output,
|
|||
|
||||
// Pass the call to the makefile instance.
|
||||
const char* no_comment = 0;
|
||||
const char* no_working_dir = 0;
|
||||
mf->AddCustomCommandToOutput(output, depends2, main_dependency,
|
||||
commandLines, no_comment);
|
||||
commandLines, no_comment, no_working_dir);
|
||||
}
|
||||
|
||||
void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
|
||||
|
@ -362,8 +363,9 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
|
|||
// Pass the call to the makefile instance.
|
||||
std::vector<std::string> no_depends;
|
||||
const char* no_comment = 0;
|
||||
const char* no_working_dir = 0;
|
||||
mf->AddCustomCommandToTarget(target, no_depends, commandLines,
|
||||
cctype, no_comment);
|
||||
cctype, no_comment, no_working_dir);
|
||||
}
|
||||
|
||||
void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt, const char*value,
|
||||
|
|
|
@ -27,7 +27,8 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
|
|||
m_Output(r.m_Output),
|
||||
m_Depends(r.m_Depends),
|
||||
m_CommandLines(r.m_CommandLines),
|
||||
m_Comment(r.m_Comment)
|
||||
m_Comment(r.m_Comment),
|
||||
m_WorkingDirectory(r.m_WorkingDirectory)
|
||||
{
|
||||
m_Used = false;
|
||||
}
|
||||
|
@ -36,11 +37,12 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
|
|||
cmCustomCommand::cmCustomCommand(const char* output,
|
||||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
const char* comment):
|
||||
const char* comment, const char* workingDirectory):
|
||||
m_Output(output?output:""),
|
||||
m_Depends(depends),
|
||||
m_CommandLines(commandLines),
|
||||
m_Comment(comment?comment:"")
|
||||
m_Comment(comment?comment:""),
|
||||
m_WorkingDirectory(workingDirectory?workingDirectory:"")
|
||||
{
|
||||
m_Used = false;
|
||||
}
|
||||
|
@ -51,6 +53,16 @@ const char* cmCustomCommand::GetOutput() const
|
|||
return m_Output.c_str();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char* cmCustomCommand::GetWorkingDirectory() const
|
||||
{
|
||||
if(m_WorkingDirectory.size() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return m_WorkingDirectory.c_str();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const std::vector<std::string>& cmCustomCommand::GetDepends() const
|
||||
{
|
||||
|
|
|
@ -35,11 +35,15 @@ public:
|
|||
cmCustomCommand(const char* output,
|
||||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
const char* comment);
|
||||
const char* comment,
|
||||
const char* workingDirectory);
|
||||
|
||||
/** Get the output file produced by the command. */
|
||||
const char* GetOutput() const;
|
||||
|
||||
/** Get the working directory. */
|
||||
const char* GetWorkingDirectory() const;
|
||||
|
||||
/** Get the vector that holds the list of dependencies. */
|
||||
const std::vector<std::string>& GetDepends() const;
|
||||
|
||||
|
@ -58,6 +62,7 @@ private:
|
|||
std::vector<std::string> m_Depends;
|
||||
cmCustomCommandLines m_CommandLines;
|
||||
std::string m_Comment;
|
||||
std::string m_WorkingDirectory;
|
||||
bool m_Used;
|
||||
};
|
||||
|
||||
|
|
|
@ -81,12 +81,15 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args)
|
|||
// Add command for generating the .h and .cxx files
|
||||
const char* no_main_dependency = 0;
|
||||
const char* no_comment = 0;
|
||||
const char* no_working_dir = 0;
|
||||
m_Makefile->AddCustomCommandToOutput(cxxres.c_str(),
|
||||
depends, no_main_dependency,
|
||||
commandLines, no_comment);
|
||||
commandLines, no_comment,
|
||||
no_working_dir);
|
||||
m_Makefile->AddCustomCommandToOutput(hname.c_str(),
|
||||
depends, no_main_dependency,
|
||||
commandLines, no_comment);
|
||||
commandLines, no_comment,
|
||||
no_working_dir);
|
||||
|
||||
cmSourceFile *sf = m_Makefile->GetSource(cxxres.c_str());
|
||||
sf->GetDepends().push_back(hname);
|
||||
|
|
|
@ -1164,6 +1164,7 @@ void cmGlobalGenerator::SetupTests()
|
|||
if (total_tests > 0)
|
||||
{
|
||||
const char* no_output = 0;
|
||||
const char* no_working_dir = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
|
||||
|
@ -1176,6 +1177,7 @@ void cmGlobalGenerator::SetupTests()
|
|||
if(const char* outDir = mf->GetDefinition("CMAKE_CFG_INTDIR"))
|
||||
{
|
||||
mf->AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
|
||||
no_working_dir,
|
||||
ctest.c_str(), "-C", outDir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ void cmGlobalVisualStudio6Generator::Generate()
|
|||
// of one configuration only.
|
||||
const char* no_output = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
const char* no_working_dir = 0;
|
||||
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
|
||||
{
|
||||
|
@ -166,12 +167,12 @@ void cmGlobalVisualStudio6Generator::Generate()
|
|||
if(gen.size())
|
||||
{
|
||||
gen[0]->GetMakefile()->
|
||||
AddUtilityCommand("ALL_BUILD", false, no_output, no_depends,
|
||||
AddUtilityCommand("ALL_BUILD", false, no_output, no_depends, no_working_dir,
|
||||
"echo", "Build all projects");
|
||||
std::string cmake_command =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
gen[0]->GetMakefile()->
|
||||
AddUtilityCommand("INSTALL", false, no_output, no_depends,
|
||||
AddUtilityCommand("INSTALL", false, no_output, no_depends, no_working_dir,
|
||||
cmake_command.c_str(),
|
||||
"-DBUILD_TYPE=$(IntDir)", "-P", "cmake_install.cmake");
|
||||
|
||||
|
|
|
@ -190,6 +190,7 @@ void cmGlobalVisualStudio7Generator::Generate()
|
|||
// add a special target that depends on ALL projects for easy build
|
||||
// of one configuration only.
|
||||
const char* no_output = 0;
|
||||
const char* no_working_dir = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
|
||||
|
@ -200,11 +201,13 @@ void cmGlobalVisualStudio7Generator::Generate()
|
|||
{
|
||||
gen[0]->GetMakefile()->
|
||||
AddUtilityCommand("ALL_BUILD", false, no_output, no_depends,
|
||||
no_working_dir,
|
||||
"echo", "Build all projects");
|
||||
std::string cmake_command =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
gen[0]->GetMakefile()->
|
||||
AddUtilityCommand("INSTALL", false, no_output, no_depends,
|
||||
no_working_dir,
|
||||
cmake_command.c_str(),
|
||||
"-DBUILD_TYPE=$(OutDir)", "-P", "cmake_install.cmake");
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ void cmGlobalVisualStudio8Generator::Generate()
|
|||
// Add a special target on which all other targets depend that
|
||||
// checks the build system and optionally re-runs CMake.
|
||||
const char* no_output = 0;
|
||||
const char* no_working_directory = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
|
||||
|
@ -82,6 +83,7 @@ void cmGlobalVisualStudio8Generator::Generate()
|
|||
std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true,
|
||||
no_output, no_depends,
|
||||
no_working_directory,
|
||||
"echo", "Checking build system");
|
||||
|
||||
// Add a custom rule to re-run CMake if any input files changed.
|
||||
|
@ -127,9 +129,10 @@ void cmGlobalVisualStudio8Generator::Generate()
|
|||
// target.
|
||||
const char* no_comment = 0;
|
||||
const char* no_main_dependency = 0;
|
||||
const char* no_working_directory = 0;
|
||||
mf->AddCustomCommandToOutput(
|
||||
CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.cmake", listFiles,
|
||||
no_main_dependency, commandLines, no_comment, true);
|
||||
no_main_dependency, commandLines, no_comment, no_working_directory, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,8 +279,10 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
|
|||
cmMakefile* mf = root->GetMakefile();
|
||||
// Add ALL_BUILD
|
||||
const char* no_output = 0;
|
||||
const char* no_working_directory = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
mf->AddUtilityCommand("ALL_BUILD", false, no_output, no_depends,
|
||||
no_working_directory,
|
||||
"echo", "Build all projects");
|
||||
cmTarget* allbuild = mf->FindTarget("ALL_BUILD");
|
||||
// ADD install
|
||||
|
@ -288,12 +290,14 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
|
|||
if(m_XcodeVersion == 15)
|
||||
{
|
||||
mf->AddUtilityCommand("install", false, no_output, no_depends,
|
||||
no_working_directory,
|
||||
cmake_command.c_str(),
|
||||
"-P", "cmake_install.cmake");
|
||||
}
|
||||
else
|
||||
{
|
||||
mf->AddUtilityCommand("install", false, no_output, no_depends,
|
||||
no_working_directory,
|
||||
cmake_command.c_str(),
|
||||
"-DBUILD_TYPE=$(CONFIGURATION)",
|
||||
"-P", "cmake_install.cmake");
|
||||
|
@ -317,6 +321,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
|
|||
std::string ctest_command =
|
||||
mf->GetRequiredDefinition("CMAKE_CTEST_COMMAND");
|
||||
mf->AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
|
||||
no_working_directory,
|
||||
ctest_command.c_str());
|
||||
}
|
||||
// Add XCODE depend helper
|
||||
|
@ -338,6 +343,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
|
|||
cmCustomCommandLines commandLines;
|
||||
commandLines.push_back(makecommand);
|
||||
mf->AddUtilityCommand("XCODE_DEPEND_HELPER", false, no_output, no_depends,
|
||||
no_working_directory,
|
||||
commandLines);
|
||||
|
||||
// Add Re-Run CMake rules
|
||||
|
|
|
@ -44,8 +44,10 @@ bool cmIncludeExternalMSProjectCommand::InitialPass(std::vector<std::string> con
|
|||
utility_name += args[0];
|
||||
|
||||
const char* no_output = 0;
|
||||
const char* no_working_directory = 0;
|
||||
m_Makefile->AddUtilityCommand(utility_name.c_str(), true,
|
||||
no_output, depends,
|
||||
no_working_directory,
|
||||
args[0].c_str(), args[1].c_str());
|
||||
|
||||
}
|
||||
|
|
|
@ -1749,10 +1749,18 @@ void cmLocalGenerator::AppendFlags(std::string& flags,
|
|||
//----------------------------------------------------------------------------
|
||||
std::string
|
||||
cmLocalGenerator::ConstructScript(const cmCustomCommandLines& commandLines,
|
||||
const char* workingDirectory,
|
||||
const char* newline)
|
||||
|
||||
{
|
||||
// Store the script in a string.
|
||||
std::string script;
|
||||
if(workingDirectory)
|
||||
{
|
||||
script += "cd ";
|
||||
script += this->Convert(workingDirectory, START_OUTPUT, SHELL);
|
||||
script += newline;
|
||||
}
|
||||
|
||||
// Write each command on a single line.
|
||||
for(cmCustomCommandLines::const_iterator cl = commandLines.begin();
|
||||
|
|
|
@ -165,6 +165,7 @@ public:
|
|||
protected:
|
||||
/** Construct a script from the given list of command lines. */
|
||||
std::string ConstructScript(const cmCustomCommandLines& commandLines,
|
||||
const char* workingDirectory,
|
||||
const char* newline = "\n");
|
||||
|
||||
///! Fill out these strings for the given target. Libraries to link, flags, and linkflags.
|
||||
|
|
|
@ -2405,13 +2405,19 @@ cmLocalUnixMakefileGenerator3
|
|||
cmSystemTools::SetForceUnixPaths(true);
|
||||
}
|
||||
}
|
||||
|
||||
commands1.push_back(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
// push back the custom commands
|
||||
this->CreateCDCommand(commands1,m_Makefile->GetStartOutputDirectory(),
|
||||
const char* dir =m_Makefile->GetStartOutputDirectory();
|
||||
// if the command specified a working directory use it.
|
||||
if(cc.GetWorkingDirectory())
|
||||
{
|
||||
dir = cc.GetWorkingDirectory();
|
||||
}
|
||||
|
||||
this->CreateCDCommand(commands1, dir,
|
||||
m_Makefile->GetHomeOutputDirectory());
|
||||
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
||||
}
|
||||
|
|
|
@ -252,8 +252,9 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule()
|
|||
cmCustomCommandLines commandLines;
|
||||
commandLines.push_back(commandLine);
|
||||
const char* no_comment = 0;
|
||||
const char* no_working_directory = 0;
|
||||
m_Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(),
|
||||
commandLines, no_comment, true);
|
||||
commandLines, no_comment, no_working_directory, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -448,7 +449,9 @@ void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
|
|||
if (command)
|
||||
{
|
||||
std::string script =
|
||||
this->ConstructScript(command->GetCommandLines(), "\\\n\t");
|
||||
this->ConstructScript(command->GetCommandLines(),
|
||||
command->GetWorkingDirectory(),
|
||||
"\\\n\t");
|
||||
const char* comment = command->GetComment();
|
||||
const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
|
||||
this->WriteCustomRule(fout, source.c_str(), script.c_str(),
|
||||
|
@ -511,11 +514,13 @@ cmLocalVisualStudio6Generator
|
|||
// Add the rule with the given dependencies and commands.
|
||||
const char* no_main_dependency = 0;
|
||||
const char* no_comment = 0;
|
||||
const char* no_working_directory = 0;
|
||||
m_Makefile->AddCustomCommandToOutput(output,
|
||||
depends,
|
||||
no_main_dependency,
|
||||
commandLines,
|
||||
no_comment);
|
||||
no_comment,
|
||||
no_working_directory);
|
||||
|
||||
// Replace the dependencies with the output of this rule so that the
|
||||
// next rule added will run after this one.
|
||||
|
@ -724,6 +729,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
|
|||
prelink_newline = "";
|
||||
}
|
||||
customRuleCode += this->ConstructScript(cr->GetCommandLines(),
|
||||
cr->GetWorkingDirectory(),
|
||||
prelink_newline);
|
||||
}
|
||||
for (std::vector<cmCustomCommand>::const_iterator cr =
|
||||
|
@ -735,6 +741,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
|
|||
prelink_newline = "";
|
||||
}
|
||||
customRuleCode += this->ConstructScript(cr->GetCommandLines(),
|
||||
cr->GetWorkingDirectory(),
|
||||
prelink_newline);
|
||||
}
|
||||
if(prelink_total > 0)
|
||||
|
@ -760,6 +767,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
|
|||
postbuild_newline = "";
|
||||
}
|
||||
customRuleCode += this->ConstructScript(cr->GetCommandLines(),
|
||||
cr->GetWorkingDirectory(),
|
||||
postbuild_newline);
|
||||
}
|
||||
if(postbuild_total > 0)
|
||||
|
|
|
@ -254,9 +254,10 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule()
|
|||
|
||||
cmCustomCommandLines commandLines;
|
||||
commandLines.push_back(commandLine);
|
||||
const char* no_working_directory = 0;
|
||||
const char* no_comment = 0;
|
||||
m_Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(),
|
||||
commandLines, no_comment, true);
|
||||
commandLines, no_comment, no_working_directory, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1096,7 +1097,8 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
|
|||
if (command)
|
||||
{
|
||||
// Construct the entire set of commands in one string.
|
||||
std::string script = this->ConstructScript(command->GetCommandLines());
|
||||
std::string script = this->ConstructScript(command->GetCommandLines(),
|
||||
command->GetWorkingDirectory());
|
||||
const char* comment = command->GetComment();
|
||||
const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
|
||||
this->WriteCustomRule(fout, source.c_str(), script.c_str(),
|
||||
|
@ -1254,7 +1256,7 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
|
|||
fout << "\nCommandLine=\"";
|
||||
init = true;
|
||||
}
|
||||
std::string script = this->ConstructScript(cr->GetCommandLines());
|
||||
std::string script = this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory());
|
||||
fout << this->EscapeForXML(script.c_str()).c_str();
|
||||
}
|
||||
if (init)
|
||||
|
@ -1275,7 +1277,8 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
|
|||
fout << "\nCommandLine=\"";
|
||||
init = true;
|
||||
}
|
||||
std::string script = this->ConstructScript(cr->GetCommandLines());
|
||||
std::string script = this->ConstructScript(cr->GetCommandLines(),
|
||||
cr->GetWorkingDirectory());
|
||||
fout << this->EscapeForXML(script.c_str()).c_str();
|
||||
}
|
||||
if (init)
|
||||
|
@ -1296,7 +1299,7 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
|
|||
fout << "\nCommandLine=\"";
|
||||
init = true;
|
||||
}
|
||||
std::string script = this->ConstructScript(cr->GetCommandLines());
|
||||
std::string script = this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory());
|
||||
fout << this->EscapeForXML(script.c_str()).c_str();
|
||||
}
|
||||
if (init)
|
||||
|
|
|
@ -469,7 +469,8 @@ cmMakefile::AddCustomCommandToTarget(const char* target,
|
|||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
cmTarget::CustomCommandType type,
|
||||
const char* comment)
|
||||
const char* comment,
|
||||
const char* workingDir)
|
||||
{
|
||||
// Find the target to which to add the custom command.
|
||||
cmTargets::iterator ti = m_Targets.find(target);
|
||||
|
@ -477,7 +478,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target,
|
|||
{
|
||||
// Add the command to the appropriate build step for the target.
|
||||
const char* no_output = 0;
|
||||
cmCustomCommand cc(no_output, depends, commandLines, comment);
|
||||
cmCustomCommand cc(no_output, depends, commandLines, comment, workingDir);
|
||||
switch(type)
|
||||
{
|
||||
case cmTarget::PRE_BUILD:
|
||||
|
@ -512,6 +513,7 @@ cmMakefile::AddCustomCommandToOutput(const char* output,
|
|||
const char* main_dependency,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
const char* comment,
|
||||
const char* workingDir,
|
||||
bool replace)
|
||||
{
|
||||
// Choose a source file on which to store the custom command.
|
||||
|
@ -586,7 +588,7 @@ cmMakefile::AddCustomCommandToOutput(const char* output,
|
|||
if(file)
|
||||
{
|
||||
cmCustomCommand* cc =
|
||||
new cmCustomCommand(output, depends2, commandLines, comment);
|
||||
new cmCustomCommand(output, depends2, commandLines, comment, workingDir);
|
||||
file->SetCustomCommand(cc);
|
||||
}
|
||||
}
|
||||
|
@ -608,7 +610,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
|
|||
// same then it added a post-build rule to the target. Preserve
|
||||
// this behavior.
|
||||
this->AddCustomCommandToTarget(target, depends, commandLines,
|
||||
cmTarget::POST_BUILD, comment);
|
||||
cmTarget::POST_BUILD, comment, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -627,7 +629,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
|
|||
{
|
||||
// The source looks like a real file. Use it as the main dependency.
|
||||
this->AddCustomCommandToOutput(output, depends, source,
|
||||
commandLines, comment);
|
||||
commandLines, comment, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -636,7 +638,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
|
|||
std::vector<std::string> depends2 = depends;
|
||||
depends2.push_back(source);
|
||||
this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
|
||||
commandLines, comment);
|
||||
commandLines, comment, 0);
|
||||
}
|
||||
|
||||
// If the rule was added to the source (and not a .rule file),
|
||||
|
@ -664,6 +666,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
|
|||
void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
|
||||
const char* output,
|
||||
const std::vector<std::string>& depends,
|
||||
const char* workingDirectory,
|
||||
const char* command,
|
||||
const char* arg1,
|
||||
const char* arg2,
|
||||
|
@ -693,12 +696,14 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
|
|||
commandLines.push_back(commandLine);
|
||||
|
||||
// Call the real signature of this method.
|
||||
this->AddUtilityCommand(utilityName, all, output, depends, commandLines);
|
||||
this->AddUtilityCommand(utilityName, all, output, workingDirectory,
|
||||
depends, commandLines);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
|
||||
const char* output,
|
||||
const char* workingDirectory,
|
||||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines)
|
||||
{
|
||||
|
@ -707,9 +712,8 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
|
|||
target.SetType(cmTarget::UTILITY, utilityName);
|
||||
target.SetInAll(all);
|
||||
target.SetMakefile(this);
|
||||
|
||||
// Store the custom command in the target.
|
||||
cmCustomCommand cc(output, depends, commandLines, 0);
|
||||
cmCustomCommand cc(output, depends, commandLines, 0, workingDirectory);
|
||||
target.GetPostBuildCommands().push_back(cc);
|
||||
|
||||
// Add the target to the set of targets.
|
||||
|
@ -1442,7 +1446,6 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
|
|||
{
|
||||
cmSystemTools::Message(error.str().c_str());
|
||||
}
|
||||
//std::cerr << "[" << source.c_str() << "] results in: [" << parser.GetResult() << "]" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,12 +138,12 @@ public:
|
|||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
cmTarget::CustomCommandType type,
|
||||
const char* comment);
|
||||
const char* comment, const char* workingDir);
|
||||
void AddCustomCommandToOutput(const char* output,
|
||||
const std::vector<std::string>& depends,
|
||||
const char* main_dependency,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
const char* comment,
|
||||
const char* comment, const char* workingDir,
|
||||
bool replace = false);
|
||||
void AddCustomCommandOldStyle(const char* target,
|
||||
const std::vector<std::string>& outputs,
|
||||
|
@ -171,6 +171,7 @@ public:
|
|||
void AddUtilityCommand(const char* utilityName, bool all,
|
||||
const char* output,
|
||||
const std::vector<std::string>& depends,
|
||||
const char* workingDirectory,
|
||||
const char* command,
|
||||
const char* arg1=0,
|
||||
const char* arg2=0,
|
||||
|
@ -178,6 +179,7 @@ public:
|
|||
const char* arg4=0);
|
||||
void AddUtilityCommand(const char* utilityName, bool all,
|
||||
const char* output,
|
||||
const char* workingDirectory,
|
||||
const std::vector<std::string>& depends,
|
||||
const cmCustomCommandLines& commandLines);
|
||||
|
||||
|
|
|
@ -127,10 +127,12 @@ void cmQTWrapCPPCommand::FinalPass()
|
|||
realdepends.push_back(m_WrapHeaders[classNum]);
|
||||
|
||||
const char* no_main_dependency = 0;
|
||||
const char* no_working_dir = 0;
|
||||
m_Makefile->AddCustomCommandToOutput(res.c_str(),
|
||||
realdepends,
|
||||
no_main_dependency,
|
||||
commandLines,
|
||||
"QT Wrapped File");
|
||||
"QT Wrapped File",
|
||||
no_working_dir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,11 +179,13 @@ void cmQTWrapUICommand::FinalPass()
|
|||
depends.push_back(m_WrapUserInterface[classNum]);
|
||||
const char* no_main_dependency = 0;
|
||||
const char* no_comment = 0;
|
||||
const char* no_working_dir = 0;
|
||||
m_Makefile->AddCustomCommandToOutput(hres.c_str(),
|
||||
depends,
|
||||
no_main_dependency,
|
||||
hCommandLines,
|
||||
no_comment);
|
||||
no_comment,
|
||||
no_working_dir);
|
||||
|
||||
depends.push_back(hres);
|
||||
|
||||
|
@ -191,7 +193,8 @@ void cmQTWrapUICommand::FinalPass()
|
|||
depends,
|
||||
no_main_dependency,
|
||||
cxxCommandLines,
|
||||
no_comment);
|
||||
no_comment,
|
||||
no_working_dir);
|
||||
|
||||
depends.clear();
|
||||
depends.push_back(hres);
|
||||
|
@ -200,6 +203,7 @@ void cmQTWrapUICommand::FinalPass()
|
|||
depends,
|
||||
no_main_dependency,
|
||||
mocCommandLines,
|
||||
no_comment);
|
||||
no_comment,
|
||||
no_working_dir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,6 +182,8 @@ void cmVTKWrapJavaCommand::FinalPass()
|
|||
}
|
||||
|
||||
const char* no_output = 0;
|
||||
const char* no_working_directory = 0;
|
||||
m_Makefile->AddUtilityCommand((m_LibraryName+"JavaClasses").c_str(),
|
||||
true, no_output, alldepends, "");
|
||||
true, no_output,
|
||||
alldepends, "", no_working_directory);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue