[CMake] Overriding read-only project's CMakeLists.txt

Michael Wild themiwi at gmail.com
Tue Dec 29 11:55:02 EST 2009


On 29. Dec, 2009, at 17:26 , Kenneth Porter wrote:

> Where can I put build instructions that are build-host-wide, not project-wide?
> 
> I'm relatively new to cmake. I want to "inject" some code before the project's own script, and I'd prefer not to modify the project (since then I'd have to maintain the patch).
> 
> I want to set the CMAKE_<target>_PREFIX variables based on the version of Visual Studio used and whether it's a debug or release build. (I've been given code to do this on the VTK list, but I don't see how to use it apart from editing VTK's file.)
> 

Have a look at the -C option which allows you to set cache variables before anything else runs. You can use that in a batch script to set up things automatically.

And it's not CMAKE_<target>_PREFIX you want (no such variable, except CMAKE_INSTALL_PREFIX, which is probably not what you meant), but CMAKE_<CONFIG>_POSTFIX, where <CONFIG> is Debug, Release, RelWithDebInfo, MinSizeRel and any other configuration the project lists in CMAKE_CONFIGURATION_TYPES.


Michael



More information about the CMake mailing list