[CMake] Execute command after project generation

Nicolas Schneider nioncode at gmail.com
Fri Jan 29 14:13:46 EST 2016


Is it possible to execute commands after the generation step of the
project files?

I want to set custom properties in the generated Visual Studio project,
because it should be built as a driver, which requires a few extra steps.
These changes should be done automatically by CMake (or a script run
after project generation) to be in sync between all developers.

I also tried just setting the properties with something like: cmake
--build . -- /p:FilesToPackage="a;b;c"

But it seems like CMake does not pass the command as raw string, because
msbuild complains about non-existing property, like it does when called
directly without quotes: msbuild project /p:FilesToPackage=a;b;c
which would treat 'b' as a property key instead of part of the value for
FilesToPackage.

The only workaround, currently, is to use:
cmake ..
modifyProjects.py
cmake --build .

However, I assume this does not work correctly if CMake regenerates the
project files because of changes in CMakeLists (because
modifyProjects.py will not be called automatically by CMake), correct?


More information about the CMake mailing list