summaryrefslogtreecommitdiffstats
path: root/Tests/ObjectLibrary/A
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/A
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/A')
-rw-r--r--Tests/ObjectLibrary/A/CMakeLists.txt17
-rw-r--r--Tests/ObjectLibrary/A/a.h6
-rw-r--r--Tests/ObjectLibrary/A/a1.c.in2
-rw-r--r--Tests/ObjectLibrary/A/a2.c2
4 files changed, 27 insertions, 0 deletions
diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt
new file mode 100644
index 0000000..e0a620e
--- /dev/null
+++ b/Tests/ObjectLibrary/A/CMakeLists.txt
@@ -0,0 +1,17 @@
+# 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(-DA)
+
+add_custom_command(
+ OUTPUT a1.c
+ DEPENDS a1.c.in
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/a1.c.in
+ ${CMAKE_CURRENT_BINARY_DIR}/a1.c
+ )
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+add_library(A OBJECT a1.c a2.c)
diff --git a/Tests/ObjectLibrary/A/a.h b/Tests/ObjectLibrary/A/a.h
new file mode 100644
index 0000000..6bfbc82
--- /dev/null
+++ b/Tests/ObjectLibrary/A/a.h
@@ -0,0 +1,6 @@
+#ifndef A
+# error "A not defined"
+#endif
+#ifdef B
+# error "B must not be defined"
+#endif
diff --git a/Tests/ObjectLibrary/A/a1.c.in b/Tests/ObjectLibrary/A/a1.c.in
new file mode 100644
index 0000000..d1eaf58
--- /dev/null
+++ b/Tests/ObjectLibrary/A/a1.c.in
@@ -0,0 +1,2 @@
+#include "a.h"
+int a1(void) { return 0; }
diff --git a/Tests/ObjectLibrary/A/a2.c b/Tests/ObjectLibrary/A/a2.c
new file mode 100644
index 0000000..d8f225e
--- /dev/null
+++ b/Tests/ObjectLibrary/A/a2.c
@@ -0,0 +1,2 @@
+#include "a.h"
+int a2(void) { return 0; }