ENH: Make the LinkLibraries command contribute dependencies towards AddLibraries.
This commit is contained in:
parent
1f8df8585e
commit
36f80fe6c8
|
@ -16,10 +16,12 @@ SET( CMAKE_ANALYZE_LIB_DEPENDS "ON" )
|
||||||
# | |
|
# | |
|
||||||
# One <------ Four -----> Two <----- Five <---+
|
# One <------ Four -----> Two <----- Five <---+
|
||||||
# |
|
# |
|
||||||
# ^ ^ |
|
# ^ ^ ^ | ^ ^ ^
|
||||||
# | | |
|
# | | +-----+ | | | +----+
|
||||||
# +--------- Three <-------+
|
# | | | | | | |
|
||||||
#
|
# +--------- Three <------+ +------- SixA SixB
|
||||||
|
# | |
|
||||||
|
# +-----------------------+
|
||||||
# NoDepA:
|
# NoDepA:
|
||||||
# NoDepB: NoDepA
|
# NoDepB: NoDepA
|
||||||
# NoDepC: NoDepA
|
# NoDepC: NoDepA
|
||||||
|
@ -28,11 +30,16 @@ SET( CMAKE_ANALYZE_LIB_DEPENDS "ON" )
|
||||||
# Three: One Four
|
# Three: One Four
|
||||||
# Four: One Two A
|
# Four: One Two A
|
||||||
# Five: Two
|
# 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
|
# The libraries One,...,Five have their dependencies explicitly
|
||||||
# encoded. The libraries NoDepA,...,NoDepC do not.
|
# 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( NoDepA NoDepB NoDepC )
|
||||||
SUBDIRS( One Two Three Four Five )
|
SUBDIRS( One Two Three Four Five Six )
|
||||||
SUBDIRS( Exec )
|
SUBDIRS( Exec )
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
ADD_EXECUTABLE( exec ExecMain.c )
|
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,
|
# since NoDepB and NoDepC do not have explicit dependency information,
|
||||||
# and they depend on NoDepA, we have to manually specify that dependency.
|
# 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 )
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
void NoDepBFunction();
|
void NoDepBFunction();
|
||||||
void NoDepCFunction();
|
void NoDepCFunction();
|
||||||
void FiveFunction();
|
void SixAFunction();
|
||||||
|
void SixBFunction();
|
||||||
|
|
||||||
int main( )
|
int main( )
|
||||||
{
|
{
|
||||||
FiveFunction();
|
SixAFunction();
|
||||||
|
SixBFunction();
|
||||||
NoDepBFunction();
|
NoDepBFunction();
|
||||||
NoDepCFunction();
|
NoDepCFunction();
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
|
@ -0,0 +1,8 @@
|
||||||
|
void FiveFunction();
|
||||||
|
void TwoFunction();
|
||||||
|
|
||||||
|
void SixAFunction()
|
||||||
|
{
|
||||||
|
FiveFunction();
|
||||||
|
TwoFunction();
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
void TwoFunction();
|
||||||
|
void FiveFunction();
|
||||||
|
void FourFunction();
|
||||||
|
|
||||||
|
void SixBFunction()
|
||||||
|
{
|
||||||
|
TwoFunction();
|
||||||
|
FiveFunction();
|
||||||
|
FourFunction();
|
||||||
|
}
|
Loading…
Reference in New Issue