Ver código fonte

ENH: Make the LinkLibraries command contribute dependencies towards AddLibraries.

Amitha Perera 24 anos atrás
pai
commit
36f80fe6c8

+ 14 - 7
Tests/Dependency/CMakeLists.txt

@@ -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 )

+ 2 - 2
Tests/Dependency/Exec/CMakeLists.txt

@@ -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 )

+ 4 - 2
Tests/Dependency/Exec/ExecMain.c

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

+ 12 - 0
Tests/Dependency/Six/CMakeLists.txt

@@ -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 )

+ 8 - 0
Tests/Dependency/Six/SixASrc.c

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

+ 10 - 0
Tests/Dependency/Six/SixBSrc.c

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