summaryrefslogtreecommitdiffstats
path: root/Tests/ExportImport
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2012-09-23 11:45:17 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-01-05 00:18:37 (GMT)
commit894f52f32d96ae92df0ba3dac2a70fe9c87e818d (patch)
treeac4350fb4cea5b188f7880ea4207d4a4fecbdf7e /Tests/ExportImport
parentf5b1980fb27fa902d37856ec3e22daddfeb9d52f (diff)
downloadCMake-894f52f32d96ae92df0ba3dac2a70fe9c87e818d.zip
CMake-894f52f32d96ae92df0ba3dac2a70fe9c87e818d.tar.gz
CMake-894f52f32d96ae92df0ba3dac2a70fe9c87e818d.tar.bz2
Handle INTERFACE properties transitively for includes and defines.
Contextually, the behavior is as if the properties content from another target is included in the string and then the result is evaluated.
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt75
-rw-r--r--Tests/ExportImport/Export/testLibDepends.c16
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt15
-rw-r--r--Tests/ExportImport/Import/A/deps_iface.cpp24
4 files changed, 129 insertions, 1 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index e19ab88..569845a 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -90,9 +90,82 @@ set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3)
# Test exporting dependent libraries into different exports
add_library(testLibRequired testLibRequired.c)
add_library(testLibDepends testLibDepends.c)
+set_property(TARGET testLibDepends APPEND PROPERTY
+ INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:testLibRequired,INTERFACE_INCLUDE_DIRECTORIES>
+)
+set_property(TARGET testLibDepends APPEND PROPERTY
+ COMPILE_DEFINITIONS
+ $<TARGET_PROPERTY:testLibRequired,INTERFACE_COMPILE_DEFINITIONS>
+)
+set_property(TARGET testLibDepends APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:testLibRequired,INTERFACE_INCLUDE_DIRECTORIES>
+)
+set_property(TARGET testLibDepends APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS
+ $<TARGET_PROPERTY:testLibRequired,INTERFACE_COMPILE_DEFINITIONS>
+)
target_link_libraries(testLibDepends testLibRequired)
-install(TARGETS testLibRequired EXPORT RequiredExp DESTINATION lib )
+macro(add_include_lib _libName)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "// no content\n")
+ add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c")
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_libName}")
+ set_property(TARGET ${_libName} APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/${_libName}")
+ if (NOT "${ARGV1}" STREQUAL "NO_HEADER")
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" "// no content\n")
+ endif()
+endmacro()
+
+add_include_lib(testLibIncludeRequired1)
+add_include_lib(testLibIncludeRequired2)
+add_include_lib(testLibIncludeRequired3 NO_HEADER)
+# Generate testLibIncludeRequired4 in the testLibIncludeRequired3 directory
+# with an error. If the includes from testLibIncludeRequired3 appear first,
+# the error will be hit.
+# Below, the '3' library appears before the '4' library
+# but we are testing that the INSTALL_INTERFACE causes it not to be used
+# at build time.
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired3/testLibIncludeRequired4.h" "#error Should not be included\n")
+add_include_lib(testLibIncludeRequired4)
+add_include_lib(testLibIncludeRequired5 NO_HEADER)
+# Generate testLibIncludeRequired6 in the testLibIncludeRequired5 directory
+# with an error. If the includes from testLibIncludeRequired5 appear first,
+# the error will be hit.
+# Below, the '5' library appears before the '6' library
+# but we are testing that when the installed IMPORTED target is used, from
+# the Import side of this unit test, the '6' include from the '5' directory
+# will not be used because it is in the BUILD_INTERFACE only.
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired5/testLibIncludeRequired6.h" "#error Should not be included\n")
+add_include_lib(testLibIncludeRequired6)
+
+set_property(TARGET testLibRequired APPEND PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:testLibIncludeRequired1,INTERFACE_INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:$<1:$<TARGET_NAME:testLibIncludeRequired2>>,INTERFACE_INCLUDE_DIRECTORIES>
+ $<INSTALL_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired3,INTERFACE_INCLUDE_DIRECTORIES>>
+ $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired4,INTERFACE_INCLUDE_DIRECTORIES>>
+ $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired5,INTERFACE_INCLUDE_DIRECTORIES>>
+ $<INSTALL_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired6,INTERFACE_INCLUDE_DIRECTORIES>>
+)
+
+set_property(TARGET testLibRequired APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS
+ testLibRequired_IFACE_DEFINE
+ $<BUILD_INTERFACE:BuildOnly_DEFINE>
+ $<INSTALL_INTERFACE:InstallOnly_DEFINE>
+)
+
+install(TARGETS testLibRequired
+ testLibIncludeRequired1
+ testLibIncludeRequired2
+ testLibIncludeRequired3
+ testLibIncludeRequired4
+ testLibIncludeRequired5
+ testLibIncludeRequired6
+ EXPORT RequiredExp DESTINATION lib )
install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredConfig.cmake DESTINATION lib/cmake/testLibRequired)
install(TARGETS testLibDepends EXPORT DependsExp DESTINATION lib )
diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c
index 2849b33..fb5a002 100644
--- a/Tests/ExportImport/Export/testLibDepends.c
+++ b/Tests/ExportImport/Export/testLibDepends.c
@@ -1,4 +1,20 @@
+#include "testLibIncludeRequired1.h"
+#include "testLibIncludeRequired2.h"
+#include "testLibIncludeRequired4.h"
+
+#ifndef testLibRequired_IFACE_DEFINE
+#error Expected testLibRequired_IFACE_DEFINE
+#endif
+
+#ifndef BuildOnly_DEFINE
+#error Expected BuildOnly_DEFINE
+#endif
+
+#ifdef InstallOnly_DEFINE
+#error Unexpected InstallOnly_DEFINE
+#endif
+
extern int testLibRequired(void);
int testLibDepends(void) { return testLibRequired(); }
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index 8841792..b77562e 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -152,3 +152,18 @@ check_function_exists(testLib1 HAVE_TESTLIB1_FUNCTION)
if (NOT HAVE_TESTLIB1_FUNCTION)
message(SEND_ERROR "Using imported target testLib2 in check_function_exists() failed !")
endif()
+
+#-----------------------------------------------------------------------------
+# Test that dependent imported targets have usable
+# INTERFACE_COMPILE_DEFINITIONS and INTERFACE_INCLUDE_DIRECTORIES
+
+add_library(deps_iface deps_iface.cpp)
+target_link_libraries(deps_iface testLibsDepends)
+set_property(TARGET deps_iface APPEND PROPERTY
+ COMPILE_DEFINITIONS
+ $<TARGET_PROPERTY:testLibDepends,INTERFACE_COMPILE_DEFINITIONS>
+)
+set_property(TARGET deps_iface APPEND PROPERTY
+ INCLUDE_DIRECTORIES
+ $<TARGET_PROPERTY:testLibDepends,INTERFACE_INCLUDE_DIRECTORIES>
+)
diff --git a/Tests/ExportImport/Import/A/deps_iface.cpp b/Tests/ExportImport/Import/A/deps_iface.cpp
new file mode 100644
index 0000000..7190b92
--- /dev/null
+++ b/Tests/ExportImport/Import/A/deps_iface.cpp
@@ -0,0 +1,24 @@
+
+#include "testLibIncludeRequired1.h"
+#include "testLibIncludeRequired2.h"
+#include "testLibIncludeRequired6.h"
+
+#ifndef testLibRequired_IFACE_DEFINE
+#error Expected testLibRequired_IFACE_DEFINE
+#endif
+
+#ifdef BuildOnly_DEFINE
+#error Unexpected BuildOnly_DEFINE
+#endif
+
+#ifndef InstallOnly_DEFINE
+#error Expected InstallOnly_DEFINE
+#endif
+
+extern int testLibDepends(void);
+
+
+int main(int,char **)
+{
+ return testLibDepends();
+}