Fix add custom command so that it actually executes the code
This commit is contained in:
parent
0333f15b96
commit
58ee855503
|
@ -31,6 +31,7 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
||||||
|
|
||||||
std::string source, command, target;
|
std::string source, command, target;
|
||||||
std::vector<std::string> command_args, depends, outputs;
|
std::vector<std::string> command_args, depends, outputs;
|
||||||
|
std::string outDir = m_Makefile->GetCurrentOutputDirectory();
|
||||||
|
|
||||||
enum tdoing {
|
enum tdoing {
|
||||||
doing_source,
|
doing_source,
|
||||||
|
@ -129,7 +130,31 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
||||||
depends,
|
depends,
|
||||||
outputs,
|
outputs,
|
||||||
target.c_str());
|
target.c_str());
|
||||||
|
|
||||||
|
int cc = outputs.size()-1;
|
||||||
|
while( cc >= 0 )
|
||||||
|
{
|
||||||
|
std::string fileName = outputs[cc];
|
||||||
|
|
||||||
|
std::string directory = cmSystemTools::GetFilenamePath(fileName);
|
||||||
|
if ( directory == std::string() )
|
||||||
|
{
|
||||||
|
directory = outDir;
|
||||||
|
}
|
||||||
|
fileName = cmSystemTools::GetFilenameName(fileName);
|
||||||
|
|
||||||
|
std::string::size_type pos = fileName.rfind(".");
|
||||||
|
fileName = fileName.substr(0, pos);
|
||||||
|
// Add the generated source to the package target's source list.
|
||||||
|
cmSourceFile file;
|
||||||
|
file.SetName(fileName.c_str(), directory.c_str(), "c", false);
|
||||||
|
m_Makefile->AddSource(file, target.c_str());
|
||||||
|
cc--;
|
||||||
|
}
|
||||||
|
m_Makefile->GetTargets()[target.c_str()].GetSourceLists().push_back(target);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,25 @@
|
||||||
*
|
*
|
||||||
* cmAddCustomCommandCommand defines a new command that can
|
* cmAddCustomCommandCommand defines a new command that can
|
||||||
* be executed within the CMake
|
* be executed within the CMake
|
||||||
|
*
|
||||||
|
* In makefile terms this creates new target in the following form:
|
||||||
|
* OUTPUT1: SOURCE DEPENDS
|
||||||
|
* COMMAND ARGS
|
||||||
|
* OUTPUT2: SOURCE DEPENDS
|
||||||
|
* COMMAND ARGS
|
||||||
|
* ...
|
||||||
|
* Example of usage:
|
||||||
|
* ADD_CUSTOM_COMMAND(
|
||||||
|
* SOURCE ${VTK_TIFF_FAX_EXE}
|
||||||
|
* COMMAND ${VTK_TIFF_FAX_EXE}
|
||||||
|
* ARGS -c const ${VTK_BINARY_DIR}/Utilities/tiff/tif_fax3sm.c
|
||||||
|
* TARGET vtktiff
|
||||||
|
* OUTPUTS ${VTK_BINARY_DIR}/Utilities/tiff/tif_fax3sm.c
|
||||||
|
* )
|
||||||
|
* This will create custom target which will generate file tif_fax3sm.c
|
||||||
|
* using command ${VTK_TIFF_FAX_EXE}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class cmAddCustomCommandCommand : public cmCommand
|
class cmAddCustomCommandCommand : public cmCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue