summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-07-08 13:19:07 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-07-08 13:19:07 (GMT)
commitad91d0edd5b8e56dc6afffa38e01bcc7d0d265cd (patch)
tree0568b4d765d56e81590d9b9141346b001c0d0a7d /Tests
parentb98574dab2f4fb28c53025c5204cc06ece7de0c2 (diff)
parent8f86407cfd4331dc1f2eb67f4f179ed8fe9dea06 (diff)
downloadCMake-ad91d0edd5b8e56dc6afffa38e01bcc7d0d265cd.zip
CMake-ad91d0edd5b8e56dc6afffa38e01bcc7d0d265cd.tar.gz
CMake-ad91d0edd5b8e56dc6afffa38e01bcc7d0d265cd.tar.bz2
Merge topic 'auto_export_dll_symbols'
8f86407c Windows: Optionally generate DLL module definition files automatically 069aa93b bindexplib: Add support for "/bigobj" format objects 61bbbdcf bindexplib: Fix treatment of some symbols de70c922 bindexplib: Teach DumpFile to return errors 8ea69dfe bindexplib: Build source as part of CMakeLib 2963cb2a bindexplib: Wrap long lines 4ff09893 bindexplib: Drop code that CMake does not need 7de8276c bindexplib: Add copyright/license notice block 65086ad7 bindexplib: Import original implementation from CERN
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/AutoExportDll/AutoExport.cmake7
-rw-r--r--Tests/RunCMake/AutoExportDll/AutoExportBuild-stderr.txt1
-rw-r--r--Tests/RunCMake/AutoExportDll/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake26
-rw-r--r--Tests/RunCMake/AutoExportDll/foo.c15
-rw-r--r--Tests/RunCMake/AutoExportDll/hello.cxx13
-rw-r--r--Tests/RunCMake/AutoExportDll/hello.h18
-rw-r--r--Tests/RunCMake/AutoExportDll/say.cxx37
-rw-r--r--Tests/RunCMake/AutoExportDll/sub/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/AutoExportDll/sub/sub.cxx4
-rw-r--r--Tests/RunCMake/AutoExportDll/world.cxx6
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
12 files changed, 138 insertions, 0 deletions
diff --git a/Tests/RunCMake/AutoExportDll/AutoExport.cmake b/Tests/RunCMake/AutoExportDll/AutoExport.cmake
new file mode 100644
index 0000000..3b2b2c5
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/AutoExport.cmake
@@ -0,0 +1,7 @@
+project(autoexport)
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${autoexport_BINARY_DIR}/bin)
+add_subdirectory(sub)
+add_library(autoexport SHARED hello.cxx world.cxx foo.c)
+add_executable(say say.cxx)
+target_link_libraries(say autoexport autoexport2)
diff --git a/Tests/RunCMake/AutoExportDll/AutoExportBuild-stderr.txt b/Tests/RunCMake/AutoExportDll/AutoExportBuild-stderr.txt
new file mode 100644
index 0000000..d483c2c
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/AutoExportBuild-stderr.txt
@@ -0,0 +1 @@
+^.*$
diff --git a/Tests/RunCMake/AutoExportDll/CMakeLists.txt b/Tests/RunCMake/AutoExportDll/CMakeLists.txt
new file mode 100644
index 0000000..18dfd26
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.2)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
new file mode 100644
index 0000000..3784a6a
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
@@ -0,0 +1,26 @@
+include(RunCMake)
+set(RunCMake_TEST_NO_CLEAN TRUE)
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/AutoExport-build")
+# start by cleaning up because we don't clean up along the way
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+# configure the AutoExport test
+run_cmake(AutoExport)
+unset(RunCMake_TEST_OPTIONS)
+# don't run this test on VS 6 as it is not supported
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 6|Watcom WMake|Borland Makefiles")
+ return()
+endif()
+# we build debug so the say.exe will be found in Debug/say.exe for
+# Visual Studio generators
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode")
+ set(INTDIR "Debug/")
+endif()
+# build AutoExport
+run_cmake_command(AutoExportBuild ${CMAKE_COMMAND} --build
+ ${RunCMake_TEST_BINARY_DIR} --config Debug --clean-first)
+# run the executable that uses symbols from the dll
+if(WIN32)
+ set(EXE_EXT ".exe")
+endif()
+run_cmake_command(AutoExportRun
+ ${RunCMake_BINARY_DIR}/AutoExport-build/bin/${INTDIR}say${EXE_EXT})
diff --git a/Tests/RunCMake/AutoExportDll/foo.c b/Tests/RunCMake/AutoExportDll/foo.c
new file mode 100644
index 0000000..4b1318b
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/foo.c
@@ -0,0 +1,15 @@
+#ifdef _MSC_VER
+#include "windows.h"
+#else
+#define WINAPI
+#endif
+
+int WINAPI foo()
+{
+ return 10;
+}
+
+int bar()
+{
+ return 5;
+}
diff --git a/Tests/RunCMake/AutoExportDll/hello.cxx b/Tests/RunCMake/AutoExportDll/hello.cxx
new file mode 100644
index 0000000..3933fc1
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/hello.cxx
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include "hello.h"
+int Hello::Data = 0;
+void Hello::real()
+{
+ return;
+}
+void hello()
+{
+ printf("hello");
+}
+void Hello::operator delete[](void*) {};
+void Hello::operator delete(void*) {};
diff --git a/Tests/RunCMake/AutoExportDll/hello.h b/Tests/RunCMake/AutoExportDll/hello.h
new file mode 100644
index 0000000..3749b97
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/hello.h
@@ -0,0 +1,18 @@
+#ifndef _MSC_VER
+#define winexport
+#else
+#ifdef autoexport_EXPORTS
+#define winexport
+#else
+#define winexport __declspec(dllimport)
+#endif
+#endif
+
+class Hello
+{
+public:
+ static winexport int Data;
+ void real();
+ static void operator delete[](void*);
+ static void operator delete(void*);
+};
diff --git a/Tests/RunCMake/AutoExportDll/say.cxx b/Tests/RunCMake/AutoExportDll/say.cxx
new file mode 100644
index 0000000..655b3c2
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/say.cxx
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include "hello.h"
+#ifdef _MSC_VER
+#include "windows.h"
+#else
+#define WINAPI
+#endif
+
+extern "C"
+{
+// test __cdecl stuff
+ int WINAPI foo();
+// test regular C
+ int bar();
+}
+
+// test c++ functions
+// forward declare hello and world
+void hello();
+void world();
+
+int main()
+{
+ // test static data (needs declspec to work)
+ Hello::Data = 120;
+ Hello h;
+ h.real();
+ hello();
+ printf(" ");
+ world();
+ printf("\n");
+ foo();
+ printf("\n");
+ bar();
+ printf("\n");
+ return 0;
+}
diff --git a/Tests/RunCMake/AutoExportDll/sub/CMakeLists.txt b/Tests/RunCMake/AutoExportDll/sub/CMakeLists.txt
new file mode 100644
index 0000000..8b70e7d
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/sub/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_library(autoexport2 SHARED sub.cxx)
+if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ # Try msvc "big" object format.
+ target_compile_options(autoexport2 PRIVATE /bigobj)
+endif()
diff --git a/Tests/RunCMake/AutoExportDll/sub/sub.cxx b/Tests/RunCMake/AutoExportDll/sub/sub.cxx
new file mode 100644
index 0000000..9766b41
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/sub/sub.cxx
@@ -0,0 +1,4 @@
+int sub()
+{
+ return 10;
+}
diff --git a/Tests/RunCMake/AutoExportDll/world.cxx b/Tests/RunCMake/AutoExportDll/world.cxx
new file mode 100644
index 0000000..3a54df3
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/world.cxx
@@ -0,0 +1,6 @@
+#include "stdio.h"
+
+void world()
+{
+ printf("world");
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index bc706d3..743ef4b 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -266,3 +266,6 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
endif()
add_RunCMake_test_group(CPack "DEB;RPM")
+# add a test to make sure symbols are exported from a shared library
+# for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used
+add_RunCMake_test(AutoExportDll)