From f9c1c6225c4366918465b86e4c6976ecc266245f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 25 Jan 2012 14:04:26 -0500 Subject: [PATCH] Add test covering imported target scope rules --- Tests/CMakeOnly/CMakeLists.txt | 2 ++ Tests/CMakeOnly/TargetScope/CMakeLists.txt | 13 +++++++++++++ Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt | 6 ++++++ Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt | 9 +++++++++ Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt | 6 ++++++ 5 files changed, 36 insertions(+) create mode 100644 Tests/CMakeOnly/TargetScope/CMakeLists.txt create mode 100644 Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt create mode 100644 Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt create mode 100644 Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 20e6a3aba..96b9972aa 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -16,3 +16,5 @@ add_CMakeOnly_test(CheckSymbolExists) add_CMakeOnly_test(CheckCXXSymbolExists) add_CMakeOnly_test(AllFindModules) + +add_CMakeOnly_test(TargetScope) diff --git a/Tests/CMakeOnly/TargetScope/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/CMakeLists.txt new file mode 100644 index 000000000..fa5d8e234 --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.8) +project(TargetScope NONE) + +add_subdirectory(Sub) + +if(TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal visible in top directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in top directory") +endif() + +add_subdirectory(Sib) diff --git a/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt new file mode 100644 index 000000000..7f6f4e8fd --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt @@ -0,0 +1,6 @@ +if(TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal visible in sibling directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in sibling directory") +endif() diff --git a/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt new file mode 100644 index 000000000..27318f585 --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(SubLibLocal UNKNOWN IMPORTED) +add_library(SubLibGlobal UNKNOWN IMPORTED GLOBAL) +add_subdirectory(Sub) +if(NOT TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal not visible in own directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in own directory") +endif() diff --git a/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt new file mode 100644 index 000000000..a351daadf --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt @@ -0,0 +1,6 @@ +if(NOT TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal not visible in subdirectory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in subdirectory") +endif()