diff options
author | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:34:34 +0900 |
---|---|---|
committer | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:34:34 +0900 |
commit | cc1a12d36421addf6726f86a5b24f913024d8b3a (patch) | |
tree | 253958b9b8d3ffe9120c78cf3bd5389b8e4a0ea0 /Tests/Dependency | |
download | cmake-tizen_2.3.tar.gz cmake-tizen_2.3.tar.bz2 cmake-tizen_2.3.zip |
Initialize Tizen 2.3tizen_2.3_releasesubmit/tizen_2.3/20150202.102300submit/tizen_2.3/20140531.0637312.3a_releasetizen_2.3
Diffstat (limited to 'Tests/Dependency')
64 files changed, 463 insertions, 0 deletions
diff --git a/Tests/Dependency/1/CMakeLists.txt b/Tests/Dependency/1/CMakeLists.txt new file mode 100644 index 0000000..b50b2e9 --- /dev/null +++ b/Tests/Dependency/1/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/1/OneSrc.c b/Tests/Dependency/1/OneSrc.c new file mode 100644 index 0000000..9801c25 --- /dev/null +++ b/Tests/Dependency/1/OneSrc.c @@ -0,0 +1,3 @@ +void OneFunction() +{ +} diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt new file mode 100644 index 0000000..86e128f --- /dev/null +++ b/Tests/Dependency/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT( Dependency ) + +# to test directories with only one character One was changed to 1 +# There is one executable that depends on eight libraries. The +# system has the following dependency graph: +# +# NoDepA: +# NoDepB: NoDepA +# NoDepC: NoDepA +# 1: +# Two: Three +# Three: 1 Four +# Four: 1 Two NoDepA +# Five: Two +# SixA: Two Five +# SixB: Four Five +# Seven: Two +# Eight: Seven +# +# Exec: NoDepB NoDepC SixA SixB +# Exec2: Eight Five +# Exec3: Eight Five +# Exec4: Five Two +# +# The libraries One,...,Eight 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. + +ADD_SUBDIRECTORY(NoDepA) +ADD_SUBDIRECTORY(NoDepB) +ADD_SUBDIRECTORY(NoDepC) +ADD_SUBDIRECTORY(1) +ADD_SUBDIRECTORY(Two) +ADD_SUBDIRECTORY(Three) +ADD_SUBDIRECTORY(Four) +ADD_SUBDIRECTORY(Five) +ADD_SUBDIRECTORY(Six) +ADD_SUBDIRECTORY(Seven) +ADD_SUBDIRECTORY(Eight) +ADD_SUBDIRECTORY(Exec) +ADD_SUBDIRECTORY(Exec2) +ADD_SUBDIRECTORY(Exec3) +ADD_SUBDIRECTORY(Exec4) + +# Specific cases added to test fixes to problems found in real +# projects. +ADD_SUBDIRECTORY(Case1) +ADD_SUBDIRECTORY(Case2) +ADD_SUBDIRECTORY(Case3) +ADD_SUBDIRECTORY(Case4) diff --git a/Tests/Dependency/Case1/CMakeLists.txt b/Tests/Dependency/Case1/CMakeLists.txt new file mode 100644 index 0000000..4c5fc20 --- /dev/null +++ b/Tests/Dependency/Case1/CMakeLists.txt @@ -0,0 +1,19 @@ +project(CASE1) + +# The old anaylize lib depends stuff in cmTarget gets this case wrong. +# The cmComputeLinkDepends implementation gets it right. + +add_library(case1a STATIC a.c) + +add_library(case1b STATIC b.c b2.c) +target_link_libraries(case1b case1a) + +add_library(case1c STATIC c.c c2.c) +target_link_libraries(case1c case1b) + +add_library(case1d STATIC d.c) +target_link_libraries(case1d case1c) + +add_executable(hello main.c) +target_link_libraries(hello case1c case1b case1d case1c) + diff --git a/Tests/Dependency/Case1/a.c b/Tests/Dependency/Case1/a.c new file mode 100644 index 0000000..d702db1 --- /dev/null +++ b/Tests/Dependency/Case1/a.c @@ -0,0 +1,5 @@ +int a() +{ + return 5; +} + diff --git a/Tests/Dependency/Case1/b.c b/Tests/Dependency/Case1/b.c new file mode 100644 index 0000000..6bdfafa --- /dev/null +++ b/Tests/Dependency/Case1/b.c @@ -0,0 +1,6 @@ +extern int a(); + +int b() +{ + return a()+17; +} diff --git a/Tests/Dependency/Case1/b2.c b/Tests/Dependency/Case1/b2.c new file mode 100644 index 0000000..f37e1bb --- /dev/null +++ b/Tests/Dependency/Case1/b2.c @@ -0,0 +1,4 @@ +int b2() +{ + return 3; +} diff --git a/Tests/Dependency/Case1/c.c b/Tests/Dependency/Case1/c.c new file mode 100644 index 0000000..c180a59 --- /dev/null +++ b/Tests/Dependency/Case1/c.c @@ -0,0 +1,6 @@ +extern int b(); + +int c() +{ + return b()+42; +} diff --git a/Tests/Dependency/Case1/c2.c b/Tests/Dependency/Case1/c2.c new file mode 100644 index 0000000..4cf4426 --- /dev/null +++ b/Tests/Dependency/Case1/c2.c @@ -0,0 +1,6 @@ +extern int b2(); + +int c2() +{ + return b2()+1; +} diff --git a/Tests/Dependency/Case1/d.c b/Tests/Dependency/Case1/d.c new file mode 100644 index 0000000..ea5457d --- /dev/null +++ b/Tests/Dependency/Case1/d.c @@ -0,0 +1,7 @@ +extern int c2(); + +int d() +{ + return c2()+2; +} + diff --git a/Tests/Dependency/Case1/main.c b/Tests/Dependency/Case1/main.c new file mode 100644 index 0000000..1e5f6d4 --- /dev/null +++ b/Tests/Dependency/Case1/main.c @@ -0,0 +1,10 @@ +extern int b(); +extern int c(); +extern int d(); + +int main() +{ + c(); + b(); + d(); +} diff --git a/Tests/Dependency/Case2/CMakeLists.txt b/Tests/Dependency/Case2/CMakeLists.txt new file mode 100644 index 0000000..21caaad --- /dev/null +++ b/Tests/Dependency/Case2/CMakeLists.txt @@ -0,0 +1,22 @@ +project(CASE2 C) + +add_library(case2Foo1 STATIC foo1.c foo1b.c foo1c.c) +add_library(case2Foo2 STATIC foo2.c foo2b.c foo2c.c) +add_library(case2Foo3 STATIC foo3.c foo3b.c foo3c.c) +target_link_libraries(case2Foo1 case2Foo2) +target_link_libraries(case2Foo2 case2Foo3) +target_link_libraries(case2Foo3 case2Foo1) +set_property(TARGET case2Foo1 PROPERTY LINK_INTERFACE_MULTIPLICITY 3) + +add_library(case2Bar1 STATIC bar1.c) +add_library(case2Bar2 STATIC bar2.c) +add_library(case2Bar3 STATIC bar3.c) +target_link_libraries(case2Bar1 case2Bar2 case2Foo1) +target_link_libraries(case2Bar2 case2Bar3) +target_link_libraries(case2Bar3 case2Bar1) + +add_executable(case2Zot zot.c) +target_link_libraries(case2Zot case2Bar1) + +#set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1) +#set(CMAKE_LINK_DEPENDS_DEBUG_MODE 1) diff --git a/Tests/Dependency/Case2/bar1.c b/Tests/Dependency/Case2/bar1.c new file mode 100644 index 0000000..6108fba --- /dev/null +++ b/Tests/Dependency/Case2/bar1.c @@ -0,0 +1,4 @@ +extern int foo1(); +extern int bar2(void); +int bar1(void) { return bar2(); } +int bar1_from_bar3(void) { return foo1(); } diff --git a/Tests/Dependency/Case2/bar2.c b/Tests/Dependency/Case2/bar2.c new file mode 100644 index 0000000..b9a2360 --- /dev/null +++ b/Tests/Dependency/Case2/bar2.c @@ -0,0 +1,2 @@ +extern int bar3(void); +int bar2(void) { return bar3(); } diff --git a/Tests/Dependency/Case2/bar3.c b/Tests/Dependency/Case2/bar3.c new file mode 100644 index 0000000..73e8556 --- /dev/null +++ b/Tests/Dependency/Case2/bar3.c @@ -0,0 +1,2 @@ +extern int bar1_from_bar3(void); +int bar3(void) { return bar1_from_bar3(); } diff --git a/Tests/Dependency/Case2/foo1.c b/Tests/Dependency/Case2/foo1.c new file mode 100644 index 0000000..5f1f8ac --- /dev/null +++ b/Tests/Dependency/Case2/foo1.c @@ -0,0 +1,2 @@ +extern int foo2(void); +int foo1(void) { return foo2(); } diff --git a/Tests/Dependency/Case2/foo1b.c b/Tests/Dependency/Case2/foo1b.c new file mode 100644 index 0000000..e2b6dc3 --- /dev/null +++ b/Tests/Dependency/Case2/foo1b.c @@ -0,0 +1,2 @@ +extern int foo2b(void); +int foo1b(void) { return foo2b(); } diff --git a/Tests/Dependency/Case2/foo1c.c b/Tests/Dependency/Case2/foo1c.c new file mode 100644 index 0000000..1dcca58 --- /dev/null +++ b/Tests/Dependency/Case2/foo1c.c @@ -0,0 +1,2 @@ +extern int foo2c(void); +int foo1c(void) { return foo2c(); } diff --git a/Tests/Dependency/Case2/foo2.c b/Tests/Dependency/Case2/foo2.c new file mode 100644 index 0000000..6019236 --- /dev/null +++ b/Tests/Dependency/Case2/foo2.c @@ -0,0 +1,2 @@ +extern int foo3(void); +int foo2(void) { return foo3(); } diff --git a/Tests/Dependency/Case2/foo2b.c b/Tests/Dependency/Case2/foo2b.c new file mode 100644 index 0000000..34d6944 --- /dev/null +++ b/Tests/Dependency/Case2/foo2b.c @@ -0,0 +1,2 @@ +extern int foo3b(void); +int foo2b(void) { return foo3b(); } diff --git a/Tests/Dependency/Case2/foo2c.c b/Tests/Dependency/Case2/foo2c.c new file mode 100644 index 0000000..dbc54de --- /dev/null +++ b/Tests/Dependency/Case2/foo2c.c @@ -0,0 +1,2 @@ +extern int foo3c(void); +int foo2c(void) { return foo3c(); } diff --git a/Tests/Dependency/Case2/foo3.c b/Tests/Dependency/Case2/foo3.c new file mode 100644 index 0000000..dacef6a --- /dev/null +++ b/Tests/Dependency/Case2/foo3.c @@ -0,0 +1,2 @@ +extern int foo1b(void); +int foo3(void) { return foo1b(); } diff --git a/Tests/Dependency/Case2/foo3b.c b/Tests/Dependency/Case2/foo3b.c new file mode 100644 index 0000000..ca25fd8 --- /dev/null +++ b/Tests/Dependency/Case2/foo3b.c @@ -0,0 +1,2 @@ +extern int foo1c(void); +int foo3b(void) { return foo1c(); } diff --git a/Tests/Dependency/Case2/foo3c.c b/Tests/Dependency/Case2/foo3c.c new file mode 100644 index 0000000..0ad65fe --- /dev/null +++ b/Tests/Dependency/Case2/foo3c.c @@ -0,0 +1 @@ +int foo3c(void) { return 0; } diff --git a/Tests/Dependency/Case2/zot.c b/Tests/Dependency/Case2/zot.c new file mode 100644 index 0000000..f25b493 --- /dev/null +++ b/Tests/Dependency/Case2/zot.c @@ -0,0 +1,5 @@ +extern int bar1(void); +int main(void) +{ + return bar1(); +} diff --git a/Tests/Dependency/Case3/CMakeLists.txt b/Tests/Dependency/Case3/CMakeLists.txt new file mode 100644 index 0000000..f01dd05 --- /dev/null +++ b/Tests/Dependency/Case3/CMakeLists.txt @@ -0,0 +1,10 @@ +project(CASE3 C) + +add_library(case3Foo1 STATIC foo1.c foo1b.c) +add_library(case3Foo2 STATIC foo2.c) + +add_executable(case3Bar bar.c) +target_link_libraries(case3Bar case3Foo1 case3Foo2 case3Foo1) + +#set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1) +#set(CMAKE_LINK_DEPENDS_DEBUG_MODE 1) diff --git a/Tests/Dependency/Case3/bar.c b/Tests/Dependency/Case3/bar.c new file mode 100644 index 0000000..62959c1 --- /dev/null +++ b/Tests/Dependency/Case3/bar.c @@ -0,0 +1,5 @@ +extern int foo1(void); +int main(void) +{ + return foo1(); +} diff --git a/Tests/Dependency/Case3/foo1.c b/Tests/Dependency/Case3/foo1.c new file mode 100644 index 0000000..5f1f8ac --- /dev/null +++ b/Tests/Dependency/Case3/foo1.c @@ -0,0 +1,2 @@ +extern int foo2(void); +int foo1(void) { return foo2(); } diff --git a/Tests/Dependency/Case3/foo1b.c b/Tests/Dependency/Case3/foo1b.c new file mode 100644 index 0000000..6ae3bab --- /dev/null +++ b/Tests/Dependency/Case3/foo1b.c @@ -0,0 +1 @@ +int foo1b(void) { return 0; } diff --git a/Tests/Dependency/Case3/foo2.c b/Tests/Dependency/Case3/foo2.c new file mode 100644 index 0000000..33dbbfc --- /dev/null +++ b/Tests/Dependency/Case3/foo2.c @@ -0,0 +1,2 @@ +extern int foo1b(void); +int foo2(void) { return foo1b(); } diff --git a/Tests/Dependency/Case4/CMakeLists.txt b/Tests/Dependency/Case4/CMakeLists.txt new file mode 100644 index 0000000..a71049d --- /dev/null +++ b/Tests/Dependency/Case4/CMakeLists.txt @@ -0,0 +1,19 @@ +project(CASE4 C) + +# This is not really a circular dependency. "case4Bar" refers to a +# third-party library that happens to match the executable name, which +# is okay when the executable is not a linkable target (ENABLE_EXPORTS +# is not set). This tests whether CMake avoids incorrectly reporting +# a circular dependency. In practice case4Foo may be a shared +# library, but we skip that here because we do not want it to actually +# have to find the third-party library. +add_library(case4Foo STATIC foo.c) +target_link_libraries(case4Foo case4Bar) + +# The executable avoids linking to a library with its own name, which +# has been a CMake-ism for a long time, so we will not get a link +# failure. An imported target or executable with an OUTPUT_NAME set +# may be used if the user really wants to link a third-party library +# into an executable of the same name. +add_executable(case4Bar bar.c) +target_link_libraries(case4Bar case4Foo) diff --git a/Tests/Dependency/Case4/bar.c b/Tests/Dependency/Case4/bar.c new file mode 100644 index 0000000..d0bb0c4 --- /dev/null +++ b/Tests/Dependency/Case4/bar.c @@ -0,0 +1,2 @@ +extern int foo(); +int main() { return foo(); } diff --git a/Tests/Dependency/Case4/foo.c b/Tests/Dependency/Case4/foo.c new file mode 100644 index 0000000..9fe07f8 --- /dev/null +++ b/Tests/Dependency/Case4/foo.c @@ -0,0 +1 @@ +int foo() { return 0; } diff --git a/Tests/Dependency/Eight/CMakeLists.txt b/Tests/Dependency/Eight/CMakeLists.txt new file mode 100644 index 0000000..5d8e756 --- /dev/null +++ b/Tests/Dependency/Eight/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( Eight EightSrc.c ) +TARGET_LINK_LIBRARIES( Eight Seven ) + diff --git a/Tests/Dependency/Eight/EightSrc.c b/Tests/Dependency/Eight/EightSrc.c new file mode 100644 index 0000000..7bfa481 --- /dev/null +++ b/Tests/Dependency/Eight/EightSrc.c @@ -0,0 +1,6 @@ +void SevenFunction(); + +void EightFunction() +{ + SevenFunction(); +} diff --git a/Tests/Dependency/Exec/CMakeLists.txt b/Tests/Dependency/Exec/CMakeLists.txt new file mode 100644 index 0000000..97fffe7 --- /dev/null +++ b/Tests/Dependency/Exec/CMakeLists.txt @@ -0,0 +1,7 @@ +# 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 SixB SixA ) + +ADD_EXECUTABLE( exec ExecMain.c ) + diff --git a/Tests/Dependency/Exec/ExecMain.c b/Tests/Dependency/Exec/ExecMain.c new file mode 100644 index 0000000..d2f551c --- /dev/null +++ b/Tests/Dependency/Exec/ExecMain.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +void NoDepBFunction(); +void NoDepCFunction(); +void SixAFunction(); +void SixBFunction(); + +int main( ) +{ + SixAFunction(); + SixBFunction(); + NoDepBFunction(); + NoDepCFunction(); + + printf("Dependency test executable ran successfully.\n"); + + return 0; +} diff --git a/Tests/Dependency/Exec2/CMakeLists.txt b/Tests/Dependency/Exec2/CMakeLists.txt new file mode 100644 index 0000000..ee0c74d --- /dev/null +++ b/Tests/Dependency/Exec2/CMakeLists.txt @@ -0,0 +1,12 @@ +# Here, Eight depends on Seven, which has the same dependencies as Five. +# If the dependencies of Five are emitted, and then we attempt to emit the +# dependencies of Seven, then we find that they have already been done. So: +# Original line: Eight Five +# Add deps of Five: Eight Five Two ... NoDepA +# Now, we must make sure that Seven gets inserted between Five and Two, and +# not at the end. Unfortunately, if we get it wrong, the test will only +# fail on a platform where the link order makes a difference. +LINK_LIBRARIES( Eight Five ) + +ADD_EXECUTABLE( exec2 ExecMain.c ) + diff --git a/Tests/Dependency/Exec2/ExecMain.c b/Tests/Dependency/Exec2/ExecMain.c new file mode 100644 index 0000000..d08a796 --- /dev/null +++ b/Tests/Dependency/Exec2/ExecMain.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void FiveFunction(); +void EightFunction(); + +int main( ) +{ + FiveFunction(); + EightFunction(); + + printf("Dependency test executable ran successfully.\n"); + + return 0; +} diff --git a/Tests/Dependency/Exec3/CMakeLists.txt b/Tests/Dependency/Exec3/CMakeLists.txt new file mode 100644 index 0000000..b33e732 --- /dev/null +++ b/Tests/Dependency/Exec3/CMakeLists.txt @@ -0,0 +1,6 @@ +# Here, Five already has it's immediate dependency, Two satisfied. We must +# make sure Two gets output anyway, because Eight indirectly depends on it. +LINK_LIBRARIES( Five Two Eight Five ) + +ADD_EXECUTABLE( exec3 ExecMain.c ) + diff --git a/Tests/Dependency/Exec3/ExecMain.c b/Tests/Dependency/Exec3/ExecMain.c new file mode 100644 index 0000000..d08a796 --- /dev/null +++ b/Tests/Dependency/Exec3/ExecMain.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void FiveFunction(); +void EightFunction(); + +int main( ) +{ + FiveFunction(); + EightFunction(); + + printf("Dependency test executable ran successfully.\n"); + + return 0; +} diff --git a/Tests/Dependency/Exec4/CMakeLists.txt b/Tests/Dependency/Exec4/CMakeLists.txt new file mode 100644 index 0000000..6fcb153 --- /dev/null +++ b/Tests/Dependency/Exec4/CMakeLists.txt @@ -0,0 +1,6 @@ +# Even though Five's dependency on Two is explicitly satisfied, Two +# must be emitted again in order to satisfy a cyclic dependency on Three. +LINK_LIBRARIES( Five Two Five ) + +ADD_EXECUTABLE( exec4 ExecMain.c ) + diff --git a/Tests/Dependency/Exec4/ExecMain.c b/Tests/Dependency/Exec4/ExecMain.c new file mode 100644 index 0000000..3f53573 --- /dev/null +++ b/Tests/Dependency/Exec4/ExecMain.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void FiveFunction(); +void TwoFunction(); + +int main( ) +{ + FiveFunction(); + TwoFunction(); + + 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..df0f162 --- /dev/null +++ b/Tests/Dependency/Four/CMakeLists.txt @@ -0,0 +1,6 @@ +INCLUDE_DIRECTORIES(${Dependency_BINARY_DIR}/Two) +ADD_LIBRARY( Four FourSrc.c ) +TARGET_LINK_LIBRARIES( Four One Two NoDepA ) + +# TwoCustom must build before Four. +ADD_DEPENDENCIES(Four TwoCustom) diff --git a/Tests/Dependency/Four/FourSrc.c b/Tests/Dependency/Four/FourSrc.c new file mode 100644 index 0000000..23a66a4 --- /dev/null +++ b/Tests/Dependency/Four/FourSrc.c @@ -0,0 +1,15 @@ +#include <two-test.h> /* Requires TwoCustom to be built first. */ +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/Seven/CMakeLists.txt b/Tests/Dependency/Seven/CMakeLists.txt new file mode 100644 index 0000000..51a38d8 --- /dev/null +++ b/Tests/Dependency/Seven/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( Seven SevenSrc.c ) +TARGET_LINK_LIBRARIES( Seven Two ) + diff --git a/Tests/Dependency/Seven/SevenSrc.c b/Tests/Dependency/Seven/SevenSrc.c new file mode 100644 index 0000000..e1f3329 --- /dev/null +++ b/Tests/Dependency/Seven/SevenSrc.c @@ -0,0 +1,6 @@ +void TwoFunction(); + +void SevenFunction() +{ + TwoFunction(); +} diff --git a/Tests/Dependency/Six/CMakeLists.txt b/Tests/Dependency/Six/CMakeLists.txt new file mode 100644 index 0000000..d0abdd6 --- /dev/null +++ b/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 ) +LINK_LIBRARIES( Five ) + +ADD_LIBRARY( SixA SixASrc.c ) + +ADD_LIBRARY( SixB SixBSrc.c ) +TARGET_LINK_LIBRARIES( SixB Four ) + diff --git a/Tests/Dependency/Six/SixASrc.c b/Tests/Dependency/Six/SixASrc.c new file mode 100644 index 0000000..7ea3711 --- /dev/null +++ b/Tests/Dependency/Six/SixASrc.c @@ -0,0 +1,8 @@ +void FiveFunction(); +void TwoFunction(); + +void SixAFunction() +{ + FiveFunction(); + TwoFunction(); +} diff --git a/Tests/Dependency/Six/SixBSrc.c b/Tests/Dependency/Six/SixBSrc.c new file mode 100644 index 0000000..92f9607 --- /dev/null +++ b/Tests/Dependency/Six/SixBSrc.c @@ -0,0 +1,10 @@ +void TwoFunction(); +void FiveFunction(); +void FourFunction(); + +void SixBFunction() +{ + TwoFunction(); + FiveFunction(); + FourFunction(); +} 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..587c848 --- /dev/null +++ b/Tests/Dependency/Two/CMakeLists.txt @@ -0,0 +1,20 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +ADD_LIBRARY( Two TwoSrc.c ) +TARGET_LINK_LIBRARIES( Two Three ) + +# Setup a target to cause failure if Two does not depend on it or if +# Two actually links to it. This will test that a utility dependency +# on a library target works properly. +ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/two-test.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/two-test.h.in + ${CMAKE_CURRENT_BINARY_DIR}/two-test.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/two-test.h.in + ) +ADD_LIBRARY( TwoCustom TwoCustomSrc.c ${CMAKE_CURRENT_BINARY_DIR}/two-test.h) +SET_TARGET_PROPERTIES(TwoCustom PROPERTIES EXCLUDE_FROM_ALL 1) +TARGET_LINK_LIBRARIES(TwoCustom Three) + +# Add a utility dependency to make sure it works without linking. +ADD_DEPENDENCIES(Two TwoCustom) diff --git a/Tests/Dependency/Two/TwoCustomSrc.c b/Tests/Dependency/Two/TwoCustomSrc.c new file mode 100644 index 0000000..ac31dcf --- /dev/null +++ b/Tests/Dependency/Two/TwoCustomSrc.c @@ -0,0 +1,10 @@ +extern void NoFunction(); + +/* Provide a function that is supposed to be found in the Three + library. If Two links to TwoCustom then TwoCustom will come before + Three and this symbol will be used. Since NoFunction is not + defined, that will cause a link failure. */ +void ThreeFunction() +{ + NoFunction(); +} diff --git a/Tests/Dependency/Two/TwoSrc.c b/Tests/Dependency/Two/TwoSrc.c new file mode 100644 index 0000000..0b3366b --- /dev/null +++ b/Tests/Dependency/Two/TwoSrc.c @@ -0,0 +1,10 @@ +#include <two-test.h> + +void TwoFunction() +{ + static int count = 0; + if( count == 0 ) { + ++count; + ThreeFunction(); + } +} diff --git a/Tests/Dependency/Two/two-test.h.in b/Tests/Dependency/Two/two-test.h.in new file mode 100644 index 0000000..8c6a7f7 --- /dev/null +++ b/Tests/Dependency/Two/two-test.h.in @@ -0,0 +1 @@ +extern void ThreeFunction(); |