Commit 36f80fe6 authored by Amitha Perera's avatar Amitha Perera
Browse files

ENH: Make the LinkLibraries command contribute dependencies towards AddLibraries.

parent 1f8df858
......@@ -15,11 +15,13 @@ 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 )
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 )
......@@ -2,11 +2,13 @@
void NoDepBFunction();
void NoDepCFunction();
void FiveFunction();
void SixAFunction();
void SixBFunction();
int main( )
{
FiveFunction();
SixAFunction();
SixBFunction();
NoDepBFunction();
NoDepCFunction();
......
# 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 )
void FiveFunction();
void TwoFunction();
void SixAFunction()
{
FiveFunction();
TwoFunction();
}
void TwoFunction();
void FiveFunction();
void FourFunction();
void SixBFunction()
{
TwoFunction();
FiveFunction();
FourFunction();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment