diff options
author | Brad King <brad.king@kitware.com> | 2017-06-22 13:58:23 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-06-22 13:58:28 (GMT) |
commit | 9f3bf3cb9d014c3acce0709af7cce82554bc7a89 (patch) | |
tree | 2dda6674f6d70d62b64056623bc664c7f2ae94a0 /Tests | |
parent | 1218731a2a1f018f562808d7cd5ea857403dbad3 (diff) | |
parent | 51865fc67ecd61d9cbf984be0310f2e9fb8ff455 (diff) | |
download | CMake-9f3bf3cb9d014c3acce0709af7cce82554bc7a89.zip CMake-9f3bf3cb9d014c3acce0709af7cce82554bc7a89.tar.gz CMake-9f3bf3cb9d014c3acce0709af7cce82554bc7a89.tar.bz2 |
Merge topic 'vs_csharp_link_to_managed_cxx'
51865fc6 Vs: allow CSharp targets to be linked to CXX targets
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !993
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CSharpLinkToCxx/CMakeLists.txt | 17 | ||||
-rw-r--r-- | Tests/CSharpLinkToCxx/cli.cpp | 10 | ||||
-rw-r--r-- | Tests/CSharpLinkToCxx/cli.hpp | 10 | ||||
-rw-r--r-- | Tests/CSharpLinkToCxx/csharp.cs | 16 |
5 files changed, 54 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d138f58..d16df1c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -331,6 +331,7 @@ if(BUILD_TESTING) if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") ADD_TEST_MACRO(CSharpOnly CSharpOnly) + ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx) endif() ADD_TEST_MACRO(COnly COnly) diff --git a/Tests/CSharpLinkToCxx/CMakeLists.txt b/Tests/CSharpLinkToCxx/CMakeLists.txt new file mode 100644 index 0000000..c4269e0 --- /dev/null +++ b/Tests/CSharpLinkToCxx/CMakeLists.txt @@ -0,0 +1,17 @@ +# test if CSharp application correctly links +# to managed C++ binary +cmake_minimum_required(VERSION 3.9) +project (CSharpLinkToCxx CXX CSharp) + +# we have to change the default flags for the +# managed C++ project to build +string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) +string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + +add_library(CLIApp SHARED cli.hpp cli.cpp) + +target_compile_options(CLIApp PRIVATE "/clr") + +add_executable(CSharpLinkToCxx csharp.cs) + +target_link_libraries(CSharpLinkToCxx CLIApp) diff --git a/Tests/CSharpLinkToCxx/cli.cpp b/Tests/CSharpLinkToCxx/cli.cpp new file mode 100644 index 0000000..97ac724 --- /dev/null +++ b/Tests/CSharpLinkToCxx/cli.cpp @@ -0,0 +1,10 @@ +#include "cli.hpp" + +using namespace System; + +namespace CLIApp { +void MyCli::testMyCli() +{ + Console::WriteLine("#message from CLIApp"); +} +} diff --git a/Tests/CSharpLinkToCxx/cli.hpp b/Tests/CSharpLinkToCxx/cli.hpp new file mode 100644 index 0000000..a8c116d --- /dev/null +++ b/Tests/CSharpLinkToCxx/cli.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace CLIApp { +public +ref class MyCli +{ +public: + void testMyCli(); +}; +} diff --git a/Tests/CSharpLinkToCxx/csharp.cs b/Tests/CSharpLinkToCxx/csharp.cs new file mode 100644 index 0000000..35c5cc3 --- /dev/null +++ b/Tests/CSharpLinkToCxx/csharp.cs @@ -0,0 +1,16 @@ +using System; +using CLIApp; + +namespace CSharpLinkToCxx +{ + internal class CSharpLinkToCxx + { + public static void Main(string[] args) + { + Console.WriteLine("#message from CSharpLinkToCxx"); + + var app = new MyCli(); + app.testMyCli(); + } + } +} |