ENH: Make the LinkLibraries command contribute dependencies towards AddLibraries.

This commit is contained in:
Amitha Perera 2002-05-01 16:24:47 -04:00
parent 1f8df8585e
commit 36f80fe6c8
6 changed files with 50 additions and 11 deletions

View File

@ -16,10 +16,12 @@ SET( CMAKE_ANALYZE_LIB_DEPENDS "ON" )
# | |
# One <------ Four -----> Two <----- Five <---+
# |
# ^ ^ |
# | | |
# +--------- Three <-------+
#
# ^ ^ ^ | ^ ^ ^
# | | +-----+ | | | +----+
# | | | | | | |
# +--------- Three <------+ +------- SixA SixB
# | |
# +-----------------------+
# NoDepA:
# NoDepB: NoDepA
# NoDepC: NoDepA
@ -28,11 +30,16 @@ SET( CMAKE_ANALYZE_LIB_DEPENDS "ON" )
# Three: One Four
# Four: One Two A
# Five: Two
# Exec: NoDepB NoDepC Five
# SixA: Two Five
# SixB: Four Five
# Exec: NoDepB NoDepC SixA SixB
#
# The libraries One,...,Five have their dependencies explicitly
# encoded. The libraries NoDepA,...,NoDepC do not.
#
# Although SixB does not depend on Two, there is a dependency listed
# in the corresponding CMakeLists.txt just because of commands used.
SUBDIRS( NoDepA NoDepB NoDepC )
SUBDIRS( One Two Three Four Five )
SUBDIRS( One Two Three Four Five Six )
SUBDIRS( Exec )

View File

@ -1,6 +1,6 @@
ADD_EXECUTABLE( exec ExecMain.c )
# This executable directly depends on NoDepB, NoDepC and Five. However,
# This executable directly depends on NoDepB, NoDepC, SixA and SixB. However,
# since NoDepB and NoDepC do not have explicit dependency information,
# and they depend on NoDepA, we have to manually specify that dependency.
LINK_LIBRARIES( NoDepB NoDepC NoDepA Five )
LINK_LIBRARIES( NoDepB NoDepC NoDepA SixB SixA )

View File

@ -2,11 +2,13 @@
void NoDepBFunction();
void NoDepCFunction();
void FiveFunction();
void SixAFunction();
void SixBFunction();
int main( )
{
FiveFunction();
SixAFunction();
SixBFunction();
NoDepBFunction();
NoDepCFunction();

View File

@ -0,0 +1,12 @@
# In some projects, people don't use TARGET_LINK_LIBRARIES, but just
# use an all-encompassing LINK_LIBRARIES. And sometimes they don't
# specify them in the correct order.
LINK_LIBRARIES( Two )
ADD_LIBRARY( SixA SixASrc.c )
ADD_LIBRARY( SixB SixBSrc.c )
TARGET_LINK_LIBRARIES( SixB Four )
LINK_LIBRARIES( Five )

View File

@ -0,0 +1,8 @@
void FiveFunction();
void TwoFunction();
void SixAFunction()
{
FiveFunction();
TwoFunction();
}

View File

@ -0,0 +1,10 @@
void TwoFunction();
void FiveFunction();
void FourFunction();
void SixBFunction()
{
TwoFunction();
FiveFunction();
FourFunction();
}