Add test covering imported target scope rules

This commit is contained in:
Brad King 2012-01-25 14:04:26 -05:00
parent ca39c5cdd1
commit f9c1c6225c
5 changed files with 36 additions and 0 deletions

View File

@ -16,3 +16,5 @@ add_CMakeOnly_test(CheckSymbolExists)
add_CMakeOnly_test(CheckCXXSymbolExists)
add_CMakeOnly_test(AllFindModules)
add_CMakeOnly_test(TargetScope)

View File

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

View File

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

View File

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

View File

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