|
|
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
cmake::cmake()
|
|
|
{
|
|
|
m_Verbose = false;
|
|
|
+ m_UsePathTranslation = false;
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator);
|
|
|
cmMakefileGenerator::RegisterGenerator(new cmNMakeMakefileGenerator);
|
|
|
@@ -67,8 +68,9 @@ void cmake::Usage(const char* program)
|
|
|
std::cerr << "cmake version " << cmMakefile::GetMajorVersion()
|
|
|
<< "." << cmMakefile::GetMinorVersion() << " - "
|
|
|
<< cmMakefile::GetReleaseVersion() << "\n";
|
|
|
- std::cerr << "Usage: " << program << " [srcdir] [options]\n"
|
|
|
+ std::cerr << "Usage: " << program << " [srcdir] [outdir] [options]\n"
|
|
|
<< "Where cmake is run from the directory where you want the object files written. If srcdir is not specified, the current directory is used for both source and object files.\n";
|
|
|
+ std::cerr << "If outdir is specified, pathname translation is enabled, and srcdir and outdir are used as given to access the roots of source and output directories.\n";
|
|
|
std::cerr << "Options are:\n";
|
|
|
std::cerr << "\n-i (puts cmake in wizard mode, not available for ccmake)\n";
|
|
|
std::cerr << "\n-DVAR:TYPE=VALUE (create a cache file entry)\n";
|
|
|
@@ -128,29 +130,9 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
|
|
|
{
|
|
|
m_Local = false;
|
|
|
bool directoriesSet = false;
|
|
|
- // watch for cmake and cmake srcdir invocations
|
|
|
- if (args.size() <= 2)
|
|
|
- {
|
|
|
- directoriesSet = true;
|
|
|
- builder.SetHomeOutputDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- builder.SetStartOutputDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- if (args.size() == 2)
|
|
|
- {
|
|
|
- builder.SetHomeDirectory
|
|
|
- (cmSystemTools::CollapseFullPath(args[1].c_str()).c_str());
|
|
|
- builder.SetStartDirectory
|
|
|
- (cmSystemTools::CollapseFullPath(args[1].c_str()).c_str());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- builder.SetHomeDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- builder.SetStartDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ std::string srcdir;
|
|
|
+ std::string outdir;
|
|
|
|
|
|
for(unsigned int i=1; i < args.size(); ++i)
|
|
|
{
|
|
|
@@ -159,6 +141,12 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
|
|
|
{
|
|
|
directoriesSet = true;
|
|
|
std::string path = arg.substr(2);
|
|
|
+ if( cmSystemTools::CollapseFullPath(path.c_str()) != path &&
|
|
|
+ path.size() > 0 && path[0] != '.' )
|
|
|
+ {
|
|
|
+ cmSystemTools::AddPathTranslation( cmSystemTools::CollapseFullPath(path.c_str()), path );
|
|
|
+ m_UsePathTranslation = true;
|
|
|
+ }
|
|
|
builder.SetHomeDirectory(path.c_str());
|
|
|
}
|
|
|
else if(arg.find("-S",0) == 0)
|
|
|
@@ -178,6 +166,12 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
|
|
|
{
|
|
|
directoriesSet = true;
|
|
|
std::string path = arg.substr(2);
|
|
|
+ if( cmSystemTools::CollapseFullPath(path.c_str()) != path &&
|
|
|
+ path.size() > 0 && path[0] != '.' )
|
|
|
+ {
|
|
|
+ cmSystemTools::AddPathTranslation( cmSystemTools::CollapseFullPath(path.c_str()), path );
|
|
|
+ m_UsePathTranslation = true;
|
|
|
+ }
|
|
|
builder.SetHomeOutputDirectory(path.c_str());
|
|
|
}
|
|
|
else if(arg.find("-V",0) == 0)
|
|
|
@@ -207,31 +201,66 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
|
|
|
builder.SetMakefileGenerator(gen);
|
|
|
}
|
|
|
}
|
|
|
- // no option assume it is the path to the source
|
|
|
+ // no option assume it is the path to the source or to the output
|
|
|
else
|
|
|
{
|
|
|
- directoriesSet = true;
|
|
|
- builder.SetHomeOutputDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- builder.SetStartOutputDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- builder.SetHomeDirectory
|
|
|
- (cmSystemTools::CollapseFullPath(arg.c_str()).c_str());
|
|
|
- builder.SetStartDirectory
|
|
|
- (cmSystemTools::CollapseFullPath(arg.c_str()).c_str());
|
|
|
+ if( srcdir.size() == 0 )
|
|
|
+ {
|
|
|
+ srcdir = arg;
|
|
|
+ }
|
|
|
+ else if( outdir.size() == 0 )
|
|
|
+ {
|
|
|
+ // Make sure the symbolic output directory specified matches
|
|
|
+ // the current directory, and that the symbolic path is
|
|
|
+ // absolute. Even if not, set the outdir variable so that
|
|
|
+ // further attempts to set the output directory (with
|
|
|
+ // another command line argument) fails.
|
|
|
+ if( cmSystemTools::CollapseFullPath( arg.c_str() ) == cmSystemTools::GetCurrentWorkingDirectory() )
|
|
|
+ {
|
|
|
+ outdir = arg;
|
|
|
+ if( srcdir.size() > 0 && srcdir[0] != '.' && outdir.size() > 0 && outdir[0] != '.' )
|
|
|
+ {
|
|
|
+ cmSystemTools::AddPathTranslation( cmSystemTools::GetCurrentWorkingDirectory(), outdir );
|
|
|
+ cmSystemTools::AddPathTranslation( cmSystemTools::CollapseFullPath(srcdir.c_str()), srcdir );
|
|
|
+ m_UsePathTranslation = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "Symbolic paths must be absolute for path translation. One of \"" << srcdir
|
|
|
+ << "\" or \"" << outdir << "\" is not.\n"
|
|
|
+ << "Not performing path name translation." << std::endl;
|
|
|
+ outdir = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "The current working directory (" << cmSystemTools::GetCurrentWorkingDirectory() << ")\n"
|
|
|
+ << "does not match the binary directory (" << (cmSystemTools::CollapseFullPath(arg.c_str())) << ")\n"
|
|
|
+ << "[ given as " << arg << " ].\n"
|
|
|
+ << "Not performing path name translation." << std::endl;
|
|
|
+ outdir = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "Ignoring parameter " << arg << std::endl;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if(!directoriesSet)
|
|
|
{
|
|
|
- builder.SetHomeOutputDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- builder.SetStartOutputDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- builder.SetHomeDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
- builder.SetStartDirectory
|
|
|
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
|
|
|
+ if( srcdir.size() == 0 ) srcdir = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
+
|
|
|
+ outdir = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
+ srcdir = cmSystemTools::CollapseFullPath( srcdir.c_str() );
|
|
|
+
|
|
|
+ builder.SetHomeOutputDirectory( outdir.c_str() );
|
|
|
+ builder.SetStartOutputDirectory( outdir.c_str() );
|
|
|
+ builder.SetHomeDirectory( srcdir.c_str() );
|
|
|
+ builder.SetStartDirectory( srcdir.c_str() );
|
|
|
}
|
|
|
+
|
|
|
if (!m_Local)
|
|
|
{
|
|
|
builder.SetStartDirectory(builder.GetHomeDirectory());
|
|
|
@@ -242,10 +271,13 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
|
|
|
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the cache
|
|
|
void cmake::AddCMakePaths(const std::vector<std::string>& args)
|
|
|
{
|
|
|
- // Find our own executable.
|
|
|
+ // Find our own executable. If path translations are enabled and the
|
|
|
+ // user supplies the full path to cmake, use it as the canonical
|
|
|
+ // name (i.e. don't translate to a local disk path).
|
|
|
std::string cMakeSelf = args[0];
|
|
|
cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
|
|
|
- cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
|
|
|
+ if(!(m_UsePathTranslation && cmSystemTools::FileExists(cMakeSelf.c_str()) && cMakeSelf[0]!='.'))
|
|
|
+ cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
|
|
|
if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
|
|
|
{
|
|
|
#ifdef CMAKE_BUILD_DIR
|