mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-26 10:48:38 -06:00
Do not link library dependencies in VS solutions
In VS 8 and greater this commit implements add_dependencies(myexe mylib) # depend without linking by adding the LinkLibraryDependencies="false" option to project files. Previously the above code would cause myexe to link to mylib in VS 8 and greater. This option prevents dependencies specified only in the solution from being linked. We already specify the real link library dependencies in the project files, and any project depending on this to link would not have worked in Makefile generators. We were already avoiding this problem in VS 7.1 and below by inserting intermediate mylib_UTILITY targets. It was more important for those versions because if a static library depended on another library the librarian would copy the dependees into the depender! This is no longer the case with VS 8 and above so we do not need that workaround. See issue #9732.
This commit is contained in:
@@ -846,6 +846,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
||||
cmTarget &target,
|
||||
bool isDebug)
|
||||
{
|
||||
cmGlobalVisualStudio7Generator* gg =
|
||||
static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
|
||||
std::string temp;
|
||||
std::string extraLinkOptions;
|
||||
if(target.GetType() == cmTarget::EXECUTABLE)
|
||||
@@ -949,6 +951,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
||||
}
|
||||
fout << "\t\t\t<Tool\n"
|
||||
<< "\t\t\t\tName=\"" << tool << "\"\n";
|
||||
if(!gg->NeedLinkLibraryDependencies(target))
|
||||
{
|
||||
fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
|
||||
}
|
||||
linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
|
||||
// Use the NOINHERIT macro to avoid getting VS project default
|
||||
// libraries which may be set by the user to something bad.
|
||||
@@ -1021,6 +1027,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
||||
}
|
||||
fout << "\t\t\t<Tool\n"
|
||||
<< "\t\t\t\tName=\"" << tool << "\"\n";
|
||||
if(!gg->NeedLinkLibraryDependencies(target))
|
||||
{
|
||||
fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
|
||||
}
|
||||
linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
|
||||
// Use the NOINHERIT macro to avoid getting VS project default
|
||||
// libraries which may be set by the user to something bad.
|
||||
|
||||
Reference in New Issue
Block a user