Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Tests/CSharpLinkToCxx/CMakeLists.txt
3148 views
1
# test if CSharp application correctly links
2
# to managed C++ binary
3
cmake_minimum_required(VERSION 3.10)
4
project (CSharpLinkToCxx CXX CSharp)
5
6
# we have to change the default flags for the
7
# managed C++ project to build
8
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
9
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
10
11
add_library(CLIApp SHARED cli.hpp cli.cpp)
12
13
target_compile_options(CLIApp PRIVATE "/clr")
14
15
add_executable(CSharpLinkToCxx csharp.cs)
16
17
target_link_libraries(CSharpLinkToCxx CLIApp)
18
19
# this unmanaged C++ library will be added to the C#/.NET
20
# references of CSharpLinkToCxx but it will show a warning
21
# because it is unmanaged
22
add_library(CppNativeApp SHARED cpp_native.hpp cpp_native.cpp)
23
target_link_libraries(CSharpLinkToCxx CppNativeApp)
24
25
# Link a static C++ library into the CSharp executable.
26
# We do not actually use any symbols but this helps cover
27
# link language selection.
28
add_library(CppStaticLib STATIC cpp_static.cpp)
29
target_link_libraries(CSharpLinkToCxx CppStaticLib)
30
31