summaryrefslogtreecommitdiffstats
path: root/Tests/ExportImport/Import
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-28 13:40:21 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-28 13:40:21 (GMT)
commit976b426b2d72f2987b5591bee241f9e2752437f5 (patch)
tree78d58dfc762fc79235f826297f15897db5c5fa29 /Tests/ExportImport/Import
parent1332b557941e461b6651efdda895f55a778dd644 (diff)
downloadCMake-976b426b2d72f2987b5591bee241f9e2752437f5.zip
CMake-976b426b2d72f2987b5591bee241f9e2752437f5.tar.gz
CMake-976b426b2d72f2987b5591bee241f9e2752437f5.tar.bz2
ENH: Added ExportImport test to test new export/import features.
Diffstat (limited to 'Tests/ExportImport/Import')
-rw-r--r--Tests/ExportImport/Import/CMakeLists.txt50
-rw-r--r--Tests/ExportImport/Import/imp_mod1.c12
-rw-r--r--Tests/ExportImport/Import/imp_testExe1.c8
3 files changed, 70 insertions, 0 deletions
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
new file mode 100644
index 0000000..4c19819
--- /dev/null
+++ b/Tests/ExportImport/Import/CMakeLists.txt
@@ -0,0 +1,50 @@
+project(Import C)
+
+# We need ansi C support.
+if(CMAKE_ANSI_CFLAGS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
+endif(CMAKE_ANSI_CFLAGS)
+
+# Import targets from the exported build tree.
+include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
+
+# Import targets from the exported install tree.
+include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
+
+# Try referencing an executable imported from the install tree.
+add_custom_command(
+ OUTPUT ${Import_BINARY_DIR}/exp_generated.c
+ COMMAND exp_testExe1 ${Import_BINARY_DIR}/exp_generated.c
+ DEPENDS exp_testExe1
+ )
+
+add_executable(imp_testExe1
+ imp_testExe1.c
+ ${Import_BINARY_DIR}/exp_generated.c
+ )
+
+# Try linking to a library imported from the install tree.
+target_link_libraries(imp_testExe1 exp_testLib2 exp_testLib3)
+
+# Try building a plugin to an executable imported from the install tree.
+add_library(imp_mod1 MODULE imp_mod1.c)
+target_link_libraries(imp_mod1 exp_testExe2)
+
+# Try referencing an executable imported from the build tree.
+add_custom_command(
+ OUTPUT ${Import_BINARY_DIR}/bld_generated.c
+ COMMAND bld_testExe1 ${Import_BINARY_DIR}/bld_generated.c
+ DEPENDS bld_testExe1
+ )
+
+add_executable(imp_testExe1b
+ imp_testExe1.c
+ ${Import_BINARY_DIR}/bld_generated.c
+ )
+
+# Try linking to a library imported from the build tree.
+target_link_libraries(imp_testExe1b bld_testLib2 bld_testLib3)
+
+# Try building a plugin to an executable imported from the build tree.
+add_library(imp_mod1b MODULE imp_mod1.c)
+target_link_libraries(imp_mod1b bld_testExe2)
diff --git a/Tests/ExportImport/Import/imp_mod1.c b/Tests/ExportImport/Import/imp_mod1.c
new file mode 100644
index 0000000..d276631
--- /dev/null
+++ b/Tests/ExportImport/Import/imp_mod1.c
@@ -0,0 +1,12 @@
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define testExe2_IMPORT __declspec(dllimport)
+#else
+# define testExe2_IMPORT
+#endif
+
+testExe2_IMPORT int testExe2Func(void);
+
+int imp_mod1()
+{
+ return testExe2Func();
+}
diff --git a/Tests/ExportImport/Import/imp_testExe1.c b/Tests/ExportImport/Import/imp_testExe1.c
new file mode 100644
index 0000000..da51ddc
--- /dev/null
+++ b/Tests/ExportImport/Import/imp_testExe1.c
@@ -0,0 +1,8 @@
+extern int generated_by_testExe1();
+extern int testLib2();
+extern int testLib3();
+
+int main()
+{
+ return testLib2() + generated_by_testExe1() + testLib3();
+}