2001-03-08 18:30:18 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
2001-03-08 18:30:18 +03:00
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
2001-03-08 18:30:18 +03:00
|
|
|
|
2002-01-21 23:30:43 +03:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
2001-03-08 18:30:18 +03:00
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmUtilitySourceCommand.h"
|
|
|
|
|
|
|
|
// cmUtilitySourceCommand
|
2002-12-12 02:13:33 +03:00
|
|
|
bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args)
|
2001-03-08 18:30:18 +03:00
|
|
|
{
|
2002-12-12 02:13:33 +03:00
|
|
|
if(args.size() < 3)
|
2001-03-08 18:30:18 +03:00
|
|
|
{
|
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
|
|
|
}
|
2002-03-29 22:20:32 +03:00
|
|
|
|
2001-03-08 18:30:18 +03:00
|
|
|
std::vector<std::string>::const_iterator arg = args.begin();
|
|
|
|
|
|
|
|
// The first argument is the cache entry name.
|
|
|
|
std::string cacheEntry = *arg++;
|
|
|
|
const char* cacheValue =
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->GetDefinition(cacheEntry.c_str());
|
2005-07-28 00:37:44 +04:00
|
|
|
// If it exists already and appears up to date then we are done. If
|
|
|
|
// the string contains "(IntDir)" but that is not the
|
|
|
|
// CMAKE_CFG_INTDIR setting then the value is out of date.
|
|
|
|
const char* intDir = m_Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
|
|
|
|
if(cacheValue &&
|
|
|
|
(strstr(cacheValue, "(IntDir)") == 0 ||
|
|
|
|
intDir && strcmp(intDir, "$(IntDir)") == 0) &&
|
|
|
|
(m_Makefile->GetCacheMajorVersion() != 0 &&
|
|
|
|
m_Makefile->GetCacheMinorVersion() != 0 ))
|
2001-03-08 18:30:18 +03:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The second argument is the utility's executable name, which will be
|
|
|
|
// needed later.
|
|
|
|
std::string utilityName = *arg++;
|
|
|
|
|
|
|
|
// The third argument specifies the relative directory of the source
|
|
|
|
// of the utility.
|
|
|
|
std::string relativeSource = *arg++;
|
|
|
|
std::string utilitySource = m_Makefile->GetCurrentDirectory();
|
|
|
|
utilitySource = utilitySource+"/"+relativeSource;
|
|
|
|
|
|
|
|
// If the directory doesn't exist, the source has not been included.
|
|
|
|
if(!cmSystemTools::FileExists(utilitySource.c_str()))
|
|
|
|
{ return true; }
|
|
|
|
|
|
|
|
// Make sure all the files exist in the source directory.
|
|
|
|
while(arg != args.end())
|
|
|
|
{
|
|
|
|
std::string file = utilitySource+"/"+*arg++;
|
|
|
|
if(!cmSystemTools::FileExists(file.c_str()))
|
|
|
|
{ return true; }
|
|
|
|
}
|
|
|
|
|
2001-03-09 18:53:32 +03:00
|
|
|
// The source exists.
|
2006-03-10 21:54:57 +03:00
|
|
|
std::string cmakeCFGout =
|
|
|
|
m_Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
|
2001-03-09 18:53:32 +03:00
|
|
|
std::string utilityDirectory = m_Makefile->GetCurrentOutputDirectory();
|
2001-06-07 22:52:29 +04:00
|
|
|
std::string exePath;
|
|
|
|
if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
|
|
|
|
{
|
|
|
|
exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
|
|
|
|
}
|
|
|
|
if(exePath.size())
|
|
|
|
{
|
|
|
|
utilityDirectory = exePath;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
utilityDirectory += "/"+relativeSource;
|
|
|
|
}
|
2001-03-09 18:53:32 +03:00
|
|
|
|
|
|
|
// Construct the cache entry for the executable's location.
|
|
|
|
std::string utilityExecutable =
|
2001-04-09 18:31:36 +04:00
|
|
|
utilityDirectory+"/"+cmakeCFGout+"/"
|
|
|
|
+utilityName+cmSystemTools::GetExecutableExtension();
|
2003-08-01 21:54:53 +04:00
|
|
|
|
|
|
|
// make sure we remove any /./ in the name
|
|
|
|
cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");
|
2001-03-08 18:30:18 +03:00
|
|
|
|
|
|
|
// Enter the value into the cache.
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->AddCacheDefinition(cacheEntry.c_str(),
|
|
|
|
utilityExecutable.c_str(),
|
|
|
|
"Path to an internal program.",
|
|
|
|
cmCacheManager::FILEPATH);
|
2001-06-07 22:52:29 +04:00
|
|
|
// add a value into the cache that maps from the
|
|
|
|
// full path to the name of the project
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(utilityExecutable);
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->AddCacheDefinition(utilityExecutable.c_str(),
|
|
|
|
utilityName.c_str(),
|
|
|
|
"Executable to project name.",
|
|
|
|
cmCacheManager::INTERNAL);
|
2001-03-08 18:30:18 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|