Commit 089aa3e1 authored by Ken Martin's avatar Ken Martin
Browse files

option to make utilities in the all target

parent 2383d6ff
......@@ -43,16 +43,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// cmAddCustomTargetCommand
bool cmAddCustomTargetCommand::Invoke(std::vector<std::string>& args)
{
bool all = false;
if(args.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> dep;
m_Makefile->ExpandVariablesInString(args[0]);
m_Makefile->ExpandVariablesInString(args[1]);
// all target option
if (args.size() >= 3)
{
if (args[2] == "ALL")
{
all = true;
}
}
m_Makefile->AddUtilityCommand(args[0].c_str(),
args[1].c_str());
args[1].c_str(), all);
return true;
}
......@@ -90,7 +90,8 @@ public:
virtual const char* GetFullDocumentation()
{
return
"ADD_CUSTOM_TARGET(Name \"command to run\")";
"ADD_CUSTOM_TARGET(Name \"command to run\" ALL)\n"
"The ALL option is optional. If it is specified it indicates that this target should be added to the Build all target.";
}
cmTypeMacro(cmAddCustomTargetCommand, cmCommand);
......
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmAddTargetCommand.h"
// cmAddTargetCommand
bool cmAddTargetCommand::Invoke(std::vector<std::string>& args)
{
bool all = false;
if(args.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
// all target option
if (args.size() >= 3)
{
if (args[2] == "ALL")
{
all = true;
}
}
std::vector<std::string> dep;
m_Makefile->AddUtilityCommand(args[0].c_str(),
args[1].c_str(), all);
return true;
}
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2001 Insight Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the Insight Consortium, nor the names of any consortium members,
nor of any contributors, may be used to endorse or promote products derived
from this software without specific prior written permission.
* Modified source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef cmAddTargetCommand_h
#define cmAddTargetCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
/** \class cmAddTargetCommand
* \brief Command that adds a target to the build system.
*
* cmAddTargetCommand adds an extra target to the build system.
* This is useful when you would like to add special
* targets like "install,", "clean," and so on.
*/
class cmAddTargetCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmAddTargetCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool Invoke(std::vector<std::string>& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName()
{return "ADD_TARGET";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Add an extra target to the build system.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"ADD_TARGET(Name \"command to run\" ALL)\n"
"Add a target to the make process. The third argument ALL is optional. If it is specified then the target will be added to the all target." ;
}
cmTypeMacro(cmAddTargetCommand, cmCommand);
};
#endif
......@@ -95,7 +95,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
allListFiles.push_back(m_Makefile);
// add a special target that depends on ALL projects for easy build
// of Debug only
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"");
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"", false);
m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles);
// For each cmMakefile, create a DSP for it, and
......@@ -144,7 +144,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
for(cmTargets::const_iterator al = atgts.begin();
al != atgts.end(); ++al)
{
if(al->second.GetType() != cmTarget::UTILITY)
if(al->second.IsInAll())
{
l->second.GetLinkLibraries().push_back(
cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL));
......
......@@ -95,7 +95,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
allListFiles.push_back(m_Makefile);
// add a special target that depends on ALL projects for easy build
// of Debug only
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"");
m_Makefile->AddUtilityCommand("ALL_BUILD", "echo \"Build all projects\"", false);
m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles);
// For each cmMakefile, create a DSP for it, and
......@@ -144,7 +144,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
for(cmTargets::const_iterator al = atgts.begin();
al != atgts.end(); ++al)
{
if(al->second.GetType() != cmTarget::UTILITY)
if(al->second.IsInAll())
{
l->second.GetLinkLibraries().push_back(
cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL));
......
......@@ -482,12 +482,24 @@ void cmMakefile::AddExecutable(const char *exeName,
void cmMakefile::AddUtilityCommand(const char* utilityName,
const char* command)
const char* command,
bool all)
{
std::vector<std::string> empty;
this->AddUtilityCommand(utilityName,command,all,
empty,empty);
}
void cmMakefile::AddUtilityCommand(const char* utilityName,
const char* command,
bool all,
const std::vector<std::string> &dep,
const std::vector<std::string> &out)
{
cmTarget target;
target.SetType(cmTarget::UTILITY);
std::vector<std::string> empty;
cmCustomCommand cc(utilityName, command, empty, empty);
target.SetInAll(all);
cmCustomCommand cc(utilityName, command, dep, out);
target.GetCustomCommands().push_back(cc);
m_Targets.insert(cmTargets::value_type(utilityName,target));
}
......
......@@ -140,7 +140,13 @@ public:
* a command that is run every time a target is built.
*/
void AddUtilityCommand(const char* utilityName,
const char* command);
const char* command,
bool all);
void AddUtilityCommand(const char* utilityName,
const char* command,
bool all,
const std::vector<std::string> &depends,
const std::vector<std::string> &outputs);
/**
* Add a utility on which this project depends. A utility is an executable
......
......@@ -65,6 +65,13 @@ public:
void SetType(TargetType f) { m_TargetType = f; }
/**
* Indicate whether the target is part of the all target
*/
bool IsInAll() const { return m_InAll; }
bool GetInAll() const { return m_InAll; }
void SetInAll(bool f) { m_InAll = f; }
/**
* Get the list of the custom commands for this target
*/
......@@ -110,6 +117,7 @@ private:
TargetType m_TargetType;
std::vector<cmSourceFile> m_SourceFiles;
LinkLibraries m_LinkLibraries;
bool m_InAll;
};
typedef std::map<std::string,cmTarget> cmTargets;
......
......@@ -104,6 +104,8 @@ void cmVTKWrapJavaCommand::FinalPass()
int lastClass = m_WrapClasses.size();
std::vector<std::string> depends;
std::vector<std::string> depends2;
std::vector<std::string> alldepends;
std::vector<std::string> empty;
std::string wjava = "${VTK_WRAP_JAVA_EXE}";
std::string pjava = "${VTK_PARSE_JAVA_EXE}";
std::string hints = "${VTK_WRAP_HINTS}";
......@@ -118,7 +120,8 @@ void cmVTKWrapJavaCommand::FinalPass()
// wrap java
std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx";
std::string res2 = m_OriginalNames[classNum] + ".java";
std::string res2 = resultDirectory + "/" +
m_OriginalNames[classNum] + ".java";
std::string cmd = wjava + " " + m_WrapHeaders[classNum] + " "
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx";
......@@ -127,11 +130,19 @@ void cmVTKWrapJavaCommand::FinalPass()
res.c_str(), m_LibraryName.c_str());
cmd = pjava + " " + m_WrapHeaders[classNum] + " "
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + resultDirectory + "/" + m_OriginalNames[classNum] + ".java";
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + res2;
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
cmd.c_str(), depends2,
res2.c_str(), m_LibraryName.c_str());
alldepends.push_back(res2);
}
m_Makefile->AddUtilityCommand((m_LibraryName+"JavaClasses").c_str(),
"",
true,
alldepends,
empty);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment