How it works

Once a library or executable target has been declared, one can latch additional commands onto the target by using add_custom_command. As we have seen, these commands will be executed at specific times, contextually to the execution of the target they are attached to. CMake understands the following options for the execution order of custom commands:

  • PRE_BUILD: For commands to be executed before any other rules pertaining to the target are executed. This is however only supported for Visual Studio 7 or later.
  • PRE_LINK: With this option, commands are executed after the target has been compiled but before the linker or archiver are invoked. Using PRE_BUILD with generators other than Visual Studio 7 or later will be interpreted ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.