CMakeLists.txt 796 B

1234567891011121314151617181920212223
  1. # test if CSharp application correctly links
  2. # to managed C++ binary
  3. cmake_minimum_required(VERSION 3.9)
  4. project (CSharpLinkToCxx CXX CSharp)
  5. # we have to change the default flags for the
  6. # managed C++ project to build
  7. string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  8. string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
  9. add_library(CLIApp SHARED cli.hpp cli.cpp)
  10. target_compile_options(CLIApp PRIVATE "/clr")
  11. add_executable(CSharpLinkToCxx csharp.cs)
  12. target_link_libraries(CSharpLinkToCxx CLIApp)
  13. # this unmanaged C++ library will be added to the C#/.NET
  14. # references of CSharpLinkToCxx but it will show a warning
  15. # because it is unmanaged
  16. add_library(CppNativeApp SHARED cpp_native.hpp cpp_native.cpp)
  17. target_link_libraries(CSharpLinkToCxx CppNativeApp)