COMMON_LANGUAGE_RUNTIME NetCore does not generate CLRSupport Tag
I want to use CMake for the new .net core C++/CLI compilation. When specifying COMMON_LANGUAGE_RUNTIME "NetCore"
there is already an option /clr:NetCore
added to the ClCompile
tag which is sort of correct. But the better thing would rather be to generate a <CLRSupport>NetCore</CLRSupport>
property. This is also what Visual Studio does when you activate CLR support on your projects via UI.
https://devblogs.microsoft.com/cppblog/porting-a-c-cli-project-to-net-core/
With only the command line option Visual Studio will not play well. It will indicate "No Common Language Runtime Support" in the project properties and you get errors in the editor.
CMakeList.txt
cmake_minimum_required(VERSION 3.9)
project(netcore-test)
add_library(${PROJECT_NAME} SHARED)
set_target_properties(${PROJECT_NAME} PROPERTIES
DOTNET_TARGET_FRAMEWORK "net5.0"
COMMON_LANGUAGE_RUNTIME "NetCore"
)
target_sources(${PROJECT_NAME}
PRIVATE main.cpp
)
main.cpp
using namespace System;
int main()
{
Console::WriteLine("Test");
}
Edited by Daniel Kuschny