I have recently taken hold of a Windows project written in C#, and managed to create CMakeLists so that one can generate a solution on-the-fly and build it using Visual Studio.
This comes as a replacement for the legacy *.sln file that all developers were checking out from the repo. So far, so good. Now I would like to be more specific about the target platform and allow "Any CPU", just like the said legacy solution did. More precisely, I would like the *.csproj files to show:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" Label="Configuration">
I have followed this GitLab thread but adding either target_compile_options(MyProject PRIVATE "/platform:anycpu") or set(CMAKE_CSharp_FLAGS "/platform:anycpu") only adds <PlatformTarget>anycpu</PlatformTarget> into the relevant PropertyGroup, rather than transforming the "Release|x64" to a "Release|AnyCPU":
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<PlatformTarget>anycpu</PlatformTarget>
The project has a main CMakeLists.txt which adds subdirectories (add_subdirectory). The sub-project CMakeLists are structured as follows:
cmake_minimum_required(VERSION 3.10)
project(MyProject VERSION 1.0.0 LANGUAGES CSharp)
include(CSharpUtilities)
add_executable(MyProject...)
csharp_set_designer_cs_properties(...)
csharp_set_xaml_cs_properties(...)
target_compile_options(MyProject PRIVATE "/platform:anycpu" )
set_source_files_properties(...)
I am quite hung up on this as it has implications for TeamCity, which seems to be looking up specific pairs of {Configuration, Platform} directly by parsing the *.csproj files, and complaining if it cannot find "Release|AnyCPU".
Many thanks for any hints.