summaryrefslogtreecommitdiffstats
path: root/Tests/ExportImport/Export
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/Export
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/Export')
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt33
-rw-r--r--Tests/ExportImport/Export/testExe1.c24
-rw-r--r--Tests/ExportImport/Export/testExe2.c12
-rw-r--r--Tests/ExportImport/Export/testLib1.c1
-rw-r--r--Tests/ExportImport/Export/testLib2.c4
-rw-r--r--Tests/ExportImport/Export/testLib3.c7
6 files changed, 81 insertions, 0 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
new file mode 100644
index 0000000..eef146a
--- /dev/null
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -0,0 +1,33 @@
+project(Export C)
+
+# We need ansi C support.
+if(CMAKE_ANSI_CFLAGS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
+endif(CMAKE_ANSI_CFLAGS)
+
+add_executable(testExe1 testExe1.c)
+
+add_executable(testExe2 testExe2.c)
+set_property(TARGET testExe2 PROPERTY ENABLE_EXPORTS 1)
+
+add_library(testLib1 STATIC testLib1.c)
+add_library(testLib2 STATIC testLib2.c)
+target_link_libraries(testLib2 testLib1)
+
+add_library(testLib3 SHARED testLib3.c)
+
+# Install and export from install tree.
+install(
+ TARGETS testExe1 testLib1 testLib2 testExe2 testLib3
+ EXPORT exp
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ )
+install(EXPORT exp NAMESPACE exp_ DESTINATION lib/exp)
+
+# Export from build tree.
+export(TARGETS testExe1 testLib1 testLib2 testExe2 testLib3
+ NAMESPACE bld_
+ FILE ExportBuildTree.cmake
+ )
diff --git a/Tests/ExportImport/Export/testExe1.c b/Tests/ExportImport/Export/testExe1.c
new file mode 100644
index 0000000..39177d0
--- /dev/null
+++ b/Tests/ExportImport/Export/testExe1.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int main(int argc, const char* argv[])
+{
+ if(argc < 2)
+ {
+ fprintf(stderr, "Must specify output file.\n");
+ return 1;
+ }
+ {
+ FILE* f = fopen(argv[1], "w");
+ if(f)
+ {
+ fprintf(f, "int generated_by_testExe1() { return 0; }\n");
+ fclose(f);
+ }
+ else
+ {
+ fprintf(stderr, "Error writing to %s\n", argv[1]);
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/testExe2.c b/Tests/ExportImport/Export/testExe2.c
new file mode 100644
index 0000000..f7d9345
--- /dev/null
+++ b/Tests/ExportImport/Export/testExe2.c
@@ -0,0 +1,12 @@
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define testExe2_EXPORT __declspec(dllexport)
+#else
+# define testExe2_EXPORT
+#endif
+
+testExe2_EXPORT int testExe2Func(void) { return 123; }
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/testLib1.c b/Tests/ExportImport/Export/testLib1.c
new file mode 100644
index 0000000..5491bf9
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib1.c
@@ -0,0 +1 @@
+int testLib1() { return 0; }
diff --git a/Tests/ExportImport/Export/testLib2.c b/Tests/ExportImport/Export/testLib2.c
new file mode 100644
index 0000000..5feb83d
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib2.c
@@ -0,0 +1,4 @@
+
+extern int testLib1();
+
+int testLib2() { return testLib1(); }
diff --git a/Tests/ExportImport/Export/testLib3.c b/Tests/ExportImport/Export/testLib3.c
new file mode 100644
index 0000000..bfff187
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib3.c
@@ -0,0 +1,7 @@
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define testLib3_EXPORT __declspec(dllexport)
+#else
+# define testLib3_EXPORT
+#endif
+
+testLib3_EXPORT int testLib3(void) { return 0; }