summaryrefslogtreecommitdiffstats
path: root/Tests/ExportImport
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-08-11 20:23:10 (GMT)
committerBrad King <brad.king@kitware.com>2008-08-11 20:23:10 (GMT)
commit7b873cd951e72cdd73ead785e3fc2fdddf73292d (patch)
tree58b12b3cf54ee2616db402b9dfeb7aab25035c7d /Tests/ExportImport
parente322d288af7a2e9f413a703e07399976377c7dd0 (diff)
downloadCMake-7b873cd951e72cdd73ead785e3fc2fdddf73292d.zip
CMake-7b873cd951e72cdd73ead785e3fc2fdddf73292d.tar.gz
CMake-7b873cd951e72cdd73ead785e3fc2fdddf73292d.tar.bz2
ENH: Test target_link_libraries INTERFACE option
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt19
-rw-r--r--Tests/ExportImport/Export/testLib4lib.c4
-rw-r--r--Tests/ExportImport/Export/testLib4libdbg.c14
-rw-r--r--Tests/ExportImport/Export/testLib4libopt.c14
-rw-r--r--Tests/ExportImport/Import/CMakeLists.txt2
-rw-r--r--Tests/ExportImport/Import/imp_testExe1.c12
6 files changed, 63 insertions, 2 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index 9f1bab3..5ac0b36 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -35,6 +35,22 @@ set_property(TARGET testLib3 PROPERTY SOVERSION 3)
add_library(testLib4 SHARED testLib4.c)
set_property(TARGET testLib4 PROPERTY FRAMEWORK 1)
+# Test using the target_link_libraries command to set the
+# LINK_INTERFACE_LIBRARIES* properties. We construct two libraries
+# providing the same two symbols. In each library one of the symbols
+# will work and the other one will fail to link. The import part of
+# this test will try to use the symbol corresponding to the
+# configuration in which it is built. If the proper library is not
+# used via the link interface the import test will fail to link.
+add_library(testLib4lib STATIC testLib4lib.c)
+add_library(testLib4libdbg STATIC testLib4libopt.c testLib4libdbg.c)
+add_library(testLib4libopt STATIC testLib4libdbg.c testLib4libopt.c)
+set_property(TARGET testLib4libdbg PROPERTY COMPILE_DEFINITIONS LIB_DBG)
+set_property(TARGET testLib4libopt PROPERTY COMPILE_DEFINITIONS LIB_OPT)
+target_link_libraries(testLib4
+ INTERFACE testLib4lib debug testLib4libdbg optimized testLib4libopt
+ )
+
add_executable(testExe3 testExe3.c)
set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1)
@@ -42,7 +58,7 @@ set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1)
install(
TARGETS
testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3
- testExe2lib
+ testExe2lib testLib4lib testLib4libdbg testLib4libopt
EXPORT exp
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib NAMELINK_SKIP
@@ -67,6 +83,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3
FILE ExportBuildTree.cmake
)
export(TARGETS testExe2 testLib4 testExe3 testExe2lib
+ testLib4lib testLib4libdbg testLib4libopt
NAMESPACE bld_
APPEND FILE ExportBuildTree.cmake
)
diff --git a/Tests/ExportImport/Export/testLib4lib.c b/Tests/ExportImport/Export/testLib4lib.c
new file mode 100644
index 0000000..bf3c11e
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib4lib.c
@@ -0,0 +1,4 @@
+int testLib4lib(void)
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/testLib4libdbg.c b/Tests/ExportImport/Export/testLib4libdbg.c
new file mode 100644
index 0000000..453f262
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib4libdbg.c
@@ -0,0 +1,14 @@
+#ifdef LIB_DBG
+/* We are building in testLib4libdbg. Provide the correct symbol. */
+int testLib4libdbg(void)
+{
+ return 0;
+}
+#else
+/* We are not building in testLib4libdbg. Poison the symbol. */
+extern int testLib4libdbg_noexist(void);
+int testLib4libdbg(void)
+{
+ return testLib4libdbg_noexist();
+}
+#endif
diff --git a/Tests/ExportImport/Export/testLib4libopt.c b/Tests/ExportImport/Export/testLib4libopt.c
new file mode 100644
index 0000000..605edd0
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib4libopt.c
@@ -0,0 +1,14 @@
+#ifdef LIB_OPT
+/* We are building in testLib4libopt. Provide the correct symbol. */
+int testLib4libopt(void)
+{
+ return 0;
+}
+#else
+/* We are not building in testLib4libopt. Poison the symbol. */
+extern int testLib4libopt_noexist(void);
+int testLib4libopt(void)
+{
+ return testLib4libopt_noexist();
+}
+#endif
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
index 5a946ed..1ac9d3a 100644
--- a/Tests/ExportImport/Import/CMakeLists.txt
+++ b/Tests/ExportImport/Import/CMakeLists.txt
@@ -32,6 +32,7 @@ add_executable(imp_testExe1
# Try linking to a library imported from the install tree.
target_link_libraries(imp_testExe1 exp_testLib2 exp_testLib3 exp_testLib4)
+set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_DEBUG EXE_DBG)
# Try building a plugin to an executable imported from the install tree.
add_library(imp_mod1 MODULE imp_mod1.c)
@@ -57,6 +58,7 @@ add_executable(imp_testExe1b
# Try linking to a library imported from the build tree.
target_link_libraries(imp_testExe1b bld_testLib2 bld_testLib3 bld_testLib4)
+set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_DEBUG EXE_DBG)
# Try building a plugin to an executable imported from the build tree.
add_library(imp_mod1b MODULE imp_mod1.c)
diff --git a/Tests/ExportImport/Import/imp_testExe1.c b/Tests/ExportImport/Import/imp_testExe1.c
index 0fbb689..6424d33 100644
--- a/Tests/ExportImport/Import/imp_testExe1.c
+++ b/Tests/ExportImport/Import/imp_testExe1.c
@@ -3,9 +3,19 @@ extern int generated_by_testExe3();
extern int testLib2();
extern int testLib3();
extern int testLib4();
+extern int testLib4lib();
+
+/* Switch a symbol between debug and optimized builds to make sure the
+ proper library is found from the testLib4 link interface. */
+#ifdef EXE_DBG
+# define testLib4libcfg testLib4libdbg
+#else
+# define testLib4libcfg testLib4libopt
+#endif
+extern testLib4libcfg(void);
int main()
{
return (testLib2() + generated_by_testExe1() + testLib3() + testLib4()
- + generated_by_testExe3());
+ + generated_by_testExe3() + testLib4lib() + testLib4libcfg());
}