diff options
author | Brad King <brad.king@kitware.com> | 2007-12-21 20:04:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-12-21 20:04:06 (GMT) |
commit | 3cf3bb664aa9b6c447c90c33cd6b5c1dff8c1a10 (patch) | |
tree | a392ebf61b0938354d5a73979a452102ff5eef7c /Source/cmGlobalVisualStudioGenerator.cxx | |
parent | d2be142e3bd2b1347a5bce0c75740b3b2e7acd94 (diff) | |
download | CMake-3cf3bb664aa9b6c447c90c33cd6b5c1dff8c1a10.zip CMake-3cf3bb664aa9b6c447c90c33cd6b5c1dff8c1a10.tar.gz CMake-3cf3bb664aa9b6c447c90c33cd6b5c1dff8c1a10.tar.bz2 |
ENH: Make static library targets depend on targets to which they "link" for the purpose of build ordering. This makes the build order consistent for static and shared library builds. It is also useful when custom command inputs of one library are generated as custom commands outputs of another. It may be useful in the future for Fortran module dependencies. Implemented for Makefiles, Xcode, and VS 8 and above. Added sample code to do it for VS 7.1 and below, but left it disabled with comments explaining why. Likely it will never be needed on VS 7.1 or below anyway.
Diffstat (limited to 'Source/cmGlobalVisualStudioGenerator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index fdc62f4..2319b04 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -197,6 +197,12 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosDirectory() //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::FixUtilityDepends() { + // Skip for VS versions 8 and above. + if(!this->VSLinksDependencies()) + { + return; + } + // For VS versions before 8: // // When a target that links contains a project-level dependency on a @@ -232,6 +238,33 @@ cmGlobalVisualStudioGenerator::FixUtilityDependsForTarget(cmTarget& target) return; } +#if 0 + // This feature makes a mess in SLN files for VS 7.1 and below. It + // creates an extra target for every target that is "linked" by a + // static library. Without this feature static libraries do not + // wait until their "link" dependencies are built to build. This is + // not a problem 99.9% of the time, and projects that do have the + // problem can enable this work-around by using add_dependencies. + + // Static libraries cannot depend directly on the targets to which + // they link because VS will copy those targets into the library + // (for VS < 8). To work around the problem we copy the + // dependencies to be utility dependencies so that the work-around + // below is used. + if(target.GetType() == cmTarget::STATIC_LIBRARY) + { + cmTarget::LinkLibraryVectorType const& libs = target.GetLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator i = libs.begin(); + i != libs.end(); ++i) + { + if(cmTarget* depTarget = this->FindTarget(0, i->first.c_str(), false)) + { + target.AddUtility(depTarget->GetName()); + } + } + } +#endif + // Look at each utility dependency. for(std::set<cmStdString>::const_iterator ui = target.GetUtilities().begin(); |