summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/AutoExportDll
diff options
context:
space:
mode:
authorMarkus Mayer <markus.mayer@brainlab.com>2020-04-30 10:53:50 (GMT)
committerMarkus Mayer <markus.mayer@brainlab.com>2020-05-04 07:58:09 (GMT)
commitbe75622e49614fcb96e99316f7a6e8a438538e7f (patch)
tree259dcb3088d77c3b452d6b39b0269c735236207c /Tests/RunCMake/AutoExportDll
parent2291253c1ba2f2f5f8192ba283f8291b9b6ea24f (diff)
downloadCMake-be75622e49614fcb96e99316f7a6e8a438538e7f.zip
CMake-be75622e49614fcb96e99316f7a6e8a438538e7f.tar.gz
CMake-be75622e49614fcb96e99316f7a6e8a438538e7f.tar.bz2
bindexplib: Do not export symbols from managed code
Fixes: #20653
Diffstat (limited to 'Tests/RunCMake/AutoExportDll')
-rw-r--r--Tests/RunCMake/AutoExportDll/AutoExport.cmake6
-rw-r--r--Tests/RunCMake/AutoExportDll/cppCLI.cxx22
-rw-r--r--Tests/RunCMake/AutoExportDll/say.cxx8
3 files changed, 34 insertions, 2 deletions
diff --git a/Tests/RunCMake/AutoExportDll/AutoExport.cmake b/Tests/RunCMake/AutoExportDll/AutoExport.cmake
index a550005..85eff7e 100644
--- a/Tests/RunCMake/AutoExportDll/AutoExport.cmake
+++ b/Tests/RunCMake/AutoExportDll/AutoExport.cmake
@@ -5,6 +5,10 @@ add_subdirectory(sub)
add_library(objlib OBJECT objlib.c)
set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(autoexport SHARED hello.cxx world.cxx foo.c $<TARGET_OBJECTS:objlib>)
+add_library(autoexport3 SHARED cppCLI.cxx)
+if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600)
+ set_property(TARGET autoexport3 PROPERTY COMMON_LANGUAGE_RUNTIME "")
+endif()
add_executable(say say.cxx)
if(MSVC)
@@ -18,4 +22,4 @@ if(MSVC)
target_compile_definitions(say PRIVATE HAS_JUSTNOP)
endif()
endif()
-target_link_libraries(say autoexport autoexport2)
+target_link_libraries(say autoexport autoexport2 autoexport3)
diff --git a/Tests/RunCMake/AutoExportDll/cppCLI.cxx b/Tests/RunCMake/AutoExportDll/cppCLI.cxx
new file mode 100644
index 0000000..816bb6e
--- /dev/null
+++ b/Tests/RunCMake/AutoExportDll/cppCLI.cxx
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+#ifdef __cplusplus_cli
+# include <msclr\marshal_cppstd.h>
+
+void cliFunction()
+{
+ System::String ^ result = "cliFunction";
+ result = result->Trim();
+ printf(msclr::interop::marshal_as<std::string>(result).c_str());
+}
+#else
+void cliFunction()
+{
+ printf("cliFunction (but /cli was not passed to the compiler)");
+}
+#endif
+
+void nonCliFunction()
+{
+ printf("nonCliFunction");
+}
diff --git a/Tests/RunCMake/AutoExportDll/say.cxx b/Tests/RunCMake/AutoExportDll/say.cxx
index 654b5e0..8fc768a 100644
--- a/Tests/RunCMake/AutoExportDll/say.cxx
+++ b/Tests/RunCMake/AutoExportDll/say.cxx
@@ -17,9 +17,11 @@ void justnop();
}
// test c++ functions
-// forward declare hello and world
+// forward declare hello, world, cliFunction and nonCliFunction
void hello();
void world();
+void cliFunction();
+void nonCliFunction();
// test exports for executable target
extern "C" {
@@ -44,6 +46,10 @@ int main()
bar();
objlib();
printf("\n");
+ cliFunction();
+ printf("\n");
+ nonCliFunction();
+ printf("\n");
#ifdef HAS_JUSTNOP
justnop();
#endif