summaryrefslogtreecommitdiffstats
path: root/Tests/Dependency
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-08-07 14:13:15 (GMT)
committerBrad King <brad.king@kitware.com>2008-08-07 14:13:15 (GMT)
commitc76f3ae5b5b9709fc2cd97d838e52c52412bf5c5 (patch)
tree28c704f174b5d826ef3a1427c00bdcb647ab0f4d /Tests/Dependency
parentb8fc8b324d2e1b892d0b41cf3581226c210131d0 (diff)
downloadCMake-c76f3ae5b5b9709fc2cd97d838e52c52412bf5c5.zip
CMake-c76f3ae5b5b9709fc2cd97d838e52c52412bf5c5.tar.gz
CMake-c76f3ae5b5b9709fc2cd97d838e52c52412bf5c5.tar.bz2
ENH: Test fake circular dependency case
A recent change fixed a case in which CMake incorrectly diagnosed a circular dependency involving a non-linkable executable target. This adds a test for that case.
Diffstat (limited to 'Tests/Dependency')
-rw-r--r--Tests/Dependency/CMakeLists.txt1
-rw-r--r--Tests/Dependency/Case4/CMakeLists.txt23
-rw-r--r--Tests/Dependency/Case4/bar.c2
-rw-r--r--Tests/Dependency/Case4/foo.c1
4 files changed, 27 insertions, 0 deletions
diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt
index d2c1c1a..d700374 100644
--- a/Tests/Dependency/CMakeLists.txt
+++ b/Tests/Dependency/CMakeLists.txt
@@ -52,3 +52,4 @@ ADD_SUBDIRECTORY(Exec4)
ADD_SUBDIRECTORY(Case1)
ADD_SUBDIRECTORY(Case2)
ADD_SUBDIRECTORY(Case3)
+ADD_SUBDIRECTORY(Case4)
diff --git a/Tests/Dependency/Case4/CMakeLists.txt b/Tests/Dependency/Case4/CMakeLists.txt
new file mode 100644
index 0000000..87ab507
--- /dev/null
+++ b/Tests/Dependency/Case4/CMakeLists.txt
@@ -0,0 +1,23 @@
+project(CASE4 C)
+
+IF(CMAKE_ANSI_CFLAGS)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
+ENDIF(CMAKE_ANSI_CFLAGS)
+
+# 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; }