summaryrefslogtreecommitdiffstats
path: root/Tests/ObjectLibrary/B
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-03-12 18:41:34 (GMT)
committerBrad King <brad.king@kitware.com>2012-03-16 14:12:30 (GMT)
commit69d3d1835c5f4bdf9fbe5e920517a74d82482455 (patch)
tree3b20f13c838fa2cdfc3af0a0b4041b9359800d94 /Tests/ObjectLibrary/B
parentc403f27a2de2327f5c895972e16a81d80968c40c (diff)
downloadCMake-69d3d1835c5f4bdf9fbe5e920517a74d82482455.zip
CMake-69d3d1835c5f4bdf9fbe5e920517a74d82482455.tar.gz
CMake-69d3d1835c5f4bdf9fbe5e920517a74d82482455.tar.bz2
Test OBJECT library success cases
Add "ObjectLibrary" test to build and use OBJECT libraries. Build multiple object libraries in separate directories with different flags. Use a custom command to generate a source file in one OBJECT library. Reference the OBJECT libraries for inclusion in a STATIC library, a SHARED library, and an EXECUTABLE target. Use the static and shared libraries each in executables that end up using the object library symbols. Verify that object library symbols are exported from the shared library.
Diffstat (limited to 'Tests/ObjectLibrary/B')
-rw-r--r--Tests/ObjectLibrary/B/CMakeLists.txt15
-rw-r--r--Tests/ObjectLibrary/B/b.h11
-rw-r--r--Tests/ObjectLibrary/B/b1.c2
-rw-r--r--Tests/ObjectLibrary/B/b1_vs6.c1
-rw-r--r--Tests/ObjectLibrary/B/b2.c2
-rw-r--r--Tests/ObjectLibrary/B/b2_vs6.c1
6 files changed, 32 insertions, 0 deletions
diff --git a/Tests/ObjectLibrary/B/CMakeLists.txt b/Tests/ObjectLibrary/B/CMakeLists.txt
new file mode 100644
index 0000000..498d45d
--- /dev/null
+++ b/Tests/ObjectLibrary/B/CMakeLists.txt
@@ -0,0 +1,15 @@
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6")
+ # VS 6 generator does not use per-target object locations.
+ set(vs6 _vs6)
+endif()
+
+# Add -fPIC so objects can be used in shared libraries.
+# TODO: Need property for this.
+if(CMAKE_SHARED_LIBRARY_C_FLAGS)
+ set(CMAKE_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_C_FLAGS}")
+endif()
+
+add_definitions(-DB)
+add_library(B OBJECT b1.c b2.c)
+add_library(Bexport OBJECT b1${vs6}.c b2${vs6}.c)
+set_property(TARGET Bexport PROPERTY COMPILE_DEFINITIONS Bexport)
diff --git a/Tests/ObjectLibrary/B/b.h b/Tests/ObjectLibrary/B/b.h
new file mode 100644
index 0000000..632004d
--- /dev/null
+++ b/Tests/ObjectLibrary/B/b.h
@@ -0,0 +1,11 @@
+#ifdef A
+# error "A must not be defined"
+#endif
+#ifndef B
+# error "B not defined"
+#endif
+#if defined(_WIN32) && defined(Bexport)
+# define EXPORT_B __declspec(dllexport)
+#else
+# define EXPORT_B
+#endif
diff --git a/Tests/ObjectLibrary/B/b1.c b/Tests/ObjectLibrary/B/b1.c
new file mode 100644
index 0000000..fdeffe4
--- /dev/null
+++ b/Tests/ObjectLibrary/B/b1.c
@@ -0,0 +1,2 @@
+#include "b.h"
+EXPORT_B int b1(void) { return 0; }
diff --git a/Tests/ObjectLibrary/B/b1_vs6.c b/Tests/ObjectLibrary/B/b1_vs6.c
new file mode 100644
index 0000000..b606e10
--- /dev/null
+++ b/Tests/ObjectLibrary/B/b1_vs6.c
@@ -0,0 +1 @@
+#include "b1.c"
diff --git a/Tests/ObjectLibrary/B/b2.c b/Tests/ObjectLibrary/B/b2.c
new file mode 100644
index 0000000..6e0d17c
--- /dev/null
+++ b/Tests/ObjectLibrary/B/b2.c
@@ -0,0 +1,2 @@
+#include "b.h"
+EXPORT_B int b2(void) { return 0; }
diff --git a/Tests/ObjectLibrary/B/b2_vs6.c b/Tests/ObjectLibrary/B/b2_vs6.c
new file mode 100644
index 0000000..d96a43e
--- /dev/null
+++ b/Tests/ObjectLibrary/B/b2_vs6.c
@@ -0,0 +1 @@
+#include "b2.c"