[Cmake-commits] [cmake-commits] king committed cmLinkDirectoriesCommand.cxx 1.14 1.15 cmLinkDirectoriesCommand.h 1.15 1.16 cmPolicies.cxx 1.50 1.51 cmPolicies.h 1.29 1.30
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Nov 24 11:16:41 EST 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv28729/Source
Modified Files:
cmLinkDirectoriesCommand.cxx cmLinkDirectoriesCommand.h
cmPolicies.cxx cmPolicies.h
Log Message:
Teach link_directories to recognize relative paths
We create CMake Policy CMP0015 to make link_directories() treat relative
paths with respect to the source tree while retaining compatibility.
This makes it consistent with include_directories() and other commands.
Changes based on patch from Alex. See issue #9697.
Index: cmLinkDirectoriesCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLinkDirectoriesCommand.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C 2 -d -r1.15 -r1.16
*** cmLinkDirectoriesCommand.h 28 Sep 2009 15:42:47 -0000 1.15
--- cmLinkDirectoriesCommand.h 24 Nov 2009 16:16:38 -0000 1.16
***************
*** 71,74 ****
--- 71,76 ----
cmTypeMacro(cmLinkDirectoriesCommand, cmCommand);
+ private:
+ void AddLinkDir(std::string const& dir);
};
Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C 2 -d -r1.29 -r1.30
*** cmPolicies.h 27 Oct 2009 13:07:39 -0000 1.29
--- cmPolicies.h 24 Nov 2009 16:16:38 -0000 1.30
***************
*** 51,54 ****
--- 51,55 ----
CMP0013, // Duplicate binary directories not allowed
CMP0014, // Input directories must have CMakeLists.txt
+ CMP0015, // link_directories() treats paths relative to source dir
// Always the last entry. Useful mostly to avoid adding a comma
Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.50
retrieving revision 1.51
diff -C 2 -d -r1.50 -r1.51
*** cmPolicies.cxx 27 Oct 2009 13:07:38 -0000 1.50
--- cmPolicies.cxx 24 Nov 2009 16:16:38 -0000 1.51
***************
*** 407,410 ****
--- 407,425 ----
"The NEW behavior for this policy is to report an error.",
2,8,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0015, "CMP0015",
+ "link_directories() treats paths relative to the source dir.",
+ "In CMake 2.6.4 and lower the link_directories() command passed relative "
+ "paths unchanged to the linker. "
+ "In CMake 2.8.1 and above the link_directories() command prefers to "
+ "interpret relative paths with respect to CMAKE_CURRENT_SOURCE_DIR, "
+ "which is consistent with include_directories() and other commands. "
+ "The OLD behavior for this policy is to use relative paths verbatim in "
+ "the linker command. "
+ "The NEW behavior for this policy is to convert relative paths to "
+ "absolute paths by appending the relative path to "
+ "CMAKE_CURRENT_SOURCE_DIR.",
+ 2,8,1, cmPolicies::WARN);
}
Index: cmLinkDirectoriesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLinkDirectoriesCommand.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -C 2 -d -r1.14 -r1.15
*** cmLinkDirectoriesCommand.cxx 28 Sep 2009 15:42:47 -0000 1.14
--- cmLinkDirectoriesCommand.cxx 24 Nov 2009 16:16:37 -0000 1.15
***************
*** 24,32 ****
i != args.end(); ++i)
{
! std::string unixPath = *i;
! cmSystemTools::ConvertToUnixSlashes(unixPath);
! this->Makefile->AddLinkDirectory(unixPath.c_str());
}
return true;
}
--- 24,70 ----
i != args.end(); ++i)
{
! this->AddLinkDir(*i);
}
return true;
}
+ //----------------------------------------------------------------------------
+ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
+ {
+ std::string unixPath = dir;
+ cmSystemTools::ConvertToUnixSlashes(unixPath);
+ if(!cmSystemTools::FileIsFullPath(unixPath.c_str()))
+ {
+ bool convertToAbsolute = false;
+ cmOStringStream e;
+ e << "This command specifies the relative path\n"
+ << " " << unixPath << "\n"
+ << "as a link directory.\n";
+ cmPolicies* policies = this->Makefile->GetPolicies();
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015))
+ {
+ case cmPolicies::WARN:
+ e << policies->GetPolicyWarning(cmPolicies::CMP0015);
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ case cmPolicies::OLD:
+ // OLD behavior does not convert
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ e << policies->GetRequiredPolicyError(cmPolicies::CMP0015);
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ case cmPolicies::NEW:
+ // NEW behavior converts
+ convertToAbsolute = true;
+ break;
+ }
+ if (convertToAbsolute)
+ {
+ std::string tmp = this->Makefile->GetStartDirectory();
+ tmp += "/";
+ tmp += unixPath;
+ unixPath = tmp;
+ }
+ }
+ this->Makefile->AddLinkDirectory(unixPath.c_str());
+ }
More information about the Cmake-commits
mailing list