summaryrefslogtreecommitdiffstats
path: root/Tests/Dependency
diff options
context:
space:
mode:
authorAmitha Perera <perera@cs.rpi.edu>2002-05-01 18:00:21 (GMT)
committerAmitha Perera <perera@cs.rpi.edu>2002-05-01 18:00:21 (GMT)
commit1f8df8585ef36aa980d13a0cb6646de399bceff9 (patch)
tree3106ab0d6e942aa15c783425316235c75c790e8b /Tests/Dependency
parentd53458de9ac298344a87d6703de78991d6770832 (diff)
downloadCMake-1f8df8585ef36aa980d13a0cb6646de399bceff9.zip
CMake-1f8df8585ef36aa980d13a0cb6646de399bceff9.tar.gz
CMake-1f8df8585ef36aa980d13a0cb6646de399bceff9.tar.bz2
ENH: Add library dependency analysis.
Diffstat (limited to 'Tests/Dependency')
-rw-r--r--Tests/Dependency/CMakeLists.txt38
-rw-r--r--Tests/Dependency/Exec/CMakeLists.txt6
-rw-r--r--Tests/Dependency/Exec/ExecMain.c16
-rw-r--r--Tests/Dependency/Five/CMakeLists.txt3
-rw-r--r--Tests/Dependency/Five/FiveSrc.c6
-rw-r--r--Tests/Dependency/Four/CMakeLists.txt3
-rw-r--r--Tests/Dependency/Four/FourSrc.c14
-rw-r--r--Tests/Dependency/NoDepA/CMakeLists.txt1
-rw-r--r--Tests/Dependency/NoDepA/NoDepASrc.c3
-rw-r--r--Tests/Dependency/NoDepB/CMakeLists.txt3
-rw-r--r--Tests/Dependency/NoDepB/NoDepBSrc.c6
-rw-r--r--Tests/Dependency/NoDepC/CMakeLists.txt3
-rw-r--r--Tests/Dependency/NoDepC/NoDepCSrc.c6
-rw-r--r--Tests/Dependency/One/CMakeLists.txt3
-rw-r--r--Tests/Dependency/One/OneSrc.c3
-rw-r--r--Tests/Dependency/Three/CMakeLists.txt3
-rw-r--r--Tests/Dependency/Three/ThreeSrc.c12
-rw-r--r--Tests/Dependency/Two/CMakeLists.txt3
-rw-r--r--Tests/Dependency/Two/TwoSrc.c10
19 files changed, 142 insertions, 0 deletions
diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt
new file mode 100644
index 0000000..81365d1
--- /dev/null
+++ b/Tests/Dependency/CMakeLists.txt
@@ -0,0 +1,38 @@
+PROJECT( Dependency )
+
+SET( LIBRARY_OUTPUT_PATH ${Dependency_BINARY_DIR}/Lib )
+SET( CMAKE_ANALYZE_LIB_DEPENDS "ON" )
+
+# There is one executable that depends on eight libraries. The
+# system has the following dependency graph:
+#
+# +----------- NoDepC <---- EXECUTABLE
+# | | |
+# V | |
+# | |
+# NoDepA <----- NoDepB <-------+ |
+# |
+# ^ |
+# | |
+# One <------ Four -----> Two <----- Five <---+
+# |
+# ^ ^ |
+# | | |
+# +--------- Three <-------+
+#
+# NoDepA:
+# NoDepB: NoDepA
+# NoDepC: NoDepA
+# One:
+# Two: Three
+# Three: One Four
+# Four: One Two A
+# Five: Two
+# Exec: NoDepB NoDepC Five
+#
+# The libraries One,...,Five have their dependencies explicitly
+# encoded. The libraries NoDepA,...,NoDepC do not.
+
+SUBDIRS( NoDepA NoDepB NoDepC )
+SUBDIRS( One Two Three Four Five )
+SUBDIRS( Exec )
diff --git a/Tests/Dependency/Exec/CMakeLists.txt b/Tests/Dependency/Exec/CMakeLists.txt
new file mode 100644
index 0000000..7214b05
--- /dev/null
+++ b/Tests/Dependency/Exec/CMakeLists.txt
@@ -0,0 +1,6 @@
+ADD_EXECUTABLE( exec ExecMain.c )
+
+# This executable directly depends on NoDepB, NoDepC and Five. 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 )
diff --git a/Tests/Dependency/Exec/ExecMain.c b/Tests/Dependency/Exec/ExecMain.c
new file mode 100644
index 0000000..b666a24
--- /dev/null
+++ b/Tests/Dependency/Exec/ExecMain.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+void NoDepBFunction();
+void NoDepCFunction();
+void FiveFunction();
+
+int main( )
+{
+ FiveFunction();
+ NoDepBFunction();
+ NoDepCFunction();
+
+ printf("Dependency test executable ran successfully.\n");
+
+ return 0;
+}
diff --git a/Tests/Dependency/Five/CMakeLists.txt b/Tests/Dependency/Five/CMakeLists.txt
new file mode 100644
index 0000000..27f6a1f
--- /dev/null
+++ b/Tests/Dependency/Five/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY( Five FiveSrc.c )
+TARGET_LINK_LIBRARIES( Five Two )
+
diff --git a/Tests/Dependency/Five/FiveSrc.c b/Tests/Dependency/Five/FiveSrc.c
new file mode 100644
index 0000000..33d8ad7
--- /dev/null
+++ b/Tests/Dependency/Five/FiveSrc.c
@@ -0,0 +1,6 @@
+void TwoFunction();
+
+void FiveFunction()
+{
+ TwoFunction();
+}
diff --git a/Tests/Dependency/Four/CMakeLists.txt b/Tests/Dependency/Four/CMakeLists.txt
new file mode 100644
index 0000000..ba3711f
--- /dev/null
+++ b/Tests/Dependency/Four/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY( Four FourSrc.c )
+TARGET_LINK_LIBRARIES( Four One Two NoDepA )
+
diff --git a/Tests/Dependency/Four/FourSrc.c b/Tests/Dependency/Four/FourSrc.c
new file mode 100644
index 0000000..e8fefcd
--- /dev/null
+++ b/Tests/Dependency/Four/FourSrc.c
@@ -0,0 +1,14 @@
+void NoDepAFunction();
+void OneFunction();
+void TwoFunction();
+
+void FourFunction()
+{
+ static int count = 0;
+ if( count == 0 ) {
+ ++count;
+ TwoFunction();
+ }
+ OneFunction();
+ NoDepAFunction();
+}
diff --git a/Tests/Dependency/NoDepA/CMakeLists.txt b/Tests/Dependency/NoDepA/CMakeLists.txt
new file mode 100644
index 0000000..cedf185
--- /dev/null
+++ b/Tests/Dependency/NoDepA/CMakeLists.txt
@@ -0,0 +1 @@
+ADD_LIBRARY( NoDepA NoDepASrc.c )
diff --git a/Tests/Dependency/NoDepA/NoDepASrc.c b/Tests/Dependency/NoDepA/NoDepASrc.c
new file mode 100644
index 0000000..8c4072b
--- /dev/null
+++ b/Tests/Dependency/NoDepA/NoDepASrc.c
@@ -0,0 +1,3 @@
+void NoDepAFunction()
+{
+}
diff --git a/Tests/Dependency/NoDepB/CMakeLists.txt b/Tests/Dependency/NoDepB/CMakeLists.txt
new file mode 100644
index 0000000..0d69f68
--- /dev/null
+++ b/Tests/Dependency/NoDepB/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY( NoDepB NoDepBSrc.c )
+# This library depends on NoDepA, but the
+# dependency is not explicitly specified.
diff --git a/Tests/Dependency/NoDepB/NoDepBSrc.c b/Tests/Dependency/NoDepB/NoDepBSrc.c
new file mode 100644
index 0000000..ddc71c5
--- /dev/null
+++ b/Tests/Dependency/NoDepB/NoDepBSrc.c
@@ -0,0 +1,6 @@
+void NoDepAFunction();
+
+void NoDepBFunction()
+{
+ NoDepAFunction();
+}
diff --git a/Tests/Dependency/NoDepC/CMakeLists.txt b/Tests/Dependency/NoDepC/CMakeLists.txt
new file mode 100644
index 0000000..88b29ba
--- /dev/null
+++ b/Tests/Dependency/NoDepC/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY( NoDepC NoDepCSrc.c )
+# This library depends on NoDepA, but the
+# dependency is not explicitly specified.
diff --git a/Tests/Dependency/NoDepC/NoDepCSrc.c b/Tests/Dependency/NoDepC/NoDepCSrc.c
new file mode 100644
index 0000000..b478c59
--- /dev/null
+++ b/Tests/Dependency/NoDepC/NoDepCSrc.c
@@ -0,0 +1,6 @@
+void NoDepAFunction();
+
+void NoDepCFunction()
+{
+ NoDepAFunction();
+}
diff --git a/Tests/Dependency/One/CMakeLists.txt b/Tests/Dependency/One/CMakeLists.txt
new file mode 100644
index 0000000..b50b2e9
--- /dev/null
+++ b/Tests/Dependency/One/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY( One OneSrc.c )
+# This library has no dependencies
+TARGET_LINK_LIBRARIES( One "" )
diff --git a/Tests/Dependency/One/OneSrc.c b/Tests/Dependency/One/OneSrc.c
new file mode 100644
index 0000000..9801c25
--- /dev/null
+++ b/Tests/Dependency/One/OneSrc.c
@@ -0,0 +1,3 @@
+void OneFunction()
+{
+}
diff --git a/Tests/Dependency/Three/CMakeLists.txt b/Tests/Dependency/Three/CMakeLists.txt
new file mode 100644
index 0000000..6b20dcb
--- /dev/null
+++ b/Tests/Dependency/Three/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY( Three ThreeSrc.c )
+TARGET_LINK_LIBRARIES( Three One Four )
+
diff --git a/Tests/Dependency/Three/ThreeSrc.c b/Tests/Dependency/Three/ThreeSrc.c
new file mode 100644
index 0000000..9c77f17
--- /dev/null
+++ b/Tests/Dependency/Three/ThreeSrc.c
@@ -0,0 +1,12 @@
+void OneFunction();
+void FourFunction();
+
+void ThreeFunction()
+{
+ static int count = 0;
+ if( count == 0 ) {
+ ++count;
+ FourFunction();
+ }
+ OneFunction();
+}
diff --git a/Tests/Dependency/Two/CMakeLists.txt b/Tests/Dependency/Two/CMakeLists.txt
new file mode 100644
index 0000000..6a9630e
--- /dev/null
+++ b/Tests/Dependency/Two/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY( Two TwoSrc.c )
+TARGET_LINK_LIBRARIES( Two Three )
+
diff --git a/Tests/Dependency/Two/TwoSrc.c b/Tests/Dependency/Two/TwoSrc.c
new file mode 100644
index 0000000..981df09
--- /dev/null
+++ b/Tests/Dependency/Two/TwoSrc.c
@@ -0,0 +1,10 @@
+void ThreeFunction();
+
+void TwoFunction()
+{
+ static int count = 0;
+ if( count == 0 ) {
+ ++count;
+ ThreeFunction();
+ }
+}