How to run script after a project creation.

Hi,

We are using CMake to perform a migration of C/C++ code from Windows to Linux.
It is a project composed of many libraries and highly dependent on Windows, so the migration is done little by little.

One of the needs we have is to be able to create Visual Studio 2019 projects based on part of the libraries, from the CMake script and integrate them into the Visual Studio solution that we already have.

We have a problem:

When we generate the Visual Studio project (.vcxproj) Cmake creates the fields in the profiles:

<PropertyGroup>
     <OutDir Condition="'"</OutDir>
     <IntDir Condition="'"</IntDir>
     <TargetName> </TargetName>

These fields are priority fields and we don’t see how to prevent CMake from generating them. As they are priorities (even being empty) Visual Studio ignores the .props file in these.

We need to remove them for everything to work properly.
This must be done after building the file itself by CMake.
We have made a small script (in powerShell) to do it. It works well.
What we do not get is how to place this execution in the CMake Script so that it executes the execution of this script at the end of this creation.
We have tried several ways without success.
What would be the correct path?

Thanks in advanced,

Best Regards,
Abraham.

There is no slot that CMake provides for user code to run at such a time.

I don’t know that CMake’s VS generation integrates well with existing projects as it wasn’t really a design decision. I think it can include other project files though.

Cc: @brad.king

We need to remove them for everything to work properly.
This must be done after building the file itself by CMake.

We don’t support that. If there is a problem with .vcxproj generation, the solution is to work on getting CMake updated to generate it correctly.

Hi,

I think just like you. If the MSBuild project can be built properly, we don’t need to run any extra scripts.

Ok, is there any way we can configure CMake not to generate the keys:

<OutDir Condition="'" <IntDir Condition="'"

We don’t need them to be empty, we need them not to exist so that the .prop file implements them in the same way throughout the solution (regardless of the project).

Best Regards,
Abraham.